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
b333fe2e
Unverified
Commit
b333fe2e
authored
Apr 28, 2022
by
Kate Lovett
Committed by
GitHub
Apr 28, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Fix `BottomNavigationBar` label style text colors" (#102756)
parent
9211d7cc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
28 deletions
+18
-28
bottom_navigation_bar.dart
packages/flutter/lib/src/material/bottom_navigation_bar.dart
+16
-22
bottom_navigation_bar_test.dart
...ges/flutter/test/material/bottom_navigation_bar_test.dart
+2
-6
No files found.
packages/flutter/lib/src/material/bottom_navigation_bar.dart
View file @
b333fe2e
...
@@ -138,7 +138,7 @@ class BottomNavigationBar extends StatefulWidget {
...
@@ -138,7 +138,7 @@ class BottomNavigationBar extends StatefulWidget {
///
///
/// If [selectedLabelStyle].color and [unselectedLabelStyle].color values
/// If [selectedLabelStyle].color and [unselectedLabelStyle].color values
/// are non-null, they will be used instead of [selectedItemColor] and
/// are non-null, they will be used instead of [selectedItemColor] and
/// [unselectedItemColor]
to style the label color
.
/// [unselectedItemColor].
///
///
/// If custom [IconThemeData]s are used, you must provide both
/// If custom [IconThemeData]s are used, you must provide both
/// [selectedIconTheme] and [unselectedIconTheme], and both
/// [selectedIconTheme] and [unselectedIconTheme], and both
...
@@ -384,7 +384,7 @@ class _BottomNavigationTile extends StatelessWidget {
...
@@ -384,7 +384,7 @@ class _BottomNavigationTile extends StatelessWidget {
this
.
animation
,
this
.
animation
,
this
.
iconSize
,
{
this
.
iconSize
,
{
this
.
onTap
,
this
.
onTap
,
this
.
itemC
olorTween
,
this
.
c
olorTween
,
this
.
flex
,
this
.
flex
,
this
.
selected
=
false
,
this
.
selected
=
false
,
required
this
.
selectedLabelStyle
,
required
this
.
selectedLabelStyle
,
...
@@ -410,7 +410,7 @@ class _BottomNavigationTile extends StatelessWidget {
...
@@ -410,7 +410,7 @@ class _BottomNavigationTile extends StatelessWidget {
final
Animation
<
double
>
animation
;
final
Animation
<
double
>
animation
;
final
double
iconSize
;
final
double
iconSize
;
final
VoidCallback
?
onTap
;
final
VoidCallback
?
onTap
;
final
ColorTween
?
itemC
olorTween
;
final
ColorTween
?
c
olorTween
;
final
double
?
flex
;
final
double
?
flex
;
final
bool
selected
;
final
bool
selected
;
final
IconThemeData
?
selectedIconTheme
;
final
IconThemeData
?
selectedIconTheme
;
...
@@ -513,7 +513,7 @@ class _BottomNavigationTile extends StatelessWidget {
...
@@ -513,7 +513,7 @@ class _BottomNavigationTile extends StatelessWidget {
child:
_Tile
(
child:
_Tile
(
layout:
layout
,
layout:
layout
,
icon:
_TileIcon
(
icon:
_TileIcon
(
itemColorTween:
itemC
olorTween
!,
colorTween:
c
olorTween
!,
animation:
animation
,
animation:
animation
,
iconSize:
iconSize
,
iconSize:
iconSize
,
selected:
selected
,
selected:
selected
,
...
@@ -522,7 +522,7 @@ class _BottomNavigationTile extends StatelessWidget {
...
@@ -522,7 +522,7 @@ class _BottomNavigationTile extends StatelessWidget {
unselectedIconTheme:
unselectedIconTheme
,
unselectedIconTheme:
unselectedIconTheme
,
),
),
label:
_Label
(
label:
_Label
(
itemColorTween:
itemC
olorTween
!,
colorTween:
c
olorTween
!,
animation:
animation
,
animation:
animation
,
item:
item
,
item:
item
,
selectedLabelStyle:
selectedLabelStyle
,
selectedLabelStyle:
selectedLabelStyle
,
...
@@ -602,7 +602,7 @@ class _Tile extends StatelessWidget {
...
@@ -602,7 +602,7 @@ class _Tile extends StatelessWidget {
class
_TileIcon
extends
StatelessWidget
{
class
_TileIcon
extends
StatelessWidget
{
const
_TileIcon
({
const
_TileIcon
({
required
this
.
itemC
olorTween
,
required
this
.
c
olorTween
,
required
this
.
animation
,
required
this
.
animation
,
required
this
.
iconSize
,
required
this
.
iconSize
,
required
this
.
selected
,
required
this
.
selected
,
...
@@ -612,7 +612,7 @@ class _TileIcon extends StatelessWidget {
...
@@ -612,7 +612,7 @@ class _TileIcon extends StatelessWidget {
})
:
assert
(
selected
!=
null
),
})
:
assert
(
selected
!=
null
),
assert
(
item
!=
null
);
assert
(
item
!=
null
);
final
ColorTween
itemC
olorTween
;
final
ColorTween
c
olorTween
;
final
Animation
<
double
>
animation
;
final
Animation
<
double
>
animation
;
final
double
iconSize
;
final
double
iconSize
;
final
bool
selected
;
final
bool
selected
;
...
@@ -622,7 +622,7 @@ class _TileIcon extends StatelessWidget {
...
@@ -622,7 +622,7 @@ class _TileIcon extends StatelessWidget {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
final
Color
?
iconColor
=
itemC
olorTween
.
evaluate
(
animation
);
final
Color
?
iconColor
=
c
olorTween
.
evaluate
(
animation
);
final
IconThemeData
defaultIconTheme
=
IconThemeData
(
final
IconThemeData
defaultIconTheme
=
IconThemeData
(
color:
iconColor
,
color:
iconColor
,
size:
iconSize
,
size:
iconSize
,
...
@@ -646,14 +646,14 @@ class _TileIcon extends StatelessWidget {
...
@@ -646,14 +646,14 @@ class _TileIcon extends StatelessWidget {
class
_Label
extends
StatelessWidget
{
class
_Label
extends
StatelessWidget
{
const
_Label
({
const
_Label
({
required
this
.
itemC
olorTween
,
required
this
.
c
olorTween
,
required
this
.
animation
,
required
this
.
animation
,
required
this
.
item
,
required
this
.
item
,
required
this
.
selectedLabelStyle
,
required
this
.
selectedLabelStyle
,
required
this
.
unselectedLabelStyle
,
required
this
.
unselectedLabelStyle
,
required
this
.
showSelectedLabels
,
required
this
.
showSelectedLabels
,
required
this
.
showUnselectedLabels
,
required
this
.
showUnselectedLabels
,
})
:
assert
(
itemC
olorTween
!=
null
),
})
:
assert
(
c
olorTween
!=
null
),
assert
(
animation
!=
null
),
assert
(
animation
!=
null
),
assert
(
item
!=
null
),
assert
(
item
!=
null
),
assert
(
selectedLabelStyle
!=
null
),
assert
(
selectedLabelStyle
!=
null
),
...
@@ -661,7 +661,7 @@ class _Label extends StatelessWidget {
...
@@ -661,7 +661,7 @@ class _Label extends StatelessWidget {
assert
(
showSelectedLabels
!=
null
),
assert
(
showSelectedLabels
!=
null
),
assert
(
showUnselectedLabels
!=
null
);
assert
(
showUnselectedLabels
!=
null
);
final
ColorTween
itemC
olorTween
;
final
ColorTween
c
olorTween
;
final
Animation
<
double
>
animation
;
final
Animation
<
double
>
animation
;
final
BottomNavigationBarItem
item
;
final
BottomNavigationBarItem
item
;
final
TextStyle
selectedLabelStyle
;
final
TextStyle
selectedLabelStyle
;
...
@@ -679,16 +679,10 @@ class _Label extends StatelessWidget {
...
@@ -679,16 +679,10 @@ class _Label extends StatelessWidget {
selectedLabelStyle
,
selectedLabelStyle
,
animation
.
value
,
animation
.
value
,
)!;
)!;
final
ColorTween
labelColor
=
ColorTween
(
begin:
unselectedLabelStyle
.
color
??
itemColorTween
.
begin
,
end:
selectedLabelStyle
.
color
??
itemColorTween
.
end
,
);
Widget
text
=
DefaultTextStyle
.
merge
(
Widget
text
=
DefaultTextStyle
.
merge
(
style:
customStyle
.
copyWith
(
style:
customStyle
.
copyWith
(
fontSize:
selectedFontSize
,
fontSize:
selectedFontSize
,
color:
labelColor
.
evaluate
(
animation
),
color:
colorTween
.
evaluate
(
animation
),
),
),
// The font size should grow here when active, but because of the way
// The font size should grow here when active, but because of the way
// font rendering works, it doesn't grow smoothly if we just animate
// font rendering works, it doesn't grow smoothly if we just animate
...
@@ -929,10 +923,10 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
...
@@ -929,10 +923,10 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
break
;
break
;
}
}
final
ColorTween
itemC
olorTween
;
final
ColorTween
c
olorTween
;
switch
(
_effectiveType
)
{
switch
(
_effectiveType
)
{
case
BottomNavigationBarType
.
fixed
:
case
BottomNavigationBarType
.
fixed
:
itemC
olorTween
=
ColorTween
(
c
olorTween
=
ColorTween
(
begin:
widget
.
unselectedItemColor
begin:
widget
.
unselectedItemColor
??
bottomTheme
.
unselectedItemColor
??
bottomTheme
.
unselectedItemColor
??
themeData
.
unselectedWidgetColor
,
??
themeData
.
unselectedWidgetColor
,
...
@@ -943,7 +937,7 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
...
@@ -943,7 +937,7 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
);
);
break
;
break
;
case
BottomNavigationBarType
.
shifting
:
case
BottomNavigationBarType
.
shifting
:
itemC
olorTween
=
ColorTween
(
c
olorTween
=
ColorTween
(
begin:
widget
.
unselectedItemColor
begin:
widget
.
unselectedItemColor
??
bottomTheme
.
unselectedItemColor
??
bottomTheme
.
unselectedItemColor
??
themeData
.
colorScheme
.
surface
,
??
themeData
.
colorScheme
.
surface
,
...
@@ -977,7 +971,7 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
...
@@ -977,7 +971,7 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
onTap:
()
{
onTap:
()
{
widget
.
onTap
?.
call
(
i
);
widget
.
onTap
?.
call
(
i
);
},
},
itemColorTween:
itemC
olorTween
,
colorTween:
c
olorTween
,
flex:
_evaluateFlex
(
_animations
[
i
]),
flex:
_evaluateFlex
(
_animations
[
i
]),
selected:
i
==
widget
.
currentIndex
,
selected:
i
==
widget
.
currentIndex
,
showSelectedLabels:
widget
.
showSelectedLabels
??
bottomTheme
.
showSelectedLabels
??
true
,
showSelectedLabels:
widget
.
showSelectedLabels
??
bottomTheme
.
showSelectedLabels
??
true
,
...
...
packages/flutter/test/material/bottom_navigation_bar_test.dart
View file @
b333fe2e
...
@@ -140,10 +140,8 @@ void main() {
...
@@ -140,10 +140,8 @@ void main() {
});
});
testWidgets
(
'Custom selected and unselected font styles'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Custom selected and unselected font styles'
,
(
WidgetTester
tester
)
async
{
const
Color
selectedTextColor
=
Color
(
0xff00ff00
);
const
TextStyle
selectedTextStyle
=
TextStyle
(
fontWeight:
FontWeight
.
w200
,
fontSize:
18.0
);
const
Color
unselectedTextColor
=
Color
(
0xff0000ff
);
const
TextStyle
unselectedTextStyle
=
TextStyle
(
fontWeight:
FontWeight
.
w600
,
fontSize:
12.0
);
const
TextStyle
selectedTextStyle
=
TextStyle
(
color:
selectedTextColor
,
fontWeight:
FontWeight
.
w200
,
fontSize:
18.0
);
const
TextStyle
unselectedTextStyle
=
TextStyle
(
color:
unselectedTextColor
,
fontWeight:
FontWeight
.
w600
,
fontSize:
12.0
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
...
@@ -169,10 +167,8 @@ void main() {
...
@@ -169,10 +167,8 @@ void main() {
final
TextStyle
selectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
!;
final
TextStyle
selectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
!;
final
TextStyle
unselectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'Alarm'
)).
text
.
style
!;
final
TextStyle
unselectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'Alarm'
)).
text
.
style
!;
expect
(
selectedFontStyle
.
color
,
equals
(
selectedTextColor
));
expect
(
selectedFontStyle
.
fontSize
,
equals
(
selectedTextStyle
.
fontSize
));
expect
(
selectedFontStyle
.
fontSize
,
equals
(
selectedTextStyle
.
fontSize
));
expect
(
selectedFontStyle
.
fontWeight
,
equals
(
selectedTextStyle
.
fontWeight
));
expect
(
selectedFontStyle
.
fontWeight
,
equals
(
selectedTextStyle
.
fontWeight
));
expect
(
unselectedFontStyle
.
color
,
equals
(
unselectedTextColor
));
expect
(
expect
(
tester
.
firstWidget
<
Transform
>(
find
.
ancestor
(
of:
find
.
text
(
'Alarm'
),
matching:
find
.
byType
(
Transform
))).
transform
,
tester
.
firstWidget
<
Transform
>(
find
.
ancestor
(
of:
find
.
text
(
'Alarm'
),
matching:
find
.
byType
(
Transform
))).
transform
,
equals
(
Matrix4
.
diagonal3
(
Vector3
.
all
(
unselectedTextStyle
.
fontSize
!
/
selectedTextStyle
.
fontSize
!))),
equals
(
Matrix4
.
diagonal3
(
Vector3
.
all
(
unselectedTextStyle
.
fontSize
!
/
selectedTextStyle
.
fontSize
!))),
...
...
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