Skip to content

Commit

Permalink
FIX: #198
Browse files Browse the repository at this point in the history
  • Loading branch information
rydmike committed Oct 14, 2023
1 parent 84855db commit e2960e5
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 1 deletion.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,21 @@ All changes to the **FlexColorScheme** (FCS) package are documented here.

## 7.4.0 - WIP

**October 4, 2023**
**October 14, 2023**

- Added CONTRIBUTING and CODE OF CONDUCT guidance to the repository.

**PACKAGE**

**NEW**
- Added `isDense` property to `FlexSubThemes.inputDecoratorTheme()`.
- Added `inputDecoratorIsDense` property to `FlexSubThemesData`.
- Added `contentPadding` property to `FlexSubThemes.inputDecoratorTheme()`.
- Added `inputDecoratorContentPadding` property to `FlexSubThemesData`.

**FIX**
- Fixed [#198 AppBar color issue when using seed generated scheme with key color locked](https://github.com/rydmike/flex_color_scheme/issues/198).

**TODO PACKAGE**
- Add TabBar theme property `tabAlignment`.
- Add TextStyles
Expand Down
16 changes: 16 additions & 0 deletions lib/src/flex_color_scheme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2808,6 +2808,14 @@ class FlexColorScheme with Diagnosticable {

// Compute the effective ColorScheme based on all selection options.
final ColorScheme effectiveColorScheme = seedScheme?.copyWith(
// Add the locked effective colors back to our SeedScheme.
// Fixes: https://github.com/rydmike/flex_color_scheme/issues/198
primary: effectiveColors.primary,
primaryContainer: effectiveColors.primaryContainer,
secondary: effectiveColors.secondary,
secondaryContainer: effectiveColors.secondaryContainer,
tertiary: effectiveColors.tertiary,
tertiaryContainer: effectiveColors.tertiaryContainer,
// We made a seeded color scheme, we use it as given but set
// override values for props we have not handled via FCS direct
// props further below. We don't adjust onColors for
Expand Down Expand Up @@ -4700,6 +4708,14 @@ class FlexColorScheme with Diagnosticable {
: dialogBackground ?? surfaceSchemeColors.dialogBackground;
// Compute the effective ColorScheme based on all selection options.
final ColorScheme effectiveColorScheme = seedScheme?.copyWith(
// Add the locked effective colors back to our SeedScheme.
// Fixes: https://github.com/rydmike/flex_color_scheme/issues/198
primary: effectiveColors.primary,
primaryContainer: effectiveColors.primaryContainer,
secondary: effectiveColors.secondary,
secondaryContainer: effectiveColors.secondaryContainer,
tertiary: effectiveColors.tertiary,
tertiaryContainer: effectiveColors.tertiaryContainer,
// We made a seeded color scheme, we use it as given but set
// override values for props we have not handled via FCS direct
// props further below. We don't adjust onColors for
Expand Down
74 changes: 74 additions & 0 deletions test/flex_color_scheme_sub_themes_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -548,5 +548,79 @@ void main() {
// Expect appBar color to be source blue color.
expect(appBarColor, equals(targetColor));
});
test(
'FCS8.016-prim: GIVEN a FlexColorScheme.dark with sub themes '
'using primary appbar background color, using seed generation '
'and locking primary to source primary color '
'EXPECT expect AppBar to be primary colored.', () {
final FlexColorScheme fcs = FlexColorScheme.dark(
scheme: FlexScheme.flutterDash,
subThemesData: const FlexSubThemesData(
appBarBackgroundSchemeColor: SchemeColor.primary,
),
keyColors: const FlexKeyColors(
keepPrimary: true,
),
);
final ThemeData fcsTheme = fcs.toTheme;
final ColorScheme scheme = fcs.toScheme;
const Color sourceColor = FlexColor.dashBlueDarkPrimary;
final Color targetColor = scheme.primary;
final Color? appBarColor = fcsTheme.appBarTheme.backgroundColor;
// Expect primary color to be source blue color.
expect(sourceColor, equals(targetColor));
// Expect appBar color to be source blue color.
expect(appBarColor, equals(targetColor));
});
test(
'FCS8.016-sec: GIVEN a FlexColorScheme.dark with sub themes '
'using secondary appbar background color, using seed generation '
'and locking secondary to source secondary color '
'EXPECT expect AppBar to be secondary colored.', () {
final FlexColorScheme fcs = FlexColorScheme.dark(
scheme: FlexScheme.flutterDash,
subThemesData: const FlexSubThemesData(
appBarBackgroundSchemeColor: SchemeColor.secondary,
),
keyColors: const FlexKeyColors(
useSecondary: true,
keepSecondary: true,
),
);
final ThemeData fcsTheme = fcs.toTheme;
final ColorScheme scheme = fcs.toScheme;
const Color sourceColor = FlexColor.dashBlueDarkSecondary;
final Color targetColor = scheme.secondary;
final Color? appBarColor = fcsTheme.appBarTheme.backgroundColor;
// Expect secondary color to be source blue color.
expect(sourceColor, equals(targetColor));
// Expect appBar color to be source blue color.
expect(appBarColor, equals(targetColor));
});
test(
'FCS8.016-tert: GIVEN a FlexColorScheme.dark with sub themes '
'using tertiary appbar background color, using seed generation '
'and locking tertiary to source tertiary color '
'EXPECT expect AppBar to be tertiary colored.', () {
final FlexColorScheme fcs = FlexColorScheme.dark(
scheme: FlexScheme.flutterDash,
subThemesData: const FlexSubThemesData(
appBarBackgroundSchemeColor: SchemeColor.tertiary,
),
keyColors: const FlexKeyColors(
useTertiary: true,
keepTertiary: true,
),
);
final ThemeData fcsTheme = fcs.toTheme;
final ColorScheme scheme = fcs.toScheme;
const Color sourceColor = FlexColor.dashBlueDarkTertiary;
final Color targetColor = scheme.tertiary;
final Color? appBarColor = fcsTheme.appBarTheme.backgroundColor;
// Expect secondary color to be source blue color.
expect(sourceColor, equals(targetColor));
// Expect appBar color to be source blue color.
expect(appBarColor, equals(targetColor));
});
});
}

0 comments on commit e2960e5

Please sign in to comment.