Make default shadow color black (#46053)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46053

tsia, default should be black like android

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D61370471

fbshipit-source-id: a69933049f9db30a17322bd53ef30035ae145a63
This commit is contained in:
Joe Vilches
2024-08-15 20:59:11 -07:00
committed by Facebook GitHub Bot
parent cae9ae5b48
commit de39ebb9f8
@@ -10,6 +10,8 @@
#import <CoreImage/CoreImage.h>
#import <React/RCTConversions.h>
#import <react/renderer/graphics/Color.h>
#import <math.h>
using namespace facebook::react;
@@ -82,6 +84,12 @@ static CGRect insetRect(CGRect rect, CGFloat left, CGFloat top, CGFloat right, C
rect.origin.x + left, rect.origin.y + top, rect.size.width - right - left, rect.size.height - bottom - top);
}
static CGColorRef colorRefFromSharedColor(const SharedColor &color)
{
CGColorRef colorRef = RCTUIColorFromSharedColor(color).CGColor;
return colorRef ? colorRef : [UIColor blackColor].CGColor;
}
// Core graphics has support for shadows that looks similar to web and are very
// fast to apply. The only issue is that this shadow does not take a spread
// radius like on web. To get around this, we draw the shadow rect (the rect
@@ -110,7 +118,7 @@ static void renderOutsetShadows(
CGFloat offsetY = it->offsetY;
CGFloat blurRadius = it->blurRadius;
CGFloat spreadDistance = it->spreadDistance;
CGColorRef color = RCTUIColorFromSharedColor(it->color).CGColor;
CGColorRef color = colorRefFromSharedColor(it->color);
// First, define the shadow rect. This is the rect that will be filled
// and _cast_ the shadow. As a result, the size does not incorporate
@@ -211,7 +219,7 @@ static void renderInsetShadows(
CGFloat offsetY = it->offsetY;
CGFloat blurRadius = it->blurRadius;
CGFloat spreadDistance = it->spreadDistance;
CGColorRef color = RCTUIColorFromSharedColor(it->color).CGColor;
CGColorRef color = colorRefFromSharedColor(it->color);
// Second, create the two offscreen rects we will use to create the correct
// inset shadow shape. shadowRect has an originX such that it AND the clear