Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix surface component for Android #3149

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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