Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3a11873

Browse files
committedAug 2, 2019
fix: use verticalTextAlignment instead of verticalAlignment
1 parent bdf9f2d commit 3a11873

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed
 

‎src/label-common.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import { Label as HtmlViewDefinition, TextShadow } from './label';
22
import { booleanConverter, Color, CSSType, dip } from 'tns-core-modules/ui/core/view';
33
import { Label as TNLabel } from 'tns-core-modules/ui/label/label';
44
import { Style } from 'tns-core-modules/ui/styling/style';
5-
import { CssProperty, Property } from 'tns-core-modules/ui/core/properties';
5+
import { CssProperty, InheritedCssProperty, makeParser, makeValidator, Property } from 'tns-core-modules/ui/core/properties';
66
import { isIOS } from 'tns-core-modules/platform';
77
import { layout } from 'tns-core-modules/utils/utils';
8+
// import { CssProperty, InheritedCssProperty, makeParser, makeValidator, Property } from "../core/properties";
89

910
export const cssProperty = (target: Object, key: string | symbol) => {
1011
// property getter
@@ -77,3 +78,14 @@ export const textShadowProperty = new CssProperty<Style, string | TextShadow>({
7778
}
7879
});
7980
textShadowProperty.register(Style);
81+
82+
export type VerticalTextAlignment = 'initial' | 'top' | 'middle' | 'bottom';
83+
84+
const textAlignmentConverter = makeParser<VerticalTextAlignment>(makeValidator<VerticalTextAlignment>('initial', 'top', 'middle', 'bottom'));
85+
export const textAlignmentProperty = new InheritedCssProperty<Style, VerticalTextAlignment>({
86+
name: 'verticalTextAlignment',
87+
cssName: 'vertical-text-align',
88+
defaultValue: 'initial',
89+
valueConverter: textAlignmentConverter
90+
});
91+
textAlignmentProperty.register(Style);

‎src/label.android.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { htmlProperty, LabelBase, lineBreakProperty, maxLinesProperty, textShadowProperty } from './label-common';
1+
import { htmlProperty, LabelBase, lineBreakProperty, maxLinesProperty, textShadowProperty, VerticalTextAlignment, verticalTextAlignmentProperty } from './label-common';
22
// import { backgroundColorProperty } from 'tns-core-modules/ui/page/page';
33
import { TextTransform, VerticalAlignment, verticalAlignmentProperty, WhiteSpace, whiteSpaceProperty } from 'tns-core-modules/ui/text-base/text-base';
44
import { Font } from 'tns-core-modules/ui/styling/font';
@@ -265,10 +265,10 @@ export class Label extends LabelBase {
265265
this.nativeViewProtected.setShadowLayer(layout.toDevicePixels(value.blurRadius), layout.toDevicePixels(value.offsetX), layout.toDevicePixels(value.offsetY), value.color.android);
266266
}
267267

268-
[verticalAlignmentProperty.setNative](value: VerticalAlignment) {
268+
[verticalTextAlignmentProperty.setNative](value: VerticalTextAlignment) {
269269
const horizontalGravity = this.nativeTextViewProtected.getGravity() & android.view.Gravity.HORIZONTAL_GRAVITY_MASK;
270270
switch (value) {
271-
case 'stretch':
271+
case 'initial':
272272
case 'top':
273273
this.nativeTextViewProtected.setGravity(android.view.Gravity.TOP | horizontalGravity);
274274
break;

0 commit comments

Comments
 (0)
Please sign in to comment.