forked from JackDanielsAndCode/react-native-multi-slider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ios.js
121 lines (108 loc) · 2.8 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
'use strict';
var ReactNative = require('react-native');
var {
AppRegistry,
StyleSheet,
View,
Text,
SliderIOS,
Image
} = ReactNative;
var createReactClass = require('create-react-class');
var MultiSlider = require('./Slider.js');
var customMarker = require('./customMarker.js');
var Slider = createReactClass({
getInitialState: function () {
return {
sliderOneChanging: false,
sliderOneValue: [5]
}
},
SliderOneValuesChangeStart: function () {
this.setState({
sliderOneChanging: true
})
},
SliderOneValuesChange: function (values) {
this.setState({
sliderOneValue: values[0]
})
},
SliderOneValuesChangeFinish: function () {
this.setState({
sliderOneChanging: false
})
},
render: function() {
return (
<View style={styles.container}>
<Text style={styles.title}>Sliders</Text>
<View style={styles.sliders}>
<View style={styles.sliderOne}>
<Text style={styles.text}>One Marker with callback example:</Text>
<Text style={[styles.text, this.state.sliderOneChanging && {color:'red'}]}>{this.state.sliderOneValue}</Text>
</View>
<MultiSlider
values={this.state.sliderOneValue}
sliderLength={280}
onValuesChangeStart={this.SliderOneValuesChangeStart}
onValuesChange={this.SliderOneValuesChange}
onValuesChangeFinish={this.SliderOneValuesChangeFinish}
/>
<Text style={styles.text}>Two Markers</Text>
<MultiSlider values={[3,7]} sliderLength={280} />
<Text style={styles.text}>Custom Marker</Text>
<MultiSlider
selectedStyle={{
backgroundColor: 'gold'
}}
unselectedStyle={{
backgroundColor: 'silver'
}}
values={[5]}
containerStyle={{
height:40,
}}
trackStyle={{
height:10,
backgroundColor: 'red'
}}
touchDimensions={{
height: 40,
width: 40,
borderRadius: 20,
slipDisplacement: 40
}}
customMarker={customMarker}
sliderLength={280} />
<Text style={styles.text}>Native RCT Slider</Text>
<SliderIOS />
</View>
</View>
);
}
});
var styles = StyleSheet.create({
container: {
flex:1,
flexDirection:'column',
justifyContent: 'space-around',
alignItems: "center",
},
sliders: {
margin: 20,
width: 280
},
text: {
alignSelf: "center",
paddingVertical: 20
},
title: {
fontSize:30
},
sliderOne: {
flexDirection: 'row',
justifyContent: 'space-around'
}
});
AppRegistry.registerComponent('Slider', () => Slider);