mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 20:11:24 +08:00
feat(text-base): Add Span vertical-align support (#8257)
This commit is contained in:

committed by
GitHub

parent
e2a9af2bc7
commit
faa0181b9c
@ -201,6 +201,18 @@ function onFormattedTextPropertyChanged(textBase: TextBaseCommon, oldValue: Form
|
||||
}
|
||||
}
|
||||
|
||||
export function getClosestPropertyValue<T>(property: CssProperty<any, T>, span: Span): T {
|
||||
if (property.isSet(span.style)) {
|
||||
return span.style[property.name];
|
||||
} else if (property.isSet(span.parent.style)) {
|
||||
// parent is FormattedString
|
||||
return span.parent.style[property.name];
|
||||
} else if (property.isSet(span.parent.parent.style)) {
|
||||
// parent.parent is TextBase
|
||||
return span.parent.parent.style[property.name];
|
||||
}
|
||||
}
|
||||
|
||||
const textAlignmentConverter = makeParser<TextAlignment>(makeValidator<TextAlignment>("initial", "left", "center", "right"));
|
||||
export const textAlignmentProperty = new InheritedCssProperty<Style, TextAlignment>({ name: "textAlignment", cssName: "text-align", defaultValue: "initial", valueConverter: textAlignmentConverter });
|
||||
textAlignmentProperty.register(Style);
|
||||
@ -217,10 +229,10 @@ const textDecorationConverter = makeParser<TextDecoration>(makeValidator<TextDec
|
||||
export const textDecorationProperty = new CssProperty<Style, TextDecoration>({ name: "textDecoration", cssName: "text-decoration", defaultValue: "none", valueConverter: textDecorationConverter });
|
||||
textDecorationProperty.register(Style);
|
||||
|
||||
export const letterSpacingProperty = new CssProperty<Style, number>({ name: "letterSpacing", cssName: "letter-spacing", defaultValue: 0, affectsLayout: isIOS, valueConverter: v => parseFloat(v) });
|
||||
export const letterSpacingProperty = new InheritedCssProperty<Style, number>({ name: "letterSpacing", cssName: "letter-spacing", defaultValue: 0, affectsLayout: isIOS, valueConverter: v => parseFloat(v) });
|
||||
letterSpacingProperty.register(Style);
|
||||
|
||||
export const lineHeightProperty = new CssProperty<Style, number>({ name: "lineHeight", cssName: "line-height", affectsLayout: isIOS, valueConverter: v => parseFloat(v) });
|
||||
export const lineHeightProperty = new InheritedCssProperty<Style, number>({ name: "lineHeight", cssName: "line-height", affectsLayout: isIOS, valueConverter: v => parseFloat(v) });
|
||||
lineHeightProperty.register(Style);
|
||||
|
||||
export const resetSymbol = Symbol("textPropertyDefault");
|
||||
|
Reference in New Issue
Block a user