Created
November 25, 2021 14:38
-
-
Save ruvaleev/2fffd08fe3ea2834d56dd68c91b96523 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const generateBoxShadowStyle = ( | |
xOffset, | |
yOffset, | |
shadowColorIos, | |
shadowOpacity, | |
shadowRadius, | |
elevation, | |
shadowColorAndroid, | |
) => { | |
if (Platform.OS === 'ios') { | |
// styles.boxShadow = { | |
return { | |
shadowColor: shadowColorIos, | |
shadowOffset: {width: xOffset, height: yOffset}, | |
shadowOpacity, | |
shadowRadius, | |
}; | |
} else if (Platform.OS === 'android') { | |
// styles.boxShadow = { | |
return { | |
elevation, | |
shadowColor: shadowColorAndroid, | |
}; | |
} else { | |
return { | |
boxShadow: '0px 0px 4px 4px rgba(0, 0, 0, 0.2)', | |
} | |
} | |
}; | |
// В компоненте теперь можно такое применять: | |
<View style={[generateBoxShadowStyle(-2, 4, 'black', 0.2, 3, 2, 'black'), styles.someStyle]}></View> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment