Created
October 7, 2019 15:43
-
-
Save jasonmerino/d07d683ea28b2cd0b9d4dcf6954c73e8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import React, { FC } from 'react'; | |
import { | |
ViewProps, | |
View, | |
FlexAlignType, | |
ViewStyle, | |
StyleProp, | |
} from 'react-native'; | |
interface IProps extends ViewProps { | |
alignHorizontal?: | |
| 'flex-start' | |
| 'flex-end' | |
| 'center' | |
| 'space-between' | |
| 'space-around' | |
| 'space-evenly'; | |
alignVertical?: FlexAlignType; | |
flex?: boolean; | |
} | |
export const Row: FC<IProps> = props => { | |
const { style, flex, alignVertical, alignHorizontal, ...viewProps } = props; | |
const styles: StyleProp<ViewStyle>[] = [style, { flexDirection: 'row' }]; | |
if (flex) { | |
styles.push({ flex: 1 }); | |
} | |
if (alignVertical !== undefined) { | |
styles.push({ alignItems: alignVertical }); | |
} | |
if (alignHorizontal !== undefined) { | |
styles.push({ justifyContent: alignHorizontal }); | |
} | |
return <View style={styles} {...viewProps} />; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment