forked from prscX/react-native-fluidic-slider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRNFluidicSlider.js
66 lines (52 loc) · 1.46 KB
/
RNFluidicSlider.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
import React, { Component } from "react";
import { StyleSheet, ViewPropTypes, Platform } from "react-native";
import PropTypes from "prop-types";
import { requireNativeComponent } from "react-native";
import style from './RNFluidicSlider.style'
class RNFluidicSlider extends Component {
static propTypes = {
...ViewPropTypes,
min: PropTypes.number,
max: PropTypes.number,
initialPosition: PropTypes.number,
barColor: PropTypes.string,
bubbleColor: PropTypes.string,
barTextColor: PropTypes.string,
bubbleTextColor: PropTypes.string,
beginTracking: PropTypes.func,
endTracking: PropTypes.func
};
static defaultProps = {
min: 0,
max: 100,
initialPosition: 0.5,
barColor: "#6168e7",
bubbleColor: "#FFFFFF",
barTextColor: "#FFFFFF",
bubbleTextColor: "#000000"
};
_onChange = (event, position) => {
if (event.nativeEvent.event === "beginTracking") {
this.props.beginTracking && this.props.beginTracking(event.nativeEvent.value)
} else if (event.nativeEvent.event === "endTracking") {
this.props.endTracking && this.props.endTracking(event.nativeEvent.value);
}
};
render() {
return (
<FluidicSlider
style={style.container}
onChange={this._onChange}
{...this.props}
/>
);
}
}
const FluidicSlider = requireNativeComponent(
"RNFluidicSlider",
RNFluidicSlider,
{
nativeOnly: { onChange: true }
}
);
export { RNFluidicSlider };