Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
a6e945fb
Unverified
Commit
a6e945fb
authored
Mar 22, 2022
by
Darren Austin
Committed by
GitHub
Mar 22, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `surfaceTint` color to the ColorScheme. (#100153)
parent
69b92f04
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
6 deletions
+36
-6
color_scheme.dart
packages/flutter/lib/src/material/color_scheme.dart
+29
-6
color_scheme_test.dart
packages/flutter/test/material/color_scheme_test.dart
+7
-0
No files found.
packages/flutter/lib/src/material/color_scheme.dart
View file @
a6e945fb
...
...
@@ -104,6 +104,7 @@ class ColorScheme with Diagnosticable {
Color
?
inverseSurface
,
Color
?
onInverseSurface
,
Color
?
inversePrimary
,
Color
?
surfaceTint
,
@Deprecated
(
'Use primary or primaryContainer instead. '
'This feature was deprecated after v2.6.0-0.0.pre.'
...
...
@@ -143,7 +144,8 @@ class ColorScheme with Diagnosticable {
_onInverseSurface
=
onInverseSurface
,
_inversePrimary
=
inversePrimary
,
_primaryVariant
=
primaryVariant
,
_secondaryVariant
=
secondaryVariant
;
_secondaryVariant
=
secondaryVariant
,
_surfaceTint
=
surfaceTint
;
/// Generate a [ColorScheme] derived from the given `seedColor`.
///
...
...
@@ -197,6 +199,7 @@ class ColorScheme with Diagnosticable {
Color
?
onInverseSurface
,
Color
?
inversePrimary
,
Color
?
shadow
,
Color
?
surfaceTint
,
})
{
final
Scheme
scheme
;
switch
(
brightness
)
{
...
...
@@ -235,6 +238,7 @@ class ColorScheme with Diagnosticable {
onInverseSurface:
onInverseSurface
??
Color
(
scheme
.
inverseOnSurface
),
inversePrimary:
inversePrimary
??
Color
(
scheme
.
inversePrimary
),
shadow:
shadow
??
Color
(
scheme
.
shadow
),
surfaceTint:
surfaceTint
??
Color
(
scheme
.
primary
),
brightness:
brightness
,
);
}
...
...
@@ -270,6 +274,7 @@ class ColorScheme with Diagnosticable {
Color
?
inverseSurface
,
Color
?
onInverseSurface
,
Color
?
inversePrimary
,
Color
?
surfaceTint
,
@Deprecated
(
'Use primary or primaryContainer instead. '
'This feature was deprecated after v2.6.0-0.0.pre.'
...
...
@@ -309,7 +314,8 @@ class ColorScheme with Diagnosticable {
_onInverseSurface
=
onInverseSurface
,
_inversePrimary
=
inversePrimary
,
_primaryVariant
=
primaryVariant
,
_secondaryVariant
=
secondaryVariant
;
_secondaryVariant
=
secondaryVariant
,
_surfaceTint
=
surfaceTint
;
/// Create the recommended dark color scheme that matches the
/// [baseline Material color scheme](https://material.io/design/color/dark-theme.html#ui-application).
...
...
@@ -342,6 +348,7 @@ class ColorScheme with Diagnosticable {
Color
?
inverseSurface
,
Color
?
onInverseSurface
,
Color
?
inversePrimary
,
Color
?
surfaceTint
,
@Deprecated
(
'Use primary or primaryContainer instead. '
'This feature was deprecated after v2.6.0-0.0.pre.'
...
...
@@ -381,7 +388,8 @@ class ColorScheme with Diagnosticable {
_onInverseSurface
=
onInverseSurface
,
_inversePrimary
=
inversePrimary
,
_primaryVariant
=
primaryVariant
,
_secondaryVariant
=
secondaryVariant
;
_secondaryVariant
=
secondaryVariant
,
_surfaceTint
=
surfaceTint
;
/// 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).
...
...
@@ -414,6 +422,7 @@ class ColorScheme with Diagnosticable {
Color
?
inverseSurface
,
Color
?
onInverseSurface
,
Color
?
inversePrimary
,
Color
?
surfaceTint
,
@Deprecated
(
'Use primary or primaryContainer instead. '
'This feature was deprecated after v2.6.0-0.0.pre.'
...
...
@@ -453,7 +462,8 @@ class ColorScheme with Diagnosticable {
_onInverseSurface
=
onInverseSurface
,
_inversePrimary
=
inversePrimary
,
_primaryVariant
=
primaryVariant
,
_secondaryVariant
=
secondaryVariant
;
_secondaryVariant
=
secondaryVariant
,
_surfaceTint
=
surfaceTint
;
/// Create a high contrast ColorScheme based on the dark
/// [baseline Material color scheme](https://material.io/design/color/dark-theme.html#ui-application).
...
...
@@ -486,6 +496,7 @@ class ColorScheme with Diagnosticable {
Color
?
inverseSurface
,
Color
?
onInverseSurface
,
Color
?
inversePrimary
,
Color
?
surfaceTint
,
@Deprecated
(
'Use primary or primaryContainer instead. '
'This feature was deprecated after v2.6.0-0.0.pre.'
...
...
@@ -525,7 +536,8 @@ class ColorScheme with Diagnosticable {
_onInverseSurface
=
onInverseSurface
,
_inversePrimary
=
inversePrimary
,
_primaryVariant
=
primaryVariant
,
_secondaryVariant
=
secondaryVariant
;
_secondaryVariant
=
secondaryVariant
,
_surfaceTint
=
surfaceTint
;
/// Create a color scheme from a [MaterialColor] swatch.
///
...
...
@@ -730,6 +742,11 @@ class ColorScheme with Diagnosticable {
/// backgrounds, like button text in a SnackBar.
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
;
/// A darker version of the primary color.
@Deprecated
(
...
...
@@ -777,6 +794,7 @@ class ColorScheme with Diagnosticable {
Color
?
inverseSurface
,
Color
?
onInverseSurface
,
Color
?
inversePrimary
,
Color
?
surfaceTint
,
@Deprecated
(
'Use primary or primaryContainer instead. '
'This feature was deprecated after v2.6.0-0.0.pre.'
...
...
@@ -819,6 +837,7 @@ class ColorScheme with Diagnosticable {
inversePrimary
:
inversePrimary
??
this
.
inversePrimary
,
primaryVariant:
primaryVariant
??
this
.
primaryVariant
,
secondaryVariant:
secondaryVariant
??
this
.
secondaryVariant
,
surfaceTint:
_surfaceTint
??
this
.
surfaceTint
,
);
}
...
...
@@ -857,6 +876,7 @@ class ColorScheme with Diagnosticable {
inversePrimary:
Color
.
lerp
(
a
.
inversePrimary
,
b
.
inversePrimary
,
t
),
primaryVariant:
Color
.
lerp
(
a
.
primaryVariant
,
b
.
primaryVariant
,
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 {
&&
other
.
onInverseSurface
==
onInverseSurface
&&
other
.
inversePrimary
==
inversePrimary
&&
other
.
primaryVariant
==
primaryVariant
&&
other
.
secondaryVariant
==
secondaryVariant
;
&&
other
.
secondaryVariant
==
secondaryVariant
&&
other
.
surfaceTint
==
surfaceTint
;
}
@override
...
...
@@ -932,6 +953,7 @@ class ColorScheme with Diagnosticable {
inversePrimary
,
primaryVariant
,
secondaryVariant
,
surfaceTint
,
),
);
...
...
@@ -969,5 +991,6 @@ class ColorScheme with Diagnosticable {
properties
.
add
(
ColorProperty
(
'inversePrimary'
,
inversePrimary
,
defaultValue:
defaultScheme
.
inversePrimary
));
properties
.
add
(
ColorProperty
(
'primaryVariant'
,
primaryVariant
,
defaultValue:
defaultScheme
.
primaryVariant
));
properties
.
add
(
ColorProperty
(
'secondaryVariant'
,
secondaryVariant
,
defaultValue:
defaultScheme
.
secondaryVariant
));
properties
.
add
(
ColorProperty
(
'surfaceTint'
,
surfaceTint
,
defaultValue:
defaultScheme
.
surfaceTint
));
}
}
packages/flutter/test/material/color_scheme_test.dart
View file @
a6e945fb
...
...
@@ -40,6 +40,7 @@ void main() {
expect
(
scheme
.
inverseSurface
,
scheme
.
onSurface
);
expect
(
scheme
.
onInverseSurface
,
scheme
.
surface
);
expect
(
scheme
.
inversePrimary
,
scheme
.
onPrimary
);
expect
(
scheme
.
surfaceTint
,
scheme
.
primary
);
expect
(
scheme
.
primaryVariant
,
const
Color
(
0xff3700b3
));
expect
(
scheme
.
secondaryVariant
,
const
Color
(
0xff018786
));
...
...
@@ -79,6 +80,7 @@ void main() {
expect
(
scheme
.
inverseSurface
,
scheme
.
onSurface
);
expect
(
scheme
.
onInverseSurface
,
scheme
.
surface
);
expect
(
scheme
.
inversePrimary
,
scheme
.
onPrimary
);
expect
(
scheme
.
surfaceTint
,
scheme
.
primary
);
expect
(
scheme
.
primaryVariant
,
const
Color
(
0xff3700b3
));
expect
(
scheme
.
secondaryVariant
,
const
Color
(
0xff03dac6
));
...
...
@@ -118,6 +120,7 @@ void main() {
expect
(
scheme
.
inverseSurface
,
scheme
.
onSurface
);
expect
(
scheme
.
onInverseSurface
,
scheme
.
surface
);
expect
(
scheme
.
inversePrimary
,
scheme
.
onPrimary
);
expect
(
scheme
.
surfaceTint
,
scheme
.
primary
);
expect
(
scheme
.
primaryVariant
,
const
Color
(
0xff000088
));
expect
(
scheme
.
secondaryVariant
,
const
Color
(
0xff018786
));
...
...
@@ -157,6 +160,7 @@ void main() {
expect
(
scheme
.
inverseSurface
,
scheme
.
onSurface
);
expect
(
scheme
.
onInverseSurface
,
scheme
.
surface
);
expect
(
scheme
.
inversePrimary
,
scheme
.
onPrimary
);
expect
(
scheme
.
surfaceTint
,
scheme
.
primary
);
expect
(
scheme
.
primaryVariant
,
const
Color
(
0xffbe9eff
));
expect
(
scheme
.
secondaryVariant
,
const
Color
(
0xff66fff9
));
...
...
@@ -191,6 +195,7 @@ void main() {
expect
(
scheme
.
onInverseSurface
,
const
Color
(
0xfff1f0f4
));
expect
(
scheme
.
inversePrimary
,
const
Color
(
0xff9ccaff
));
expect
(
scheme
.
shadow
,
const
Color
(
0xff000000
));
expect
(
scheme
.
surfaceTint
,
const
Color
(
0xff0061a6
));
expect
(
scheme
.
brightness
,
Brightness
.
light
);
});
...
...
@@ -223,6 +228,7 @@ void main() {
expect
(
scheme
.
onInverseSurface
,
const
Color
(
0xff2f3033
));
expect
(
scheme
.
inversePrimary
,
const
Color
(
0xff0061a6
));
expect
(
scheme
.
shadow
,
const
Color
(
0xff000000
));
expect
(
scheme
.
surfaceTint
,
const
Color
(
0xff9ccaff
));
expect
(
scheme
.
brightness
,
Brightness
.
dark
);
});
...
...
@@ -261,6 +267,7 @@ void main() {
expect
(
scheme
.
onInverseSurface
,
baseScheme
.
onInverseSurface
);
expect
(
scheme
.
inversePrimary
,
baseScheme
.
inversePrimary
);
expect
(
scheme
.
shadow
,
baseScheme
.
shadow
);
expect
(
scheme
.
surfaceTint
,
baseScheme
.
surfaceTint
);
expect
(
scheme
.
brightness
,
baseScheme
.
brightness
);
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment