Skip to content

Commit

Permalink
Open app store while clicking update.
Browse files Browse the repository at this point in the history
  • Loading branch information
jigar-f committed Oct 10, 2023
1 parent 131d00b commit 2dab44f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 22 deletions.
36 changes: 14 additions & 22 deletions lib/account/settings.dart
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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<Color>(grey5),
),
));
});
}

void openSplitTunneling(BuildContext context) =>
context.pushRoute(SplitTunneling());

Expand All @@ -44,6 +30,16 @@ class Settings extends StatelessWidget {
}
}

Future<void> 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(
Expand Down Expand Up @@ -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(
Expand Down
16 changes: 16 additions & 0 deletions lib/common/app_methods.dart
Original file line number Diff line number Diff line change
@@ -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,
);
}
}

0 comments on commit 2dab44f

Please sign in to comment.