diff --git a/src/label-common.ts b/src/label-common.ts index 095406f..a8b230d 100644 --- a/src/label-common.ts +++ b/src/label-common.ts @@ -2,9 +2,10 @@ import { Label as HtmlViewDefinition, TextShadow } from './label'; import { booleanConverter, Color, CSSType, dip } from 'tns-core-modules/ui/core/view'; import { Label as TNLabel } from 'tns-core-modules/ui/label/label'; import { Style } from 'tns-core-modules/ui/styling/style'; -import { CssProperty, Property } from 'tns-core-modules/ui/core/properties'; +import { CssProperty, InheritedCssProperty, makeParser, makeValidator, Property } from 'tns-core-modules/ui/core/properties'; import { isIOS } from 'tns-core-modules/platform'; import { layout } from 'tns-core-modules/utils/utils'; +// import { CssProperty, InheritedCssProperty, makeParser, makeValidator, Property } from "../core/properties"; export const cssProperty = (target: Object, key: string | symbol) => { // property getter @@ -77,3 +78,14 @@ export const textShadowProperty = new CssProperty({ } }); textShadowProperty.register(Style); + +export type VerticalTextAlignment = 'initial' | 'top' | 'middle' | 'bottom'; + +const textAlignmentConverter = makeParser(makeValidator('initial', 'top', 'middle', 'bottom')); +export const textAlignmentProperty = new InheritedCssProperty({ + name: 'verticalTextAlignment', + cssName: 'vertical-text-align', + defaultValue: 'initial', + valueConverter: textAlignmentConverter +}); +textAlignmentProperty.register(Style); diff --git a/src/label.android.ts b/src/label.android.ts index 6a5a76f..fe00db0 100644 --- a/src/label.android.ts +++ b/src/label.android.ts @@ -1,4 +1,4 @@ -import { htmlProperty, LabelBase, lineBreakProperty, maxLinesProperty, textShadowProperty } from './label-common'; +import { htmlProperty, LabelBase, lineBreakProperty, maxLinesProperty, textShadowProperty, VerticalTextAlignment, verticalTextAlignmentProperty } from './label-common'; // import { backgroundColorProperty } from 'tns-core-modules/ui/page/page'; import { TextTransform, VerticalAlignment, verticalAlignmentProperty, WhiteSpace, whiteSpaceProperty } from 'tns-core-modules/ui/text-base/text-base'; import { Font } from 'tns-core-modules/ui/styling/font'; @@ -265,10 +265,10 @@ export class Label extends LabelBase { this.nativeViewProtected.setShadowLayer(layout.toDevicePixels(value.blurRadius), layout.toDevicePixels(value.offsetX), layout.toDevicePixels(value.offsetY), value.color.android); } - [verticalAlignmentProperty.setNative](value: VerticalAlignment) { + [verticalTextAlignmentProperty.setNative](value: VerticalTextAlignment) { const horizontalGravity = this.nativeTextViewProtected.getGravity() & android.view.Gravity.HORIZONTAL_GRAVITY_MASK; switch (value) { - case 'stretch': + case 'initial': case 'top': this.nativeTextViewProtected.setGravity(android.view.Gravity.TOP | horizontalGravity); break;