Skip to content

Commit

Permalink
feat: My account, account page, introduce VoicesTextButton's customColor
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalheartxs committed Sep 24, 2024
1 parent 072e1f7 commit 0d8f0ce
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
12 changes: 9 additions & 3 deletions catalyst_voices/lib/pages/account/account_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down Expand Up @@ -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',
),
),
],
),
Expand Down Expand Up @@ -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,
Expand Down
20 changes: 19 additions & 1 deletion catalyst_voices/lib/widgets/buttons/voices_text_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -22,13 +22,17 @@ 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({
super.key,
this.onTap,
this.leading,
this.trailing,
this.color,
required this.child,
}) : _variant = _Variant.primary;

Expand All @@ -37,6 +41,7 @@ class VoicesTextButton extends StatelessWidget {
this.onTap,
this.leading,
this.trailing,
this.color,
required this.child,
}) : _variant = _Variant.neutral;

Expand All @@ -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(
Expand Down Expand Up @@ -75,6 +90,9 @@ class VoicesTextButton extends StatelessWidget {
_Variant.secondary => TextButton.styleFrom(
foregroundColor: Theme.of(context).colorScheme.secondary,
),
_Variant.customColor => TextButton.styleFrom(
foregroundColor: color,
),
};
}
}

0 comments on commit 0d8f0ce

Please sign in to comment.