fix: No need for an uninstall confirmation dialog as OS already handles this

This commit is contained in:
Alberto Ponces 2022-09-18 22:47:24 +01:00
parent 110c3326bd
commit 79d0396630
3 changed files with 37 additions and 37 deletions

View File

@ -130,9 +130,6 @@
"uninstallButton": "Uninstall",
"patchButton": "Patch",
"unpatchButton": "Unpatch",
"uninstallDialogTitle": "Uninstall",
"uninstallDialogText": "Are you sure you want to uninstall this app?",
"unpatchDialogTitle": "Unpatch",
"unpatchDialogText": "Are you sure you want to unpatch this app?",
"rootDialogTitle": "Error",
"rootDialogText": "App was installed with root mode enabled but currently root mode is disabled.\nPlease enable root mode first.",

View File

@ -99,7 +99,7 @@ class AppInfoView extends StatelessWidget {
),
const Spacer(),
InkWell(
onTap: () => model.showUninstallAlertDialog(
onTap: () => model.showUninstallDialog(
context,
app,
false,
@ -171,7 +171,7 @@ class AppInfoView extends StatelessWidget {
app.isRooted ? const Spacer() : Container(),
app.isRooted
? InkWell(
onTap: () => model.showUninstallAlertDialog(
onTap: () => model.showUninstallDialog(
context,
app,
true,

View File

@ -1,3 +1,4 @@
// ignore_for_file: use_build_context_synchronously
import 'package:device_apps/device_apps.dart';
import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart';
@ -44,7 +45,7 @@ class AppInfoViewModel extends BaseViewModel {
locator<NavigationViewModel>().setIndex(1);
}
Future<void> showUninstallAlertDialog(
Future<void> showUninstallDialog(
BuildContext context,
PatchedApplication app,
bool onlyUnpatch,
@ -66,38 +67,40 @@ class AppInfoViewModel extends BaseViewModel {
),
);
} else {
return showDialog(
context: context,
builder: (context) => AlertDialog(
title: I18nText(
onlyUnpatch
? 'appInfoView.unpatchDialogTitle'
: 'appInfoView.uninstallDialogTitle',
),
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
content: I18nText(
onlyUnpatch
? 'appInfoView.unpatchDialogText'
: 'appInfoView.uninstallDialogText',
),
actions: <Widget>[
CustomMaterialButton(
isFilled: false,
label: I18nText('cancelButton'),
onPressed: () => Navigator.of(context).pop(),
if (onlyUnpatch) {
return showDialog(
context: context,
builder: (context) => AlertDialog(
title: I18nText(
'appInfoView.unpatchButton',
),
CustomMaterialButton(
label: I18nText('okButton'),
onPressed: () {
uninstallApp(app, onlyUnpatch);
locator<HomeViewModel>().initialize(context);
Navigator.of(context).pop();
Navigator.of(context).pop();
},
)
],
),
);
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
content: I18nText(
'appInfoView.unpatchDialogText',
),
actions: <Widget>[
CustomMaterialButton(
isFilled: false,
label: I18nText('cancelButton'),
onPressed: () => Navigator.of(context).pop(),
),
CustomMaterialButton(
label: I18nText('okButton'),
onPressed: () {
uninstallApp(app, onlyUnpatch);
locator<HomeViewModel>().initialize(context);
Navigator.of(context).pop();
Navigator.of(context).pop();
},
)
],
),
);
} else {
uninstallApp(app, onlyUnpatch);
locator<HomeViewModel>().initialize(context);
Navigator.of(context).pop();
}
}
}