Skip to content

Commit cf1a668

Browse files
refactor: remove middle layer in Surface
1 parent 75de389 commit cf1a668

File tree

1 file changed

+13
-29
lines changed

1 file changed

+13
-29
lines changed

src/components/Surface.tsx

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -238,21 +238,16 @@ const Surface = forwardRef<View, Props>(
238238
...restStyle
239239
} = (StyleSheet.flatten(style) || {}) as ViewStyle;
240240

241-
const [filteredStyle, borderRadiusStyle, marginStyle] = splitStyles(
242-
restStyle,
243-
(style) => style.startsWith('border') && style.endsWith('Radius'),
244-
(style) => style.startsWith('margin')
241+
const [filteredStyle, marginStyle] = splitStyles(restStyle, (style) =>
242+
style.startsWith('margin')
245243
);
246244

247-
const sharedStyles = {
248-
flex: height ? 1 : undefined,
249-
};
250-
251245
const innerLayerViewStyles = [
252246
filteredStyle,
253-
sharedStyles,
254-
borderRadiusStyle,
255-
{ backgroundColor: backgroundColorStyle || backgroundColor },
247+
{
248+
flex: height ? 1 : undefined,
249+
backgroundColor: backgroundColorStyle || backgroundColor,
250+
},
256251
];
257252

258253
const outerLayerViewStyles = {
@@ -303,16 +298,10 @@ const Surface = forwardRef<View, Props>(
303298
testID={`${testID}-outer-layer`}
304299
>
305300
<Animated.View
306-
style={[getStyleForAnimatedShadowLayer(1), sharedStyles]}
307-
testID={`${testID}-middle-layer`}
301+
style={[getStyleForAnimatedShadowLayer(1), innerLayerViewStyles]}
302+
testID={testID}
308303
>
309-
<Animated.View
310-
{...props}
311-
testID={testID}
312-
style={innerLayerViewStyles}
313-
>
314-
{children}
315-
</Animated.View>
304+
{children}
316305
</Animated.View>
317306
</Animated.View>
318307
);
@@ -339,16 +328,11 @@ const Surface = forwardRef<View, Props>(
339328
testID={`${testID}-outer-layer`}
340329
>
341330
<Animated.View
342-
style={[getStyleForShadowLayer(1), sharedStyles]}
343-
testID={`${testID}-middle-layer`}
331+
{...props}
332+
style={[getStyleForShadowLayer(1), innerLayerViewStyles]}
333+
testID={testID}
344334
>
345-
<Animated.View
346-
{...props}
347-
testID={testID}
348-
style={innerLayerViewStyles}
349-
>
350-
{children}
351-
</Animated.View>
335+
{children}
352336
</Animated.View>
353337
</Animated.View>
354338
);

0 commit comments

Comments
 (0)