Created
June 11, 2017 10:08
-
-
Save patcito/c6b14786375507df0204dbd2b74608e1 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 from "react"; | |
import { StyleSheet, Text, View, Image, TouchableOpacity } from "react-native"; | |
export default class ToggleButton extends React.Component { | |
renderItem = (item, index, list) => { | |
return ( | |
<View | |
style={[ | |
styles.button, | |
{ | |
marginLeft: index !== 0 ? 10 : 0 | |
} | |
]} | |
key={item} | |
> | |
<Text style={styles.text}>{item}</Text> | |
</View> | |
); | |
}; | |
render() { | |
const { items, value } = this.props; | |
return ( | |
<View style={styles.container}> | |
{items.map(this.renderItem)} | |
</View> | |
); | |
} | |
} | |
const styles = StyleSheet.create({ | |
container: { | |
flexDirection: "row" | |
}, | |
button: { | |
backgroundColor: "purple", | |
height: 30, | |
justifyContent: "center", | |
alignItems: "center", | |
paddingHorizontal: 20, | |
borderRadius: 15 | |
}, | |
text: { | |
color: "white", | |
fontSize: 16 | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment