From 58b9222446e47d976761ffd347546717b043aa23 Mon Sep 17 00:00:00 2001 From: Daniel Eshkeri Date: Fri, 13 Dec 2024 12:28:24 +0000 Subject: [PATCH] fix: Fab icon color (#222) --- .../lib/pages/components/button_example.dart | 12 ++++++------ lib/src/components/fabs/fab.dart | 19 ++++++++++++++++++- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/example/lib/pages/components/button_example.dart b/example/lib/pages/components/button_example.dart index 926379d9..379f95f3 100644 --- a/example/lib/pages/components/button_example.dart +++ b/example/lib/pages/components/button_example.dart @@ -36,7 +36,7 @@ class _ButtonExampleState extends State { fabs = [ ZetaFAB( scrollController: _scrollController, - label: 'Small Circle Primary', + label: 'Small Circle Disabled', size: ZetaFabSize.small, expanded: false, shape: ZetaWidgetBorder.full, @@ -45,7 +45,7 @@ class _ButtonExampleState extends State { ZetaFAB( scrollController: _scrollController, expanded: false, - label: 'Small Rounded Primary', + label: 'Small Rounded Secondary', size: ZetaFabSize.small, shape: ZetaWidgetBorder.rounded, type: ZetaFabType.secondary, @@ -53,7 +53,7 @@ class _ButtonExampleState extends State { ), ZetaFAB( scrollController: _scrollController, - label: 'Small Sharp Primary', + label: 'Small Sharp Inverse', size: ZetaFabSize.small, shape: ZetaWidgetBorder.sharp, expanded: false, @@ -62,7 +62,7 @@ class _ButtonExampleState extends State { ), ZetaFAB( scrollController: _scrollController, - label: 'Large Circle Primary', + label: 'Large Circle Secondary', size: ZetaFabSize.large, shape: ZetaWidgetBorder.full, type: ZetaFabType.secondary, @@ -71,7 +71,7 @@ class _ButtonExampleState extends State { ), ZetaFAB( scrollController: _scrollController, - label: 'Large Rounded Secondary', + label: 'Large Rounded Inverse', size: ZetaFabSize.large, shape: ZetaWidgetBorder.rounded, expanded: false, @@ -80,7 +80,7 @@ class _ButtonExampleState extends State { ), ZetaFAB( scrollController: _scrollController, - label: 'Large Sharp Secondary', + label: 'Large Sharp Primary', size: ZetaFabSize.large, shape: ZetaWidgetBorder.sharp, type: ZetaFabType.primary, diff --git a/lib/src/components/fabs/fab.dart b/lib/src/components/fabs/fab.dart index 486a1749..d8e554da 100644 --- a/lib/src/components/fabs/fab.dart +++ b/lib/src/components/fabs/fab.dart @@ -162,7 +162,13 @@ class _ZetaFABState extends State { 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, @@ -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 {