diff --git a/assets/i18n/en.json b/assets/i18n/en.json index 88fe3fb7..2445fe60 100644 --- a/assets/i18n/en.json +++ b/assets/i18n/en.json @@ -95,7 +95,8 @@ "installErrorDialogTitle": "Error", "installErrorDialogText1": "Root install is not possible with the current patches selection.\nRepatch your app or choose non-root install.", "installErrorDialogText2": "Non-root install is not possible with the current patches selection.\nRepatch your app or choose root install if you have your device rooted.", - "installErrorDialogText3": "Root install is not possible as the original APK was selected from storage.\nSelect an installed app or choose non-root install." + "installErrorDialogText3": "Root install is not possible as the original APK was selected from storage.\nSelect an installed app or choose non-root install.", + "noExit": "Installer is still running..." }, "settingsView": { "widgetTitle": "Settings", diff --git a/lib/ui/views/installer/installer_view.dart b/lib/ui/views/installer/installer_view.dart index 8ac9ca7c..10a1f365 100644 --- a/lib/ui/views/installer/installer_view.dart +++ b/lib/ui/views/installer/installer_view.dart @@ -29,6 +29,7 @@ class InstallerView extends StatelessWidget { color: Theme.of(context).textTheme.headline6!.color, ), ), + onBackButtonPressed: () => model.onWillPop(context), actions: [ Visibility( visible: !model.isPatching && !model.hasErrors, @@ -143,13 +144,7 @@ class InstallerView extends StatelessWidget { ], ), ), - onWillPop: () async { - if (!model.isPatching) { - model.cleanPatcher(); - Navigator.of(context).pop(); - } - return false; - }, + onWillPop: () => model.onWillPop(context), ), ); } diff --git a/lib/ui/views/installer/installer_viewmodel.dart b/lib/ui/views/installer/installer_viewmodel.dart index cfe3394f..8e83ab1b 100644 --- a/lib/ui/views/installer/installer_viewmodel.dart +++ b/lib/ui/views/installer/installer_viewmodel.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_background/flutter_background.dart'; import 'package:flutter_i18n/flutter_i18n.dart'; +import 'package:fluttertoast/fluttertoast.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:revanced_manager/app/app.locator.dart'; import 'package:revanced_manager/models/patch.dart'; @@ -215,4 +216,21 @@ class InstallerViewModel extends BaseViewModel { break; } } + + Future onWillPop(BuildContext context) async { + if (isPatching) { + Fluttertoast.showToast( + msg: FlutterI18n.translate( + context, + 'installerView.noExit', + ), + toastLength: Toast.LENGTH_LONG, + gravity: ToastGravity.CENTER, + ); + return false; + } + cleanPatcher(); + Navigator.of(context).pop(); + return true; + } } diff --git a/lib/ui/widgets/shared/custom_sliver_app_bar.dart b/lib/ui/widgets/shared/custom_sliver_app_bar.dart index 45899476..798bff69 100644 --- a/lib/ui/widgets/shared/custom_sliver_app_bar.dart +++ b/lib/ui/widgets/shared/custom_sliver_app_bar.dart @@ -5,6 +5,7 @@ class CustomSliverAppBar extends StatelessWidget { final List? actions; final PreferredSizeWidget? bottom; final bool isMainView; + final Function()? onBackButtonPressed; const CustomSliverAppBar({ Key? key, @@ -12,6 +13,7 @@ class CustomSliverAppBar extends StatelessWidget { this.actions, this.bottom, this.isMainView = false, + this.onBackButtonPressed, }) : super(key: key); @override @@ -24,7 +26,7 @@ class CustomSliverAppBar extends StatelessWidget { automaticallyImplyLeading: !isMainView, flexibleSpace: FlexibleSpaceBar( titlePadding: EdgeInsets.only( - bottom: 14.0, + bottom: bottom != null ? 16.0 : 14.0, left: isMainView ? 20.0 : 55.0, ), title: title, @@ -36,7 +38,8 @@ class CustomSliverAppBar extends StatelessWidget { Icons.arrow_back, color: Theme.of(context).textTheme.headline6!.color, ), - onPressed: () => Navigator.of(context).pop(), + onPressed: + onBackButtonPressed ?? () => Navigator.of(context).pop(), ), backgroundColor: MaterialStateColor.resolveWith( (states) => states.contains(MaterialState.scrolledUnder)