Skip to content

Commit

Permalink
fix: use verticalTextAlignment instead of verticalAlignment
Browse files Browse the repository at this point in the history
  • Loading branch information
farfromrefug committed Aug 2, 2019
1 parent bdf9f2d commit 3a11873
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
14 changes: 13 additions & 1 deletion src/label-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -77,3 +78,14 @@ export const textShadowProperty = new CssProperty<Style, string | TextShadow>({
}
});
textShadowProperty.register(Style);

export type VerticalTextAlignment = 'initial' | 'top' | 'middle' | 'bottom';

const textAlignmentConverter = makeParser<VerticalTextAlignment>(makeValidator<VerticalTextAlignment>('initial', 'top', 'middle', 'bottom'));
export const textAlignmentProperty = new InheritedCssProperty<Style, VerticalTextAlignment>({
name: 'verticalTextAlignment',
cssName: 'vertical-text-align',
defaultValue: 'initial',
valueConverter: textAlignmentConverter
});
textAlignmentProperty.register(Style);
6 changes: 3 additions & 3 deletions src/label.android.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 3a11873

Please sign in to comment.