mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2024-11-10 01:01:56 +01:00
feat: Prevent exiting installer on new back button as well and show why exiting is not possible during patching
This commit is contained in:
parent
2a2bb8212f
commit
bed2cf76d5
4 changed files with 27 additions and 10 deletions
|
@ -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",
|
||||
|
|
|
@ -29,6 +29,7 @@ class InstallerView extends StatelessWidget {
|
|||
color: Theme.of(context).textTheme.headline6!.color,
|
||||
),
|
||||
),
|
||||
onBackButtonPressed: () => model.onWillPop(context),
|
||||
actions: <Widget>[
|
||||
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),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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<bool> 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ class CustomSliverAppBar extends StatelessWidget {
|
|||
final List<Widget>? 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)
|
||||
|
|
Loading…
Reference in a new issue