Skip to content

Commit

Permalink
Fix disabled color foreground on FilledButton (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdlukaa authored Mar 7, 2022
2 parents e5a948f + 65bd0fa commit 4c0f254
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
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

0 comments on commit 4c0f254

Please # to comment.