mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
feat: improve predictive back (#1487)
Signed-off-by: validcube <pun.butrach@gmail.com>
This commit is contained in:
parent
98c16eb1dc
commit
06ff36c836
@ -582,8 +582,8 @@ class ManagerAPI {
|
|||||||
return showDialog(
|
return showDialog(
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => WillPopScope(
|
builder: (context) => PopScope(
|
||||||
onWillPop: () async => false,
|
canPop: false,
|
||||||
child: AlertDialog(
|
child: AlertDialog(
|
||||||
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
|
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
|
||||||
title: I18nText('warning'),
|
title: I18nText('warning'),
|
||||||
|
@ -15,7 +15,8 @@ class InstallerView extends StatelessWidget {
|
|||||||
return ViewModelBuilder<InstallerViewModel>.reactive(
|
return ViewModelBuilder<InstallerViewModel>.reactive(
|
||||||
onViewModelReady: (model) => model.initialize(context),
|
onViewModelReady: (model) => model.initialize(context),
|
||||||
viewModelBuilder: () => InstallerViewModel(),
|
viewModelBuilder: () => InstallerViewModel(),
|
||||||
builder: (context, model, child) => WillPopScope(
|
builder: (context, model, child) => PopScope(
|
||||||
|
onPopInvoked: (bool didPop) => model.onPopInvoked(context, didPop),
|
||||||
child: SafeArea(
|
child: SafeArea(
|
||||||
top: false,
|
top: false,
|
||||||
bottom: model.isPatching,
|
bottom: model.isPatching,
|
||||||
@ -83,7 +84,7 @@ class InstallerView extends StatelessWidget {
|
|||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
onBackButtonPressed: () => model.onWillPop(context),
|
onBackButtonPressed: () => model.onBackButtonInvoked(context),
|
||||||
bottom: PreferredSize(
|
bottom: PreferredSize(
|
||||||
preferredSize: const Size(double.infinity, 1.0),
|
preferredSize: const Size(double.infinity, 1.0),
|
||||||
child: GradientProgressIndicator(progress: model.progress),
|
child: GradientProgressIndicator(progress: model.progress),
|
||||||
@ -111,7 +112,6 @@ class InstallerView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
onWillPop: () => model.onWillPop(context),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,8 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
Future<void> copyLogs() async {
|
Future<void> copyLogs() async {
|
||||||
final info = await AboutInfo.getInfo();
|
final info = await AboutInfo.getInfo();
|
||||||
dynamic getValue(String patchName, Option option) {
|
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) {
|
if (savedOption != null) {
|
||||||
return savedOption.value;
|
return savedOption.value;
|
||||||
} else {
|
} else {
|
||||||
@ -203,7 +204,6 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
'App: ${_app.packageName} v${_app.version}',
|
'App: ${_app.packageName} v${_app.version}',
|
||||||
'Patches version: ${_managerAPI.patchesVersion}',
|
'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(", ")}',
|
'Patches: ${_patches.map((p) => p.name + (p.options.isEmpty ? '' : ' [${p.options.map((o) => '${o.title}: ${getValue(p.name, o)}').join(", ")}]')).toList().join(", ")}',
|
||||||
|
|
||||||
'\n- Settings',
|
'\n- Settings',
|
||||||
'Allow changing patch selection: ${_managerAPI.isPatchesChangeEnabled()}',
|
'Allow changing patch selection: ${_managerAPI.isPatchesChangeEnabled()}',
|
||||||
'Version compatibility check: ${_managerAPI.isVersionCompatibilityCheckEnabled()}',
|
'Version compatibility check: ${_managerAPI.isVersionCompatibilityCheckEnabled()}',
|
||||||
@ -427,25 +427,38 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> onWillPop(BuildContext context) async {
|
bool canPop() {
|
||||||
if (isPatching) {
|
return !isPatching;
|
||||||
if (!cancel) {
|
}
|
||||||
cancel = true;
|
|
||||||
_toast.showBottom('installerView.pressBackAgain');
|
void onBackButtonInvoked(BuildContext context) {
|
||||||
} else if (!isCanceled) {
|
if (canPop()) {
|
||||||
await stopPatcher();
|
onPopInvoked(context, true);
|
||||||
} else {
|
|
||||||
_toast.showBottom('installerView.noExit');
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!cancel) {
|
|
||||||
cleanPatcher();
|
|
||||||
} else {
|
} 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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,13 +13,11 @@ class NavigationView extends StatelessWidget {
|
|||||||
return ViewModelBuilder<NavigationViewModel>.reactive(
|
return ViewModelBuilder<NavigationViewModel>.reactive(
|
||||||
onViewModelReady: (model) => model.initialize(context),
|
onViewModelReady: (model) => model.initialize(context),
|
||||||
viewModelBuilder: () => locator<NavigationViewModel>(),
|
viewModelBuilder: () => locator<NavigationViewModel>(),
|
||||||
builder: (context, model, child) => WillPopScope(
|
builder: (context, model, child) => PopScope(
|
||||||
onWillPop: () async {
|
canPop: model.currentIndex == 0,
|
||||||
if (model.currentIndex == 0) {
|
onPopInvoked: (bool didPop) {
|
||||||
return true;
|
if (!didPop) {
|
||||||
} else {
|
|
||||||
model.setIndex(0);
|
model.setIndex(0);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
|
Loading…
Reference in New Issue
Block a user