Skip to content

Instantly share code, notes, and snippets.

@patcito
Created June 11, 2017 10:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patcito/c6b14786375507df0204dbd2b74608e1 to your computer and use it in GitHub Desktop.
Save patcito/c6b14786375507df0204dbd2b74608e1 to your computer and use it in GitHub Desktop.
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