mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-06-12 12:47:37 +02:00
feat: improve predictive back (#1487)
Signed-off-by: validcube <pun.butrach@gmail.com>
This commit is contained in:
@ -182,7 +182,8 @@ class InstallerViewModel extends BaseViewModel {
|
||||
Future<void> copyLogs() async {
|
||||
final info = await AboutInfo.getInfo();
|
||||
dynamic getValue(String patchName, Option option) {
|
||||
final Option? savedOption = _managerAPI.getPatchOption(_app.packageName, patchName, option.key);
|
||||
final Option? savedOption =
|
||||
_managerAPI.getPatchOption(_app.packageName, patchName, option.key);
|
||||
if (savedOption != null) {
|
||||
return savedOption.value;
|
||||
} else {
|
||||
@ -203,7 +204,6 @@ class InstallerViewModel extends BaseViewModel {
|
||||
'App: ${_app.packageName} v${_app.version}',
|
||||
'Patches version: ${_managerAPI.patchesVersion}',
|
||||
'Patches: ${_patches.map((p) => p.name + (p.options.isEmpty ? '' : ' [${p.options.map((o) => '${o.title}: ${getValue(p.name, o)}').join(", ")}]')).toList().join(", ")}',
|
||||
|
||||
'\n- Settings',
|
||||
'Allow changing patch selection: ${_managerAPI.isPatchesChangeEnabled()}',
|
||||
'Version compatibility check: ${_managerAPI.isVersionCompatibilityCheckEnabled()}',
|
||||
@ -427,25 +427,38 @@ class InstallerViewModel extends BaseViewModel {
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> onWillPop(BuildContext context) async {
|
||||
if (isPatching) {
|
||||
if (!cancel) {
|
||||
cancel = true;
|
||||
_toast.showBottom('installerView.pressBackAgain');
|
||||
} else if (!isCanceled) {
|
||||
await stopPatcher();
|
||||
} else {
|
||||
_toast.showBottom('installerView.noExit');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (!cancel) {
|
||||
cleanPatcher();
|
||||
bool canPop() {
|
||||
return !isPatching;
|
||||
}
|
||||
|
||||
void onBackButtonInvoked(BuildContext context) {
|
||||
if (canPop()) {
|
||||
onPopInvoked(context, true);
|
||||
} else {
|
||||
_patcherAPI.cleanPatcher();
|
||||
onPopInvoked(context, false);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> onPopInvoked(BuildContext context, bool didPop) async {
|
||||
if (didPop) {
|
||||
if (!cancel) {
|
||||
cleanPatcher();
|
||||
} else {
|
||||
_patcherAPI.cleanPatcher();
|
||||
}
|
||||
screenshotCallback.dispose();
|
||||
Navigator.of(context).pop();
|
||||
} else {
|
||||
if (isPatching) {
|
||||
if (!cancel) {
|
||||
cancel = true;
|
||||
_toast.showBottom('installerView.pressBackAgain');
|
||||
} else if (!isCanceled) {
|
||||
await stopPatcher();
|
||||
} else {
|
||||
_toast.showBottom('installerView.noExit');
|
||||
}
|
||||
}
|
||||
}
|
||||
screenshotCallback.dispose();
|
||||
Navigator.of(context).pop();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user