Last active
November 26, 2017 20:44
-
-
Save diogocapela/0bbba701ee74012361f1005bd6d3c28d to your computer and use it in GitHub Desktop.
react-native components
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 from 'react'; | |
import { View } from 'react-native'; | |
const Card = (props) => { | |
return ( | |
<View style={styles.containerStyle}> | |
{props.children} | |
</View> | |
); | |
}; | |
const styles = { | |
containerStyle: { | |
borderWidth: 1, | |
borderRadius: 2, | |
borderColor: '#ddd', | |
borderBottomWidth: 0, | |
shadowColor: '#000', | |
shadowOffset: { width: 0, height: 2 }, | |
shadowOpacity: 0.1, | |
shadowRadius: 2, | |
elevation: 1, | |
marginLeft: 5, | |
marginRight: 5, | |
marginTop: 10 | |
} | |
}; | |
export default Card; |
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 from 'react'; | |
import { View } from 'react-native'; | |
const CardSection = (props) => { | |
return ( | |
<View style={styles.containerStyle}> | |
{props.children} | |
</View> | |
); | |
}; | |
const styles = { | |
containerStyle: { | |
borderBottomWidth: 1, | |
padding: 5, | |
backgroundColor: '#fff', | |
justifyContent: 'flex-start', | |
flexDirection: 'row', | |
borderColor: '#ddd', | |
position: 'relative' | |
} | |
}; | |
export default CardSection; |
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 libraries for making a component | |
import React from 'react'; | |
import { Text, View } from 'react-native'; | |
// Make a component | |
const Header = (props) => { | |
const { textStyle, viewStyle } = styles; | |
return ( | |
<View style={viewStyle}> | |
<Text style={textStyle}>{props.headerText}</Text> | |
</View> | |
); | |
}; | |
const styles = { | |
viewStyle: { | |
backgroundColor: '#F8F8F8', | |
justifyContent: 'center', | |
alignItems: 'center', | |
height: 60, | |
paddingTop: 15, | |
shadowColor: '#000', | |
shadowOffset: { width: 0, height: 2 }, | |
shadowOpacity: 0.2, | |
elevation: 2, | |
position: 'relative' | |
}, | |
textStyle: { | |
fontSize: 20 | |
} | |
}; | |
// Make the component available to other parts of the app | |
export default Header; |
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 from 'react'; | |
import { TextInput, View, Text } from 'react-native'; | |
const Input = ({ label, value, onChangeText, placeholder, secureTextEntry }) => { | |
const { inputStyle, labelStyle, containerStyle } = styles; | |
return ( | |
<View style={containerStyle}> | |
<Text style={labelStyle}>{label}</Text> | |
<TextInput | |
secureTextEntry={secureTextEntry} | |
placeholder={placeholder} | |
autoCorrect={false} | |
style={inputStyle} | |
value={value} | |
onChangeText={onChangeText} | |
/> | |
</View> | |
); | |
}; | |
const styles = { | |
inputStyle: { | |
color: '#000', | |
paddingRight: 5, | |
paddingLeft: 5, | |
fontSize: 18, | |
lineHeight: 23, | |
flex: 2 | |
}, | |
labelStyle: { | |
fontSize: 18, | |
paddingLeft: 20, | |
flex: 1 | |
}, | |
containerStyle: { | |
height: 40, | |
flex: 1, | |
flexDirection: 'row', | |
alignItems: 'center' | |
} | |
}; | |
export { Input }; |
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 from 'react'; | |
import { View, ActivityIndicator } from 'react-native'; | |
const Spinner = ({ size }) => { | |
return ( | |
<View style={styles.spinnerStyle}> | |
<ActivityIndicator size={size || 'large'} /> | |
</View> | |
); | |
}; | |
const styles = { | |
spinnerStyle: { | |
flex: 1, | |
justifyContent: 'center', | |
alignItems: 'center' | |
} | |
}; | |
export { Spinner }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment