mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-06-12 12:47:37 +02: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:
@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user