Unverified Commit 19ff5969 authored by Gary Qian's avatar Gary Qian Committed by GitHub

Add missing properties to TextStyle.apply (#54305)

parent cf5e4b54
......@@ -794,12 +794,17 @@ class TextStyle with Diagnosticable {
double fontSizeFactor = 1.0,
double fontSizeDelta = 0.0,
int fontWeightDelta = 0,
FontStyle fontStyle,
double letterSpacingFactor = 1.0,
double letterSpacingDelta = 0.0,
double wordSpacingFactor = 1.0,
double wordSpacingDelta = 0.0,
double heightFactor = 1.0,
double heightDelta = 0.0,
TextBaseline textBaseline,
Locale locale,
List<ui.Shadow> shadows,
List<ui.FontFeature> fontFeatures,
}) {
assert(fontSizeFactor != null);
assert(fontSizeDelta != null);
......@@ -834,16 +839,16 @@ class TextStyle with Diagnosticable {
fontFamilyFallback: fontFamilyFallback ?? this.fontFamilyFallback,
fontSize: fontSize == null ? null : fontSize * fontSizeFactor + fontSizeDelta,
fontWeight: fontWeight == null ? null : FontWeight.values[(fontWeight.index + fontWeightDelta).clamp(0, FontWeight.values.length - 1) as int],
fontStyle: fontStyle,
fontStyle: fontStyle ?? this.fontStyle,
letterSpacing: letterSpacing == null ? null : letterSpacing * letterSpacingFactor + letterSpacingDelta,
wordSpacing: wordSpacing == null ? null : wordSpacing * wordSpacingFactor + wordSpacingDelta,
textBaseline: textBaseline,
height: height == null ? null : height * heightFactor + heightDelta,
locale: locale,
locale: locale ?? this.locale,
foreground: foreground,
background: background,
shadows: shadows,
fontFeatures: fontFeatures,
shadows: shadows ?? this.shadows,
fontFeatures: fontFeatures ?? this.fontFeatures,
decoration: decoration ?? this.decoration,
decorationColor: decorationColor ?? this.decorationColor,
decorationStyle: decorationStyle ?? this.decorationStyle,
......
......@@ -774,12 +774,17 @@ class _TextStyleProxy implements TextStyle {
double fontSizeFactor = 1.0,
double fontSizeDelta = 0.0,
int fontWeightDelta = 0,
FontStyle fontStyle,
double letterSpacingFactor = 1.0,
double letterSpacingDelta = 0.0,
double wordSpacingFactor = 1.0,
double wordSpacingDelta = 0.0,
double heightFactor = 1.0,
double heightDelta = 0.0,
TextBaseline textBaseline,
Locale locale,
List<ui.Shadow> shadows,
List<ui.FontFeature> fontFeatures,
}) {
throw UnimplementedError();
}
......
......@@ -233,6 +233,11 @@ void main() {
final ui.TextStyle uis1 = s2.getTextStyle();
expect(uis1.toString(), 'TextStyle(color: unspecified, decoration: unspecified, decorationColor: unspecified, decorationStyle: unspecified, decorationThickness: unspecified, fontWeight: unspecified, fontStyle: unspecified, textBaseline: unspecified, fontFamily: foo, fontFamilyFallback: [Roboto, test], fontSize: unspecified, letterSpacing: unspecified, wordSpacing: unspecified, height: unspecified, locale: unspecified, background: unspecified, foreground: unspecified, shadows: unspecified, fontFeatures: unspecified)');
expect(s2.apply().fontFamily, 'foo');
expect(s2.apply().fontFamilyFallback, const <String>['Roboto', 'test']);
expect(s2.apply(fontFamily: 'bar').fontFamily, 'bar');
expect(s2.apply(fontFamilyFallback: const <String>['Banana']).fontFamilyFallback, const <String>['Banana']);
}, skip: isBrowser);
test('TextStyle.debugLabel', () {
......@@ -367,4 +372,16 @@ void main() {
expect(paragraphStyle0 == paragraphStyle1, true);
});
test('TextStyle apply', () {
const TextStyle style = TextStyle(fontSize: 10);
expect(style.apply().shadows, isNull);
expect(style.apply(shadows: const <ui.Shadow>[ui.Shadow(blurRadius: 2.0)]).shadows, const <ui.Shadow>[ui.Shadow(blurRadius: 2.0)]);
expect(style.apply().fontStyle, isNull);
expect(style.apply(fontStyle: FontStyle.italic).fontStyle, FontStyle.italic);
expect(style.apply().locale, isNull);
expect(style.apply(locale: const Locale.fromSubtags(languageCode: 'es')).locale, const Locale.fromSubtags(languageCode: 'es'));
expect(style.apply().fontFeatures, isNull);
expect(style.apply(fontFeatures: const <ui.FontFeature>[ui.FontFeature.enable('test')]).fontFeatures, const <ui.FontFeature>[ui.FontFeature.enable('test')]);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment