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", "uninstallButton": "Uninstall",
"patchButton": "Patch", "patchButton": "Patch",
"unpatchButton": "Unpatch", "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?", "unpatchDialogText": "Are you sure you want to unpatch this app?",
"rootDialogTitle": "Error", "rootDialogTitle": "Error",
"rootDialogText": "App was installed with root mode enabled but currently root mode is disabled.\nPlease enable root mode first.", "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(), const Spacer(),
InkWell( InkWell(
onTap: () => model.showUninstallAlertDialog( onTap: () => model.showUninstallDialog(
context, context,
app, app,
false, false,
@ -171,7 +171,7 @@ class AppInfoView extends StatelessWidget {
app.isRooted ? const Spacer() : Container(), app.isRooted ? const Spacer() : Container(),
app.isRooted app.isRooted
? InkWell( ? InkWell(
onTap: () => model.showUninstallAlertDialog( onTap: () => model.showUninstallDialog(
context, context,
app, app,
true, true,

View File

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