From 79d0396630212719e93ebcbac447415e5a50090d Mon Sep 17 00:00:00 2001 From: Alberto Ponces Date: Sun, 18 Sep 2022 22:47:24 +0100 Subject: [PATCH] fix: No need for an uninstall confirmation dialog as OS already handles this --- assets/i18n/en.json | 3 - lib/ui/widgets/appInfoView/app_info_view.dart | 4 +- .../appInfoView/app_info_viewmodel.dart | 67 ++++++++++--------- 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/assets/i18n/en.json b/assets/i18n/en.json index 01f0206a60..82d1a69190 100644 --- a/assets/i18n/en.json +++ b/assets/i18n/en.json @@ -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.", diff --git a/lib/ui/widgets/appInfoView/app_info_view.dart b/lib/ui/widgets/appInfoView/app_info_view.dart index 9fa567a943..d4af366728 100644 --- a/lib/ui/widgets/appInfoView/app_info_view.dart +++ b/lib/ui/widgets/appInfoView/app_info_view.dart @@ -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, diff --git a/lib/ui/widgets/appInfoView/app_info_viewmodel.dart b/lib/ui/widgets/appInfoView/app_info_viewmodel.dart index 8bd9c47d26..e023e8dbe3 100644 --- a/lib/ui/widgets/appInfoView/app_info_viewmodel.dart +++ b/lib/ui/widgets/appInfoView/app_info_viewmodel.dart @@ -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().setIndex(1); } - Future showUninstallAlertDialog( + Future 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: [ - 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().initialize(context); - Navigator.of(context).pop(); - Navigator.of(context).pop(); - }, - ) - ], - ), - ); + backgroundColor: Theme.of(context).colorScheme.secondaryContainer, + content: I18nText( + 'appInfoView.unpatchDialogText', + ), + actions: [ + CustomMaterialButton( + isFilled: false, + label: I18nText('cancelButton'), + onPressed: () => Navigator.of(context).pop(), + ), + CustomMaterialButton( + label: I18nText('okButton'), + onPressed: () { + uninstallApp(app, onlyUnpatch); + locator().initialize(context); + Navigator.of(context).pop(); + Navigator.of(context).pop(); + }, + ) + ], + ), + ); + } else { + uninstallApp(app, onlyUnpatch); + locator().initialize(context); + Navigator.of(context).pop(); + } } }