Created
May 1, 2016 17:16
-
-
Save peterlazar1993/c9b092bb2fe641fafcaf2f0a150161a9 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, { Component, StyleSheet, View } from 'react-native'; | |
import Emoji from './emoji'; | |
const styles = StyleSheet.create({ | |
container: { | |
flexDirection: 'row', | |
justifyContent: 'space-around', | |
marginTop: 5, | |
marginBottom: 5, | |
}, | |
}); | |
export default class EmojiStrip extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { selected: null, emoji: 'hello' }; | |
this.emojis = ['smiley', 'neutral_face', 'disappointed', 'x']; | |
} | |
onSelectEmoji = (emoji) => this.setState({ selected: emoji }); | |
isEmojiSelected = (emoji) => { | |
if (this.state.selected === emoji) { | |
return true; | |
} | |
return false; | |
} | |
renderEmojis = () => this.emojis.map((emoji, index) => | |
<Emoji | |
key={index} | |
emoji={emoji} | |
enabled={this.isEmojiSelected(emoji)} | |
onSelectEmoji={this.onSelectEmoji} | |
/> | |
); | |
render() { | |
return ( | |
<View style={styles.container}> | |
{ | |
this.renderEmojis() | |
} | |
</View> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment