Unverified Commit a6e945fb authored by Darren Austin's avatar Darren Austin Committed by GitHub

Add `surfaceTint` color to the ColorScheme. (#100153)

parent 69b92f04
...@@ -104,6 +104,7 @@ class ColorScheme with Diagnosticable { ...@@ -104,6 +104,7 @@ class ColorScheme with Diagnosticable {
Color? inverseSurface, Color? inverseSurface,
Color? onInverseSurface, Color? onInverseSurface,
Color? inversePrimary, Color? inversePrimary,
Color? surfaceTint,
@Deprecated( @Deprecated(
'Use primary or primaryContainer instead. ' 'Use primary or primaryContainer instead. '
'This feature was deprecated after v2.6.0-0.0.pre.' 'This feature was deprecated after v2.6.0-0.0.pre.'
...@@ -143,7 +144,8 @@ class ColorScheme with Diagnosticable { ...@@ -143,7 +144,8 @@ class ColorScheme with Diagnosticable {
_onInverseSurface = onInverseSurface, _onInverseSurface = onInverseSurface,
_inversePrimary = inversePrimary, _inversePrimary = inversePrimary,
_primaryVariant = primaryVariant, _primaryVariant = primaryVariant,
_secondaryVariant = secondaryVariant; _secondaryVariant = secondaryVariant,
_surfaceTint = surfaceTint;
/// Generate a [ColorScheme] derived from the given `seedColor`. /// Generate a [ColorScheme] derived from the given `seedColor`.
/// ///
...@@ -197,6 +199,7 @@ class ColorScheme with Diagnosticable { ...@@ -197,6 +199,7 @@ class ColorScheme with Diagnosticable {
Color? onInverseSurface, Color? onInverseSurface,
Color? inversePrimary, Color? inversePrimary,
Color? shadow, Color? shadow,
Color? surfaceTint,
}) { }) {
final Scheme scheme; final Scheme scheme;
switch (brightness) { switch (brightness) {
...@@ -235,6 +238,7 @@ class ColorScheme with Diagnosticable { ...@@ -235,6 +238,7 @@ class ColorScheme with Diagnosticable {
onInverseSurface: onInverseSurface ?? Color(scheme.inverseOnSurface), onInverseSurface: onInverseSurface ?? Color(scheme.inverseOnSurface),
inversePrimary: inversePrimary ?? Color(scheme.inversePrimary), inversePrimary: inversePrimary ?? Color(scheme.inversePrimary),
shadow: shadow ?? Color(scheme.shadow), shadow: shadow ?? Color(scheme.shadow),
surfaceTint: surfaceTint ?? Color(scheme.primary),
brightness: brightness, brightness: brightness,
); );
} }
...@@ -270,6 +274,7 @@ class ColorScheme with Diagnosticable { ...@@ -270,6 +274,7 @@ class ColorScheme with Diagnosticable {
Color? inverseSurface, Color? inverseSurface,
Color? onInverseSurface, Color? onInverseSurface,
Color? inversePrimary, Color? inversePrimary,
Color? surfaceTint,
@Deprecated( @Deprecated(
'Use primary or primaryContainer instead. ' 'Use primary or primaryContainer instead. '
'This feature was deprecated after v2.6.0-0.0.pre.' 'This feature was deprecated after v2.6.0-0.0.pre.'
...@@ -309,7 +314,8 @@ class ColorScheme with Diagnosticable { ...@@ -309,7 +314,8 @@ class ColorScheme with Diagnosticable {
_onInverseSurface = onInverseSurface, _onInverseSurface = onInverseSurface,
_inversePrimary = inversePrimary, _inversePrimary = inversePrimary,
_primaryVariant = primaryVariant, _primaryVariant = primaryVariant,
_secondaryVariant = secondaryVariant; _secondaryVariant = secondaryVariant,
_surfaceTint = surfaceTint;
/// Create the recommended dark color scheme that matches the /// Create the recommended dark color scheme that matches the
/// [baseline Material color scheme](https://material.io/design/color/dark-theme.html#ui-application). /// [baseline Material color scheme](https://material.io/design/color/dark-theme.html#ui-application).
...@@ -342,6 +348,7 @@ class ColorScheme with Diagnosticable { ...@@ -342,6 +348,7 @@ class ColorScheme with Diagnosticable {
Color? inverseSurface, Color? inverseSurface,
Color? onInverseSurface, Color? onInverseSurface,
Color? inversePrimary, Color? inversePrimary,
Color? surfaceTint,
@Deprecated( @Deprecated(
'Use primary or primaryContainer instead. ' 'Use primary or primaryContainer instead. '
'This feature was deprecated after v2.6.0-0.0.pre.' 'This feature was deprecated after v2.6.0-0.0.pre.'
...@@ -381,7 +388,8 @@ class ColorScheme with Diagnosticable { ...@@ -381,7 +388,8 @@ class ColorScheme with Diagnosticable {
_onInverseSurface = onInverseSurface, _onInverseSurface = onInverseSurface,
_inversePrimary = inversePrimary, _inversePrimary = inversePrimary,
_primaryVariant = primaryVariant, _primaryVariant = primaryVariant,
_secondaryVariant = secondaryVariant; _secondaryVariant = secondaryVariant,
_surfaceTint = surfaceTint;
/// Create a high contrast ColorScheme based on a purple primary color that /// Create a high contrast ColorScheme based on a purple primary color that
/// matches the [baseline Material color scheme](https://material.io/design/color/the-color-system.html#color-theme-creation). /// matches the [baseline Material color scheme](https://material.io/design/color/the-color-system.html#color-theme-creation).
...@@ -414,6 +422,7 @@ class ColorScheme with Diagnosticable { ...@@ -414,6 +422,7 @@ class ColorScheme with Diagnosticable {
Color? inverseSurface, Color? inverseSurface,
Color? onInverseSurface, Color? onInverseSurface,
Color? inversePrimary, Color? inversePrimary,
Color? surfaceTint,
@Deprecated( @Deprecated(
'Use primary or primaryContainer instead. ' 'Use primary or primaryContainer instead. '
'This feature was deprecated after v2.6.0-0.0.pre.' 'This feature was deprecated after v2.6.0-0.0.pre.'
...@@ -453,7 +462,8 @@ class ColorScheme with Diagnosticable { ...@@ -453,7 +462,8 @@ class ColorScheme with Diagnosticable {
_onInverseSurface = onInverseSurface, _onInverseSurface = onInverseSurface,
_inversePrimary = inversePrimary, _inversePrimary = inversePrimary,
_primaryVariant = primaryVariant, _primaryVariant = primaryVariant,
_secondaryVariant = secondaryVariant; _secondaryVariant = secondaryVariant,
_surfaceTint = surfaceTint;
/// Create a high contrast ColorScheme based on the dark /// Create a high contrast ColorScheme based on the dark
/// [baseline Material color scheme](https://material.io/design/color/dark-theme.html#ui-application). /// [baseline Material color scheme](https://material.io/design/color/dark-theme.html#ui-application).
...@@ -486,6 +496,7 @@ class ColorScheme with Diagnosticable { ...@@ -486,6 +496,7 @@ class ColorScheme with Diagnosticable {
Color? inverseSurface, Color? inverseSurface,
Color? onInverseSurface, Color? onInverseSurface,
Color? inversePrimary, Color? inversePrimary,
Color? surfaceTint,
@Deprecated( @Deprecated(
'Use primary or primaryContainer instead. ' 'Use primary or primaryContainer instead. '
'This feature was deprecated after v2.6.0-0.0.pre.' 'This feature was deprecated after v2.6.0-0.0.pre.'
...@@ -525,7 +536,8 @@ class ColorScheme with Diagnosticable { ...@@ -525,7 +536,8 @@ class ColorScheme with Diagnosticable {
_onInverseSurface = onInverseSurface, _onInverseSurface = onInverseSurface,
_inversePrimary = inversePrimary, _inversePrimary = inversePrimary,
_primaryVariant = primaryVariant, _primaryVariant = primaryVariant,
_secondaryVariant = secondaryVariant; _secondaryVariant = secondaryVariant,
_surfaceTint = surfaceTint;
/// Create a color scheme from a [MaterialColor] swatch. /// Create a color scheme from a [MaterialColor] swatch.
/// ///
...@@ -730,6 +742,11 @@ class ColorScheme with Diagnosticable { ...@@ -730,6 +742,11 @@ class ColorScheme with Diagnosticable {
/// backgrounds, like button text in a SnackBar. /// backgrounds, like button text in a SnackBar.
Color get inversePrimary => _inversePrimary ?? onPrimary; Color get inversePrimary => _inversePrimary ?? onPrimary;
final Color? _surfaceTint;
/// A color used as an overlay on a surface color to indicate a component's
/// elevation.
Color get surfaceTint => _surfaceTint ?? primary;
final Color? _primaryVariant; final Color? _primaryVariant;
/// A darker version of the primary color. /// A darker version of the primary color.
@Deprecated( @Deprecated(
...@@ -777,6 +794,7 @@ class ColorScheme with Diagnosticable { ...@@ -777,6 +794,7 @@ class ColorScheme with Diagnosticable {
Color? inverseSurface, Color? inverseSurface,
Color? onInverseSurface, Color? onInverseSurface,
Color? inversePrimary, Color? inversePrimary,
Color? surfaceTint,
@Deprecated( @Deprecated(
'Use primary or primaryContainer instead. ' 'Use primary or primaryContainer instead. '
'This feature was deprecated after v2.6.0-0.0.pre.' 'This feature was deprecated after v2.6.0-0.0.pre.'
...@@ -819,6 +837,7 @@ class ColorScheme with Diagnosticable { ...@@ -819,6 +837,7 @@ class ColorScheme with Diagnosticable {
inversePrimary : inversePrimary ?? this.inversePrimary, inversePrimary : inversePrimary ?? this.inversePrimary,
primaryVariant: primaryVariant ?? this.primaryVariant, primaryVariant: primaryVariant ?? this.primaryVariant,
secondaryVariant: secondaryVariant ?? this.secondaryVariant, secondaryVariant: secondaryVariant ?? this.secondaryVariant,
surfaceTint: _surfaceTint ?? this.surfaceTint,
); );
} }
...@@ -857,6 +876,7 @@ class ColorScheme with Diagnosticable { ...@@ -857,6 +876,7 @@ class ColorScheme with Diagnosticable {
inversePrimary: Color.lerp(a.inversePrimary, b.inversePrimary, t), inversePrimary: Color.lerp(a.inversePrimary, b.inversePrimary, t),
primaryVariant: Color.lerp(a.primaryVariant, b.primaryVariant, t), primaryVariant: Color.lerp(a.primaryVariant, b.primaryVariant, t),
secondaryVariant: Color.lerp(a.secondaryVariant, b.secondaryVariant, t), secondaryVariant: Color.lerp(a.secondaryVariant, b.secondaryVariant, t),
surfaceTint: Color.lerp(a.surfaceTint, b.surfaceTint, t),
); );
} }
...@@ -896,7 +916,8 @@ class ColorScheme with Diagnosticable { ...@@ -896,7 +916,8 @@ class ColorScheme with Diagnosticable {
&& other.onInverseSurface == onInverseSurface && other.onInverseSurface == onInverseSurface
&& other.inversePrimary == inversePrimary && other.inversePrimary == inversePrimary
&& other.primaryVariant == primaryVariant && other.primaryVariant == primaryVariant
&& other.secondaryVariant == secondaryVariant; && other.secondaryVariant == secondaryVariant
&& other.surfaceTint == surfaceTint;
} }
@override @override
...@@ -932,6 +953,7 @@ class ColorScheme with Diagnosticable { ...@@ -932,6 +953,7 @@ class ColorScheme with Diagnosticable {
inversePrimary, inversePrimary,
primaryVariant, primaryVariant,
secondaryVariant, secondaryVariant,
surfaceTint,
), ),
); );
...@@ -969,5 +991,6 @@ class ColorScheme with Diagnosticable { ...@@ -969,5 +991,6 @@ class ColorScheme with Diagnosticable {
properties.add(ColorProperty('inversePrimary', inversePrimary, defaultValue: defaultScheme.inversePrimary)); properties.add(ColorProperty('inversePrimary', inversePrimary, defaultValue: defaultScheme.inversePrimary));
properties.add(ColorProperty('primaryVariant', primaryVariant, defaultValue: defaultScheme.primaryVariant)); properties.add(ColorProperty('primaryVariant', primaryVariant, defaultValue: defaultScheme.primaryVariant));
properties.add(ColorProperty('secondaryVariant', secondaryVariant, defaultValue: defaultScheme.secondaryVariant)); properties.add(ColorProperty('secondaryVariant', secondaryVariant, defaultValue: defaultScheme.secondaryVariant));
properties.add(ColorProperty('surfaceTint', surfaceTint, defaultValue: defaultScheme.surfaceTint));
} }
} }
...@@ -40,6 +40,7 @@ void main() { ...@@ -40,6 +40,7 @@ void main() {
expect(scheme.inverseSurface, scheme.onSurface); expect(scheme.inverseSurface, scheme.onSurface);
expect(scheme.onInverseSurface, scheme.surface); expect(scheme.onInverseSurface, scheme.surface);
expect(scheme.inversePrimary, scheme.onPrimary); expect(scheme.inversePrimary, scheme.onPrimary);
expect(scheme.surfaceTint, scheme.primary);
expect(scheme.primaryVariant, const Color(0xff3700b3)); expect(scheme.primaryVariant, const Color(0xff3700b3));
expect(scheme.secondaryVariant, const Color(0xff018786)); expect(scheme.secondaryVariant, const Color(0xff018786));
...@@ -79,6 +80,7 @@ void main() { ...@@ -79,6 +80,7 @@ void main() {
expect(scheme.inverseSurface, scheme.onSurface); expect(scheme.inverseSurface, scheme.onSurface);
expect(scheme.onInverseSurface, scheme.surface); expect(scheme.onInverseSurface, scheme.surface);
expect(scheme.inversePrimary, scheme.onPrimary); expect(scheme.inversePrimary, scheme.onPrimary);
expect(scheme.surfaceTint, scheme.primary);
expect(scheme.primaryVariant, const Color(0xff3700b3)); expect(scheme.primaryVariant, const Color(0xff3700b3));
expect(scheme.secondaryVariant, const Color(0xff03dac6)); expect(scheme.secondaryVariant, const Color(0xff03dac6));
...@@ -118,6 +120,7 @@ void main() { ...@@ -118,6 +120,7 @@ void main() {
expect(scheme.inverseSurface, scheme.onSurface); expect(scheme.inverseSurface, scheme.onSurface);
expect(scheme.onInverseSurface, scheme.surface); expect(scheme.onInverseSurface, scheme.surface);
expect(scheme.inversePrimary, scheme.onPrimary); expect(scheme.inversePrimary, scheme.onPrimary);
expect(scheme.surfaceTint, scheme.primary);
expect(scheme.primaryVariant, const Color(0xff000088)); expect(scheme.primaryVariant, const Color(0xff000088));
expect(scheme.secondaryVariant, const Color(0xff018786)); expect(scheme.secondaryVariant, const Color(0xff018786));
...@@ -157,6 +160,7 @@ void main() { ...@@ -157,6 +160,7 @@ void main() {
expect(scheme.inverseSurface, scheme.onSurface); expect(scheme.inverseSurface, scheme.onSurface);
expect(scheme.onInverseSurface, scheme.surface); expect(scheme.onInverseSurface, scheme.surface);
expect(scheme.inversePrimary, scheme.onPrimary); expect(scheme.inversePrimary, scheme.onPrimary);
expect(scheme.surfaceTint, scheme.primary);
expect(scheme.primaryVariant, const Color(0xffbe9eff)); expect(scheme.primaryVariant, const Color(0xffbe9eff));
expect(scheme.secondaryVariant, const Color(0xff66fff9)); expect(scheme.secondaryVariant, const Color(0xff66fff9));
...@@ -191,6 +195,7 @@ void main() { ...@@ -191,6 +195,7 @@ void main() {
expect(scheme.onInverseSurface, const Color(0xfff1f0f4)); expect(scheme.onInverseSurface, const Color(0xfff1f0f4));
expect(scheme.inversePrimary, const Color(0xff9ccaff)); expect(scheme.inversePrimary, const Color(0xff9ccaff));
expect(scheme.shadow, const Color(0xff000000)); expect(scheme.shadow, const Color(0xff000000));
expect(scheme.surfaceTint, const Color(0xff0061a6));
expect(scheme.brightness, Brightness.light); expect(scheme.brightness, Brightness.light);
}); });
...@@ -223,6 +228,7 @@ void main() { ...@@ -223,6 +228,7 @@ void main() {
expect(scheme.onInverseSurface, const Color(0xff2f3033)); expect(scheme.onInverseSurface, const Color(0xff2f3033));
expect(scheme.inversePrimary, const Color(0xff0061a6)); expect(scheme.inversePrimary, const Color(0xff0061a6));
expect(scheme.shadow, const Color(0xff000000)); expect(scheme.shadow, const Color(0xff000000));
expect(scheme.surfaceTint, const Color(0xff9ccaff));
expect(scheme.brightness, Brightness.dark); expect(scheme.brightness, Brightness.dark);
}); });
...@@ -261,6 +267,7 @@ void main() { ...@@ -261,6 +267,7 @@ void main() {
expect(scheme.onInverseSurface, baseScheme.onInverseSurface); expect(scheme.onInverseSurface, baseScheme.onInverseSurface);
expect(scheme.inversePrimary, baseScheme.inversePrimary); expect(scheme.inversePrimary, baseScheme.inversePrimary);
expect(scheme.shadow, baseScheme.shadow); expect(scheme.shadow, baseScheme.shadow);
expect(scheme.surfaceTint, baseScheme.surfaceTint);
expect(scheme.brightness, baseScheme.brightness); expect(scheme.brightness, baseScheme.brightness);
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment