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
b96ae03b
Unverified
Commit
b96ae03b
authored
Feb 21, 2019
by
Michael Goderbauer
Committed by
GitHub
Feb 21, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add backgroundColor argument to TextStyle for convenience (#28172)
parent
6f5e88a5
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
128 additions
and
9 deletions
+128
-9
text_style.dart
packages/flutter/lib/src/painting/text_style.dart
+71
-7
theme_test.dart
packages/flutter/test/material/theme_test.dart
+3
-2
text_style_test.dart
packages/flutter/test/painting/text_style_test.dart
+54
-0
No files found.
packages/flutter/lib/src/painting/text_style.dart
View file @
b96ae03b
This diff is collapsed.
Click to expand it.
packages/flutter/test/material/theme_test.dart
View file @
b96ae03b
...
...
@@ -666,6 +666,7 @@ class _TextStyleProxy implements TextStyle {
// Do make sure that all the properties correctly forward to the _delegate.
@override
Color
get
color
=>
_delegate
.
color
;
@override
Color
get
backgroundColor
=>
_delegate
.
backgroundColor
;
@override
String
get
debugLabel
=>
_delegate
.
debugLabel
;
@override
TextDecoration
get
decoration
=>
_delegate
.
decoration
;
@override
Color
get
decorationColor
=>
_delegate
.
decorationColor
;
...
...
@@ -700,7 +701,7 @@ class _TextStyleProxy implements TextStyle {
}
@override
TextStyle
apply
({
Color
color
,
TextDecoration
decoration
,
Color
decorationColor
,
TextDecorationStyle
decorationStyle
,
String
fontFamily
,
List
<
String
>
fontFamilyFallback
,
double
fontSizeFactor
=
1.0
,
double
fontSizeDelta
=
0.0
,
int
fontWeightDelta
=
0
,
double
letterSpacingFactor
=
1.0
,
double
letterSpacingDelta
=
0.0
,
double
wordSpacingFactor
=
1.0
,
double
wordSpacingDelta
=
0.0
,
double
heightFactor
=
1.0
,
double
heightDelta
=
0.0
})
{
TextStyle
apply
({
Color
color
,
Color
backgroundColor
,
TextDecoration
decoration
,
Color
decorationColor
,
TextDecorationStyle
decorationStyle
,
String
fontFamily
,
List
<
String
>
fontFamilyFallback
,
double
fontSizeFactor
=
1.0
,
double
fontSizeDelta
=
0.0
,
int
fontWeightDelta
=
0
,
double
letterSpacingFactor
=
1.0
,
double
letterSpacingDelta
=
0.0
,
double
wordSpacingFactor
=
1.0
,
double
wordSpacingDelta
=
0.0
,
double
heightFactor
=
1.0
,
double
heightDelta
=
0.0
})
{
throw
UnimplementedError
();
}
...
...
@@ -710,7 +711,7 @@ class _TextStyleProxy implements TextStyle {
}
@override
TextStyle
copyWith
({
Color
color
,
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
({
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
();
}
...
...
packages/flutter/test/painting/text_style_test.dart
View file @
b96ae03b
...
...
@@ -294,4 +294,58 @@ void main() {
expect
(
TextStyle
.
lerp
(
redPaintTextStyle
,
bluePaintTextStyle
,
.
25
).
foreground
.
color
,
red
);
expect
(
TextStyle
.
lerp
(
redPaintTextStyle
,
bluePaintTextStyle
,
.
75
).
foreground
.
color
,
blue
);
});
test
(
'backgroundColor'
,
()
{
const
TextStyle
s1
=
TextStyle
();
expect
(
s1
.
backgroundColor
,
isNull
);
expect
(
s1
.
toString
(),
'TextStyle(<all styles inherited>)'
);
const
TextStyle
s2
=
TextStyle
(
backgroundColor:
Color
(
0xFF00FF00
));
expect
(
s2
.
backgroundColor
,
const
Color
(
0xFF00FF00
));
expect
(
s2
.
toString
(),
'TextStyle(inherit: true, backgroundColor: Color(0xff00ff00))'
);
final
ui
.
TextStyle
ts2
=
s2
.
getTextStyle
();
expect
(
ts2
.
toString
(),
contains
(
'background: Paint(Color(0xff00ff00))'
));
});
test
(
'TextStyle background and backgroundColor combos'
,
()
{
const
Color
red
=
Color
.
fromARGB
(
255
,
255
,
0
,
0
);
const
Color
blue
=
Color
.
fromARGB
(
255
,
0
,
0
,
255
);
const
TextStyle
redTextStyle
=
TextStyle
(
backgroundColor:
red
);
const
TextStyle
blueTextStyle
=
TextStyle
(
backgroundColor:
blue
);
final
TextStyle
redPaintTextStyle
=
TextStyle
(
background:
Paint
()..
color
=
red
);
final
TextStyle
bluePaintTextStyle
=
TextStyle
(
background:
Paint
()..
color
=
blue
);
// merge/copyWith
final
TextStyle
redBlueBothForegroundMerged
=
redTextStyle
.
merge
(
blueTextStyle
);
expect
(
redBlueBothForegroundMerged
.
backgroundColor
,
blue
);
expect
(
redBlueBothForegroundMerged
.
foreground
,
isNull
);
final
TextStyle
redBlueBothPaintMerged
=
redPaintTextStyle
.
merge
(
bluePaintTextStyle
);
expect
(
redBlueBothPaintMerged
.
backgroundColor
,
null
);
expect
(
redBlueBothPaintMerged
.
background
,
bluePaintTextStyle
.
background
);
final
TextStyle
redPaintBlueColorMerged
=
redPaintTextStyle
.
merge
(
blueTextStyle
);
expect
(
redPaintBlueColorMerged
.
backgroundColor
,
null
);
expect
(
redPaintBlueColorMerged
.
background
,
redPaintTextStyle
.
background
);
final
TextStyle
blueColorRedPaintMerged
=
blueTextStyle
.
merge
(
redPaintTextStyle
);
expect
(
blueColorRedPaintMerged
.
backgroundColor
,
null
);
expect
(
blueColorRedPaintMerged
.
background
,
redPaintTextStyle
.
background
);
// apply
expect
(
redPaintTextStyle
.
apply
(
backgroundColor:
blue
).
backgroundColor
,
isNull
);
expect
(
redPaintTextStyle
.
apply
(
backgroundColor:
blue
).
background
.
color
,
red
);
expect
(
redTextStyle
.
apply
(
backgroundColor:
blue
).
backgroundColor
,
blue
);
// lerp
expect
(
TextStyle
.
lerp
(
redTextStyle
,
blueTextStyle
,
.
25
).
backgroundColor
,
Color
.
lerp
(
red
,
blue
,
.
25
));
expect
(
TextStyle
.
lerp
(
redTextStyle
,
bluePaintTextStyle
,
.
25
).
backgroundColor
,
isNull
);
expect
(
TextStyle
.
lerp
(
redTextStyle
,
bluePaintTextStyle
,
.
25
).
background
.
color
,
red
);
expect
(
TextStyle
.
lerp
(
redTextStyle
,
bluePaintTextStyle
,
.
75
).
background
.
color
,
blue
);
expect
(
TextStyle
.
lerp
(
redPaintTextStyle
,
bluePaintTextStyle
,
.
25
).
backgroundColor
,
isNull
);
expect
(
TextStyle
.
lerp
(
redPaintTextStyle
,
bluePaintTextStyle
,
.
25
).
background
.
color
,
red
);
expect
(
TextStyle
.
lerp
(
redPaintTextStyle
,
bluePaintTextStyle
,
.
75
).
background
.
color
,
blue
);
});
}
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