Last active
October 7, 2019 19:01
-
-
Save jasonmerino/97a6531835ca4525ec99dedb39d99030 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
import React, { FC } from 'react'; | |
import { ViewProps, View, FlexAlignType } from 'react-native'; | |
interface IProps extends ViewProps { | |
alignVertical?: | |
| 'flex-start' | |
| 'flex-end' | |
| 'center' | |
| 'space-between' | |
| 'space-around' | |
| 'space-evenly'; | |
alignHorizontal?: FlexAlignType; | |
flex?: boolean; | |
} | |
export const Column: FC<IProps> = props => { | |
const { style, flex, alignVertical, alignHorizontal, ...viewProps } = props; | |
const styles = [style]; | |
if (flex) { | |
styles.push({ flex: 1 }); | |
} | |
if (alignVertical !== undefined) { | |
styles.push({ justifyContent: alignVertical }); | |
} | |
if (alignHorizontal !== undefined) { | |
styles.push({ alignItems: alignHorizontal }); | |
} | |
return <View style={styles} {...viewProps} />; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment