mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-06-12 12:47:37 +02:00
feat: Add patch options (#1354)
This commit is contained in:
@ -22,7 +22,14 @@ class PatcherView extends StatelessWidget {
|
||||
child: FloatingActionButton.extended(
|
||||
label: I18nText('patcherView.patchButton'),
|
||||
icon: const Icon(Icons.build),
|
||||
onPressed: () => model.showRemovedPatchesDialog(context),
|
||||
onPressed: () async{
|
||||
if (model.checkRequiredPatchOption(context)) {
|
||||
final bool proceed = model.showRemovedPatchesDialog(context);
|
||||
if (proceed && context.mounted) {
|
||||
model.showArmv7WarningDialog(context);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
body: CustomScrollView(
|
||||
@ -45,7 +52,10 @@ class PatcherView extends StatelessWidget {
|
||||
delegate: SliverChildListDelegate.fixed(
|
||||
<Widget>[
|
||||
AppSelectorCard(
|
||||
onPressed: () => model.navigateToAppSelector(),
|
||||
onPressed: () => {
|
||||
model.navigateToAppSelector(),
|
||||
model.ctx = context,
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Opacity(
|
||||
|
@ -21,6 +21,7 @@ class PatcherViewModel extends BaseViewModel {
|
||||
final ManagerAPI _managerAPI = locator<ManagerAPI>();
|
||||
final PatcherAPI _patcherAPI = locator<PatcherAPI>();
|
||||
PatchedApplication? selectedApp;
|
||||
BuildContext? ctx;
|
||||
List<Patch> selectedPatches = [];
|
||||
List<String> removedPatches = [];
|
||||
|
||||
@ -44,9 +45,9 @@ class PatcherViewModel extends BaseViewModel {
|
||||
return selectedApp == null;
|
||||
}
|
||||
|
||||
Future<void> showRemovedPatchesDialog(BuildContext context) async {
|
||||
bool showRemovedPatchesDialog(BuildContext context) {
|
||||
if (removedPatches.isNotEmpty) {
|
||||
return showDialog(
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: I18nText('notice'),
|
||||
@ -59,21 +60,58 @@ class PatcherViewModel extends BaseViewModel {
|
||||
CustomMaterialButton(
|
||||
isFilled: false,
|
||||
label: I18nText('noButton'),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
CustomMaterialButton(
|
||||
label: I18nText('yesButton'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
navigateToInstaller();
|
||||
showArmv7WarningDialog(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
showArmv7WarningDialog(context); // TODO(aabed): Find out why this is here
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool checkRequiredPatchOption(BuildContext context) {
|
||||
if (getNullRequiredOptions(selectedPatches, selectedApp!.packageName).isNotEmpty) {
|
||||
showRequiredOptionDialog(context);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void showRequiredOptionDialog([context]) {
|
||||
showDialog(
|
||||
context: context ?? ctx,
|
||||
builder: (context) => AlertDialog(
|
||||
title: I18nText('notice'),
|
||||
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
|
||||
content: I18nText('patcherView.requiredOptionDialogText'),
|
||||
actions: <Widget>[
|
||||
CustomMaterialButton(
|
||||
isFilled: false,
|
||||
label: I18nText('cancelButton'),
|
||||
onPressed: () => {
|
||||
Navigator.of(context).pop(),
|
||||
},
|
||||
),
|
||||
CustomMaterialButton(
|
||||
label: I18nText('okButton'),
|
||||
onPressed: () => {
|
||||
Navigator.pop(context),
|
||||
navigateToPatchesSelector(),
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> showArmv7WarningDialog(BuildContext context) async {
|
||||
@ -163,7 +201,10 @@ class PatcherViewModel extends BaseViewModel {
|
||||
final usedPatches = _managerAPI.getUsedPatches(selectedApp!.packageName);
|
||||
for (final patch in usedPatches){
|
||||
if (!patches.any((p) => p.name == patch.name)){
|
||||
removedPatches.add('\u2022 ${patch.name}');
|
||||
removedPatches.add('• ${patch.name}');
|
||||
for (final option in patch.options) {
|
||||
_managerAPI.clearPatchOption(selectedApp!.packageName, patch.name, option.key);
|
||||
}
|
||||
}
|
||||
}
|
||||
notifyListeners();
|
||||
|
Reference in New Issue
Block a user