Skip to content

Instantly share code, notes, and snippets.

@JamesZoft
Created March 29, 2018 22:41
Show Gist options
  • Save JamesZoft/388afb5c7f6f17211d29042939d74b59 to your computer and use it in GitHub Desktop.
Save JamesZoft/388afb5c7f6f17211d29042939d74b59 to your computer and use it in GitHub Desktop.
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