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
709b26d0
Unverified
Commit
709b26d0
authored
Apr 29, 2022
by
Taha Tesser
Committed by
GitHub
Apr 29, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `surfaceTintColor` to `NavigationBar` (#102628)
parent
4ffc41ad
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
13 deletions
+33
-13
navigation_bar_template.dart
dev/tools/gen_defaults/lib/navigation_bar_template.dart
+3
-5
navigation_bar.dart
packages/flutter/lib/src/material/navigation_bar.dart
+17
-7
navigation_bar_theme.dart
packages/flutter/lib/src/material/navigation_bar_theme.dart
+10
-0
navigation_bar_test.dart
packages/flutter/test/material/navigation_bar_test.dart
+3
-1
No files found.
dev/tools/gen_defaults/lib/navigation_bar_template.dart
View file @
709b26d0
...
@@ -25,11 +25,9 @@ class _TokenDefaultsM3 extends NavigationBarThemeData {
...
@@ -25,11 +25,9 @@ class _TokenDefaultsM3 extends NavigationBarThemeData {
late final ColorScheme _colors = Theme.of(context).colorScheme;
late final ColorScheme _colors = Theme.of(context).colorScheme;
late final TextTheme _textTheme = Theme.of(context).textTheme;
late final TextTheme _textTheme = Theme.of(context).textTheme;
// With Material 3, the NavigationBar uses an overlay blend for the
@override Color? get backgroundColor =>
${componentColor("md.comp.navigation-bar.container")}
;
// default color regardless of light/dark mode. This should be handled
// in the Material widget based off of elevation, but for now we will do
@override Color? get surfaceTintColor =>
${color("md.comp.navigation-bar.container.surface-tint-layer.color")}
;
// it here in the defaults.
@override Color? get backgroundColor => ElevationOverlay.colorWithOverlay(
${componentColor("md.comp.navigation-bar.container")}
, _colors.primary,
${elevation("md.comp.navigation-bar.container")}
);
@override MaterialStateProperty<IconThemeData?>? get iconTheme {
@override MaterialStateProperty<IconThemeData?>? get iconTheme {
return MaterialStateProperty.resolveWith((Set<MaterialState> states) {
return MaterialStateProperty.resolveWith((Set<MaterialState> states) {
...
...
packages/flutter/lib/src/material/navigation_bar.dart
View file @
709b26d0
...
@@ -59,6 +59,7 @@ class NavigationBar extends StatelessWidget {
...
@@ -59,6 +59,7 @@ class NavigationBar extends StatelessWidget {
required
this
.
destinations
,
required
this
.
destinations
,
this
.
onDestinationSelected
,
this
.
onDestinationSelected
,
this
.
backgroundColor
,
this
.
backgroundColor
,
this
.
surfaceTintColor
,
this
.
elevation
,
this
.
elevation
,
this
.
height
,
this
.
height
,
this
.
labelBehavior
,
this
.
labelBehavior
,
...
@@ -95,10 +96,20 @@ class NavigationBar extends StatelessWidget {
...
@@ -95,10 +96,20 @@ class NavigationBar extends StatelessWidget {
/// The color of the [NavigationBar] itself.
/// The color of the [NavigationBar] itself.
///
///
/// If null, [NavigationBarThemeData.backgroundColor] is used. If that
/// If null, [NavigationBarThemeData.backgroundColor] is used. If that
/// is also null, the default blends [ColorScheme.surface] and
/// is also null, then if [ThemeData.useMaterial3] is true, the value is
/// [ColorScheme.onSurface] using an [ElevationOverlay].
/// [ColorScheme.surface]. If that is false, the default blends [ColorScheme.surface]
/// and [ColorScheme.onSurface] using an [ElevationOverlay].
final
Color
?
backgroundColor
;
final
Color
?
backgroundColor
;
/// The color used as an overlay on [backgroundColor] to indicate elevation.
///
/// If null, [NavigationBarThemeData.surfaceTintColor] is used. If that
/// is also null, the default value is [ColorScheme.surfaceTint].
///
/// See [Material.surfaceTintColor] for more details on how this
/// overlay is applied.
final
Color
?
surfaceTintColor
;
/// The elevation of the [NavigationBar] itself.
/// The elevation of the [NavigationBar] itself.
///
///
/// If null, [NavigationBarThemeData.elevation] is used. If that
/// If null, [NavigationBarThemeData.elevation] is used. If that
...
@@ -152,6 +163,7 @@ class NavigationBar extends StatelessWidget {
...
@@ -152,6 +163,7 @@ class NavigationBar extends StatelessWidget {
color:
backgroundColor
color:
backgroundColor
??
navigationBarTheme
.
backgroundColor
??
navigationBarTheme
.
backgroundColor
??
defaults
.
backgroundColor
!,
??
defaults
.
backgroundColor
!,
surfaceTintColor:
surfaceTintColor
??
navigationBarTheme
.
surfaceTintColor
??
defaults
.
surfaceTintColor
,
elevation:
elevation
??
navigationBarTheme
.
elevation
??
defaults
.
elevation
!,
elevation:
elevation
??
navigationBarTheme
.
elevation
??
defaults
.
elevation
!,
child:
SafeArea
(
child:
SafeArea
(
child:
SizedBox
(
child:
SizedBox
(
...
@@ -1214,11 +1226,9 @@ class _TokenDefaultsM3 extends NavigationBarThemeData {
...
@@ -1214,11 +1226,9 @@ class _TokenDefaultsM3 extends NavigationBarThemeData {
late
final
ColorScheme
_colors
=
Theme
.
of
(
context
).
colorScheme
;
late
final
ColorScheme
_colors
=
Theme
.
of
(
context
).
colorScheme
;
late
final
TextTheme
_textTheme
=
Theme
.
of
(
context
).
textTheme
;
late
final
TextTheme
_textTheme
=
Theme
.
of
(
context
).
textTheme
;
// With Material 3, the NavigationBar uses an overlay blend for the
@override
Color
?
get
backgroundColor
=>
_colors
.
surface
;
// default color regardless of light/dark mode. This should be handled
// in the Material widget based off of elevation, but for now we will do
@override
Color
?
get
surfaceTintColor
=>
_colors
.
surfaceTint
;
// it here in the defaults.
@override
Color
?
get
backgroundColor
=>
ElevationOverlay
.
colorWithOverlay
(
_colors
.
surface
,
_colors
.
primary
,
3.0
);
@override
MaterialStateProperty
<
IconThemeData
?>?
get
iconTheme
{
@override
MaterialStateProperty
<
IconThemeData
?>?
get
iconTheme
{
return
MaterialStateProperty
.
resolveWith
((
Set
<
MaterialState
>
states
)
{
return
MaterialStateProperty
.
resolveWith
((
Set
<
MaterialState
>
states
)
{
...
...
packages/flutter/lib/src/material/navigation_bar_theme.dart
View file @
709b26d0
...
@@ -41,6 +41,7 @@ class NavigationBarThemeData with Diagnosticable {
...
@@ -41,6 +41,7 @@ class NavigationBarThemeData with Diagnosticable {
const
NavigationBarThemeData
({
const
NavigationBarThemeData
({
this
.
height
,
this
.
height
,
this
.
backgroundColor
,
this
.
backgroundColor
,
this
.
surfaceTintColor
,
this
.
elevation
,
this
.
elevation
,
this
.
indicatorColor
,
this
.
indicatorColor
,
this
.
indicatorShape
,
this
.
indicatorShape
,
...
@@ -55,6 +56,9 @@ class NavigationBarThemeData with Diagnosticable {
...
@@ -55,6 +56,9 @@ class NavigationBarThemeData with Diagnosticable {
/// Overrides the default value of [NavigationBar.backgroundColor].
/// Overrides the default value of [NavigationBar.backgroundColor].
final
Color
?
backgroundColor
;
final
Color
?
backgroundColor
;
/// Overrides the default value of [NavigationBar.surfaceTintColor].
final
Color
?
surfaceTintColor
;
/// Overrides the default value of [NavigationBar.elevation].
/// Overrides the default value of [NavigationBar.elevation].
final
double
?
elevation
;
final
double
?
elevation
;
...
@@ -85,6 +89,7 @@ class NavigationBarThemeData with Diagnosticable {
...
@@ -85,6 +89,7 @@ class NavigationBarThemeData with Diagnosticable {
NavigationBarThemeData
copyWith
({
NavigationBarThemeData
copyWith
({
double
?
height
,
double
?
height
,
Color
?
backgroundColor
,
Color
?
backgroundColor
,
Color
?
surfaceTintColor
,
double
?
elevation
,
double
?
elevation
,
Color
?
indicatorColor
,
Color
?
indicatorColor
,
ShapeBorder
?
indicatorShape
,
ShapeBorder
?
indicatorShape
,
...
@@ -95,6 +100,7 @@ class NavigationBarThemeData with Diagnosticable {
...
@@ -95,6 +100,7 @@ class NavigationBarThemeData with Diagnosticable {
return
NavigationBarThemeData
(
return
NavigationBarThemeData
(
height:
height
??
this
.
height
,
height:
height
??
this
.
height
,
backgroundColor:
backgroundColor
??
this
.
backgroundColor
,
backgroundColor:
backgroundColor
??
this
.
backgroundColor
,
surfaceTintColor:
surfaceTintColor
??
this
.
surfaceTintColor
,
elevation:
elevation
??
this
.
elevation
,
elevation:
elevation
??
this
.
elevation
,
indicatorColor:
indicatorColor
??
this
.
indicatorColor
,
indicatorColor:
indicatorColor
??
this
.
indicatorColor
,
indicatorShape:
indicatorShape
??
this
.
indicatorShape
,
indicatorShape:
indicatorShape
??
this
.
indicatorShape
,
...
@@ -116,6 +122,7 @@ class NavigationBarThemeData with Diagnosticable {
...
@@ -116,6 +122,7 @@ class NavigationBarThemeData with Diagnosticable {
return
NavigationBarThemeData
(
return
NavigationBarThemeData
(
height:
lerpDouble
(
a
?.
height
,
b
?.
height
,
t
),
height:
lerpDouble
(
a
?.
height
,
b
?.
height
,
t
),
backgroundColor:
Color
.
lerp
(
a
?.
backgroundColor
,
b
?.
backgroundColor
,
t
),
backgroundColor:
Color
.
lerp
(
a
?.
backgroundColor
,
b
?.
backgroundColor
,
t
),
surfaceTintColor:
Color
.
lerp
(
a
?.
surfaceTintColor
,
b
?.
surfaceTintColor
,
t
),
elevation:
lerpDouble
(
a
?.
elevation
,
b
?.
elevation
,
t
),
elevation:
lerpDouble
(
a
?.
elevation
,
b
?.
elevation
,
t
),
indicatorColor:
Color
.
lerp
(
a
?.
indicatorColor
,
b
?.
indicatorColor
,
t
),
indicatorColor:
Color
.
lerp
(
a
?.
indicatorColor
,
b
?.
indicatorColor
,
t
),
indicatorShape:
ShapeBorder
.
lerp
(
a
?.
indicatorShape
,
b
?.
indicatorShape
,
t
),
indicatorShape:
ShapeBorder
.
lerp
(
a
?.
indicatorShape
,
b
?.
indicatorShape
,
t
),
...
@@ -129,6 +136,7 @@ class NavigationBarThemeData with Diagnosticable {
...
@@ -129,6 +136,7 @@ class NavigationBarThemeData with Diagnosticable {
int
get
hashCode
=>
Object
.
hash
(
int
get
hashCode
=>
Object
.
hash
(
height
,
height
,
backgroundColor
,
backgroundColor
,
surfaceTintColor
,
elevation
,
elevation
,
indicatorColor
,
indicatorColor
,
indicatorShape
,
indicatorShape
,
...
@@ -146,6 +154,7 @@ class NavigationBarThemeData with Diagnosticable {
...
@@ -146,6 +154,7 @@ class NavigationBarThemeData with Diagnosticable {
return
other
is
NavigationBarThemeData
return
other
is
NavigationBarThemeData
&&
other
.
height
==
height
&&
other
.
height
==
height
&&
other
.
backgroundColor
==
backgroundColor
&&
other
.
backgroundColor
==
backgroundColor
&&
other
.
surfaceTintColor
==
surfaceTintColor
&&
other
.
elevation
==
elevation
&&
other
.
elevation
==
elevation
&&
other
.
indicatorColor
==
indicatorColor
&&
other
.
indicatorColor
==
indicatorColor
&&
other
.
indicatorShape
==
indicatorShape
&&
other
.
indicatorShape
==
indicatorShape
...
@@ -159,6 +168,7 @@ class NavigationBarThemeData with Diagnosticable {
...
@@ -159,6 +168,7 @@ class NavigationBarThemeData with Diagnosticable {
super
.
debugFillProperties
(
properties
);
super
.
debugFillProperties
(
properties
);
properties
.
add
(
DoubleProperty
(
'height'
,
height
,
defaultValue:
null
));
properties
.
add
(
DoubleProperty
(
'height'
,
height
,
defaultValue:
null
));
properties
.
add
(
ColorProperty
(
'backgroundColor'
,
backgroundColor
,
defaultValue:
null
));
properties
.
add
(
ColorProperty
(
'backgroundColor'
,
backgroundColor
,
defaultValue:
null
));
properties
.
add
(
ColorProperty
(
'surfaceTintColor'
,
surfaceTintColor
,
defaultValue:
null
));
properties
.
add
(
DoubleProperty
(
'elevation'
,
elevation
,
defaultValue:
null
));
properties
.
add
(
DoubleProperty
(
'elevation'
,
elevation
,
defaultValue:
null
));
properties
.
add
(
ColorProperty
(
'indicatorColor'
,
indicatorColor
,
defaultValue:
null
));
properties
.
add
(
ColorProperty
(
'indicatorColor'
,
indicatorColor
,
defaultValue:
null
));
properties
.
add
(
DiagnosticsProperty
<
ShapeBorder
>(
'indicatorShape'
,
indicatorShape
,
defaultValue:
null
));
properties
.
add
(
DiagnosticsProperty
<
ShapeBorder
>(
'indicatorShape'
,
indicatorShape
,
defaultValue:
null
));
...
...
packages/flutter/test/material/navigation_bar_test.dart
View file @
709b26d0
...
@@ -257,6 +257,7 @@ void main() {
...
@@ -257,6 +257,7 @@ void main() {
);
);
expect
(
_getMaterial
(
tester
).
color
,
const
Color
(
0xffeaeaea
));
expect
(
_getMaterial
(
tester
).
color
,
const
Color
(
0xffeaeaea
));
expect
(
_getMaterial
(
tester
).
surfaceTintColor
,
null
);
expect
(
_getMaterial
(
tester
).
elevation
,
0
);
expect
(
_getMaterial
(
tester
).
elevation
,
0
);
expect
(
tester
.
getSize
(
find
.
byType
(
NavigationBar
)).
height
,
80
);
expect
(
tester
.
getSize
(
find
.
byType
(
NavigationBar
)).
height
,
80
);
expect
(
_indicator
(
tester
)?.
color
,
const
Color
(
0x3d2196f3
));
expect
(
_indicator
(
tester
)?.
color
,
const
Color
(
0x3d2196f3
));
...
@@ -284,7 +285,8 @@ void main() {
...
@@ -284,7 +285,8 @@ void main() {
),
),
);
);
expect
(
_getMaterial
(
tester
).
color
,
const
Color
(
0xffecf6fe
));
expect
(
_getMaterial
(
tester
).
color
,
ThemeData
().
colorScheme
.
surface
);
expect
(
_getMaterial
(
tester
).
surfaceTintColor
,
ThemeData
().
colorScheme
.
surfaceTint
);
expect
(
_getMaterial
(
tester
).
elevation
,
3
);
expect
(
_getMaterial
(
tester
).
elevation
,
3
);
expect
(
tester
.
getSize
(
find
.
byType
(
NavigationBar
)).
height
,
80
);
expect
(
tester
.
getSize
(
find
.
byType
(
NavigationBar
)).
height
,
80
);
expect
(
_indicator
(
tester
)?.
color
,
const
Color
(
0xff2196f3
));
expect
(
_indicator
(
tester
)?.
color
,
const
Color
(
0xff2196f3
));
...
...
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