Skip to content

Commit

Permalink
fix: No need for an uninstall confirmation dialog as OS already handl…
Browse files Browse the repository at this point in the history
…es this
  • Loading branch information
ponces committed Sep 18, 2022
1 parent 110c332 commit 79d0396
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 37 deletions.
3 changes: 0 additions & 3 deletions assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/widgets/appInfoView/app_info_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class AppInfoView extends StatelessWidget {
),
const Spacer(),
InkWell(
onTap: () => model.showUninstallAlertDialog(
onTap: () => model.showUninstallDialog(
context,
app,
false,
Expand Down Expand Up @@ -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,
Expand Down
67 changes: 35 additions & 32 deletions lib/ui/widgets/appInfoView/app_info_viewmodel.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -44,7 +45,7 @@ class AppInfoViewModel extends BaseViewModel {
locator<NavigationViewModel>().setIndex(1);
}

Future<void> showUninstallAlertDialog(
Future<void> showUninstallDialog(
BuildContext context,
PatchedApplication app,
bool onlyUnpatch,
Expand All @@ -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();
}
}
}

Expand Down

0 comments on commit 79d0396

Please sign in to comment.