I want to build a reusable component which can be docked to any edge of the parent container, please refer the following image for reference
I can't use the flex for the blocks since there is supposed to be stuff rendered behind them in the parent container
I have only tried for the left aligned so far and it doesn't work the way I want it
// styles.js
import { StyleSheet } from 'react-native'
import { COLOR, BORDER_RADIUS } from 'app/constants'
export default StyleSheet.create({
container: {
alignItems: 'center',
},
box: {
borderWidth: 1,
borderColor: COLOR.grey_cl,
borderRadius: BORDER_RADIUS.normal,
backgroundColor: 'red',
},
boxTopAligned: {},
boxRightAligned: {},
boxBottomAligned: {},
containerLeftAligned: {
position: 'absolute',
top: 0,
left: 0,
bottom: 0,
flex: 1,
alignItems: 'stretch',
justifyContent: 'center',
},
boxLeftAligned: {
textAlign: 'center',
left: 0,
transform: [{ rotate: '90deg' }],
},
})
JSX
<View style={[[styles.container, styles.containerLeftAligned]]}>
<View
style={[
HELPER_STYLES.paddingNormal,
HELPER_STYLES.center,
styles.box,
styles.boxLeftAligned,
]}
>
<Text>{props.text}</Text>
</View>
</View>