From 2dab44f296e4b0871809a36c814ad7427a733790 Mon Sep 17 00:00:00 2001 From: Jigar-f Date: Tue, 10 Oct 2023 12:32:10 +0530 Subject: [PATCH] Open app store while clicking update. --- lib/account/settings.dart | 36 ++++++++++++++---------------------- lib/common/app_methods.dart | 16 ++++++++++++++++ 2 files changed, 30 insertions(+), 22 deletions(-) create mode 100644 lib/common/app_methods.dart diff --git a/lib/account/settings.dart b/lib/account/settings.dart index c8bd26ace..6bf2295bb 100644 --- a/lib/account/settings.dart +++ b/lib/account/settings.dart @@ -1,8 +1,11 @@ import 'package:intl/intl.dart'; +import 'package:lantern/common/app_methods.dart'; import 'package:lantern/common/common.dart'; +import 'package:lantern/common/ui/app_loading_dialog.dart'; import 'package:lantern/i18n/localization_constants.dart'; import 'package:lantern/messaging/messaging_model.dart'; import 'package:package_info_plus/package_info_plus.dart'; +import 'package:url_launcher/url_launcher.dart'; @RoutePage(name: 'Settings') class Settings extends StatelessWidget { @@ -16,23 +19,6 @@ class Settings extends StatelessWidget { void reportIssue(BuildContext context) async => await context.pushRoute(ReportIssue()); - void showProgressDialog(BuildContext context) { - showDialog( - context: context, - barrierDismissible: false, - barrierColor: Colors.transparent, - builder: (BuildContext context) { - return Center( - child: SizedBox( - width: 40.0, - height: 40.0, - child: CircularProgressIndicator( - valueColor: AlwaysStoppedAnimation(grey5), - ), - )); - }); - } - void openSplitTunneling(BuildContext context) => context.pushRoute(SplitTunneling()); @@ -44,6 +30,16 @@ class Settings extends StatelessWidget { } } + Future checkForUpdateTap(BuildContext context) async { + if (Platform.isAndroid) { + AppLoadingDialog.showLoadingDialog(context); + await sessionModel.checkForUpdates(); + AppLoadingDialog.dismissLoadingDialog(context); + } else { + AppMethods.openAppstore(); + } + } + @override Widget build(BuildContext context) { return BaseScreen( @@ -81,11 +77,7 @@ class Settings extends StatelessWidget { trailingArray: [ mirrorLTR(context: context, child: const ContinueArrow()) ], - onTap: () async { - showProgressDialog(context); - await sessionModel.checkForUpdates(); - Navigator.pop(context); - }, + onTap: () => checkForUpdateTap(context), ), //* Blocked messagingModel.getOnBoardingStatus( diff --git a/lib/common/app_methods.dart b/lib/common/app_methods.dart new file mode 100644 index 000000000..f028d8c4c --- /dev/null +++ b/lib/common/app_methods.dart @@ -0,0 +1,16 @@ +import 'package:url_launcher/url_launcher.dart'; + +class AppMethods{ + + static openAppstore(){ + //Launch App store + const appId = 'id1457872372'; + final url = Uri.parse( + "https://apps.apple.com/app/id$appId", + ); + launchUrl( + url, + mode: LaunchMode.externalApplication, + ); + } +} \ No newline at end of file