From 1d238c29f09207b975968c27707df5097de218ac Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 17 Nov 2022 12:01:52 -0600 Subject: [PATCH] WIP: centralize button heights --- .../create_backup_view.dart | 4 +- .../restore_from_file_view.dart | 4 +- .../wallet_view/desktop_wallet_view.dart | 6 +- .../advanced_settings/advanced_settings.dart | 111 +++++------------- .../backup_and_restore_settings.dart | 10 +- .../currency_settings/currency_settings.dart | 2 +- .../language_settings/language_settings.dart | 4 +- .../home/settings_menu/security_settings.dart | 2 +- .../syncing_preferences_settings.dart | 2 +- lib/widgets/desktop/primary_button.dart | 4 +- lib/widgets/desktop/secondary_button.dart | 4 +- 11 files changed, 52 insertions(+), 101 deletions(-) diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/create_backup_view.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/create_backup_view.dart index 0609e4b1b..a6241d25a 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/create_backup_view.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/create_backup_view.dart @@ -562,7 +562,7 @@ class _RestoreFromFileViewState extends State { Consumer(builder: (context, ref, __) { return PrimaryButton( width: 183, - buttonHeight: ButtonHeight.l, + buttonHeight: ButtonHeight.m, label: "Create backup", enabled: shouldEnableCreate, onPressed: !shouldEnableCreate @@ -780,7 +780,7 @@ class _RestoreFromFileViewState extends State { ), SecondaryButton( width: 183, - buttonHeight: ButtonHeight.l, + buttonHeight: ButtonHeight.m, label: "Cancel", onPressed: () {}, ), diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/restore_from_file_view.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/restore_from_file_view.dart index 9be6af4cb..d6571967d 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/restore_from_file_view.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/restore_from_file_view.dart @@ -389,7 +389,7 @@ class _RestoreFromFileViewState extends ConsumerState { children: [ PrimaryButton( width: 183, - buttonHeight: ButtonHeight.l, + buttonHeight: ButtonHeight.m, label: "Restore", enabled: !(passwordController.text.isEmpty || fileLocationController.text.isEmpty), @@ -566,7 +566,7 @@ class _RestoreFromFileViewState extends ConsumerState { ), SecondaryButton( width: 183, - buttonHeight: ButtonHeight.l, + buttonHeight: ButtonHeight.m, label: "Cancel", onPressed: () {}, ), diff --git a/lib/pages_desktop_specific/home/my_stack_view/wallet_view/desktop_wallet_view.dart b/lib/pages_desktop_specific/home/my_stack_view/wallet_view/desktop_wallet_view.dart index 952194244..d21a19aee 100644 --- a/lib/pages_desktop_specific/home/my_stack_view/wallet_view/desktop_wallet_view.dart +++ b/lib/pages_desktop_specific/home/my_stack_view/wallet_view/desktop_wallet_view.dart @@ -411,7 +411,7 @@ class _DesktopWalletViewState extends ConsumerState { if (coin == Coin.firo) SecondaryButton( width: 180, - desktopMed: true, + buttonHeight: ButtonHeight.l, label: "Anonymize funds", onPressed: () async { await showDialog( @@ -441,7 +441,7 @@ class _DesktopWalletViewState extends ConsumerState { children: [ SecondaryButton( width: 180, - desktopMed: true, + buttonHeight: ButtonHeight.l, label: "Cancel", onPressed: () { Navigator.of(context).pop(); @@ -450,7 +450,7 @@ class _DesktopWalletViewState extends ConsumerState { const SizedBox(width: 20), PrimaryButton( width: 180, - desktopMed: true, + buttonHeight: ButtonHeight.l, label: "Continue", onPressed: () { Navigator.of(context).pop(); diff --git a/lib/pages_desktop_specific/home/settings_menu/advanced_settings/advanced_settings.dart b/lib/pages_desktop_specific/home/settings_menu/advanced_settings/advanced_settings.dart index b4ff3fe6a..621683e65 100644 --- a/lib/pages_desktop_specific/home/settings_menu/advanced_settings/advanced_settings.dart +++ b/lib/pages_desktop_specific/home/settings_menu/advanced_settings/advanced_settings.dart @@ -8,6 +8,7 @@ import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/widgets/custom_buttons/draggable_switch_button.dart'; +import 'package:stackwallet/widgets/desktop/primary_button.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart'; import 'debug_info_dialog.dart'; @@ -143,7 +144,21 @@ class _AdvancedSettings extends ConsumerState { ), ], ), - const StackPrivacyButton(), + PrimaryButton( + label: "Change", + buttonHeight: ButtonHeight.xs, + width: 86, + onPressed: () async { + await showDialog( + context: context, + useSafeArea: false, + barrierDismissible: true, + builder: (context) { + return const StackPrivacyDialog(); + }, + ); + }, + ) ], ), ); @@ -172,7 +187,21 @@ class _AdvancedSettings extends ConsumerState { .textDark), textAlign: TextAlign.left, ), - ShowLogsButton(), + PrimaryButton( + buttonHeight: ButtonHeight.xs, + label: "Show logs", + width: 101, + onPressed: () async { + await showDialog( + context: context, + useSafeArea: false, + barrierDismissible: true, + builder: (context) { + return const DebugInfoDialog(); + }, + ); + }, + ), ], ), ), @@ -184,81 +213,3 @@ class _AdvancedSettings extends ConsumerState { ); } } - -class StackPrivacyButton extends ConsumerWidget { - const StackPrivacyButton({ - Key? key, - }) : super(key: key); - @override - Widget build(BuildContext context, WidgetRef ref) { - Future changePrivacySettings() async { - await showDialog( - context: context, - useSafeArea: false, - barrierDismissible: true, - builder: (context) { - return StackPrivacyDialog(); - }, - ); - } - - return SizedBox( - width: 84, - height: 37, - child: TextButton( - style: Theme.of(context) - .extension()! - .getPrimaryEnabledButtonColor(context), - onPressed: () { - // Navigator.of(context).pushNamed( - // StackPrivacyCalls.routeName, - // arguments: false, - // ); - changePrivacySettings(); - }, - child: Text( - "Change", - style: STextStyles.desktopTextExtraExtraSmall(context) - .copyWith(color: Colors.white), - ), - ), - ); - } -} - -class ShowLogsButton extends ConsumerWidget { - const ShowLogsButton({ - Key? key, - }) : super(key: key); - @override - Widget build(BuildContext context, WidgetRef ref) { - Future viewDebugLogs() async { - await showDialog( - context: context, - useSafeArea: false, - barrierDismissible: true, - builder: (context) { - return const DebugInfoDialog(); - }, - ); - } - - return SizedBox( - width: 101, - height: 37, - child: TextButton( - style: Theme.of(context) - .extension()! - .getPrimaryEnabledButtonColor(context), - onPressed: () { - viewDebugLogs(); - }, - child: Text( - "Show logs", - style: STextStyles.desktopTextExtraExtraSmall(context) - .copyWith(color: Colors.white), - ), - ), - ); - } -} diff --git a/lib/pages_desktop_specific/home/settings_menu/backup_and_restore/backup_and_restore_settings.dart b/lib/pages_desktop_specific/home/settings_menu/backup_and_restore/backup_and_restore_settings.dart index 37f3f35a6..c82b5f923 100644 --- a/lib/pages_desktop_specific/home/settings_menu/backup_and_restore/backup_and_restore_settings.dart +++ b/lib/pages_desktop_specific/home/settings_menu/backup_and_restore/backup_and_restore_settings.dart @@ -422,7 +422,7 @@ class _BackupRestoreSettings extends ConsumerState { padding: const EdgeInsets.all(10), child: !isEnabledAutoBackup ? PrimaryButton( - buttonHeight: ButtonHeight.l, + buttonHeight: ButtonHeight.m, width: 200, label: "Enable auto backup", onPressed: () { @@ -467,7 +467,7 @@ class _BackupRestoreSettings extends ConsumerState { Row( children: [ PrimaryButton( - buttonHeight: ButtonHeight.l, + buttonHeight: ButtonHeight.m, width: 190, label: "Disable auto backup", onPressed: () { @@ -476,7 +476,7 @@ class _BackupRestoreSettings extends ConsumerState { ), const SizedBox(width: 16), SecondaryButton( - buttonHeight: ButtonHeight.l, + buttonHeight: ButtonHeight.m, width: 190, label: "Edit auto backup", onPressed: () { @@ -560,7 +560,7 @@ class _BackupRestoreSettings extends ConsumerState { child: CreateBackupView(), ) : PrimaryButton( - buttonHeight: ButtonHeight.l, + buttonHeight: ButtonHeight.m, width: 200, label: "Create manual backup", onPressed: () { @@ -642,7 +642,7 @@ class _BackupRestoreSettings extends ConsumerState { child: RestoreFromFileView(), ) : PrimaryButton( - buttonHeight: ButtonHeight.l, + buttonHeight: ButtonHeight.m, width: 200, label: "Restore backup", onPressed: () { diff --git a/lib/pages_desktop_specific/home/settings_menu/currency_settings/currency_settings.dart b/lib/pages_desktop_specific/home/settings_menu/currency_settings/currency_settings.dart index 0740157ad..d9c20d8fa 100644 --- a/lib/pages_desktop_specific/home/settings_menu/currency_settings/currency_settings.dart +++ b/lib/pages_desktop_specific/home/settings_menu/currency_settings/currency_settings.dart @@ -108,7 +108,7 @@ class _CurrencySettings extends ConsumerState { ), child: PrimaryButton( width: 210, - buttonHeight: ButtonHeight.l, + buttonHeight: ButtonHeight.m, enabled: true, label: "Change currency", onPressed: () { diff --git a/lib/pages_desktop_specific/home/settings_menu/language_settings/language_settings.dart b/lib/pages_desktop_specific/home/settings_menu/language_settings/language_settings.dart index db636ba17..acddcb055 100644 --- a/lib/pages_desktop_specific/home/settings_menu/language_settings/language_settings.dart +++ b/lib/pages_desktop_specific/home/settings_menu/language_settings/language_settings.dart @@ -80,12 +80,12 @@ class _LanguageOptionSettings extends ConsumerState { crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( - padding: EdgeInsets.all( + padding: const EdgeInsets.all( 10, ), child: PrimaryButton( width: 210, - buttonHeight: ButtonHeight.l, + buttonHeight: ButtonHeight.m, enabled: true, label: "Change language", onPressed: () { diff --git a/lib/pages_desktop_specific/home/settings_menu/security_settings.dart b/lib/pages_desktop_specific/home/settings_menu/security_settings.dart index f2853e6f5..f6762afa1 100644 --- a/lib/pages_desktop_specific/home/settings_menu/security_settings.dart +++ b/lib/pages_desktop_specific/home/settings_menu/security_settings.dart @@ -503,7 +503,7 @@ class _SecuritySettings extends ConsumerState { ) : PrimaryButton( width: 210, - buttonHeight: ButtonHeight.l, + buttonHeight: ButtonHeight.m, enabled: true, label: "Set up new password", onPressed: () { diff --git a/lib/pages_desktop_specific/home/settings_menu/syncing_preferences_settings.dart b/lib/pages_desktop_specific/home/settings_menu/syncing_preferences_settings.dart index ae11f5582..815e506db 100644 --- a/lib/pages_desktop_specific/home/settings_menu/syncing_preferences_settings.dart +++ b/lib/pages_desktop_specific/home/settings_menu/syncing_preferences_settings.dart @@ -83,7 +83,7 @@ class _SyncingPreferencesSettings ), child: PrimaryButton( width: 210, - buttonHeight: ButtonHeight.l, + buttonHeight: ButtonHeight.m, enabled: true, label: "Change preferences", onPressed: () {}, diff --git a/lib/widgets/desktop/primary_button.dart b/lib/widgets/desktop/primary_button.dart index 134ff36c3..9441168e7 100644 --- a/lib/widgets/desktop/primary_button.dart +++ b/lib/widgets/desktop/primary_button.dart @@ -81,9 +81,9 @@ class PrimaryButton extends StatelessWidget { if (Util.isDesktop) { switch (buttonHeight!) { case ButtonHeight.xxs: - return 28; - case ButtonHeight.xs: return 32; + case ButtonHeight.xs: + return 37; case ButtonHeight.s: return 40; case ButtonHeight.m: diff --git a/lib/widgets/desktop/secondary_button.dart b/lib/widgets/desktop/secondary_button.dart index 7cf8e9f72..62bd900dd 100644 --- a/lib/widgets/desktop/secondary_button.dart +++ b/lib/widgets/desktop/secondary_button.dart @@ -84,9 +84,9 @@ class SecondaryButton extends StatelessWidget { if (Util.isDesktop) { switch (buttonHeight!) { case ButtonHeight.xxs: - return 28; - case ButtonHeight.xs: return 32; + case ButtonHeight.xs: + return 37; case ButtonHeight.s: return 40; case ButtonHeight.m: