Created
March 29, 2018 22:41
-
-
Save JamesZoft/388afb5c7f6f17211d29042939d74b59 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
export default class App extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
diceType: 6, | |
diceNumber: 2, | |
}; | |
} | |
render() { | |
return ( | |
<View style={{flex: 1, flexDirection: 'column'}}> | |
<View style={{width: 400, height: 200, backgroundColor: 'powderblue'}} > | |
{[...Array(this.state.diceNumber)].map((dieNumber, index) => | |
<Text> | |
{Math.floor(Math.random() * this.state.diceType) + 1} | |
</Text> | |
)} | |
</View> | |
<View style={{width: 400, height: 200, backgroundColor: 'skyblue', flexDirection: 'row'}} > | |
<View style={{width: 200}} > | |
<FloatLabelTextInput | |
placeholder={"Dice Type (d4, d6...)"} | |
value={this.state.diceType} | |
onChangeText={(text) => this.setState({diceType: text})} | |
/> | |
</View> | |
<View style={{width: 200}} > | |
<FloatLabelTextInput | |
placeholder={"Number of dice to roll"} | |
value={this.state.diceNumber} | |
onChangeText={(text) => this.setState({diceNumber: text})} | |
/> | |
</View> | |
</View> | |
</View> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment