-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ios.js
99 lines (90 loc) · 2.69 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
97
98
99
'use strict';
var React = require('react-native');
var Spinner = require('react-native-spinner');
var {
View,
AppRegistry,
StyleSheet,
Text,
TextInput,
SwitchIOS,
} = React;
var xspinner = React.createClass({
getInitialState: function () {
return {
step: '2',
disabled: false,
spinnerVal: '5',
settedSpinnerVal: '5'
}
},
getSpinnerValue: function(val){
this.setState({spinnerVal: val})
},
render: function () {
return (
<View style={styles.container}>
<Spinner
value={this.state.spinnerVal}
step={this.state.step}
disabled={this.state.disabled}
onChange={this.getSpinnerValue}
/>
<View style={styles.operation}>
<Text>设置step</Text>
<TextInput
style={[styles.opeComponent, styles.input]}
onChangeText={(text) => this.setState({step: text})}
value={this.state.step}
/>
</View>
<View style={styles.operation}>
<Text>Set value</Text>
<TextInput
style={[styles.opeComponent, styles.input]}
onChangeText={(text) => this.setState({spinnerVal: text})}
value={String(this.state.settedSpinnerVal)}
/>
</View>
<View style={styles.operation}>
<Text>Get value</Text>
<Text style={styles.opeComponent}>
{this.state.spinnerVal}
</Text>
</View>
<View style={styles.operation}>
<Text>设置disabled</Text>
<SwitchIOS
style={styles.opeComponent}
onValueChange={(value) => this.setState({disabled: value})}
value={this.state.disabled} />
</View>
</View>
);
}
});
var styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#f2f2f2',
paddingTop: 30,
paddingLeft: 10,
paddingRight: 10
},
operation: {
marginTop: 20
},
opeComponent: {
marginTop: 5
},
input: {
height: 30,
paddingTop: 5,
paddingBottom: 5,
paddingLeft: 5,
paddingRight: 5,
borderColor: 'gray',
borderWidth: 1
},
});
AppRegistry.registerComponent('xspinner', () => xspinner);