feat: Add a confirmation dialog to update Manager button

This commit is contained in:
Alberto Ponces 2022-09-07 13:03:54 +01:00
parent 351b04dd46
commit 80eeafaf2b
5 changed files with 40 additions and 13 deletions

View file

@ -18,6 +18,8 @@
"noUpdates": "No updates available",
"noInstallations": "No patched applications installed",
"installed": "Installed",
"updateDialogTitle": "Update",
"updateDialogText": "Are you sure you want to download and update Manager?",
"notificationTitle": "ReVanced Manager was updated!",
"notificationText": "Tap to open the app",
"downloadingMessage": "Downloading update!",
@ -68,8 +70,8 @@
},
"patchItem": {
"unsupportedWarningButton": "Unsupported version",
"alertDialogTitle": "Warning",
"alertDialogText": "Selecting this patch may or may not result in patching errors.\n\nApp version: {packageVersion}\nCurrent supported versions:\n{supportedVersions}"
"unsupportedDialogTitle": "Warning",
"unsupportedDialogText": "Selecting this patch may or may not result in patching errors.\n\nApp version: {packageVersion}\nCurrent supported versions:\n{supportedVersions}"
},
"installerView": {
"widgetTitle": "Installer",
@ -113,9 +115,10 @@
"openButton": "Open",
"uninstallButton": "Uninstall",
"patchButton": "Patch",
"alertDialogTitle": "Uninstall",
"alertDialogText": "Are you sure you want to uninstall this app?",
"errorDialogText": "App was installed with root mode enabled but currently root mode is disabled.\nPlease enable root mode first.",
"uninstallDialogTitle": "Uninstall",
"uninstallDialogText": "Are you sure you want to uninstall this app?",
"rootDialogTitle": "Error",
"rootDialogText": "App was installed with root mode enabled but currently root mode is disabled.\nPlease enable root mode first.",
"packageNameLabel": "Package Name",
"installTypeLabel": "Installation Type",
"rootTypeLabel": "Root",

View file

@ -47,7 +47,8 @@ class HomeView extends StatelessWidget {
),
const SizedBox(height: 10),
LatestCommitCard(
onPressed: () => model.updateManager(context),
onPressed: () =>
model.showUpdateConfirmationDialog(context),
),
const SizedBox(height: 23),
I18nText(

View file

@ -2,7 +2,7 @@
import 'dart:io';
import 'package:app_installer/app_installer.dart';
import 'package:device_apps/device_apps.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:fluttertoast/fluttertoast.dart';
@ -14,6 +14,7 @@ import 'package:revanced_manager/services/manager_api.dart';
import 'package:revanced_manager/services/patcher_api.dart';
import 'package:revanced_manager/ui/views/navigation/navigation_viewmodel.dart';
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
import 'package:revanced_manager/ui/widgets/installerView/custom_material_button.dart';
import 'package:stacked/stacked.dart';
import 'package:stacked_services/stacked_services.dart';
@ -147,4 +148,26 @@ class HomeViewModel extends BaseViewModel {
);
}
}
Future<void> showUpdateConfirmationDialog(BuildContext context) async {
return showDialog(
context: context,
builder: (context) => AlertDialog(
title: I18nText('homeView.updateDialogTitle'),
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
content: I18nText('homeView.updateDialogText'),
actions: [
CustomMaterialButton(
isFilled: false,
label: I18nText('cancelButton'),
onPressed: () => Navigator.of(context).pop(),
),
CustomMaterialButton(
label: I18nText('okButton'),
onPressed: () => updateManager(context),
)
],
),
);
}
}

View file

@ -45,9 +45,9 @@ class AppInfoViewModel extends BaseViewModel {
return showDialog(
context: context,
builder: (context) => AlertDialog(
title: I18nText('appInfoView.alertDialogTitle'),
title: I18nText('appInfoView.rootDialogTitle'),
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
content: I18nText('appInfoView.errorDialogText'),
content: I18nText('appInfoView.rootDialogText'),
actions: [
CustomMaterialButton(
label: I18nText('okButton'),
@ -60,9 +60,9 @@ class AppInfoViewModel extends BaseViewModel {
return showDialog(
context: context,
builder: (context) => AlertDialog(
title: I18nText('appInfoView.alertDialogTitle'),
title: I18nText('appInfoView.uninstallDialogTitle'),
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
content: I18nText('appInfoView.alertDialogText'),
content: I18nText('appInfoView.uninstallDialogText'),
actions: [
CustomMaterialButton(
isFilled: false,

View file

@ -144,10 +144,10 @@ class _PatchItemState extends State<PatchItem> {
return showDialog(
context: context,
builder: (context) => AlertDialog(
title: I18nText('patchItem.alertDialogTitle'),
title: I18nText('patchItem.unsupportedDialogTitle'),
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
content: I18nText(
'patchItem.alertDialogText',
'patchItem.unsupportedDialogText',
translationParams: {
'packageVersion': widget.packageVersion,
'supportedVersions':