Skip to content

Commit

Permalink
fix: fix surface component for Android (#3149)
Browse files Browse the repository at this point in the history
  • Loading branch information
Drakeoon authored and lukewalczak committed Jun 8, 2022
1 parent e8b7515 commit 2e41bb7
Showing 1 changed file with 5 additions and 26 deletions.
31 changes: 5 additions & 26 deletions src/components/Surface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,9 @@ const Surface = ({
const sharedStyle = [{ backgroundColor }, style];

if (Platform.OS === 'android') {
const elevationLevels = [
[0, 1, 2, 3, 3, 3],
[0, 3, 4, 6, 8, 10],
];

const getElevationAndroid = (layer: 0 | 1) => {
const elevationLevel = elevationLevels[layer];
const elevationLevel = [0, 3, 6, 9, 12, 15];

const getElevationAndroid = () => {
if (isAnimatedValue(elevation)) {
return elevation.interpolate({
inputRange,
Expand All @@ -159,37 +154,21 @@ const Surface = ({
style
) as ViewStyle;

const clearStyles = {
margin: 0,
padding: 0,
transform: undefined,
};

const outerLayerStyles = { margin, padding, transform, borderRadius };

return (
<Animated.View
style={[
{
elevation: getElevationAndroid(0),
elevation: getElevationAndroid(),
backgroundColor,
transform,
},
outerLayerStyles,
sharedStyle,
]}
>
<Animated.View
style={[
{
elevation: getElevationAndroid(1),
borderRadius,
},
sharedStyle,
clearStyles,
]}
>
{children}
</Animated.View>
{children}
</Animated.View>
);
}
Expand Down

0 comments on commit 2e41bb7

Please sign in to comment.