From 5f594b4c23b19301dad22cba583b414b69a62cc9 Mon Sep 17 00:00:00 2001 From: lyzhan7 <78454019+lyzhan7@users.noreply.github.com> Date: Wed, 10 Aug 2022 16:23:33 -0700 Subject: [PATCH 1/4] Copy Liron's fix --- React/Views/RCTView.m | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/React/Views/RCTView.m b/React/Views/RCTView.m index 9999bb086a9f74..a82da584fbc744 100644 --- a/React/Views/RCTView.m +++ b/React/Views/RCTView.m @@ -716,6 +716,21 @@ - (NSString *)description #endif // TODO(macOS GH#774) #if TARGET_OS_OSX // [TODO(macOS GH#774) +- (NSShadow*)shadow { + CALayer *layer = self.layer; + + // Workaround AppKit issue with directly manipulating the view layer's shadow. + if (layer.shadowColor != nil && layer.shadowOpacity > 0) { + NSShadow *shadow = [NSShadow new]; + + shadow.shadowColor = [NSColor colorWithCGColor:layer.shadowColor]; + shadow.shadowOffset = layer.shadowOffset; + shadow.shadowBlurRadius = layer.shadowRadius; + + return shadow; + } + return nil; +} - (void)viewDidMoveToWindow { // Subscribe to view bounds changed notification so that the view can be notified when a From 0051dac56dd310571ea19224dd264e834f47f95e Mon Sep 17 00:00:00 2001 From: lyzhan7 <78454019+lyzhan7@users.noreply.github.com> Date: Wed, 10 Aug 2022 16:23:50 -0700 Subject: [PATCH 2/4] Update with shadowOpacity --- React/Views/RCTView.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/React/Views/RCTView.m b/React/Views/RCTView.m index a82da584fbc744..981f4037ef1803 100644 --- a/React/Views/RCTView.m +++ b/React/Views/RCTView.m @@ -723,7 +723,7 @@ - (NSShadow*)shadow { if (layer.shadowColor != nil && layer.shadowOpacity > 0) { NSShadow *shadow = [NSShadow new]; - shadow.shadowColor = [NSColor colorWithCGColor:layer.shadowColor]; + shadow.shadowColor = [[NSColor colorWithCGColor:layer.shadowColor] colorWithAlphaComponent:layer.shadowOpacity]; shadow.shadowOffset = layer.shadowOffset; shadow.shadowBlurRadius = layer.shadowRadius; From 14bc46a090918bd15f7b18f0db0cf1334863186a Mon Sep 17 00:00:00 2001 From: lyzhan7 <78454019+lyzhan7@users.noreply.github.com> Date: Wed, 10 Aug 2022 17:08:31 -0700 Subject: [PATCH 3/4] Formatting in response to comments --- React/Views/RCTView.m | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/React/Views/RCTView.m b/React/Views/RCTView.m index 981f4037ef1803..1b4949d68cc206 100644 --- a/React/Views/RCTView.m +++ b/React/Views/RCTView.m @@ -716,21 +716,22 @@ - (NSString *)description #endif // TODO(macOS GH#774) #if TARGET_OS_OSX // [TODO(macOS GH#774) -- (NSShadow*)shadow { +// Workaround AppKit issue with directly manipulating the view layer's shadow. +- (NSShadow*)shadow +{ CALayer *layer = self.layer; + NSShadow shadow = nil; - // Workaround AppKit issue with directly manipulating the view layer's shadow. if (layer.shadowColor != nil && layer.shadowOpacity > 0) { - NSShadow *shadow = [NSShadow new]; - + shadow = [NSShadow new]; + shadow.shadowColor = [[NSColor colorWithCGColor:layer.shadowColor] colorWithAlphaComponent:layer.shadowOpacity]; shadow.shadowOffset = layer.shadowOffset; shadow.shadowBlurRadius = layer.shadowRadius; - - return shadow; } - return nil; + return shadow; } + - (void)viewDidMoveToWindow { // Subscribe to view bounds changed notification so that the view can be notified when a From 5c7a48c039d25318c0d9abc3d13523c302b24111 Mon Sep 17 00:00:00 2001 From: lyzhan7 <78454019+lyzhan7@users.noreply.github.com> Date: Wed, 10 Aug 2022 17:46:49 -0700 Subject: [PATCH 4/4] Fix build break attempt --- React/Views/RCTView.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/React/Views/RCTView.m b/React/Views/RCTView.m index 1b4949d68cc206..df7e8dcbcc7cfb 100644 --- a/React/Views/RCTView.m +++ b/React/Views/RCTView.m @@ -720,11 +720,11 @@ - (NSString *)description - (NSShadow*)shadow { CALayer *layer = self.layer; - NSShadow shadow = nil; + NSShadow *shadow = nil; if (layer.shadowColor != nil && layer.shadowOpacity > 0) { shadow = [NSShadow new]; - + shadow.shadowColor = [[NSColor colorWithCGColor:layer.shadowColor] colorWithAlphaComponent:layer.shadowOpacity]; shadow.shadowOffset = layer.shadowOffset; shadow.shadowBlurRadius = layer.shadowRadius;