Skip to content

Commit

Permalink
feat: fabs update button labels in example and fix icon color handling
Browse files Browse the repository at this point in the history
  • Loading branch information
DE7924 committed Dec 13, 2024
1 parent 419ded2 commit 95135d2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
12 changes: 6 additions & 6 deletions example/lib/pages/components/button_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class _ButtonExampleState extends State<ButtonExample> {
fabs = [
ZetaFAB(
scrollController: _scrollController,
label: 'Small Circle Primary',
label: 'Small Circle Disabled',
size: ZetaFabSize.small,
expanded: false,
shape: ZetaWidgetBorder.full,
Expand All @@ -45,15 +45,15 @@ class _ButtonExampleState extends State<ButtonExample> {
ZetaFAB(
scrollController: _scrollController,
expanded: false,
label: 'Small Rounded Primary',
label: 'Small Rounded Secondary',
size: ZetaFabSize.small,
shape: ZetaWidgetBorder.rounded,
type: ZetaFabType.secondary,
onPressed: () => setFab(1),
),
ZetaFAB(
scrollController: _scrollController,
label: 'Small Sharp Primary',
label: 'Small Sharp Inverse',
size: ZetaFabSize.small,
shape: ZetaWidgetBorder.sharp,
expanded: false,
Expand All @@ -62,7 +62,7 @@ class _ButtonExampleState extends State<ButtonExample> {
),
ZetaFAB(
scrollController: _scrollController,
label: 'Large Circle Primary',
label: 'Large Circle Secondary',
size: ZetaFabSize.large,
shape: ZetaWidgetBorder.full,
type: ZetaFabType.secondary,
Expand All @@ -71,7 +71,7 @@ class _ButtonExampleState extends State<ButtonExample> {
),
ZetaFAB(
scrollController: _scrollController,
label: 'Large Rounded Secondary',
label: 'Large Rounded Inverse',
size: ZetaFabSize.large,
shape: ZetaWidgetBorder.rounded,
expanded: false,
Expand All @@ -80,7 +80,7 @@ class _ButtonExampleState extends State<ButtonExample> {
),
ZetaFAB(
scrollController: _scrollController,
label: 'Large Sharp Secondary',
label: 'Large Sharp Primary',
size: ZetaFabSize.large,
shape: ZetaWidgetBorder.sharp,
type: ZetaFabType.primary,
Expand Down
19 changes: 18 additions & 1 deletion lib/src/components/fabs/fab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,13 @@ class _ZetaFABState extends State<ZetaFAB> {
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
ZetaIcon(widget.icon, size: widget.size.iconSize(context)),
ZetaIcon(
widget.icon,
size: widget.size.iconSize(context),
color: widget.onPressed != null
? widget.type.iconColors(context)
: Zeta.of(context).colors.iconDisabled,
),
if (widget.expanded && widget.label != null)
Row(
mainAxisSize: MainAxisSize.min,
Expand Down Expand Up @@ -206,6 +212,17 @@ extension on ZetaFabType {
return zetaColors.cool;
}
}

Color iconColors(BuildContext context) {
final zetaColors = Zeta.of(context).colors;
switch (this) {
case ZetaFabType.primary:
case ZetaFabType.inverse:
return zetaColors.iconInverse;
case ZetaFabType.secondary:
return zetaColors.iconDefault;
}
}
}

extension on ZetaWidgetBorder {
Expand Down

0 comments on commit 95135d2

Please sign in to comment.