From d03eff9e6a783e8fbed814dd407234cb198bf7e7 Mon Sep 17 00:00:00 2001 From: validcube Date: Sat, 9 Dec 2023 20:55:08 +0700 Subject: [PATCH 1/4] feat: migrate to native buttons Signed-off-by: validcube --- lib/services/manager_api.dart | 8 +-- .../app_selector/app_selector_viewmodel.dart | 17 +++--- lib/ui/views/home/home_viewmodel.dart | 27 +++++----- .../views/installer/installer_viewmodel.dart | 54 +++++++++++-------- .../patch_options/patch_options_view.dart | 8 ++- .../patch_options_viewmodel.dart | 28 ++++------ lib/ui/views/patcher/patcher_viewmodel.dart | 28 +++++----- .../patches_selector_viewmodel.dart | 14 +++-- .../settings_manage_api_url.dart | 19 +++---- .../settings_manage_keystore_password.dart | 10 ++-- .../settings_manage_sources.dart | 19 +++---- .../settings_update_theme.dart | 14 +++-- lib/ui/views/settings/settings_viewmodel.dart | 36 ++++++------- .../appInfoView/app_info_viewmodel.dart | 18 +++---- .../widgets/homeView/latest_commit_card.dart | 9 ++-- .../homeView/update_confirmation_dialog.dart | 6 +-- .../patchesSelectorView/patch_item.dart | 9 ++-- .../settingsView/settings_export_section.dart | 19 +++---- lib/ui/widgets/shared/application_item.dart | 6 +-- .../shared/custom_material_button.dart | 1 + 20 files changed, 161 insertions(+), 189 deletions(-) diff --git a/lib/services/manager_api.dart b/lib/services/manager_api.dart index 853068734e..3dc571cd6f 100644 --- a/lib/services/manager_api.dart +++ b/lib/services/manager_api.dart @@ -15,7 +15,6 @@ import 'package:revanced_manager/services/github_api.dart'; import 'package:revanced_manager/services/patcher_api.dart'; import 'package:revanced_manager/services/revanced_api.dart'; import 'package:revanced_manager/services/root_api.dart'; -import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart'; import 'package:revanced_manager/utils/check_for_supported_patch.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:timeago/timeago.dart'; @@ -62,7 +61,8 @@ class ManagerAPI { Future initialize() async { _prefs = await SharedPreferences.getInstance(); isRooted = await _rootAPI.isRooted(); - isDynamicThemeAvailable = (await getSdkVersion()) >= 31; // ANDROID_12_SDK_VERSION = 31 + isDynamicThemeAvailable = + (await getSdkVersion()) >= 31; // ANDROID_12_SDK_VERSION = 31 storedPatchesFile = (await getApplicationDocumentsDirectory()).path + storedPatchesFile; } @@ -620,12 +620,12 @@ class ManagerAPI { }, ), actions: [ - CustomMaterialButton( - label: I18nText('okButton'), + FilledButton( onPressed: () { setPatchesChangeWarning(noShow.value); Navigator.of(context).pop(); }, + child: I18nText('okButton'), ), ], ), diff --git a/lib/ui/views/app_selector/app_selector_viewmodel.dart b/lib/ui/views/app_selector/app_selector_viewmodel.dart index 7961ceb9ed..d63d5ac135 100644 --- a/lib/ui/views/app_selector/app_selector_viewmodel.dart +++ b/lib/ui/views/app_selector/app_selector_viewmodel.dart @@ -13,7 +13,6 @@ import 'package:revanced_manager/services/manager_api.dart'; import 'package:revanced_manager/services/patcher_api.dart'; import 'package:revanced_manager/services/toast.dart'; import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart'; -import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart'; import 'package:revanced_manager/utils/check_for_supported_patch.dart'; import 'package:stacked/stacked.dart'; @@ -105,7 +104,8 @@ class AppSelectorViewModel extends BaseViewModel { ]) async { final String suggestedVersion = getSuggestedVersion(application.packageName); - if (application.versionName != suggestedVersion && suggestedVersion.isNotEmpty) { + if (application.versionName != suggestedVersion && + suggestedVersion.isNotEmpty) { _managerAPI.suggestedAppVersionSelected = false; if (_managerAPI.isRequireSuggestedAppVersionEnabled() && context.mounted) { @@ -185,9 +185,9 @@ class AppSelectorViewModel extends BaseViewModel { ), ), actions: [ - CustomMaterialButton( - label: I18nText('okButton'), + FilledButton( onPressed: () => Navigator.of(context).pop(), + child: I18nText('okButton'), ), ], ), @@ -232,12 +232,12 @@ class AppSelectorViewModel extends BaseViewModel { ), ), const SizedBox(height: 30), - CustomMaterialButton( + FilledButton( onPressed: () async { Navigator.pop(innerContext); await selectAppFromStorage(context); }, - label: Row( + child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ const Icon(Icons.sd_card), @@ -247,12 +247,11 @@ class AppSelectorViewModel extends BaseViewModel { ), ), const SizedBox(height: 10), - CustomMaterialButton( - isFilled: false, + TextButton( onPressed: () { Navigator.pop(innerContext); }, - label: Row( + child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ const SizedBox(width: 10), diff --git a/lib/ui/views/home/home_viewmodel.dart b/lib/ui/views/home/home_viewmodel.dart index b85e49da1c..8df23910fa 100644 --- a/lib/ui/views/home/home_viewmodel.dart +++ b/lib/ui/views/home/home_viewmodel.dart @@ -21,7 +21,6 @@ import 'package:revanced_manager/services/toast.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/homeView/update_confirmation_dialog.dart'; -import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart'; import 'package:stacked/stacked.dart'; import 'package:stacked_services/stacked_services.dart'; @@ -65,8 +64,8 @@ class HomeViewModel extends BaseViewModel { .resolvePlatformSpecificImplementation< AndroidFlutterLocalNotificationsPlugin>() ?.requestNotificationsPermission(); - final bool isConnected = await Connectivity().checkConnectivity() != - ConnectivityResult.none; + final bool isConnected = + await Connectivity().checkConnectivity() != ConnectivityResult.none; if (!isConnected) { _toast.showBottom('homeView.noConnection'); } @@ -223,21 +222,20 @@ class HomeViewModel extends BaseViewModel { }, ), actions: [ - CustomMaterialButton( - isFilled: false, + TextButton( onPressed: () async { await _managerAPI.setPatchesConsent(false); SystemNavigator.pop(); }, - label: I18nText('quitButton'), + child: I18nText('quitButton'), ), - CustomMaterialButton( + FilledButton( onPressed: () async { await _managerAPI.setPatchesConsent(true); await _managerAPI.setPatchesAutoUpdate(autoUpdate.value); Navigator.of(context).pop(); }, - label: I18nText('okButton'), + child: I18nText('okButton'), ), ], ), @@ -324,12 +322,12 @@ class HomeViewModel extends BaseViewModel { const SizedBox(height: 16.0), Align( alignment: Alignment.centerRight, - child: CustomMaterialButton( - label: I18nText('cancelButton'), + child: FilledButton( onPressed: () { _revancedAPI.disposeManagerUpdateProgress(); Navigator.of(context).pop(); }, + child: I18nText('cancelButton'), ), ), ], @@ -355,24 +353,23 @@ class HomeViewModel extends BaseViewModel { children: [ Align( alignment: Alignment.centerRight, - child: CustomMaterialButton( - isFilled: false, - label: I18nText('cancelButton'), + child: TextButton( onPressed: () { Navigator.of(context).pop(); }, + child: I18nText('cancelButton'), ), ), const SizedBox(width: 8.0), Align( alignment: Alignment.centerRight, - child: CustomMaterialButton( - label: I18nText('updateButton'), + child: FilledButton( onPressed: () async { await InstallPlugin.installApk( downloadedApk!.path, ); }, + child: I18nText('updateButton'), ), ), ], diff --git a/lib/ui/views/installer/installer_viewmodel.dart b/lib/ui/views/installer/installer_viewmodel.dart index 53a03040d4..f2ce08c932 100644 --- a/lib/ui/views/installer/installer_viewmodel.dart +++ b/lib/ui/views/installer/installer_viewmodel.dart @@ -14,7 +14,6 @@ import 'package:revanced_manager/services/patcher_api.dart'; import 'package:revanced_manager/services/root_api.dart'; import 'package:revanced_manager/services/toast.dart'; import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart'; -import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart'; import 'package:revanced_manager/utils/about_info.dart'; import 'package:screenshot_callback/screenshot_callback.dart'; import 'package:stacked/stacked.dart'; @@ -183,13 +182,15 @@ class InstallerViewModel extends BaseViewModel { final lineCount = logLines.where((line) => line.endsWith(keyword)).length; final index = logLines.indexWhere((line) => line.endsWith(keyword)); if (newString != null && lineCount > 0) { - logLines.insert(index, newString.replaceAll('{lineCount}', lineCount.toString())); + logLines.insert( + index, newString.replaceAll('{lineCount}', lineCount.toString())); } logLines.removeWhere((lines) => lines.endsWith(keyword)); } dynamic _getPatchOptionValue(String patchName, Option option) { - final Option? savedOption = _managerAPI.getPatchOption(_app.packageName, patchName, option.key); + final Option? savedOption = + _managerAPI.getPatchOption(_app.packageName, patchName, option.key); if (savedOption != null) { return savedOption.value; } else { @@ -201,7 +202,14 @@ class InstallerViewModel extends BaseViewModel { if (patches.isEmpty) { return 'None'; } - return patches.map((p) => p.name + (p.options.isEmpty ? '' : ' [${p.options.map((o) => '${o.title}: ${_getPatchOptionValue(p.name, o)}').join(", ")}]')).toList().join(', '); + return patches + .map((p) => + p.name + + (p.options.isEmpty + ? '' + : ' [${p.options.map((o) => '${o.title}: ${_getPatchOptionValue(p.name, o)}').join(", ")}]')) + .toList() + .join(', '); } Future copyLogs() async { @@ -213,12 +221,21 @@ class InstallerViewModel extends BaseViewModel { _trimLogs(logsTrimmed, '.dex', 'Compiled {lineCount} dex files'); // Get patches added / removed - final defaultPatches = _patcherAPI.getFilteredPatches(_app.packageName).where((p) => !p.excluded).toList(); - final patchesAdded = _patches.where((p) => !defaultPatches.contains(p)).toList(); - final patchesRemoved = defaultPatches.where((p) => !_patches.contains(p)).toList(); + final defaultPatches = _patcherAPI + .getFilteredPatches(_app.packageName) + .where((p) => !p.excluded) + .toList(); + final patchesAdded = + _patches.where((p) => !defaultPatches.contains(p)).toList(); + final patchesRemoved = + defaultPatches.where((p) => !_patches.contains(p)).toList(); // Options changed - final patchesChanged = defaultPatches.where((p) => _patches.contains(p) && p.options.any((o) => _getPatchOptionValue(p.name, o) != o.value)).toList(); + final patchesChanged = defaultPatches + .where((p) => + _patches.contains(p) && + p.options.any((o) => _getPatchOptionValue(p.name, o) != o.value)) + .toList(); // Add Info final formattedLogs = [ @@ -229,21 +246,18 @@ class InstallerViewModel extends BaseViewModel { 'Android version: ${info['androidVersion']}', 'Supported architectures: ${info['supportedArch'].join(", ")}', 'Root permissions: ${isRooted ? 'Yes' : 'No'}', - '\n- Patch Info', 'App: ${_app.packageName} v${_app.version}', 'Patches version: ${_managerAPI.patchesVersion}', 'Patches added: ${_formatPatches(patchesAdded)}', 'Patches removed: ${_formatPatches(patchesRemoved)}', 'Options changed: ${_formatPatches(patchesChanged)}', - '\n- Settings', 'Allow changing patch selection: ${_managerAPI.isPatchesChangeEnabled()}', 'Version compatibility check: ${_managerAPI.isVersionCompatibilityCheckEnabled()}', 'Show universal patches: ${_managerAPI.areUniversalPatchesEnabled()}', 'Patches source: ${_managerAPI.getPatchesRepo()}', 'Integration source: ${_managerAPI.getIntegrationsRepo()}', - '\n- Logs', logsTrimmed.join('\n'), ]; @@ -265,20 +279,19 @@ class InstallerViewModel extends BaseViewModel { child: I18nText('installerView.screenshotDetected'), ), actions: [ - CustomMaterialButton( - isFilled: false, - label: I18nText('noButton'), + TextButton( onPressed: () { Navigator.of(context).pop(); }, + child: I18nText('noButton'), ), - CustomMaterialButton( - label: I18nText('yesButton'), + FilledButton( onPressed: () { copyLogs(); showPopupScreenshotWarning = true; Navigator.of(context).pop(); }, + child: I18nText('yesButton'), ), ], ), @@ -349,19 +362,18 @@ class InstallerViewModel extends BaseViewModel { ), ), actions: [ - CustomMaterialButton( - label: I18nText('cancelButton'), - isFilled: false, + TextButton( onPressed: () { Navigator.of(context).pop(); }, + child: I18nText('cancelButton'), ), - CustomMaterialButton( - label: I18nText('installerView.installButton'), + FilledButton( onPressed: () { Navigator.of(context).pop(); installResult(context, installType.value == 1); }, + child: I18nText('installerView.installButton'), ), ], ), diff --git a/lib/ui/views/patch_options/patch_options_view.dart b/lib/ui/views/patch_options/patch_options_view.dart index e35b849da3..e6ac1bb280 100644 --- a/lib/ui/views/patch_options/patch_options_view.dart +++ b/lib/ui/views/patch_options/patch_options_view.dart @@ -4,7 +4,6 @@ import 'package:google_fonts/google_fonts.dart'; import 'package:revanced_manager/models/patch.dart'; import 'package:revanced_manager/ui/views/patch_options/patch_options_viewmodel.dart'; import 'package:revanced_manager/ui/widgets/patchesSelectorView/patch_options_fields.dart'; -import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart'; import 'package:stacked/stacked.dart'; class PatchOptionsView extends StatelessWidget { @@ -82,8 +81,7 @@ class PatchOptionsView extends StatelessWidget { model.modifyOptions(value, option); }, ) - else if (option.valueType == - 'StringArray' || + else if (option.valueType == 'StringArray' || option.valueType == 'IntArray' || option.valueType == 'LongArray') IntStringLongListPatchOption( @@ -104,11 +102,11 @@ class PatchOptionsView extends StatelessWidget { const SizedBox( height: 8, ), - CustomMaterialButton( + FilledButton( onPressed: () { model.showAddOptionDialog(context); }, - label: Row( + child: Row( mainAxisSize: MainAxisSize.min, children: [ const Icon(Icons.add), diff --git a/lib/ui/views/patch_options/patch_options_viewmodel.dart b/lib/ui/views/patch_options/patch_options_viewmodel.dart index 520fd9c68e..c33ef2fc84 100644 --- a/lib/ui/views/patch_options/patch_options_viewmodel.dart +++ b/lib/ui/views/patch_options/patch_options_viewmodel.dart @@ -6,7 +6,6 @@ import 'package:revanced_manager/services/manager_api.dart'; import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart'; import 'package:revanced_manager/ui/views/patches_selector/patches_selector_viewmodel.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_card.dart'; -import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart'; import 'package:stacked/stacked.dart'; class PatchOptionsViewModel extends BaseViewModel { @@ -32,13 +31,11 @@ class PatchOptionsViewModel extends BaseViewModel { if (savedOptions.isNotEmpty) { visibleOptions = [ ...savedOptions, - ...options - .where( - (option) => - option.required && - !savedOptions.any((sOption) => sOption.key == option.key), - ) - , + ...options.where( + (option) => + option.required && + !savedOptions.any((sOption) => sOption.key == option.key), + ), ]; } else { visibleOptions = [ @@ -154,11 +151,11 @@ class PatchOptionsViewModel extends BaseViewModel { ], ), actions: [ - CustomMaterialButton( - label: I18nText('cancelButton'), + FilledButton( onPressed: () { Navigator.of(context).pop(); }, + child: I18nText('cancelButton'), ), ], contentPadding: const EdgeInsets.all(8), @@ -230,11 +227,7 @@ Future showRequiredOptionNullDialog( backgroundColor: Theme.of(context).colorScheme.secondaryContainer, title: I18nText('notice'), actions: [ - CustomMaterialButton( - isFilled: false, - label: I18nText( - 'patchOptionsView.deselectPatch', - ), + TextButton( onPressed: () async { if (managerAPI.isPatchesChangeEnabled()) { locator() @@ -256,12 +249,13 @@ Future showRequiredOptionNullDialog( PatchesSelectorViewModel().showPatchesChangeDialog(context); } }, + child: I18nText('patchOptionsView.deselectPatch'), ), - CustomMaterialButton( - label: I18nText('okButton'), + FilledButton( onPressed: () { Navigator.of(context).pop(); }, + child: I18nText('okButton'), ), ], content: I18nText( diff --git a/lib/ui/views/patcher/patcher_viewmodel.dart b/lib/ui/views/patcher/patcher_viewmodel.dart index 19d7072160..43a5d2b01f 100644 --- a/lib/ui/views/patcher/patcher_viewmodel.dart +++ b/lib/ui/views/patcher/patcher_viewmodel.dart @@ -13,7 +13,6 @@ import 'package:revanced_manager/models/patch.dart'; import 'package:revanced_manager/models/patched_application.dart'; import 'package:revanced_manager/services/manager_api.dart'; import 'package:revanced_manager/services/patcher_api.dart'; -import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart'; import 'package:revanced_manager/utils/about_info.dart'; import 'package:revanced_manager/utils/check_for_supported_patch.dart'; import 'package:stacked/stacked.dart'; @@ -61,19 +60,18 @@ class PatcherViewModel extends BaseViewModel { translationParams: {'patches': removedPatches.join('\n')}, ), actions: [ - CustomMaterialButton( - isFilled: false, - label: I18nText('noButton'), + TextButton( onPressed: () { Navigator.of(context).pop(); }, + child: I18nText('noButton'), ), - CustomMaterialButton( - label: I18nText('yesButton'), + FilledButton( onPressed: () { Navigator.of(context).pop(); showArmv7WarningDialog(context); }, + child: I18nText('yesButton'), ), ], ), @@ -100,19 +98,18 @@ class PatcherViewModel extends BaseViewModel { backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: I18nText('patcherView.requiredOptionDialogText'), actions: [ - CustomMaterialButton( - isFilled: false, - label: I18nText('cancelButton'), + TextButton( onPressed: () => { Navigator.of(context).pop(), }, + child: I18nText('cancelButton'), ), - CustomMaterialButton( - label: I18nText('okButton'), + FilledButton( onPressed: () => { Navigator.pop(context), navigateToPatchesSelector(), }, + child: I18nText('okButton'), ), ], ), @@ -133,17 +130,16 @@ class PatcherViewModel extends BaseViewModel { backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: I18nText('patcherView.armv7WarningDialogText'), actions: [ - CustomMaterialButton( - label: I18nText('noButton'), + FilledButton( onPressed: () => Navigator.of(context).pop(), + child: I18nText('noButton'), ), - CustomMaterialButton( - label: I18nText('yesButton'), - isFilled: false, + TextButton( onPressed: () { Navigator.of(context).pop(); navigateToInstaller(); }, + child: I18nText('yesButton'), ), ], ), diff --git a/lib/ui/views/patches_selector/patches_selector_viewmodel.dart b/lib/ui/views/patches_selector/patches_selector_viewmodel.dart index 173c1f5376..96ef0aca1e 100644 --- a/lib/ui/views/patches_selector/patches_selector_viewmodel.dart +++ b/lib/ui/views/patches_selector/patches_selector_viewmodel.dart @@ -10,7 +10,6 @@ import 'package:revanced_manager/services/patcher_api.dart'; import 'package:revanced_manager/services/toast.dart'; import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart'; import 'package:revanced_manager/ui/widgets/patchesSelectorView/patch_item.dart'; -import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart'; import 'package:revanced_manager/utils/check_for_supported_patch.dart'; import 'package:stacked/stacked.dart'; import 'package:stacked_services/stacked_services.dart'; @@ -100,11 +99,11 @@ class PatchesSelectorViewModel extends BaseViewModel { }, ), actions: [ - CustomMaterialButton( - label: I18nText('okButton'), + FilledButton( onPressed: () => { Navigator.of(context).pop(), }, + child: I18nText('okButton'), ), ], ), @@ -141,18 +140,17 @@ class PatchesSelectorViewModel extends BaseViewModel { ), ), actions: [ - CustomMaterialButton( - isFilled: false, - label: I18nText('okButton'), + TextButton( onPressed: () => Navigator.of(context).pop(), + child: I18nText('okButton'), ), - CustomMaterialButton( - label: I18nText('patchItem.patchesChangeWarningDialogButton'), + FilledButton( onPressed: () { Navigator.of(context) ..pop() ..pop(); }, + child: I18nText('patchItem.patchesChangeWarningDialogButton'), ), ], ), diff --git a/lib/ui/views/settings/settingsFragment/settings_manage_api_url.dart b/lib/ui/views/settings/settingsFragment/settings_manage_api_url.dart index 6fa1ccc1dd..4ce96f6b23 100644 --- a/lib/ui/views/settings/settingsFragment/settings_manage_api_url.dart +++ b/lib/ui/views/settings/settingsFragment/settings_manage_api_url.dart @@ -7,7 +7,6 @@ import 'package:revanced_manager/services/manager_api.dart'; import 'package:revanced_manager/services/toast.dart'; import 'package:revanced_manager/ui/widgets/settingsView/custom_text_field.dart'; import 'package:revanced_manager/ui/widgets/settingsView/settings_tile_dialog.dart'; -import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart'; import 'package:stacked/stacked.dart'; class SManageApiUrl extends BaseViewModel { @@ -51,16 +50,14 @@ class SManageApiUrl extends BaseViewModel { ), ), actions: [ - CustomMaterialButton( - isFilled: false, - label: I18nText('cancelButton'), + TextButton( onPressed: () { _apiUrlController.clear(); Navigator.of(context).pop(); }, + child: I18nText('cancelButton'), ), - CustomMaterialButton( - label: I18nText('okButton'), + FilledButton( onPressed: () { String apiUrl = _apiUrlController.text; if (!apiUrl.startsWith('https')) { @@ -70,6 +67,7 @@ class SManageApiUrl extends BaseViewModel { _toast.showBottom('settingsView.restartAppForChanges'); Navigator.of(context).pop(); }, + child: I18nText('okButton'), ), ], ), @@ -84,13 +82,11 @@ class SManageApiUrl extends BaseViewModel { backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: I18nText('settingsView.apiURLResetDialogText'), actions: [ - CustomMaterialButton( - isFilled: false, - label: I18nText('noButton'), + TextButton( onPressed: () => Navigator.of(context).pop(), + child: I18nText('noButton'), ), - CustomMaterialButton( - label: I18nText('yesButton'), + FilledButton( onPressed: () { _managerAPI.setApiUrl(''); _toast.showBottom('settingsView.restartAppForChanges'); @@ -98,6 +94,7 @@ class SManageApiUrl extends BaseViewModel { ..pop() ..pop(); }, + child: I18nText('yesButton'), ), ], ), diff --git a/lib/ui/views/settings/settingsFragment/settings_manage_keystore_password.dart b/lib/ui/views/settings/settingsFragment/settings_manage_keystore_password.dart index 4ac4689bde..8c5256a242 100644 --- a/lib/ui/views/settings/settingsFragment/settings_manage_keystore_password.dart +++ b/lib/ui/views/settings/settingsFragment/settings_manage_keystore_password.dart @@ -6,7 +6,6 @@ import 'package:revanced_manager/app/app.locator.dart'; import 'package:revanced_manager/services/manager_api.dart'; import 'package:revanced_manager/ui/widgets/settingsView/custom_text_field.dart'; import 'package:revanced_manager/ui/widgets/settingsView/settings_tile_dialog.dart'; -import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart'; import 'package:stacked/stacked.dart'; class SManageKeystorePassword extends BaseViewModel { @@ -47,21 +46,20 @@ class SManageKeystorePassword extends BaseViewModel { ), ), actions: [ - CustomMaterialButton( - isFilled: false, - label: I18nText('cancelButton'), + TextButton( onPressed: () { _keystorePasswordController.clear(); Navigator.of(context).pop(); }, + child: I18nText('cancelButton'), ), - CustomMaterialButton( - label: I18nText('okButton'), + FilledButton( onPressed: () { final String passwd = _keystorePasswordController.text; _managerAPI.setKeystorePassword(passwd); Navigator.of(context).pop(); }, + child: I18nText('okButton'), ), ], ), diff --git a/lib/ui/views/settings/settingsFragment/settings_manage_sources.dart b/lib/ui/views/settings/settingsFragment/settings_manage_sources.dart index 76e3171b1f..33cf43ba3f 100644 --- a/lib/ui/views/settings/settingsFragment/settings_manage_sources.dart +++ b/lib/ui/views/settings/settingsFragment/settings_manage_sources.dart @@ -7,7 +7,6 @@ import 'package:revanced_manager/services/manager_api.dart'; import 'package:revanced_manager/services/toast.dart'; import 'package:revanced_manager/ui/widgets/settingsView/custom_text_field.dart'; import 'package:revanced_manager/ui/widgets/settingsView/settings_tile_dialog.dart'; -import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart'; import 'package:stacked/stacked.dart'; class SManageSources extends BaseViewModel { @@ -107,9 +106,7 @@ class SManageSources extends BaseViewModel { ), ), actions: [ - CustomMaterialButton( - isFilled: false, - label: I18nText('cancelButton'), + TextButton( onPressed: () { _orgPatSourceController.clear(); _patSourceController.clear(); @@ -117,9 +114,9 @@ class SManageSources extends BaseViewModel { _intSourceController.clear(); Navigator.of(context).pop(); }, + child: I18nText('cancelButton'), ), - CustomMaterialButton( - label: I18nText('okButton'), + FilledButton( onPressed: () { _managerAPI.setRepoUrl(_hostSourceController.text.trim()); _managerAPI.setPatchesRepo( @@ -133,6 +130,7 @@ class SManageSources extends BaseViewModel { _toast.showBottom('settingsView.restartAppForChanges'); Navigator.of(context).pop(); }, + child: I18nText('okButton'), ), ], ), @@ -147,13 +145,11 @@ class SManageSources extends BaseViewModel { backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: I18nText('settingsView.sourcesResetDialogText'), actions: [ - CustomMaterialButton( - isFilled: false, - label: I18nText('noButton'), + TextButton( onPressed: () => Navigator.of(context).pop(), + child: I18nText('noButton'), ), - CustomMaterialButton( - label: I18nText('yesButton'), + FilledButton( onPressed: () { _managerAPI.setRepoUrl(''); _managerAPI.setPatchesRepo(''); @@ -165,6 +161,7 @@ class SManageSources extends BaseViewModel { ..pop() ..pop(); }, + child: I18nText('yesButton'), ), ], ), diff --git a/lib/ui/views/settings/settingsFragment/settings_update_theme.dart b/lib/ui/views/settings/settingsFragment/settings_update_theme.dart index 66fa683094..2bbd6b8f25 100644 --- a/lib/ui/views/settings/settingsFragment/settings_update_theme.dart +++ b/lib/ui/views/settings/settingsFragment/settings_update_theme.dart @@ -7,7 +7,6 @@ import 'package:flutter_i18n/widgets/I18nText.dart'; import 'package:revanced_manager/app/app.locator.dart'; import 'package:revanced_manager/services/manager_api.dart'; import 'package:revanced_manager/ui/widgets/settingsView/settings_section.dart'; -import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart'; class SUpdateThemeUI extends StatefulWidget { const SUpdateThemeUI({super.key}); @@ -36,9 +35,9 @@ class _SUpdateThemeUIState extends State { ), ), ), - trailing: CustomMaterialButton( - label: getThemeModeName(), + trailing: FilledButton( onPressed: () => {showThemeDialog(context)}, + child: getThemeModeName(), ), onTap: () => {showThemeDialog(context)}, ), @@ -164,19 +163,18 @@ class _SUpdateThemeUIState extends State { ), ), actions: [ - CustomMaterialButton( - isFilled: false, - label: I18nText('cancelButton'), + TextButton( onPressed: () { Navigator.of(context).pop(); }, + child: I18nText('cancelButton'), ), - CustomMaterialButton( - label: I18nText('okButton'), + FilledButton( onPressed: () { setThemeMode(context, newTheme.value); Navigator.of(context).pop(); }, + child: I18nText('okButton'), ), ], ), diff --git a/lib/ui/views/settings/settings_viewmodel.dart b/lib/ui/views/settings/settings_viewmodel.dart index e51b13827c..6757122a7d 100644 --- a/lib/ui/views/settings/settings_viewmodel.dart +++ b/lib/ui/views/settings/settings_viewmodel.dart @@ -12,7 +12,6 @@ import 'package:revanced_manager/services/toast.dart'; import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart'; import 'package:revanced_manager/ui/views/patches_selector/patches_selector_viewmodel.dart'; import 'package:revanced_manager/ui/views/settings/settingsFragment/settings_update_language.dart'; -import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart'; import 'package:share_plus/share_plus.dart'; import 'package:stacked/stacked.dart'; import 'package:stacked_services/stacked_services.dart'; @@ -65,20 +64,19 @@ class SettingsViewModel extends BaseViewModel { ), ), actions: [ - CustomMaterialButton( - isFilled: false, - label: I18nText('yesButton'), + TextButton( onPressed: () { _managerAPI.setChangingToggleModified(true); _managerAPI.setPatchesChangeEnabled(true); Navigator.of(context).pop(); }, + child: I18nText('yesButton'), ), - CustomMaterialButton( - label: I18nText('noButton'), + FilledButton( onPressed: () { Navigator.of(context).pop(); }, + child: I18nText('noButton'), ), ], ), @@ -100,21 +98,20 @@ class SettingsViewModel extends BaseViewModel { ), ), actions: [ - CustomMaterialButton( - isFilled: false, - label: I18nText('noButton'), + TextButton( onPressed: () { Navigator.of(context).pop(); }, + child: I18nText('noButton'), ), - CustomMaterialButton( - label: I18nText('yesButton'), + FilledButton( onPressed: () { _managerAPI.setChangingToggleModified(true); _patchesSelectorViewModel.selectDefaultPatches(); _managerAPI.setPatchesChangeEnabled(false); Navigator.of(context).pop(); }, + child: I18nText('yesButton'), ), ], ), @@ -145,7 +142,9 @@ class SettingsViewModel extends BaseViewModel { } Future? showRequireSuggestedAppVersionDialog( - BuildContext context, bool value,) { + BuildContext context, + bool value, + ) { if (!value) { return showDialog( context: context, @@ -163,19 +162,18 @@ class SettingsViewModel extends BaseViewModel { ), ), actions: [ - CustomMaterialButton( - isFilled: false, - label: I18nText('yesButton'), + TextButton( onPressed: () { _managerAPI.enableRequireSuggestedAppVersionStatus(false); Navigator.of(context).pop(); }, + child: I18nText('yesButton'), ), - CustomMaterialButton( - label: I18nText('noButton'), + FilledButton( onPressed: () { Navigator.of(context).pop(); }, + child: I18nText('noButton'), ), ], ), @@ -210,7 +208,7 @@ class SettingsViewModel extends BaseViewModel { final String dateTime = DateTime.now().toString().replaceAll(' ', '_').split('.').first; await FlutterFileDialog.saveFile( - params: SaveFileDialogParams( + params: SaveFileDialogParams( sourceFilePath: outFile.path, fileName: 'selected_patches_$dateTime.json', ), @@ -261,7 +259,7 @@ class SettingsViewModel extends BaseViewModel { final String dateTime = DateTime.now().toString().replaceAll(' ', '_').split('.').first; await FlutterFileDialog.saveFile( - params: SaveFileDialogParams( + params: SaveFileDialogParams( sourceFilePath: outFile.path, fileName: 'keystore_$dateTime.keystore', ), diff --git a/lib/ui/widgets/appInfoView/app_info_viewmodel.dart b/lib/ui/widgets/appInfoView/app_info_viewmodel.dart index 324415672c..6b9fd2242a 100644 --- a/lib/ui/widgets/appInfoView/app_info_viewmodel.dart +++ b/lib/ui/widgets/appInfoView/app_info_viewmodel.dart @@ -12,7 +12,6 @@ import 'package:revanced_manager/services/toast.dart'; import 'package:revanced_manager/ui/views/home/home_viewmodel.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/shared/custom_material_button.dart'; import 'package:stacked/stacked.dart'; class AppInfoViewModel extends BaseViewModel { @@ -70,9 +69,9 @@ class AppInfoViewModel extends BaseViewModel { backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: I18nText('appInfoView.rootDialogText'), actions: [ - CustomMaterialButton( - label: I18nText('okButton'), + FilledButton( onPressed: () => Navigator.of(context).pop(), + child: I18nText('okButton'), ), ], ), @@ -90,18 +89,17 @@ class AppInfoViewModel extends BaseViewModel { 'appInfoView.unpatchDialogText', ), actions: [ - CustomMaterialButton( - isFilled: false, - label: I18nText('noButton'), + TextButton( onPressed: () => Navigator.of(context).pop(), + child: I18nText('noButton'), ), - CustomMaterialButton( - label: I18nText('yesButton'), + FilledButton( onPressed: () { uninstallApp(context, app, onlyUnpatch); Navigator.of(context).pop(); Navigator.of(context).pop(); }, + child: I18nText('yesButton'), ), ], ), @@ -136,9 +134,9 @@ class AppInfoViewModel extends BaseViewModel { child: Text(getAppliedPatchesString(app.appliedPatches)), ), actions: [ - CustomMaterialButton( - label: I18nText('okButton'), + FilledButton( onPressed: () => Navigator.of(context).pop(), + child: I18nText('okButton'), ), ], ), diff --git a/lib/ui/widgets/homeView/latest_commit_card.dart b/lib/ui/widgets/homeView/latest_commit_card.dart index 9d0625ce53..5525269881 100644 --- a/lib/ui/widgets/homeView/latest_commit_card.dart +++ b/lib/ui/widgets/homeView/latest_commit_card.dart @@ -3,7 +3,6 @@ import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:revanced_manager/app/app.locator.dart'; import 'package:revanced_manager/ui/views/home/home_viewmodel.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_card.dart'; -import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart'; class LatestCommitCard extends StatefulWidget { const LatestCommitCard({ @@ -58,14 +57,14 @@ class _LatestCommitCardState extends State { initialData: false, builder: (context, snapshot) => Opacity( opacity: snapshot.hasData && snapshot.data! ? 1.0 : 0.25, - child: CustomMaterialButton( - label: I18nText('updateButton'), + child: FilledButton( onPressed: snapshot.hasData && snapshot.data! ? () => widget.model.showUpdateConfirmationDialog( widget.parentContext, false, ) : () => {}, + child: I18nText('updateButton'), ), ), ), @@ -113,14 +112,14 @@ class _LatestCommitCardState extends State { initialData: false, builder: (context, snapshot) => Opacity( opacity: snapshot.hasData && snapshot.data! ? 1.0 : 0.25, - child: CustomMaterialButton( - label: I18nText('updateButton'), + child: FilledButton( onPressed: snapshot.hasData && snapshot.data! ? () => widget.model.showUpdateConfirmationDialog( widget.parentContext, true, ) : () => {}, + child: I18nText('updateButton'), ), ), ), diff --git a/lib/ui/widgets/homeView/update_confirmation_dialog.dart b/lib/ui/widgets/homeView/update_confirmation_dialog.dart index 7839536ad5..de5b72a047 100644 --- a/lib/ui/widgets/homeView/update_confirmation_dialog.dart +++ b/lib/ui/widgets/homeView/update_confirmation_dialog.dart @@ -3,7 +3,6 @@ import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; import 'package:revanced_manager/app/app.locator.dart'; import 'package:revanced_manager/ui/views/home/home_viewmodel.dart'; -import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart'; class UpdateConfirmationDialog extends StatelessWidget { const UpdateConfirmationDialog({super.key, required this.isPatches}); @@ -86,15 +85,14 @@ class UpdateConfirmationDialog extends StatelessWidget { ], ), ), - CustomMaterialButton( - isExpanded: true, - label: I18nText('updateButton'), + FilledButton( onPressed: () { Navigator.of(context).pop(); isPatches ? model.updatePatches(context) : model.updateManager(context); }, + child: I18nText('updateButton'), ), ], ), diff --git a/lib/ui/widgets/patchesSelectorView/patch_item.dart b/lib/ui/widgets/patchesSelectorView/patch_item.dart index 11fd08392f..e641d70869 100644 --- a/lib/ui/widgets/patchesSelectorView/patch_item.dart +++ b/lib/ui/widgets/patchesSelectorView/patch_item.dart @@ -5,7 +5,6 @@ import 'package:revanced_manager/models/patch.dart'; import 'package:revanced_manager/services/manager_api.dart'; import 'package:revanced_manager/services/toast.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_card.dart'; -import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart'; // ignore: must_be_immutable class PatchItem extends StatefulWidget { @@ -226,9 +225,9 @@ class _PatchItemState extends State { }, ), actions: [ - CustomMaterialButton( - label: I18nText('okButton'), + FilledButton( onPressed: () => Navigator.of(context).pop(), + child: I18nText('okButton'), ), ], ), @@ -245,9 +244,9 @@ class _PatchItemState extends State { 'patchItem.unsupportedRequiredOption', ), actions: [ - CustomMaterialButton( - label: I18nText('okButton'), + FilledButton( onPressed: () => Navigator.of(context).pop(), + child: I18nText('okButton'), ), ], ), diff --git a/lib/ui/widgets/settingsView/settings_export_section.dart b/lib/ui/widgets/settingsView/settings_export_section.dart index 70aaf9b035..88c6f5307f 100644 --- a/lib/ui/widgets/settingsView/settings_export_section.dart +++ b/lib/ui/widgets/settingsView/settings_export_section.dart @@ -3,7 +3,6 @@ import 'package:flutter_i18n/widgets/I18nText.dart'; import 'package:revanced_manager/ui/views/settings/settingsFragment/settings_manage_keystore_password.dart'; import 'package:revanced_manager/ui/views/settings/settings_viewmodel.dart'; import 'package:revanced_manager/ui/widgets/settingsView/settings_section.dart'; -import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart'; final _settingsViewModel = SettingsViewModel(); @@ -154,17 +153,16 @@ class SExportSection extends StatelessWidget { backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: I18nText(dialogText), actions: [ - CustomMaterialButton( - isFilled: false, - label: I18nText('noButton'), + TextButton( onPressed: () => Navigator.of(context).pop(), + child: I18nText('noButton'), ), - CustomMaterialButton( - label: I18nText('yesButton'), + FilledButton( onPressed: () => { Navigator.of(context).pop(), dialogAction(), }, + child: I18nText('yesButton'), ), ], ), @@ -179,17 +177,16 @@ class SExportSection extends StatelessWidget { backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: I18nText('settingsView.regenerateKeystoreDialogText'), actions: [ - CustomMaterialButton( - isFilled: false, - label: I18nText('noButton'), + TextButton( onPressed: () => Navigator.of(context).pop(), + child: I18nText('noButton'), ), - CustomMaterialButton( - label: I18nText('yesButton'), + FilledButton( onPressed: () => { Navigator.of(context).pop(), _settingsViewModel.deleteKeystore(), }, + child: I18nText('yesButton'), ), ], ), diff --git a/lib/ui/widgets/shared/application_item.dart b/lib/ui/widgets/shared/application_item.dart index 5f527eb14a..ce432138b6 100644 --- a/lib/ui/widgets/shared/application_item.dart +++ b/lib/ui/widgets/shared/application_item.dart @@ -3,7 +3,6 @@ import 'dart:typed_data'; import 'package:flutter/material.dart'; import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_card.dart'; -import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart'; import 'package:timeago/timeago.dart'; class ApplicationItem extends StatefulWidget { @@ -24,7 +23,6 @@ class ApplicationItem extends StatefulWidget { } class _ApplicationItemState extends State { - @override void initState() { super.initState(); @@ -81,9 +79,9 @@ class _ApplicationItemState extends State { mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.end, children: [ - CustomMaterialButton( - label: I18nText('applicationItem.infoButton'), + FilledButton( onPressed: widget.onPressed, + child: I18nText('applicationItem.infoButton'), ), ], ), diff --git a/lib/ui/widgets/shared/custom_material_button.dart b/lib/ui/widgets/shared/custom_material_button.dart index c861a709ea..80d7a3f466 100644 --- a/lib/ui/widgets/shared/custom_material_button.dart +++ b/lib/ui/widgets/shared/custom_material_button.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; class CustomMaterialButton extends StatelessWidget { + @Deprecated(message: 'Use FilledButton instead') const CustomMaterialButton({ super.key, required this.label, From e8bc66a1d325f03bb9f51a9963142ead82693f79 Mon Sep 17 00:00:00 2001 From: validcube Date: Sat, 9 Dec 2023 21:01:57 +0700 Subject: [PATCH 2/4] chore: update deprecation message --- lib/ui/widgets/shared/custom_material_button.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ui/widgets/shared/custom_material_button.dart b/lib/ui/widgets/shared/custom_material_button.dart index 80d7a3f466..2980b95b2f 100644 --- a/lib/ui/widgets/shared/custom_material_button.dart +++ b/lib/ui/widgets/shared/custom_material_button.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; class CustomMaterialButton extends StatelessWidget { - @Deprecated(message: 'Use FilledButton instead') + @Deprecated('Use the native FilledButton instead') const CustomMaterialButton({ super.key, required this.label, From 3a0bed7c62d6d563b9e9436229c5417a4de7edc4 Mon Sep 17 00:00:00 2001 From: validcube Date: Sat, 9 Dec 2023 21:02:08 +0700 Subject: [PATCH 3/4] feat: use correct colour of material 3 --- lib/services/manager_api.dart | 1 - lib/ui/views/app_selector/app_selector_viewmodel.dart | 1 - lib/ui/views/installer/installer_viewmodel.dart | 2 -- lib/ui/views/patch_options/patch_options_viewmodel.dart | 2 -- lib/ui/views/patcher/patcher_viewmodel.dart | 3 --- lib/ui/views/patches_selector/patches_selector_viewmodel.dart | 2 -- .../settings/settingsFragment/settings_manage_api_url.dart | 2 -- .../settingsFragment/settings_manage_keystore_password.dart | 1 - .../settings/settingsFragment/settings_manage_sources.dart | 2 -- .../settings/settingsFragment/settings_update_language.dart | 1 - .../views/settings/settingsFragment/settings_update_theme.dart | 1 - lib/ui/views/settings/settings_viewmodel.dart | 3 --- lib/ui/widgets/appInfoView/app_info_viewmodel.dart | 3 --- lib/ui/widgets/patchesSelectorView/patch_item.dart | 2 -- lib/ui/widgets/settingsView/settings_export_section.dart | 2 -- 15 files changed, 28 deletions(-) diff --git a/lib/services/manager_api.dart b/lib/services/manager_api.dart index 3dc571cd6f..cf765c89c8 100644 --- a/lib/services/manager_api.dart +++ b/lib/services/manager_api.dart @@ -585,7 +585,6 @@ class ManagerAPI { builder: (context) => PopScope( canPop: false, child: AlertDialog( - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, title: I18nText('warning'), content: ValueListenableBuilder( valueListenable: noShow, diff --git a/lib/ui/views/app_selector/app_selector_viewmodel.dart b/lib/ui/views/app_selector/app_selector_viewmodel.dart index d63d5ac135..5b94eee7d8 100644 --- a/lib/ui/views/app_selector/app_selector_viewmodel.dart +++ b/lib/ui/views/app_selector/app_selector_viewmodel.dart @@ -168,7 +168,6 @@ class AppSelectorViewModel extends BaseViewModel { return showDialog( context: context, builder: (context) => AlertDialog( - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, title: I18nText('warning'), content: I18nText( 'appSelectorView.requireSuggestedAppVersionDialogText', diff --git a/lib/ui/views/installer/installer_viewmodel.dart b/lib/ui/views/installer/installer_viewmodel.dart index f2ce08c932..74750044ea 100644 --- a/lib/ui/views/installer/installer_viewmodel.dart +++ b/lib/ui/views/installer/installer_viewmodel.dart @@ -273,7 +273,6 @@ class InstallerViewModel extends BaseViewModel { title: I18nText( 'warning', ), - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, icon: const Icon(Icons.warning), content: SingleChildScrollView( child: I18nText('installerView.screenshotDetected'), @@ -308,7 +307,6 @@ class InstallerViewModel extends BaseViewModel { title: I18nText( 'installerView.installType', ), - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, icon: const Icon(Icons.file_download_outlined), contentPadding: const EdgeInsets.symmetric(vertical: 16), content: SingleChildScrollView( diff --git a/lib/ui/views/patch_options/patch_options_viewmodel.dart b/lib/ui/views/patch_options/patch_options_viewmodel.dart index c33ef2fc84..2dbaef7b28 100644 --- a/lib/ui/views/patch_options/patch_options_viewmodel.dart +++ b/lib/ui/views/patch_options/patch_options_viewmodel.dart @@ -133,7 +133,6 @@ class PatchOptionsViewModel extends BaseViewModel { await showDialog( context: context, builder: (context) => AlertDialog( - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, title: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, @@ -224,7 +223,6 @@ Future showRequiredOptionNullDialog( await showDialog( context: context, builder: (context) => AlertDialog( - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, title: I18nText('notice'), actions: [ TextButton( diff --git a/lib/ui/views/patcher/patcher_viewmodel.dart b/lib/ui/views/patcher/patcher_viewmodel.dart index 43a5d2b01f..48b98f1fc7 100644 --- a/lib/ui/views/patcher/patcher_viewmodel.dart +++ b/lib/ui/views/patcher/patcher_viewmodel.dart @@ -54,7 +54,6 @@ class PatcherViewModel extends BaseViewModel { context: context, builder: (context) => AlertDialog( title: I18nText('notice'), - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: I18nText( 'patcherView.removedPatchesWarningDialogText', translationParams: {'patches': removedPatches.join('\n')}, @@ -95,7 +94,6 @@ class PatcherViewModel extends BaseViewModel { context: context ?? ctx, builder: (context) => AlertDialog( title: I18nText('notice'), - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: I18nText('patcherView.requiredOptionDialogText'), actions: [ TextButton( @@ -127,7 +125,6 @@ class PatcherViewModel extends BaseViewModel { context: context, builder: (context) => AlertDialog( title: I18nText('warning'), - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: I18nText('patcherView.armv7WarningDialogText'), actions: [ FilledButton( diff --git a/lib/ui/views/patches_selector/patches_selector_viewmodel.dart b/lib/ui/views/patches_selector/patches_selector_viewmodel.dart index 96ef0aca1e..10a7f9a4f1 100644 --- a/lib/ui/views/patches_selector/patches_selector_viewmodel.dart +++ b/lib/ui/views/patches_selector/patches_selector_viewmodel.dart @@ -91,7 +91,6 @@ class PatchesSelectorViewModel extends BaseViewModel { context: context, builder: (context) => AlertDialog( title: I18nText('notice'), - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: I18nText( 'patchesSelectorView.setRequiredOption', translationParams: { @@ -127,7 +126,6 @@ class PatchesSelectorViewModel extends BaseViewModel { return showDialog( context: context, builder: (context) => AlertDialog( - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, title: I18nText('warning'), content: I18nText( 'patchItem.patchesChangeWarningDialogText', diff --git a/lib/ui/views/settings/settingsFragment/settings_manage_api_url.dart b/lib/ui/views/settings/settingsFragment/settings_manage_api_url.dart index 4ce96f6b23..5669a07303 100644 --- a/lib/ui/views/settings/settingsFragment/settings_manage_api_url.dart +++ b/lib/ui/views/settings/settingsFragment/settings_manage_api_url.dart @@ -32,7 +32,6 @@ class SManageApiUrl extends BaseViewModel { ), ], ), - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: SingleChildScrollView( child: Column( children: [ @@ -79,7 +78,6 @@ class SManageApiUrl extends BaseViewModel { context: context, builder: (context) => AlertDialog( title: I18nText('settingsView.sourcesResetDialogTitle'), - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: I18nText('settingsView.apiURLResetDialogText'), actions: [ TextButton( diff --git a/lib/ui/views/settings/settingsFragment/settings_manage_keystore_password.dart b/lib/ui/views/settings/settingsFragment/settings_manage_keystore_password.dart index 8c5256a242..fb717f64bb 100644 --- a/lib/ui/views/settings/settingsFragment/settings_manage_keystore_password.dart +++ b/lib/ui/views/settings/settingsFragment/settings_manage_keystore_password.dart @@ -32,7 +32,6 @@ class SManageKeystorePassword extends BaseViewModel { ), ], ), - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: SingleChildScrollView( child: Column( children: [ diff --git a/lib/ui/views/settings/settingsFragment/settings_manage_sources.dart b/lib/ui/views/settings/settingsFragment/settings_manage_sources.dart index 33cf43ba3f..52c30ff043 100644 --- a/lib/ui/views/settings/settingsFragment/settings_manage_sources.dart +++ b/lib/ui/views/settings/settingsFragment/settings_manage_sources.dart @@ -42,7 +42,6 @@ class SManageSources extends BaseViewModel { ), ], ), - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: SingleChildScrollView( child: Column( children: [ @@ -142,7 +141,6 @@ class SManageSources extends BaseViewModel { context: context, builder: (context) => AlertDialog( title: I18nText('settingsView.sourcesResetDialogTitle'), - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: I18nText('settingsView.sourcesResetDialogText'), actions: [ TextButton( diff --git a/lib/ui/views/settings/settingsFragment/settings_update_language.dart b/lib/ui/views/settings/settingsFragment/settings_update_language.dart index 66bb2c3e7f..1e7b4a721e 100644 --- a/lib/ui/views/settings/settingsFragment/settings_update_language.dart +++ b/lib/ui/views/settings/settingsFragment/settings_update_language.dart @@ -51,7 +51,6 @@ class SUpdateLanguage extends BaseViewModel { context: parentContext, builder: (context) => SimpleDialog( title: I18nText('settingsView.languageLabel'), - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, children: [ SizedBox( height: 500, diff --git a/lib/ui/views/settings/settingsFragment/settings_update_theme.dart b/lib/ui/views/settings/settingsFragment/settings_update_theme.dart index 2bbd6b8f25..09c1b28b19 100644 --- a/lib/ui/views/settings/settingsFragment/settings_update_theme.dart +++ b/lib/ui/views/settings/settingsFragment/settings_update_theme.dart @@ -121,7 +121,6 @@ class _SUpdateThemeUIState extends State { title: I18nText('settingsView.themeModeLabel'), icon: const Icon(Icons.palette), contentPadding: const EdgeInsets.symmetric(vertical: 16), - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: SingleChildScrollView( child: ValueListenableBuilder( valueListenable: newTheme, diff --git a/lib/ui/views/settings/settings_viewmodel.dart b/lib/ui/views/settings/settings_viewmodel.dart index 6757122a7d..6fa85730e3 100644 --- a/lib/ui/views/settings/settings_viewmodel.dart +++ b/lib/ui/views/settings/settings_viewmodel.dart @@ -51,7 +51,6 @@ class SettingsViewModel extends BaseViewModel { return showDialog( context: context, builder: (context) => AlertDialog( - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, title: I18nText('warning'), content: I18nText( 'settingsView.enablePatchesSelectionWarningText', @@ -85,7 +84,6 @@ class SettingsViewModel extends BaseViewModel { return showDialog( context: context, builder: (context) => AlertDialog( - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, title: I18nText('warning'), content: I18nText( 'settingsView.disablePatchesSelectionWarningText', @@ -149,7 +147,6 @@ class SettingsViewModel extends BaseViewModel { return showDialog( context: context, builder: (context) => AlertDialog( - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, title: I18nText('warning'), content: I18nText( 'settingsView.requireSuggestedAppVersionDialogText', diff --git a/lib/ui/widgets/appInfoView/app_info_viewmodel.dart b/lib/ui/widgets/appInfoView/app_info_viewmodel.dart index 6b9fd2242a..60b9681a84 100644 --- a/lib/ui/widgets/appInfoView/app_info_viewmodel.dart +++ b/lib/ui/widgets/appInfoView/app_info_viewmodel.dart @@ -66,7 +66,6 @@ class AppInfoViewModel extends BaseViewModel { context: context, builder: (context) => AlertDialog( title: I18nText('appInfoView.rootDialogTitle'), - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: I18nText('appInfoView.rootDialogText'), actions: [ FilledButton( @@ -84,7 +83,6 @@ class AppInfoViewModel extends BaseViewModel { title: I18nText( 'appInfoView.unpatchButton', ), - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: I18nText( 'appInfoView.unpatchDialogText', ), @@ -129,7 +127,6 @@ class AppInfoViewModel extends BaseViewModel { context: context, builder: (context) => AlertDialog( title: I18nText('appInfoView.appliedPatchesLabel'), - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: SingleChildScrollView( child: Text(getAppliedPatchesString(app.appliedPatches)), ), diff --git a/lib/ui/widgets/patchesSelectorView/patch_item.dart b/lib/ui/widgets/patchesSelectorView/patch_item.dart index e641d70869..70692ab2e8 100644 --- a/lib/ui/widgets/patchesSelectorView/patch_item.dart +++ b/lib/ui/widgets/patchesSelectorView/patch_item.dart @@ -215,7 +215,6 @@ class _PatchItemState extends State { context: context, builder: (context) => AlertDialog( title: I18nText('warning'), - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: I18nText( 'patchItem.unsupportedDialogText', translationParams: { @@ -239,7 +238,6 @@ class _PatchItemState extends State { context: context, builder: (context) => AlertDialog( title: I18nText('notice'), - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: I18nText( 'patchItem.unsupportedRequiredOption', ), diff --git a/lib/ui/widgets/settingsView/settings_export_section.dart b/lib/ui/widgets/settingsView/settings_export_section.dart index 88c6f5307f..2f7e4aa7ab 100644 --- a/lib/ui/widgets/settingsView/settings_export_section.dart +++ b/lib/ui/widgets/settingsView/settings_export_section.dart @@ -150,7 +150,6 @@ class SExportSection extends StatelessWidget { context: context, builder: (context) => AlertDialog( title: I18nText(dialogTitle), - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: I18nText(dialogText), actions: [ TextButton( @@ -174,7 +173,6 @@ class SExportSection extends StatelessWidget { context: context, builder: (context) => AlertDialog( title: I18nText('settingsView.regenerateKeystoreDialogTitle'), - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: I18nText('settingsView.regenerateKeystoreDialogText'), actions: [ TextButton( From 37dfdc4d056bab63ab2a909f2717e6c35fcb903c Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sat, 9 Dec 2023 22:52:37 +0700 Subject: [PATCH 4/4] chore: remove deprecated class --- .../shared/custom_material_button.dart | 127 ------------------ 1 file changed, 127 deletions(-) delete mode 100644 lib/ui/widgets/shared/custom_material_button.dart diff --git a/lib/ui/widgets/shared/custom_material_button.dart b/lib/ui/widgets/shared/custom_material_button.dart deleted file mode 100644 index 2980b95b2f..0000000000 --- a/lib/ui/widgets/shared/custom_material_button.dart +++ /dev/null @@ -1,127 +0,0 @@ -import 'package:flutter/material.dart'; - -class CustomMaterialButton extends StatelessWidget { - @Deprecated('Use the native FilledButton instead') - const CustomMaterialButton({ - super.key, - required this.label, - this.isFilled = true, - this.isExpanded = false, - required this.onPressed, - }); - final Widget label; - final bool isFilled; - final bool isExpanded; - final Function()? onPressed; - - @override - Widget build(BuildContext context) { - return TextButton( - style: ButtonStyle( - padding: MaterialStateProperty.all( - isExpanded - ? const EdgeInsets.symmetric(horizontal: 24, vertical: 12) - : const EdgeInsets.symmetric(horizontal: 20, vertical: 12), - ), - shape: MaterialStateProperty.all( - StadiumBorder( - side: isFilled - ? BorderSide.none - : BorderSide( - color: Theme.of(context).colorScheme.primary, - ), - ), - ), - backgroundColor: MaterialStateProperty.all( - isFilled ? Theme.of(context).colorScheme.primary : Colors.transparent, - ), - foregroundColor: MaterialStateProperty.all( - isFilled - ? Theme.of(context).colorScheme.surface - : Theme.of(context).colorScheme.primary, - ), - ), - onPressed: onPressed, - child: label, - ); - } -} - -// ignore: must_be_immutable -class TimerButton extends StatefulWidget { - TimerButton({ - super.key, - required this.seconds, - required this.isRunning, - required this.onTimerEnd, - this.label = const Text(''), - this.isFilled = true, - }); - Widget label; - bool isFilled; - int seconds; - final bool isRunning; - final Function()? onTimerEnd; - - @override - State createState() => _TimerButtonState(); -} - -class _TimerButtonState extends State { - void timer(int seconds) { - Future.delayed(const Duration(seconds: 1), () { - if (seconds > 0) { - setState(() { - seconds--; - }); - timer(seconds); - } else { - widget.onTimerEnd!(); - } - }); - } - - @override - void initState() { - //decrement seconds - if (widget.isRunning) { - timer(widget.seconds); - } - super.initState(); - } - - @override - Widget build(BuildContext build) { - return TextButton( - style: ButtonStyle( - shape: MaterialStateProperty.all( - StadiumBorder( - side: widget.isFilled - ? BorderSide.none - : BorderSide( - color: Theme.of(context).colorScheme.primary, - ), - ), - ), - backgroundColor: MaterialStateProperty.all( - widget.isFilled - ? Theme.of(context).colorScheme.primary - : Colors.transparent, - ), - foregroundColor: MaterialStateProperty.all( - widget.isFilled - ? Theme.of(context).colorScheme.surface - : Theme.of(context).colorScheme.primary, - ), - ), - onPressed: widget.isRunning ? null : widget.onTimerEnd, - child: Text( - widget.isRunning ? '${widget.seconds}' : 'Install', - style: const TextStyle( - fontSize: 16, - fontWeight: FontWeight.w600, - ), - ), - ); - } -}