From 726ef9fd8fc57294368a0e523733b70230b4e191 Mon Sep 17 00:00:00 2001 From: Igor Randjelovic Date: Sat, 20 Feb 2021 00:38:52 +0100 Subject: [PATCH] chore: cleanup --- packages/core/ui/styling/css-shadow.ts | 9 ++++++--- packages/core/ui/text-base/index.ios.ts | 9 ++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/core/ui/styling/css-shadow.ts b/packages/core/ui/styling/css-shadow.ts index 7a5593fe5..c8820f3b0 100644 --- a/packages/core/ui/styling/css-shadow.ts +++ b/packages/core/ui/styling/css-shadow.ts @@ -1,5 +1,5 @@ import { Color } from '../../color'; -import { Length } from './style-properties'; +import { Length, zeroLength } from './style-properties'; export interface CSSShadow { inset: boolean; @@ -49,8 +49,11 @@ export function parseCSSShadow(value: string): CSSShadow { .filter((n) => n !== 'inset') .filter((n) => n !== colorRaw) .map((val) => { - console.log(val); - return Length.parse(val); + try { + return Length.parse(val); + } catch (err) { + return zeroLength; + } }); const [offsetX, offsetY, blurRadius, spreadRadius] = nums; diff --git a/packages/core/ui/text-base/index.ios.ts b/packages/core/ui/text-base/index.ios.ts index a0bd7a9a3..7fcf4e961 100644 --- a/packages/core/ui/text-base/index.ios.ts +++ b/packages/core/ui/text-base/index.ios.ts @@ -9,7 +9,7 @@ import { Color } from '../../color'; import { FormattedString } from './formatted-string'; import { Span } from './span'; import { colorProperty, fontInternalProperty, Length, VerticalAlignment } from '../styling/style-properties'; -import { isString, isDefined, isNullOrUndefined } from '../../utils/types'; +import { isString, isNullOrUndefined } from '../../utils/types'; import { iOSNativeHelper } from '../../utils'; import { Trace } from '../../trace'; @@ -153,8 +153,7 @@ export class TextBase extends TextBaseCommon { if (!(value instanceof Font) || !this.formattedText) { let nativeView = this.nativeTextViewProtected; nativeView = nativeView instanceof UIButton ? nativeView.titleLabel : nativeView; - const font = value instanceof Font ? value.getUIFont(nativeView.font) : value; - nativeView.font = font; + nativeView.font = value instanceof Font ? value.getUIFont(nativeView.font) : value; } } @@ -190,7 +189,7 @@ export class TextBase extends TextBaseCommon { this._setNativeText(); } - [textShadowProperty.setNative](value: TextShadow) { + [textShadowProperty.setNative](value: CSSShadow) { this._setShadow(value); } @@ -378,7 +377,7 @@ export class TextBase extends TextBaseCommon { // layer.shadowOffset = CGSizeMake(Length.toDevicePixels(value.offsetX), Length.toDevicePixels(value.offsetY)); layer.masksToBounds = false; - // NOTE: generally should not need shouldRaterize + // NOTE: generally should not need shouldRasterize // however for various detailed animation work which involves text-shadow applicable layers, we may want to give users the control of enabling this with text-shadow // if (!(this.nativeTextViewProtected instanceof UITextView)) { // layer.shouldRasterize = true;