feat(core): text-shadow support (#8991)

This commit is contained in:
Tiago Alves
2021-01-29 19:46:58 +00:00
committed by Nathan Walker
parent 0750ce5399
commit cbba5ed19d
10 changed files with 133 additions and 28 deletions

View File

@@ -1,10 +1,10 @@
// Types
import { TextDecoration, TextAlignment, TextTransform, WhiteSpace, getClosestPropertyValue } from './text-base-common';
import { TextDecoration, TextAlignment, TextTransform, TextShadow, WhiteSpace, getClosestPropertyValue } from './text-base-common';
// Requires
import { Font } from '../styling/font';
import { backgroundColorProperty, VerticalAlignment } from '../styling/style-properties';
import { TextBaseCommon, formattedTextProperty, textAlignmentProperty, textDecorationProperty, textProperty, textTransformProperty, letterSpacingProperty, whiteSpaceProperty, lineHeightProperty, isBold, resetSymbol } from './text-base-common';
import { TextBaseCommon, formattedTextProperty, textAlignmentProperty, textDecorationProperty, textProperty, textTransformProperty, textShadowProperty, letterSpacingProperty, whiteSpaceProperty, lineHeightProperty, isBold, resetSymbol } from './text-base-common';
import { Color } from '../../color';
import { colorProperty, fontSizeProperty, fontInternalProperty, paddingLeftProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty, Length } from '../styling/style-properties';
import { FormattedString } from './formatted-string';
@@ -378,6 +378,19 @@ export class TextBase extends TextBaseCommon {
}
}
[textShadowProperty.getDefault](value: number) {
return {
radius: this.nativeTextViewProtected.getShadowRadius(),
offsetX: this.nativeTextViewProtected.getShadowDx(),
offsetY: this.nativeTextViewProtected.getShadowDy(),
color: this.nativeTextViewProtected.getShadowColor(),
};
}
[textShadowProperty.setNative](value: TextShadow) {
this.nativeViewProtected.setShadowLayer(Length.toDevicePixels(value.blurRadius, 0), Length.toDevicePixels(value.offsetX, 0), Length.toDevicePixels(value.offsetY, 0), value.color.android);
}
[letterSpacingProperty.getDefault](): number {
return org.nativescript.widgets.ViewHelper.getLetterspacing(this.nativeTextViewProtected);
}