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
47f56712
Unverified
Commit
47f56712
authored
Mar 12, 2019
by
Hans Muller
Committed by
GitHub
Mar 12, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure that animated pairs of Tabs TextStyles have matching inherited values (#29175)
parent
854d8bb0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
6 deletions
+37
-6
tabs.dart
packages/flutter/lib/src/material/tabs.dart
+11
-4
text_style.dart
packages/flutter/lib/src/painting/text_style.dart
+2
-1
tab_bar_theme_test.dart
packages/flutter/test/material/tab_bar_theme_test.dart
+17
-0
theme_test.dart
packages/flutter/test/material/theme_test.dart
+1
-1
text_style_test.dart
packages/flutter/test/painting/text_style_test.dart
+6
-0
No files found.
packages/flutter/lib/src/material/tabs.dart
View file @
47f56712
...
@@ -153,16 +153,23 @@ class _TabStyle extends AnimatedWidget {
...
@@ -153,16 +153,23 @@ class _TabStyle extends AnimatedWidget {
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
final
ThemeData
themeData
=
Theme
.
of
(
context
);
final
ThemeData
themeData
=
Theme
.
of
(
context
);
final
TabBarTheme
tabBarTheme
=
TabBarTheme
.
of
(
context
);
final
TabBarTheme
tabBarTheme
=
TabBarTheme
.
of
(
context
);
final
Animation
<
double
>
animation
=
listenable
;
final
TextStyle
defaultStyle
=
labelStyle
??
tabBarTheme
.
labelStyle
??
themeData
.
primaryTextTheme
.
body2
;
// To enable TextStyle.lerp(style1, style2, value), both styles must have
final
TextStyle
defaultUnselectedStyle
=
unselectedLabelStyle
// the same value of inherit. Force that to be inherit=true here.
final
TextStyle
defaultStyle
=
(
labelStyle
??
tabBarTheme
.
labelStyle
??
themeData
.
primaryTextTheme
.
body2
).
copyWith
(
inherit:
true
);
final
TextStyle
defaultUnselectedStyle
=
(
unselectedLabelStyle
??
tabBarTheme
.
unselectedLabelStyle
??
tabBarTheme
.
unselectedLabelStyle
??
labelStyle
??
labelStyle
??
themeData
.
primaryTextTheme
.
body2
;
??
themeData
.
primaryTextTheme
.
body2
final
Animation
<
double
>
animation
=
listenable
;
).
copyWith
(
inherit:
true
)
;
final
TextStyle
textStyle
=
selected
final
TextStyle
textStyle
=
selected
?
TextStyle
.
lerp
(
defaultStyle
,
defaultUnselectedStyle
,
animation
.
value
)
?
TextStyle
.
lerp
(
defaultStyle
,
defaultUnselectedStyle
,
animation
.
value
)
:
TextStyle
.
lerp
(
defaultUnselectedStyle
,
defaultStyle
,
animation
.
value
);
:
TextStyle
.
lerp
(
defaultUnselectedStyle
,
defaultStyle
,
animation
.
value
);
final
Color
selectedColor
=
labelColor
final
Color
selectedColor
=
labelColor
??
tabBarTheme
.
labelColor
??
tabBarTheme
.
labelColor
??
themeData
.
primaryTextTheme
.
body2
.
color
;
??
themeData
.
primaryTextTheme
.
body2
.
color
;
...
...
packages/flutter/lib/src/painting/text_style.dart
View file @
47f56712
...
@@ -522,6 +522,7 @@ class TextStyle extends Diagnosticable {
...
@@ -522,6 +522,7 @@ class TextStyle extends Diagnosticable {
/// [background] specified it will be given preference over any
/// [background] specified it will be given preference over any
/// backgroundColor parameter.
/// backgroundColor parameter.
TextStyle
copyWith
({
TextStyle
copyWith
({
bool
inherit
,
Color
color
,
Color
color
,
Color
backgroundColor
,
Color
backgroundColor
,
String
fontFamily
,
String
fontFamily
,
...
@@ -551,7 +552,7 @@ class TextStyle extends Diagnosticable {
...
@@ -551,7 +552,7 @@ class TextStyle extends Diagnosticable {
return
true
;
return
true
;
}());
}());
return
TextStyle
(
return
TextStyle
(
inherit:
inherit
,
inherit:
inherit
??
this
.
inherit
,
color:
this
.
foreground
==
null
&&
foreground
==
null
?
color
??
this
.
color
:
null
,
color:
this
.
foreground
==
null
&&
foreground
==
null
?
color
??
this
.
color
:
null
,
backgroundColor:
this
.
background
==
null
&&
background
==
null
?
backgroundColor
??
this
.
backgroundColor
:
null
,
backgroundColor:
this
.
background
==
null
&&
background
==
null
?
backgroundColor
??
this
.
backgroundColor
:
null
,
fontFamily:
fontFamily
??
this
.
fontFamily
,
fontFamily:
fontFamily
??
this
.
fontFamily
,
...
...
packages/flutter/test/material/tab_bar_theme_test.dart
View file @
47f56712
...
@@ -82,6 +82,23 @@ void main() {
...
@@ -82,6 +82,23 @@ void main() {
expect
(
unselectedRenderObject
.
text
.
style
.
fontFamily
,
equals
(
unselectedLabelStyle
.
fontFamily
));
expect
(
unselectedRenderObject
.
text
.
style
.
fontFamily
,
equals
(
unselectedLabelStyle
.
fontFamily
));
});
});
testWidgets
(
'Tab bar theme with just label style specified'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/28784
const
TextStyle
labelStyle
=
TextStyle
(
fontFamily:
'foobar'
);
const
TabBarTheme
tabBarTheme
=
TabBarTheme
(
labelStyle:
labelStyle
,
);
await
tester
.
pumpWidget
(
_withTheme
(
tabBarTheme
));
final
RenderParagraph
selectedRenderObject
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
_tab1Text
));
expect
(
selectedRenderObject
.
text
.
style
.
fontFamily
,
equals
(
labelStyle
.
fontFamily
));
final
RenderParagraph
unselectedRenderObject
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
_tab2Text
));
expect
(
unselectedRenderObject
.
text
.
style
.
fontFamily
,
equals
(
'Roboto'
));
expect
(
unselectedRenderObject
.
text
.
style
.
fontSize
,
equals
(
14.0
));
expect
(
unselectedRenderObject
.
text
.
style
.
color
,
equals
(
Colors
.
white
.
withAlpha
(
0xB2
)));
});
testWidgets
(
'Tab bar label styles override theme label styles'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Tab bar label styles override theme label styles'
,
(
WidgetTester
tester
)
async
{
const
TextStyle
labelStyle
=
TextStyle
(
fontFamily:
'1'
);
const
TextStyle
labelStyle
=
TextStyle
(
fontFamily:
'1'
);
const
TextStyle
unselectedLabelStyle
=
TextStyle
(
fontFamily:
'2'
);
const
TextStyle
unselectedLabelStyle
=
TextStyle
(
fontFamily:
'2'
);
...
...
packages/flutter/test/material/theme_test.dart
View file @
47f56712
...
@@ -731,7 +731,7 @@ class _TextStyleProxy implements TextStyle {
...
@@ -731,7 +731,7 @@ class _TextStyleProxy implements TextStyle {
}
}
@override
@override
TextStyle
copyWith
({
Color
color
,
Color
backgroundColor
,
String
fontFamily
,
List
<
String
>
fontFamilyFallback
,
double
fontSize
,
FontWeight
fontWeight
,
FontStyle
fontStyle
,
double
letterSpacing
,
double
wordSpacing
,
TextBaseline
textBaseline
,
double
height
,
Locale
locale
,
ui
.
Paint
foreground
,
ui
.
Paint
background
,
List
<
Shadow
>
shadows
,
TextDecoration
decoration
,
Color
decorationColor
,
TextDecorationStyle
decorationStyle
,
String
debugLabel
})
{
TextStyle
copyWith
({
bool
inherit
,
Color
color
,
Color
backgroundColor
,
String
fontFamily
,
List
<
String
>
fontFamilyFallback
,
double
fontSize
,
FontWeight
fontWeight
,
FontStyle
fontStyle
,
double
letterSpacing
,
double
wordSpacing
,
TextBaseline
textBaseline
,
double
height
,
Locale
locale
,
ui
.
Paint
foreground
,
ui
.
Paint
background
,
List
<
Shadow
>
shadows
,
TextDecoration
decoration
,
Color
decorationColor
,
TextDecorationStyle
decorationStyle
,
String
debugLabel
})
{
throw
UnimplementedError
();
throw
UnimplementedError
();
}
}
...
...
packages/flutter/test/painting/text_style_test.dart
View file @
47f56712
...
@@ -33,6 +33,12 @@ void main() {
...
@@ -33,6 +33,12 @@ void main() {
equals
(
'TextStyle(inherit: true, size: 10.0, weight: 800, height: 123.0x)'
),
equals
(
'TextStyle(inherit: true, size: 10.0, weight: 800, height: 123.0x)'
),
);
);
// Check that the inherit flag can be set with copyWith().
expect
(
s1
.
copyWith
(
inherit:
false
).
toString
(),
equals
(
'TextStyle(inherit: false, size: 10.0, weight: 800, height: 123.0x)'
),
);
final
TextStyle
s2
=
s1
.
copyWith
(
color:
const
Color
(
0xFF00FF00
),
height:
100.0
);
final
TextStyle
s2
=
s1
.
copyWith
(
color:
const
Color
(
0xFF00FF00
),
height:
100.0
);
expect
(
s1
.
fontFamily
,
isNull
);
expect
(
s1
.
fontFamily
,
isNull
);
expect
(
s1
.
fontSize
,
10.0
);
expect
(
s1
.
fontSize
,
10.0
);
...
...
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