From 0d8f0cee1fb553fcd4284e38e54dcc9997914824 Mon Sep 17 00:00:00 2001 From: digitalheartxs Date: Tue, 24 Sep 2024 14:07:13 +0200 Subject: [PATCH] feat: My account, account page, introduce VoicesTextButton's customColor --- .../lib/pages/account/account_page.dart | 12 ++++++++--- .../widgets/buttons/voices_text_button.dart | 20 ++++++++++++++++++- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/catalyst_voices/lib/pages/account/account_page.dart b/catalyst_voices/lib/pages/account/account_page.dart index 835806612e..a6cc518b79 100644 --- a/catalyst_voices/lib/pages/account/account_page.dart +++ b/catalyst_voices/lib/pages/account/account_page.dart @@ -3,6 +3,7 @@ import 'package:catalyst_voices/widgets/buttons/voices_text_button.dart'; import 'package:catalyst_voices_assets/catalyst_voices_assets.dart'; import 'package:catalyst_voices_brands/catalyst_voices_brands.dart'; import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; final class AccountPage extends StatelessWidget { const AccountPage({super.key}); @@ -77,10 +78,13 @@ class _KeychainCard extends StatelessWidget { style: Theme.of(context).textTheme.titleLarge, ), ), - VoicesTextButton( + VoicesTextButton.customColor( leading: VoicesAssets.icons.x.buildIcon(), - child: Text('Remove Keychain'), + color: Theme.of(context).colors.iconsError, onTap: () {}, + child: Text( + 'Remove Keychain', + ), ), ], ), @@ -160,7 +164,9 @@ class _Header extends StatelessWidget { top: 16, left: 8, child: VoicesIconButton.filled( - onTap: () {}, + onTap: () { + GoRouter.of(context).pop(); + }, style: ButtonStyle( backgroundColor: WidgetStateProperty.all( Theme.of(context).colors.elevationsOnSurfaceNeutralLv1White, diff --git a/catalyst_voices/lib/widgets/buttons/voices_text_button.dart b/catalyst_voices/lib/widgets/buttons/voices_text_button.dart index d9ce555aaa..8d2a85c78e 100644 --- a/catalyst_voices/lib/widgets/buttons/voices_text_button.dart +++ b/catalyst_voices/lib/widgets/buttons/voices_text_button.dart @@ -2,7 +2,7 @@ import 'package:catalyst_voices/widgets/buttons/voices_button_affix_decoration.d import 'package:catalyst_voices_brands/catalyst_voices_brands.dart'; import 'package:flutter/material.dart'; -enum _Variant { primary, neutral, secondary } +enum _Variant { primary, neutral, secondary, customColor } /// A button that combines a `TextButton` with optional leading and trailing /// elements. @@ -22,6 +22,9 @@ class VoicesTextButton extends StatelessWidget { /// The main content of the button. final Widget child; + /// The foreground color of the button. + final Color? color; + final _Variant _variant; const VoicesTextButton({ @@ -29,6 +32,7 @@ class VoicesTextButton extends StatelessWidget { this.onTap, this.leading, this.trailing, + this.color, required this.child, }) : _variant = _Variant.primary; @@ -37,6 +41,7 @@ class VoicesTextButton extends StatelessWidget { this.onTap, this.leading, this.trailing, + this.color, required this.child, }) : _variant = _Variant.neutral; @@ -45,9 +50,19 @@ class VoicesTextButton extends StatelessWidget { this.onTap, this.leading, this.trailing, + this.color, required this.child, }) : _variant = _Variant.secondary; + const VoicesTextButton.customColor({ + super.key, + this.onTap, + this.leading, + this.trailing, + required this.color, + required this.child, + }) : _variant = _Variant.customColor; + @override Widget build(BuildContext context) { return TextButton( @@ -75,6 +90,9 @@ class VoicesTextButton extends StatelessWidget { _Variant.secondary => TextButton.styleFrom( foregroundColor: Theme.of(context).colorScheme.secondary, ), + _Variant.customColor => TextButton.styleFrom( + foregroundColor: color, + ), }; } }