From 3e001ff9e72e4bc267ddd56bf5412a9dca08bbf2 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Fri, 19 Feb 2021 22:48:51 -0800 Subject: [PATCH] chore: cleanup --- packages/core/ui/styling/background-common.ts | 8 ++++---- packages/core/ui/styling/background.ios.ts | 14 ++++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/core/ui/styling/background-common.ts b/packages/core/ui/styling/background-common.ts index eaf515308..a6d86886b 100644 --- a/packages/core/ui/styling/background-common.ts +++ b/packages/core/ui/styling/background-common.ts @@ -4,7 +4,7 @@ import { BackgroundRepeat } from '../styling/style-properties'; import { LinearGradient } from './linear-gradient'; // Types. import { Color } from '../../color'; -import { BoxShadow } from './box-shadow'; +import { CSSShadow } from './css-shadow'; export class Background implements BackgroundDefinition { public static default = new Background(); @@ -27,7 +27,7 @@ export class Background implements BackgroundDefinition { public borderBottomLeftRadius = 0; public borderBottomRightRadius = 0; public clipPath: string; - public boxShadow: BoxShadow; + public boxShadow: CSSShadow; private clone(): Background { const clone = new Background(); @@ -181,7 +181,7 @@ export class Background implements BackgroundDefinition { return clone; } - public withBoxShadow(value: BoxShadow): Background { + public withBoxShadow(value: CSSShadow): Background { const clone = this.clone(); clone.boxShadow = value; @@ -288,7 +288,7 @@ export class Background implements BackgroundDefinition { return !!this.boxShadow; } - public getBoxShadow(): BoxShadow { + public getBoxShadow(): CSSShadow { return this.boxShadow; } diff --git a/packages/core/ui/styling/background.ios.ts b/packages/core/ui/styling/background.ios.ts index 59e670037..5096a8aeb 100644 --- a/packages/core/ui/styling/background.ios.ts +++ b/packages/core/ui/styling/background.ios.ts @@ -8,6 +8,7 @@ import { isDataURI, isFileOrResourcePath, layout } from '../../utils'; import { ImageSource } from '../../image-source'; import { CSSValue, parse as cssParse } from '../../css-value'; import { CSSShadow } from './css-shadow'; +import { Length } from './style-properties'; export * from './background-common'; @@ -717,12 +718,13 @@ function drawNoRadiusNonUniformBorders(nativeView: NativeView, background: Backg // TODO: use sublayer if its applied to a layout function drawBoxShadow(nativeView: NativeView, view: View, boxShadow: CSSShadow, background: BackgroundDefinition, useSubLayer: boolean = false) { + // TODO: fine named 'shadow-layer' first and otherwise need to search through sublayers (need logic used in text-shadow for layer - see getShadowLayer) const layer: CALayer = nativeView.layer; layer.masksToBounds = false; nativeView.clipsToBounds = false; - - // this is required (if not, shadow will get cutoff at parent's dimensions) + + // this is required (if not, shadow will get cutoff at parent's dimensions) // nativeView.clipsToBounds doesn't work view.setProperty('clipToBounds', false); @@ -731,13 +733,13 @@ function drawBoxShadow(nativeView: NativeView, view: View, boxShadow: CSSShadow, layer.backgroundColor = UIColor.whiteColor.CGColor; } // shadow opacity is handled on the shadow's color instance - layer.shadowOpacity = 1; - layer.shadowRadius = layout.toDeviceIndependentPixels(boxShadow.spreadRadius); + layer.shadowOpacity = background.color?.a ? background.color?.a / 255 : 1; + layer.shadowRadius = Length.toDevicePixels(boxShadow.spreadRadius); layer.shadowColor = boxShadow.color.ios.CGColor; const adjustedShadowOffset = { - x: layout.toDeviceIndependentPixels(boxShadow.offsetX), - y: layout.toDeviceIndependentPixels(boxShadow.offsetY), + x: Length.toDevicePixels(boxShadow.offsetX), + y: Length.toDevicePixels(boxShadow.offsetY), }; layer.shadowOffset = CGSizeMake(adjustedShadowOffset.x, adjustedShadowOffset.y);