Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fix fab icon color #222

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading