Skip to content

Commit 52b67fd

Browse files
authored
Expose decorationThickness to dart:ui (flutter#8008)
1 parent 5ccee95 commit 52b67fd

File tree

5 files changed

+185
-82
lines changed

5 files changed

+185
-82
lines changed

lib/stub_ui/text.dart

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ Int32List _encodeTextStyle(
265265
TextDecoration decoration,
266266
Color decorationColor,
267267
TextDecorationStyle decorationStyle,
268+
double decorationThickness,
268269
FontWeight fontWeight,
269270
FontStyle fontStyle,
270271
TextBaseline textBaseline,
@@ -296,20 +297,23 @@ Int32List _encodeTextStyle(
296297
result[0] |= 1 << 4;
297298
result[4] = decorationStyle.index;
298299
}
299-
if (fontWeight != null) {
300+
if (decorationThickness != null) {
300301
result[0] |= 1 << 5;
302+
}
303+
if (fontWeight != null) {
304+
result[0] |= 1 << 6;
301305
result[5] = fontWeight.index;
302306
}
303307
if (fontStyle != null) {
304-
result[0] |= 1 << 6;
308+
result[0] |= 1 << 7;
305309
result[6] = fontStyle.index;
306310
}
307311
if (textBaseline != null) {
308-
result[0] |= 1 << 7;
312+
result[0] |= 1 << 8;
309313
result[7] = textBaseline.index;
310314
}
311315
if (fontFamily != null || (fontFamilyFallback != null && fontFamilyFallback.isNotEmpty)) {
312-
result[0] |= 1 << 8;
316+
result[0] |= 1 << 9;
313317
// Passed separately to native.
314318
}
315319
if (fontSize != null) {
@@ -355,6 +359,7 @@ class TextStyle {
355359
/// * `decoration`: The decorations to paint near the text (e.g., an underline).
356360
/// * `decorationColor`: The color in which to paint the text decorations.
357361
/// * `decorationStyle`: The style in which to paint the text decorations (e.g., dashed).
362+
/// * `decorationThickness`: The thickness of the decoration as a muliplier on the thickness specified by the font.
358363
/// * `fontWeight`: The typeface thickness to use when painting the text (e.g., bold).
359364
/// * `fontStyle`: The typeface variant to use when drawing the letters (e.g., italics).
360365
/// * `fontFamily`: The name of the font to use when painting the text (e.g., Roboto). If a `fontFamilyFallback` is
@@ -379,6 +384,7 @@ class TextStyle {
379384
TextDecoration decoration,
380385
Color decorationColor,
381386
TextDecorationStyle decorationStyle,
387+
double decorationThickness,
382388
FontWeight fontWeight,
383389
FontStyle fontStyle,
384390
TextBaseline textBaseline,
@@ -401,6 +407,7 @@ class TextStyle {
401407
decoration,
402408
decorationColor,
403409
decorationStyle,
410+
decorationThickness,
404411
fontWeight,
405412
fontStyle,
406413
textBaseline,
@@ -421,6 +428,7 @@ class TextStyle {
421428
_letterSpacing = letterSpacing,
422429
_wordSpacing = wordSpacing,
423430
_height = height,
431+
_decorationThickness = decorationThickness,
424432
_locale = locale,
425433
_background = background,
426434
_foreground = foreground,
@@ -433,6 +441,7 @@ class TextStyle {
433441
final double _letterSpacing;
434442
final double _wordSpacing;
435443
final double _height;
444+
final double _decorationThickness;
436445
final Locale _locale;
437446
final Paint _background;
438447
final Paint _foreground;
@@ -450,6 +459,7 @@ class TextStyle {
450459
_letterSpacing != typedOther._letterSpacing ||
451460
_wordSpacing != typedOther._wordSpacing ||
452461
_height != typedOther._height ||
462+
_decorationThickness != typedOther._decorationThickness ||
453463
_locale != typedOther._locale ||
454464
_background != typedOther._background ||
455465
_foreground != typedOther._foreground)
@@ -466,31 +476,32 @@ class TextStyle {
466476
}
467477

468478
@override
469-
int get hashCode => hashValues(hashList(_encoded), _fontFamily, _fontFamilyFallback, _fontSize, _letterSpacing, _wordSpacing, _height, _locale, _background, _foreground, _shadows);
479+
int get hashCode => hashValues(hashList(_encoded), _fontFamily, _fontFamilyFallback, _fontSize, _letterSpacing, _wordSpacing, _height, _locale, _background, _foreground, _shadows, _decorationThickness);
470480

471481
@override
472482
String toString() {
473483
return 'TextStyle('
474-
'color: ${ _encoded[0] & 0x00002 == 0x00002 ? new Color(_encoded[1]) : "unspecified"}, '
475-
'decoration: ${ _encoded[0] & 0x00004 == 0x00004 ? new TextDecoration._(_encoded[2]) : "unspecified"}, '
476-
'decorationColor: ${ _encoded[0] & 0x00008 == 0x00008 ? new Color(_encoded[3]) : "unspecified"}, '
477-
'decorationStyle: ${ _encoded[0] & 0x00010 == 0x00010 ? TextDecorationStyle.values[_encoded[4]] : "unspecified"}, '
478-
'fontWeight: ${ _encoded[0] & 0x00020 == 0x00020 ? FontWeight.values[_encoded[5]] : "unspecified"}, '
479-
'fontStyle: ${ _encoded[0] & 0x00040 == 0x00040 ? FontStyle.values[_encoded[6]] : "unspecified"}, '
480-
'textBaseline: ${ _encoded[0] & 0x00080 == 0x00080 ? TextBaseline.values[_encoded[7]] : "unspecified"}, '
481-
'fontFamily: ${ _encoded[0] & 0x00100 == 0x00100
482-
&& _fontFamily != null ? _fontFamily : "unspecified"}, '
483-
'fontFamilyFallback: ${_encoded[0] & 0x00100 == 0x00100
484-
&& _fontFamilyFallback != null
485-
&& _fontFamilyFallback.isNotEmpty ? _fontFamilyFallback : "unspecified"}, '
486-
'fontSize: ${ _encoded[0] & 0x00200 == 0x00200 ? _fontSize : "unspecified"}, '
487-
'letterSpacing: ${ _encoded[0] & 0x00400 == 0x00400 ? "${_letterSpacing}x" : "unspecified"}, '
488-
'wordSpacing: ${ _encoded[0] & 0x00800 == 0x00800 ? "${_wordSpacing}x" : "unspecified"}, '
489-
'height: ${ _encoded[0] & 0x01000 == 0x01000 ? "${_height}x" : "unspecified"}, '
490-
'locale: ${ _encoded[0] & 0x02000 == 0x02000 ? _locale : "unspecified"}, '
491-
'background: ${ _encoded[0] & 0x04000 == 0x04000 ? _background : "unspecified"}, '
492-
'foreground: ${ _encoded[0] & 0x08000 == 0x08000 ? _foreground : "unspecified"}, '
493-
'shadows: ${ _encoded[0] & 0x10000 == 0x10000 ? _shadows : "unspecified"}'
484+
'color: ${ _encoded[0] & 0x00002 == 0x00002 ? new Color(_encoded[1]) : "unspecified"}, '
485+
'decoration: ${ _encoded[0] & 0x00004 == 0x00004 ? new TextDecoration._(_encoded[2]) : "unspecified"}, '
486+
'decorationColor: ${ _encoded[0] & 0x00008 == 0x00008 ? new Color(_encoded[3]) : "unspecified"}, '
487+
'decorationStyle: ${ _encoded[0] & 0x00010 == 0x00010 ? TextDecorationStyle.values[_encoded[4]] : "unspecified"}, '
488+
'decorationThickness: ${_encoded[0] & 0x00020 == 0x00020 ? _decorationThickness : "unspecified"}, '
489+
'fontWeight: ${ _encoded[0] & 0x00040 == 0x00040 ? FontWeight.values[_encoded[5]] : "unspecified"}, '
490+
'fontStyle: ${ _encoded[0] & 0x00080 == 0x00080 ? FontStyle.values[_encoded[6]] : "unspecified"}, '
491+
'textBaseline: ${ _encoded[0] & 0x00100 == 0x00100 ? TextBaseline.values[_encoded[7]] : "unspecified"}, '
492+
'fontFamily: ${ _encoded[0] & 0x00200 == 0x00200
493+
&& _fontFamily != null ? _fontFamily : "unspecified"}, '
494+
'fontFamilyFallback: ${ _encoded[0] & 0x00200 == 0x00200
495+
&& _fontFamilyFallback != null
496+
&& _fontFamilyFallback.isNotEmpty ? _fontFamilyFallback : "unspecified"}, '
497+
'fontSize: ${ _encoded[0] & 0x00400 == 0x00400 ? _fontSize : "unspecified"}, '
498+
'letterSpacing: ${ _encoded[0] & 0x00800 == 0x00800 ? "${_letterSpacing}x" : "unspecified"}, '
499+
'wordSpacing: ${ _encoded[0] & 0x01000 == 0x01000 ? "${_wordSpacing}x" : "unspecified"}, '
500+
'height: ${ _encoded[0] & 0x02000 == 0x02000 ? "${_height}x" : "unspecified"}, '
501+
'locale: ${ _encoded[0] & 0x04000 == 0x04000 ? _locale : "unspecified"}, '
502+
'background: ${ _encoded[0] & 0x08000 == 0x08000 ? _background : "unspecified"}, '
503+
'foreground: ${ _encoded[0] & 0x10000 == 0x10000 ? _foreground : "unspecified"}, '
504+
'shadows: ${ _encoded[0] & 0x20000 == 0x20000 ? _shadows : "unspecified"}'
494505
')';
495506
}
496507
}

0 commit comments

Comments
 (0)