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,19 +67,16 @@ class AppInfoViewModel extends BaseViewModel {
), ),
); );
} else { } else {
if (onlyUnpatch) {
return showDialog( return showDialog(
context: context, context: context,
builder: (context) => AlertDialog( builder: (context) => AlertDialog(
title: I18nText( title: I18nText(
onlyUnpatch 'appInfoView.unpatchButton',
? 'appInfoView.unpatchDialogTitle'
: 'appInfoView.uninstallDialogTitle',
), ),
backgroundColor: Theme.of(context).colorScheme.secondaryContainer, backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
content: I18nText( content: I18nText(
onlyUnpatch 'appInfoView.unpatchDialogText',
? 'appInfoView.unpatchDialogText'
: 'appInfoView.uninstallDialogText',
), ),
actions: <Widget>[ actions: <Widget>[
CustomMaterialButton( CustomMaterialButton(
@ -98,6 +96,11 @@ class AppInfoViewModel extends BaseViewModel {
], ],
), ),
); );
} else {
uninstallApp(app, onlyUnpatch);
locator<HomeViewModel>().initialize(context);
Navigator.of(context).pop();
}
} }
} }