WIP: centralize button heights

This commit is contained in:
julian 2022-11-17 12:01:52 -06:00
parent 9e7c1ccf9d
commit 1d238c29f0
11 changed files with 52 additions and 101 deletions

View file

@ -562,7 +562,7 @@ class _RestoreFromFileViewState extends State<CreateBackupView> {
Consumer(builder: (context, ref, __) { Consumer(builder: (context, ref, __) {
return PrimaryButton( return PrimaryButton(
width: 183, width: 183,
buttonHeight: ButtonHeight.l, buttonHeight: ButtonHeight.m,
label: "Create backup", label: "Create backup",
enabled: shouldEnableCreate, enabled: shouldEnableCreate,
onPressed: !shouldEnableCreate onPressed: !shouldEnableCreate
@ -780,7 +780,7 @@ class _RestoreFromFileViewState extends State<CreateBackupView> {
), ),
SecondaryButton( SecondaryButton(
width: 183, width: 183,
buttonHeight: ButtonHeight.l, buttonHeight: ButtonHeight.m,
label: "Cancel", label: "Cancel",
onPressed: () {}, onPressed: () {},
), ),

View file

@ -389,7 +389,7 @@ class _RestoreFromFileViewState extends ConsumerState<RestoreFromFileView> {
children: [ children: [
PrimaryButton( PrimaryButton(
width: 183, width: 183,
buttonHeight: ButtonHeight.l, buttonHeight: ButtonHeight.m,
label: "Restore", label: "Restore",
enabled: !(passwordController.text.isEmpty || enabled: !(passwordController.text.isEmpty ||
fileLocationController.text.isEmpty), fileLocationController.text.isEmpty),
@ -566,7 +566,7 @@ class _RestoreFromFileViewState extends ConsumerState<RestoreFromFileView> {
), ),
SecondaryButton( SecondaryButton(
width: 183, width: 183,
buttonHeight: ButtonHeight.l, buttonHeight: ButtonHeight.m,
label: "Cancel", label: "Cancel",
onPressed: () {}, onPressed: () {},
), ),

View file

@ -411,7 +411,7 @@ class _DesktopWalletViewState extends ConsumerState<DesktopWalletView> {
if (coin == Coin.firo) if (coin == Coin.firo)
SecondaryButton( SecondaryButton(
width: 180, width: 180,
desktopMed: true, buttonHeight: ButtonHeight.l,
label: "Anonymize funds", label: "Anonymize funds",
onPressed: () async { onPressed: () async {
await showDialog<void>( await showDialog<void>(
@ -441,7 +441,7 @@ class _DesktopWalletViewState extends ConsumerState<DesktopWalletView> {
children: [ children: [
SecondaryButton( SecondaryButton(
width: 180, width: 180,
desktopMed: true, buttonHeight: ButtonHeight.l,
label: "Cancel", label: "Cancel",
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
@ -450,7 +450,7 @@ class _DesktopWalletViewState extends ConsumerState<DesktopWalletView> {
const SizedBox(width: 20), const SizedBox(width: 20),
PrimaryButton( PrimaryButton(
width: 180, width: 180,
desktopMed: true, buttonHeight: ButtonHeight.l,
label: "Continue", label: "Continue",
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();

View file

@ -8,6 +8,7 @@ import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart';
import 'package:stackwallet/widgets/custom_buttons/draggable_switch_button.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 'package:stackwallet/widgets/rounded_white_container.dart';
import 'debug_info_dialog.dart'; import 'debug_info_dialog.dart';
@ -143,7 +144,21 @@ class _AdvancedSettings extends ConsumerState<AdvancedSettings> {
), ),
], ],
), ),
const StackPrivacyButton(), PrimaryButton(
label: "Change",
buttonHeight: ButtonHeight.xs,
width: 86,
onPressed: () async {
await showDialog<dynamic>(
context: context,
useSafeArea: false,
barrierDismissible: true,
builder: (context) {
return const StackPrivacyDialog();
},
);
},
)
], ],
), ),
); );
@ -172,7 +187,21 @@ class _AdvancedSettings extends ConsumerState<AdvancedSettings> {
.textDark), .textDark),
textAlign: TextAlign.left, textAlign: TextAlign.left,
), ),
ShowLogsButton(), PrimaryButton(
buttonHeight: ButtonHeight.xs,
label: "Show logs",
width: 101,
onPressed: () async {
await showDialog<dynamic>(
context: context,
useSafeArea: false,
barrierDismissible: true,
builder: (context) {
return const DebugInfoDialog();
},
);
},
),
], ],
), ),
), ),
@ -184,81 +213,3 @@ class _AdvancedSettings extends ConsumerState<AdvancedSettings> {
); );
} }
} }
class StackPrivacyButton extends ConsumerWidget {
const StackPrivacyButton({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context, WidgetRef ref) {
Future<void> changePrivacySettings() async {
await showDialog<dynamic>(
context: context,
useSafeArea: false,
barrierDismissible: true,
builder: (context) {
return StackPrivacyDialog();
},
);
}
return SizedBox(
width: 84,
height: 37,
child: TextButton(
style: Theme.of(context)
.extension<StackColors>()!
.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<void> viewDebugLogs() async {
await showDialog<dynamic>(
context: context,
useSafeArea: false,
barrierDismissible: true,
builder: (context) {
return const DebugInfoDialog();
},
);
}
return SizedBox(
width: 101,
height: 37,
child: TextButton(
style: Theme.of(context)
.extension<StackColors>()!
.getPrimaryEnabledButtonColor(context),
onPressed: () {
viewDebugLogs();
},
child: Text(
"Show logs",
style: STextStyles.desktopTextExtraExtraSmall(context)
.copyWith(color: Colors.white),
),
),
);
}
}

View file

@ -422,7 +422,7 @@ class _BackupRestoreSettings extends ConsumerState<BackupRestoreSettings> {
padding: const EdgeInsets.all(10), padding: const EdgeInsets.all(10),
child: !isEnabledAutoBackup child: !isEnabledAutoBackup
? PrimaryButton( ? PrimaryButton(
buttonHeight: ButtonHeight.l, buttonHeight: ButtonHeight.m,
width: 200, width: 200,
label: "Enable auto backup", label: "Enable auto backup",
onPressed: () { onPressed: () {
@ -467,7 +467,7 @@ class _BackupRestoreSettings extends ConsumerState<BackupRestoreSettings> {
Row( Row(
children: [ children: [
PrimaryButton( PrimaryButton(
buttonHeight: ButtonHeight.l, buttonHeight: ButtonHeight.m,
width: 190, width: 190,
label: "Disable auto backup", label: "Disable auto backup",
onPressed: () { onPressed: () {
@ -476,7 +476,7 @@ class _BackupRestoreSettings extends ConsumerState<BackupRestoreSettings> {
), ),
const SizedBox(width: 16), const SizedBox(width: 16),
SecondaryButton( SecondaryButton(
buttonHeight: ButtonHeight.l, buttonHeight: ButtonHeight.m,
width: 190, width: 190,
label: "Edit auto backup", label: "Edit auto backup",
onPressed: () { onPressed: () {
@ -560,7 +560,7 @@ class _BackupRestoreSettings extends ConsumerState<BackupRestoreSettings> {
child: CreateBackupView(), child: CreateBackupView(),
) )
: PrimaryButton( : PrimaryButton(
buttonHeight: ButtonHeight.l, buttonHeight: ButtonHeight.m,
width: 200, width: 200,
label: "Create manual backup", label: "Create manual backup",
onPressed: () { onPressed: () {
@ -642,7 +642,7 @@ class _BackupRestoreSettings extends ConsumerState<BackupRestoreSettings> {
child: RestoreFromFileView(), child: RestoreFromFileView(),
) )
: PrimaryButton( : PrimaryButton(
buttonHeight: ButtonHeight.l, buttonHeight: ButtonHeight.m,
width: 200, width: 200,
label: "Restore backup", label: "Restore backup",
onPressed: () { onPressed: () {

View file

@ -108,7 +108,7 @@ class _CurrencySettings extends ConsumerState<CurrencySettings> {
), ),
child: PrimaryButton( child: PrimaryButton(
width: 210, width: 210,
buttonHeight: ButtonHeight.l, buttonHeight: ButtonHeight.m,
enabled: true, enabled: true,
label: "Change currency", label: "Change currency",
onPressed: () { onPressed: () {

View file

@ -80,12 +80,12 @@ class _LanguageOptionSettings extends ConsumerState<LanguageOptionSettings> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Padding( Padding(
padding: EdgeInsets.all( padding: const EdgeInsets.all(
10, 10,
), ),
child: PrimaryButton( child: PrimaryButton(
width: 210, width: 210,
buttonHeight: ButtonHeight.l, buttonHeight: ButtonHeight.m,
enabled: true, enabled: true,
label: "Change language", label: "Change language",
onPressed: () { onPressed: () {

View file

@ -503,7 +503,7 @@ class _SecuritySettings extends ConsumerState<SecuritySettings> {
) )
: PrimaryButton( : PrimaryButton(
width: 210, width: 210,
buttonHeight: ButtonHeight.l, buttonHeight: ButtonHeight.m,
enabled: true, enabled: true,
label: "Set up new password", label: "Set up new password",
onPressed: () { onPressed: () {

View file

@ -83,7 +83,7 @@ class _SyncingPreferencesSettings
), ),
child: PrimaryButton( child: PrimaryButton(
width: 210, width: 210,
buttonHeight: ButtonHeight.l, buttonHeight: ButtonHeight.m,
enabled: true, enabled: true,
label: "Change preferences", label: "Change preferences",
onPressed: () {}, onPressed: () {},

View file

@ -81,9 +81,9 @@ class PrimaryButton extends StatelessWidget {
if (Util.isDesktop) { if (Util.isDesktop) {
switch (buttonHeight!) { switch (buttonHeight!) {
case ButtonHeight.xxs: case ButtonHeight.xxs:
return 28;
case ButtonHeight.xs:
return 32; return 32;
case ButtonHeight.xs:
return 37;
case ButtonHeight.s: case ButtonHeight.s:
return 40; return 40;
case ButtonHeight.m: case ButtonHeight.m:

View file

@ -84,9 +84,9 @@ class SecondaryButton extends StatelessWidget {
if (Util.isDesktop) { if (Util.isDesktop) {
switch (buttonHeight!) { switch (buttonHeight!) {
case ButtonHeight.xxs: case ButtonHeight.xxs:
return 28;
case ButtonHeight.xs:
return 32; return 32;
case ButtonHeight.xs:
return 37;
case ButtonHeight.s: case ButtonHeight.s:
return 40; return 40;
case ButtonHeight.m: case ButtonHeight.m: