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
c6f6de6d
Unverified
Commit
c6f6de6d
authored
Jun 18, 2020
by
Jose Alba
Committed by
GitHub
Jun 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Chips text scaling (#57745)
parent
5e77083b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
10 deletions
+19
-10
chip.dart
packages/flutter/lib/src/material/chip.dart
+12
-1
chip_theme.dart
packages/flutter/lib/src/material/chip_theme.dart
+1
-4
chip_test.dart
packages/flutter/test/material/chip_test.dart
+2
-2
chip_theme_test.dart
packages/flutter/test/material/chip_theme_test.dart
+4
-3
No files found.
packages/flutter/lib/src/material/chip.dart
View file @
c6f6de6d
...
@@ -1823,6 +1823,16 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip
...
@@ -1823,6 +1823,16 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip
assert
(
debugCheckHasDirectionality
(
context
));
assert
(
debugCheckHasDirectionality
(
context
));
assert
(
debugCheckHasMaterialLocalizations
(
context
));
assert
(
debugCheckHasMaterialLocalizations
(
context
));
/// The chip at text scale 1 starts with 8px on each side and as text scaling
/// gets closer to 2 the label padding is linearly interpolated from 8px to 4px.
/// Once the widget has a text scaling of 2 or higher than the label padding
/// remains 4px.
final
EdgeInsetsGeometry
_defaultLabelPadding
=
EdgeInsets
.
lerp
(
const
EdgeInsets
.
symmetric
(
horizontal:
8.0
),
const
EdgeInsets
.
symmetric
(
horizontal:
4.0
),
(
MediaQuery
.
of
(
context
).
textScaleFactor
-
1.0
).
clamp
(
0.0
,
1.0
)
as
double
,
);
final
ThemeData
theme
=
Theme
.
of
(
context
);
final
ThemeData
theme
=
Theme
.
of
(
context
);
final
ChipThemeData
chipTheme
=
ChipTheme
.
of
(
context
);
final
ChipThemeData
chipTheme
=
ChipTheme
.
of
(
context
);
final
TextDirection
textDirection
=
Directionality
.
of
(
context
);
final
TextDirection
textDirection
=
Directionality
.
of
(
context
);
...
@@ -1837,6 +1847,7 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip
...
@@ -1837,6 +1847,7 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip
final
TextStyle
effectiveLabelStyle
=
widget
.
labelStyle
??
chipTheme
.
labelStyle
;
final
TextStyle
effectiveLabelStyle
=
widget
.
labelStyle
??
chipTheme
.
labelStyle
;
final
Color
resolvedLabelColor
=
MaterialStateProperty
.
resolveAs
<
Color
>(
effectiveLabelStyle
?.
color
,
_states
);
final
Color
resolvedLabelColor
=
MaterialStateProperty
.
resolveAs
<
Color
>(
effectiveLabelStyle
?.
color
,
_states
);
final
TextStyle
resolvedLabelStyle
=
effectiveLabelStyle
?.
copyWith
(
color:
resolvedLabelColor
);
final
TextStyle
resolvedLabelStyle
=
effectiveLabelStyle
?.
copyWith
(
color:
resolvedLabelColor
);
final
EdgeInsetsGeometry
labelPadding
=
widget
.
labelPadding
??
chipTheme
.
labelPadding
??
_defaultLabelPadding
;
Widget
result
=
Material
(
Widget
result
=
Material
(
elevation:
isTapping
?
pressElevation
:
elevation
,
elevation:
isTapping
?
pressElevation
:
elevation
,
...
@@ -1896,7 +1907,7 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip
...
@@ -1896,7 +1907,7 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip
brightness:
chipTheme
.
brightness
,
brightness:
chipTheme
.
brightness
,
padding:
(
widget
.
padding
??
chipTheme
.
padding
).
resolve
(
textDirection
),
padding:
(
widget
.
padding
??
chipTheme
.
padding
).
resolve
(
textDirection
),
visualDensity:
widget
.
visualDensity
??
theme
.
visualDensity
,
visualDensity:
widget
.
visualDensity
??
theme
.
visualDensity
,
labelPadding:
(
widget
.
labelPadding
??
chipTheme
.
labelPadding
)
.
resolve
(
textDirection
),
labelPadding:
labelPadding
.
resolve
(
textDirection
),
showAvatar:
hasAvatar
,
showAvatar:
hasAvatar
,
showCheckmark:
showCheckmark
,
showCheckmark:
showCheckmark
,
checkmarkColor:
checkmarkColor
,
checkmarkColor:
checkmarkColor
,
...
...
packages/flutter/lib/src/material/chip_theme.dart
View file @
c6f6de6d
...
@@ -188,7 +188,7 @@ class ChipThemeData with Diagnosticable {
...
@@ -188,7 +188,7 @@ class ChipThemeData with Diagnosticable {
this
.
selectedShadowColor
,
this
.
selectedShadowColor
,
this
.
showCheckmark
,
this
.
showCheckmark
,
this
.
checkmarkColor
,
this
.
checkmarkColor
,
@required
this
.
labelPadding
,
this
.
labelPadding
,
@required
this
.
padding
,
@required
this
.
padding
,
@required
this
.
shape
,
@required
this
.
shape
,
@required
this
.
labelStyle
,
@required
this
.
labelStyle
,
...
@@ -200,7 +200,6 @@ class ChipThemeData with Diagnosticable {
...
@@ -200,7 +200,6 @@ class ChipThemeData with Diagnosticable {
assert
(
disabledColor
!=
null
),
assert
(
disabledColor
!=
null
),
assert
(
selectedColor
!=
null
),
assert
(
selectedColor
!=
null
),
assert
(
secondarySelectedColor
!=
null
),
assert
(
secondarySelectedColor
!=
null
),
assert
(
labelPadding
!=
null
),
assert
(
padding
!=
null
),
assert
(
padding
!=
null
),
assert
(
shape
!=
null
),
assert
(
shape
!=
null
),
assert
(
labelStyle
!=
null
),
assert
(
labelStyle
!=
null
),
...
@@ -249,7 +248,6 @@ class ChipThemeData with Diagnosticable {
...
@@ -249,7 +248,6 @@ class ChipThemeData with Diagnosticable {
const
int
selectAlpha
=
0x3d
;
// 12% + 12% = 24%
const
int
selectAlpha
=
0x3d
;
// 12% + 12% = 24%
const
int
textLabelAlpha
=
0xde
;
// 87%
const
int
textLabelAlpha
=
0xde
;
// 87%
const
ShapeBorder
shape
=
StadiumBorder
();
const
ShapeBorder
shape
=
StadiumBorder
();
const
EdgeInsetsGeometry
labelPadding
=
EdgeInsets
.
symmetric
(
horizontal:
8.0
);
const
EdgeInsetsGeometry
padding
=
EdgeInsets
.
all
(
4.0
);
const
EdgeInsetsGeometry
padding
=
EdgeInsets
.
all
(
4.0
);
primaryColor
=
primaryColor
??
(
brightness
==
Brightness
.
light
?
Colors
.
black
:
Colors
.
white
);
primaryColor
=
primaryColor
??
(
brightness
==
Brightness
.
light
?
Colors
.
black
:
Colors
.
white
);
...
@@ -269,7 +267,6 @@ class ChipThemeData with Diagnosticable {
...
@@ -269,7 +267,6 @@ class ChipThemeData with Diagnosticable {
disabledColor:
disabledColor
,
disabledColor:
disabledColor
,
selectedColor:
selectedColor
,
selectedColor:
selectedColor
,
secondarySelectedColor:
secondarySelectedColor
,
secondarySelectedColor:
secondarySelectedColor
,
labelPadding:
labelPadding
,
padding:
padding
,
padding:
padding
,
shape:
shape
,
shape:
shape
,
labelStyle:
labelStyle
,
labelStyle:
labelStyle
,
...
...
packages/flutter/test/material/chip_test.dart
View file @
c6f6de6d
...
@@ -590,9 +590,9 @@ void main() {
...
@@ -590,9 +590,9 @@ void main() {
// https://github.com/flutter/flutter/issues/12357
// https://github.com/flutter/flutter/issues/12357
expect
(
tester
.
getSize
(
find
.
text
(
'Chip A'
)),
anyOf
(
const
Size
(
252.0
,
42.0
),
const
Size
(
251.0
,
42.0
)));
expect
(
tester
.
getSize
(
find
.
text
(
'Chip A'
)),
anyOf
(
const
Size
(
252.0
,
42.0
),
const
Size
(
251.0
,
42.0
)));
expect
(
tester
.
getSize
(
find
.
text
(
'Chip B'
)),
anyOf
(
const
Size
(
252.0
,
42.0
),
const
Size
(
251.0
,
42.0
)));
expect
(
tester
.
getSize
(
find
.
text
(
'Chip B'
)),
anyOf
(
const
Size
(
252.0
,
42.0
),
const
Size
(
251.0
,
42.0
)));
expect
(
tester
.
getSize
(
find
.
byType
(
Chip
).
first
).
width
,
anyOf
(
31
8.0
,
319
.0
));
expect
(
tester
.
getSize
(
find
.
byType
(
Chip
).
first
).
width
,
anyOf
(
31
0.0
,
311
.0
));
expect
(
tester
.
getSize
(
find
.
byType
(
Chip
).
first
).
height
,
equals
(
50.0
));
expect
(
tester
.
getSize
(
find
.
byType
(
Chip
).
first
).
height
,
equals
(
50.0
));
expect
(
tester
.
getSize
(
find
.
byType
(
Chip
).
last
).
width
,
anyOf
(
31
8.0
,
319
.0
));
expect
(
tester
.
getSize
(
find
.
byType
(
Chip
).
last
).
width
,
anyOf
(
31
0.0
,
311
.0
));
expect
(
tester
.
getSize
(
find
.
byType
(
Chip
).
last
).
height
,
equals
(
50.0
));
expect
(
tester
.
getSize
(
find
.
byType
(
Chip
).
last
).
height
,
equals
(
50.0
));
// Check that individual text scales are taken into account.
// Check that individual text scales are taken into account.
...
...
packages/flutter/test/material/chip_theme_test.dart
View file @
c6f6de6d
...
@@ -184,7 +184,7 @@ void main() {
...
@@ -184,7 +184,7 @@ void main() {
expect
(
lightTheme
.
disabledColor
,
equals
(
Colors
.
black
.
withAlpha
(
0x0c
)));
expect
(
lightTheme
.
disabledColor
,
equals
(
Colors
.
black
.
withAlpha
(
0x0c
)));
expect
(
lightTheme
.
selectedColor
,
equals
(
Colors
.
black
.
withAlpha
(
0x3d
)));
expect
(
lightTheme
.
selectedColor
,
equals
(
Colors
.
black
.
withAlpha
(
0x3d
)));
expect
(
lightTheme
.
secondarySelectedColor
,
equals
(
customColor1
.
withAlpha
(
0x3d
)));
expect
(
lightTheme
.
secondarySelectedColor
,
equals
(
customColor1
.
withAlpha
(
0x3d
)));
expect
(
lightTheme
.
labelPadding
,
equals
(
const
EdgeInsets
.
symmetric
(
horizontal:
8.0
))
);
expect
(
lightTheme
.
labelPadding
,
isNull
);
expect
(
lightTheme
.
padding
,
equals
(
const
EdgeInsets
.
all
(
4.0
)));
expect
(
lightTheme
.
padding
,
equals
(
const
EdgeInsets
.
all
(
4.0
)));
expect
(
lightTheme
.
shape
,
isA
<
StadiumBorder
>());
expect
(
lightTheme
.
shape
,
isA
<
StadiumBorder
>());
expect
(
lightTheme
.
labelStyle
.
color
,
equals
(
Colors
.
black
.
withAlpha
(
0xde
)));
expect
(
lightTheme
.
labelStyle
.
color
,
equals
(
Colors
.
black
.
withAlpha
(
0xde
)));
...
@@ -202,7 +202,7 @@ void main() {
...
@@ -202,7 +202,7 @@ void main() {
expect
(
darkTheme
.
disabledColor
,
equals
(
Colors
.
white
.
withAlpha
(
0x0c
)));
expect
(
darkTheme
.
disabledColor
,
equals
(
Colors
.
white
.
withAlpha
(
0x0c
)));
expect
(
darkTheme
.
selectedColor
,
equals
(
Colors
.
white
.
withAlpha
(
0x3d
)));
expect
(
darkTheme
.
selectedColor
,
equals
(
Colors
.
white
.
withAlpha
(
0x3d
)));
expect
(
darkTheme
.
secondarySelectedColor
,
equals
(
customColor1
.
withAlpha
(
0x3d
)));
expect
(
darkTheme
.
secondarySelectedColor
,
equals
(
customColor1
.
withAlpha
(
0x3d
)));
expect
(
darkTheme
.
labelPadding
,
equals
(
const
EdgeInsets
.
symmetric
(
horizontal:
8.0
))
);
expect
(
darkTheme
.
labelPadding
,
isNull
);
expect
(
darkTheme
.
padding
,
equals
(
const
EdgeInsets
.
all
(
4.0
)));
expect
(
darkTheme
.
padding
,
equals
(
const
EdgeInsets
.
all
(
4.0
)));
expect
(
darkTheme
.
shape
,
isA
<
StadiumBorder
>());
expect
(
darkTheme
.
shape
,
isA
<
StadiumBorder
>());
expect
(
darkTheme
.
labelStyle
.
color
,
equals
(
Colors
.
white
.
withAlpha
(
0xde
)));
expect
(
darkTheme
.
labelStyle
.
color
,
equals
(
Colors
.
white
.
withAlpha
(
0xde
)));
...
@@ -220,7 +220,7 @@ void main() {
...
@@ -220,7 +220,7 @@ void main() {
expect
(
customTheme
.
disabledColor
,
equals
(
customColor1
.
withAlpha
(
0x0c
)));
expect
(
customTheme
.
disabledColor
,
equals
(
customColor1
.
withAlpha
(
0x0c
)));
expect
(
customTheme
.
selectedColor
,
equals
(
customColor1
.
withAlpha
(
0x3d
)));
expect
(
customTheme
.
selectedColor
,
equals
(
customColor1
.
withAlpha
(
0x3d
)));
expect
(
customTheme
.
secondarySelectedColor
,
equals
(
customColor2
.
withAlpha
(
0x3d
)));
expect
(
customTheme
.
secondarySelectedColor
,
equals
(
customColor2
.
withAlpha
(
0x3d
)));
expect
(
customTheme
.
labelPadding
,
equals
(
const
EdgeInsets
.
symmetric
(
horizontal:
8.0
))
);
expect
(
customTheme
.
labelPadding
,
isNull
);
expect
(
customTheme
.
padding
,
equals
(
const
EdgeInsets
.
all
(
4.0
)));
expect
(
customTheme
.
padding
,
equals
(
const
EdgeInsets
.
all
(
4.0
)));
expect
(
customTheme
.
shape
,
isA
<
StadiumBorder
>());
expect
(
customTheme
.
shape
,
isA
<
StadiumBorder
>());
expect
(
customTheme
.
labelStyle
.
color
,
equals
(
customColor1
.
withAlpha
(
0xde
)));
expect
(
customTheme
.
labelStyle
.
color
,
equals
(
customColor1
.
withAlpha
(
0xde
)));
...
@@ -235,6 +235,7 @@ void main() {
...
@@ -235,6 +235,7 @@ void main() {
labelStyle:
ThemeData
.
fallback
().
textTheme
.
bodyText1
.
copyWith
(
color:
Colors
.
black
),
labelStyle:
ThemeData
.
fallback
().
textTheme
.
bodyText1
.
copyWith
(
color:
Colors
.
black
),
).
copyWith
(
).
copyWith
(
elevation:
1.0
,
elevation:
1.0
,
labelPadding:
const
EdgeInsets
.
symmetric
(
horizontal:
8.0
),
pressElevation:
4.0
,
pressElevation:
4.0
,
shadowColor:
Colors
.
black
,
shadowColor:
Colors
.
black
,
selectedShadowColor:
Colors
.
black
,
selectedShadowColor:
Colors
.
black
,
...
...
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