diff --git a/packages/core/core-types/index.d.ts b/packages/core/core-types/index.d.ts index 19dbb1f17..57790b921 100644 --- a/packages/core/core-types/index.d.ts +++ b/packages/core/core-types/index.d.ts @@ -104,7 +104,7 @@ export namespace CoreTypes { export const send: string; } - export type TextAlignmentType = 'initial' | 'left' | 'center' | 'right'; + export type TextAlignmentType = 'initial' | 'left' | 'center' | 'right' | 'justify'; /** * Represents a text-align enumeration. */ @@ -123,6 +123,11 @@ export namespace CoreTypes { * Represents right text-align. */ export const right: TextAlignmentType; + + /** + * Represents justify text-align. + */ + export const justify: TextAlignmentType; } export type OrientationType = 'horizontal' | 'vertical'; diff --git a/packages/core/core-types/index.ts b/packages/core/core-types/index.ts index 760859bd7..250bcd4f6 100644 --- a/packages/core/core-types/index.ts +++ b/packages/core/core-types/index.ts @@ -57,11 +57,12 @@ export namespace CoreTypes { export const send = 'send'; } - export type TextAlignmentType = 'initial' | 'left' | 'center' | 'right'; + export type TextAlignmentType = 'initial' | 'left' | 'center' | 'right' | 'justify'; export module TextAlignment { export const left = 'left'; export const center = 'center'; export const right = 'right'; + export const justify = 'justify'; } export type TextDecorationType = 'none' | 'underline' | 'line-through' | 'underline line-through'; diff --git a/packages/core/ui/text-base/index.android.ts b/packages/core/ui/text-base/index.android.ts index 3e94014ae..7cdb34ebc 100644 --- a/packages/core/ui/text-base/index.android.ts +++ b/packages/core/ui/text-base/index.android.ts @@ -286,18 +286,22 @@ export class TextBase extends TextBaseCommon { [textAlignmentProperty.setNative](value: CoreTypes.TextAlignmentType) { const verticalGravity = this.nativeTextViewProtected.getGravity() & android.view.Gravity.VERTICAL_GRAVITY_MASK; switch (value) { - case 'initial': - case 'left': - this.nativeTextViewProtected.setGravity(android.view.Gravity.START | verticalGravity); - break; - case 'center': this.nativeTextViewProtected.setGravity(android.view.Gravity.CENTER_HORIZONTAL | verticalGravity); break; - case 'right': this.nativeTextViewProtected.setGravity(android.view.Gravity.END | verticalGravity); break; + default: // initial | left | justify + this.nativeTextViewProtected.setGravity(android.view.Gravity.START | verticalGravity); + break; + } + if (android.os.Build.VERSION.SDK_INT >= 25) { + if (value === 'justify') { + this.nativeTextViewProtected.setJustificationMode(android.text.Layout.JUSTIFICATION_MODE_INTER_WORD); + } else { + this.nativeTextViewProtected.setJustificationMode(android.text.Layout.JUSTIFICATION_MODE_NONE); + } } } diff --git a/packages/core/ui/text-base/index.ios.ts b/packages/core/ui/text-base/index.ios.ts index 1f8b953c4..5a1514fb9 100644 --- a/packages/core/ui/text-base/index.ios.ts +++ b/packages/core/ui/text-base/index.ios.ts @@ -171,6 +171,9 @@ export class TextBase extends TextBaseCommon { case 'right': nativeView.textAlignment = NSTextAlignment.Right; break; + case 'justify': + nativeView.textAlignment = NSTextAlignment.Justified; + break; } } diff --git a/packages/core/ui/text-base/text-base-common.ts b/packages/core/ui/text-base/text-base-common.ts index b3b0b941d..d1a2057ef 100644 --- a/packages/core/ui/text-base/text-base-common.ts +++ b/packages/core/ui/text-base/text-base-common.ts @@ -246,7 +246,7 @@ export function getClosestPropertyValue(property: CssProperty, span: } } -const textAlignmentConverter = makeParser(makeValidator('initial', 'left', 'center', 'right')); +const textAlignmentConverter = makeParser(makeValidator('initial', 'left', 'center', 'right', 'justify')); export const textAlignmentProperty = new InheritedCssProperty({ name: 'textAlignment', cssName: 'text-align',