-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
83 lines (75 loc) · 1.73 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import React from 'react';
import { StyleSheet, Slider, View } from 'react-native';
import DiceFrame from './DiceFrame.js'
export default class App extends React.Component {
constructor(props){
super(props);
this.state={
slideValue: 2,
}
}
render() {
diceList = [];
currentHBox = [];
for (let i = 0; i < this.state.slideValue; i++){
if (currentHBox.length == 0 && i+1 == this.state.slideValue){
diceList.push(
<View style={styles.hbox}>
<DiceFrame key={i}/>
</View>
);
break;
} else {
currentHBox.push(<DiceFrame key={i}/>)
}
if(currentHBox.length == 2){
diceList.push(
<View style={styles.hbox}>
{currentHBox.shift()}
{currentHBox.shift()}
</View>
);
}
}
return (
<View style={styles.container}>
{diceList}
<Slider
style={styles.slider}
step={1}
minimumValue={0}
maximumValue={6}
thumbTintColor='#000'
maximumTrackTintColor='#999'
minimumTrackTintColor='#555'
onValueChange={(slideValue) => this.setState({slideValue})}
value={this.state.slideValue}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
paddingTop: 30,
paddingBottom: 25,
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
slider: {
position: "absolute",
bottom: 5,
width: '80%',
zIndex: 100,
},
hbox: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
marginTop: 30,
paddingLeft: 20,
paddingRight: 20,
},
});