Skip to content

Commit

Permalink
open iOS store for update #1100
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Jan 16, 2023
1 parent e5bfca3 commit e324070
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
23 changes: 16 additions & 7 deletions lib/app_upgrade/view/app_upgrade_page.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import 'package:altme/app/app.dart';
import 'package:altme/dashboard/dashboard.dart';
import 'package:altme/l10n/l10n.dart';
import 'package:altme/onboarding/onboarding.dart';
import 'package:altme/splash/splash.dart';
import 'package:altme/theme/theme.dart';
import 'package:altme/wallet/wallet.dart';
import 'package:cryptocurrency_keys/cryptocurrency_keys.dart';
import 'package:file_saver/file_saver.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:secure_storage/secure_storage.dart';
import 'package:url_launcher/url_launcher.dart';

class AppUpgradePage extends StatelessWidget {
const AppUpgradePage({Key? key, required this.storeInfo}) : super(key: key);
Expand All @@ -35,11 +31,22 @@ class AppUpgradeView extends StatelessWidget {

final StoreInfo storeInfo;

Future<void> launchAppStore(String appStoreLink) async {
debugPrint(appStoreLink);
if (await canLaunchUrl(Uri.parse(appStoreLink))) {
await launchUrl(Uri.parse(appStoreLink));
} else {
throw Exception('Could not launch appStoreLink');
}
}

@override
Widget build(BuildContext context) {
final textTheme = Theme.of(context).textTheme;
final l10n = context.l10n;

// TODO(bibash): localise

return WillPopScope(
onWillPop: () async => false,
child: BasePage(
Expand Down Expand Up @@ -93,7 +100,9 @@ class AppUpgradeView extends StatelessWidget {
],
const SizedBox(height: 30),
MyGradientButton(
onPressed: () {},
onPressed: () async {
await launchAppStore(storeInfo.appStoreLink);
},
text: 'Update Now',
),
const SizedBox(height: 10),
Expand All @@ -111,7 +120,7 @@ class AppUpgradeView extends StatelessWidget {
.push<void>(BackupCredentialPage.route());
},
child: Text(
'Backup your Credential',
'Backup your Credentials',
style: Theme.of(context).textTheme.copyToClipBoard,
),
);
Expand Down
12 changes: 12 additions & 0 deletions lib/splash/cubit/splash_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class SplashCubit extends Cubit<SplashState> {
final WalletCubit walletCubit;
final DioClient client;

final log = getLogger('SplashCubit');

Future<void> initialiseApp() async {
final newVersion = NewVersion(
iOSId: 'io.altme.wallet',
Expand All @@ -41,6 +43,12 @@ class SplashCubit extends Cubit<SplashState> {
final VersionStatus? versionStatus = await newVersion.getVersionStatus();

if (versionStatus != null && versionStatus.canUpdate) {
log.i('''
localVersion: ${versionStatus.localVersion},
storeVersion: ${versionStatus.storeVersion},
appStoreLink: ${versionStatus.appStoreLink},
releaseNotes: ${versionStatus.releaseNotes}
''');
emit(
state.copyWith(
status: SplashStatus.routeToAppUpdate,
Expand Down Expand Up @@ -90,6 +98,10 @@ class SplashCubit extends Cubit<SplashState> {

Future<void> _getAppVersion() async {
final PackageInfo packageInfo = await PackageInfo.fromPlatform();
log.i('''
versionNumber: ${packageInfo.version},
buildNumber: ${packageInfo.buildNumber},
''');
emit(
state.copyWith(
versionNumber: packageInfo.version,
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: altme
description: AltMe Flutter App
version: 1.0.0+100
version: 1.7.5+140
publish_to: none

environment:
Expand Down Expand Up @@ -103,9 +103,9 @@ dependency_overrides:
ffi: ^2.0.1

dev_dependencies:
flutter_launcher_icons: "^0.11.0"
bloc_test: ^9.0.3
build_runner: ^2.1.10
flutter_launcher_icons: "^0.11.0"
flutter_test:
sdk: flutter
http_mock_adapter: ^0.3.2
Expand Down

0 comments on commit e324070

Please sign in to comment.