-
Notifications
You must be signed in to change notification settings - Fork 300
/
index.ios.js
96 lines (75 loc) · 2.22 KB
/
index.ios.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
84
85
86
87
88
89
90
91
92
93
94
95
96
var React = require('react');
var ReactNative = require('react-native');
var {
AppRegistry,
StyleSheet,
View,
TouchableOpacity,
Text
} = ReactNative;
var Spinner = require('react-native-spinkit');
var Example = React.createClass({
getInitialState() {
return {
index: 0,
types: ['CircleFlip', 'Bounce', 'Wave', 'WanderingCubes', 'Pulse', 'ChasingDots', 'ThreeBounce', 'Circle', '9CubeGrid', 'WordPress', 'FadingCircle', 'FadingCircleAlt', 'Arc', 'ArcAlt'],
size: 100,
color: "#FFFFFF",
isVisible: true
}
},
next() {
if (this.state.index++ >= this.state.types.length)
this.setState({index: 0})
else
this.setState({index: this.state.index++})
},
increaseSize() {
this.setState({size: this.state.size + 10});
},
changeColor() {
this.setState({color: '#'+Math.floor(Math.random()*16777215).toString(16)});
},
changeVisibility() {
this.setState({isVisible: !this.state.isVisible});
},
render() {
var type = this.state.types[this.state.index];
return (
<View style={styles.container}>
<Spinner style={styles.spinner} isVisible={this.state.isVisible} size={this.state.size} type={type} color={this.state.color}/>
<Text style={styles.text}>Type: {type}</Text>
<TouchableOpacity style={styles.btn} onPress={this.next}>
<Text style={styles.text}>Next</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.btn} onPress={this.increaseSize}>
<Text style={styles.text}>Increase size</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.btn} onPress={this.changeColor}>
<Text style={styles.text}>Change color</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.btn} onPress={this.changeVisibility}>
<Text style={styles.text}>Change visibility</Text>
</TouchableOpacity>
</View>
);
}
});
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#d35400',
},
spinner: {
marginBottom: 50
},
btn: {
marginTop: 20
},
text: {
color: "white"
}
});
AppRegistry.registerComponent('Example', () => Example);