Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix disabled color foreground on FilledButton #209

Merged
merged 4 commits into from
Mar 7, 2022
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Date format: DD/MM/YYYY

## [3.9.2] [dd/mm/yyyy]

- Fix: [#207](https://github.com/bdlukaa/fluent_ui/pull/207) FilledButton disabled foreground

## [3.9.1] - Input Update - [25/02/2022]

- `TextBox` updates: ([#179](https://github.com/bdlukaa/fluent_ui/pull/179))
Expand Down
5 changes: 5 additions & 0 deletions example/lib/screens/inputs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ class _InputsPageState extends State<InputsPage> {
},
),
spacer,
FilledButton(
child: const Text('Filled Button'),
onPressed: disabled ? null : () => print('pressed filled button'),
),
spacer,
IconButton(
icon: const Icon(FluentIcons.add),
onPressed: disabled ? null : () => print('pressed icon button'),
Expand Down
9 changes: 8 additions & 1 deletion lib/src/controls/inputs/buttons/filled_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,20 @@ class FilledButton extends Button {
return ButtonStyle(backgroundColor: ButtonState.resolveWith((states) {
return backgroundColor(theme, states);
}), foregroundColor: ButtonState.resolveWith((states) {
if (states.isDisabled) {
return theme.brightness.isDark ? theme.disabledColor : Colors.white;
}
return backgroundColor(theme, states).basedOnLuminance();
}));
}

static Color backgroundColor(ThemeData theme, Set<ButtonStates> states) {
if (states.isDisabled) {
return ButtonThemeData.buttonColor(theme.brightness, states);
if (theme.brightness.isDark) {
return const Color(0xFF434343);
} else {
return const Color(0xFFBFBFBF);
}
} else if (states.isPressing) {
if (theme.brightness.isDark) {
return theme.accentColor.darker;
Expand Down