diff --git a/lib/services/manager_api.dart b/lib/services/manager_api.dart index 853068734e..cf765c89c8 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; } @@ -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, @@ -620,12 +619,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..5b94eee7d8 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) { @@ -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', @@ -185,9 +184,9 @@ class AppSelectorViewModel extends BaseViewModel { ), ), actions: [ - CustomMaterialButton( - label: I18nText('okButton'), + FilledButton( onPressed: () => Navigator.of(context).pop(), + child: I18nText('okButton'), ), ], ), @@ -232,12 +231,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 +246,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 02691bb3dd..e5808c2506 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'; @@ -287,26 +286,24 @@ class InstallerViewModel extends BaseViewModel { title: I18nText( 'warning', ), - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, icon: const Icon(Icons.warning), content: SingleChildScrollView( 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'), ), ], ), @@ -323,7 +320,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( @@ -377,19 +373,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..2dbaef7b28 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 = [ @@ -136,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, @@ -154,11 +150,11 @@ class PatchOptionsViewModel extends BaseViewModel { ], ), actions: [ - CustomMaterialButton( - label: I18nText('cancelButton'), + FilledButton( onPressed: () { Navigator.of(context).pop(); }, + child: I18nText('cancelButton'), ), ], contentPadding: const EdgeInsets.all(8), @@ -227,14 +223,9 @@ Future showRequiredOptionNullDialog( await showDialog( context: context, builder: (context) => AlertDialog( - 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 +247,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..48b98f1fc7 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'; @@ -55,25 +54,23 @@ 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')}, ), 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'), ), ], ), @@ -97,22 +94,20 @@ class PatcherViewModel extends BaseViewModel { context: context ?? ctx, builder: (context) => AlertDialog( title: I18nText('notice'), - 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'), ), ], ), @@ -130,20 +125,18 @@ class PatcherViewModel extends BaseViewModel { context: context, builder: (context) => AlertDialog( title: I18nText('warning'), - 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..10a7f9a4f1 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'; @@ -92,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: { @@ -100,11 +98,11 @@ class PatchesSelectorViewModel extends BaseViewModel { }, ), actions: [ - CustomMaterialButton( - label: I18nText('okButton'), + FilledButton( onPressed: () => { Navigator.of(context).pop(), }, + child: I18nText('okButton'), ), ], ), @@ -128,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', @@ -141,18 +138,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..5669a07303 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 { @@ -33,7 +32,6 @@ class SManageApiUrl extends BaseViewModel { ), ], ), - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: SingleChildScrollView( child: Column( children: [ @@ -51,16 +49,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 +66,7 @@ class SManageApiUrl extends BaseViewModel { _toast.showBottom('settingsView.restartAppForChanges'); Navigator.of(context).pop(); }, + child: I18nText('okButton'), ), ], ), @@ -81,16 +78,13 @@ class SManageApiUrl extends BaseViewModel { context: context, builder: (context) => AlertDialog( title: I18nText('settingsView.sourcesResetDialogTitle'), - 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 +92,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..fb717f64bb 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 { @@ -33,7 +32,6 @@ class SManageKeystorePassword extends BaseViewModel { ), ], ), - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: SingleChildScrollView( child: Column( children: [ @@ -47,21 +45,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..52c30ff043 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 { @@ -43,7 +42,6 @@ class SManageSources extends BaseViewModel { ), ], ), - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: SingleChildScrollView( child: Column( children: [ @@ -107,9 +105,7 @@ class SManageSources extends BaseViewModel { ), ), actions: [ - CustomMaterialButton( - isFilled: false, - label: I18nText('cancelButton'), + TextButton( onPressed: () { _orgPatSourceController.clear(); _patSourceController.clear(); @@ -117,9 +113,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 +129,7 @@ class SManageSources extends BaseViewModel { _toast.showBottom('settingsView.restartAppForChanges'); Navigator.of(context).pop(); }, + child: I18nText('okButton'), ), ], ), @@ -144,16 +141,13 @@ class SManageSources extends BaseViewModel { context: context, builder: (context) => AlertDialog( title: I18nText('settingsView.sourcesResetDialogTitle'), - 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 +159,7 @@ class SManageSources extends BaseViewModel { ..pop() ..pop(); }, + child: I18nText('yesButton'), ), ], ), 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 66fa683094..09c1b28b19 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)}, ), @@ -122,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, @@ -164,19 +162,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..6fa85730e3 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'; @@ -52,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', @@ -65,20 +63,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'), ), ], ), @@ -87,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', @@ -100,21 +96,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,12 +140,13 @@ class SettingsViewModel extends BaseViewModel { } Future? showRequireSuggestedAppVersionDialog( - BuildContext context, bool value,) { + BuildContext context, + bool value, + ) { if (!value) { return showDialog( context: context, builder: (context) => AlertDialog( - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, title: I18nText('warning'), content: I18nText( 'settingsView.requireSuggestedAppVersionDialogText', @@ -163,19 +159,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 +205,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 +256,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..60b9681a84 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 { @@ -67,12 +66,11 @@ class AppInfoViewModel extends BaseViewModel { context: context, builder: (context) => AlertDialog( title: I18nText('appInfoView.rootDialogTitle'), - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: I18nText('appInfoView.rootDialogText'), actions: [ - CustomMaterialButton( - label: I18nText('okButton'), + FilledButton( onPressed: () => Navigator.of(context).pop(), + child: I18nText('okButton'), ), ], ), @@ -85,23 +83,21 @@ class AppInfoViewModel extends BaseViewModel { title: I18nText( 'appInfoView.unpatchButton', ), - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: I18nText( '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'), ), ], ), @@ -131,14 +127,13 @@ 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)), ), 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..70692ab2e8 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 { @@ -216,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: { @@ -226,9 +224,9 @@ class _PatchItemState extends State { }, ), actions: [ - CustomMaterialButton( - label: I18nText('okButton'), + FilledButton( onPressed: () => Navigator.of(context).pop(), + child: I18nText('okButton'), ), ], ), @@ -240,14 +238,13 @@ class _PatchItemState extends State { context: context, builder: (context) => AlertDialog( title: I18nText('notice'), - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: I18nText( '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..2f7e4aa7ab 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(); @@ -151,20 +150,18 @@ class SExportSection extends StatelessWidget { context: context, builder: (context) => AlertDialog( title: I18nText(dialogTitle), - 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'), ), ], ), @@ -176,20 +173,18 @@ class SExportSection extends StatelessWidget { context: context, builder: (context) => AlertDialog( title: I18nText('settingsView.regenerateKeystoreDialogTitle'), - 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 deleted file mode 100644 index c861a709ea..0000000000 --- a/lib/ui/widgets/shared/custom_material_button.dart +++ /dev/null @@ -1,126 +0,0 @@ -import 'package:flutter/material.dart'; - -class CustomMaterialButton extends StatelessWidget { - 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, - ), - ), - ); - } -}