-
Notifications
You must be signed in to change notification settings - Fork 133
Expand file tree
/
Copy pathminExample
More file actions
77 lines (70 loc) · 1.89 KB
/
Copy pathminExample
File metadata and controls
77 lines (70 loc) · 1.89 KB
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
import React, {useCallback, useState} from 'react';
import {StyleSheet, Text, View} from 'react-native';
import Slider from 'rn-range-slider';
import {moderateScale, SCREEN_WIDTH} from '../constants/scaling';
import colors from '../constants/theme';
const Thumb = () => {
return <View style={{width: 20, height: 20, backgroundColor: 'green'}} />;
};
const Rail = () => {
return (
<View
style={{
height: 5,
width: '100%',
backgroundColor: 'yellow',
}}
/>
);
};
const RailSelected = () => {
return <View style={{backgroundColor: 'red'}} />;
};
const Label = () => {
return (
<View>
<Text>ia ma label</Text>
</View>
);
};
const Notch = () => {
return <View style={{backgroundColor: 'blue', width: 6, height: 6}} />;
};
const CustomRangeSlider = () => {
const [low, setLow] = useState(0);
const [high, setHigh] = useState(100);
const renderThumb = useCallback(() => <Thumb />, []);
const renderRail = useCallback(() => <Rail />, []);
const renderRailSelected = useCallback(() => <RailSelected />, []);
const renderLabel = useCallback(value => <Label text={value} />, []);
const renderNotch = useCallback(() => <Notch />, []);
const handleValueChange = useCallback((low, high) => {
console.log(low, high);
setLow(low);
setHigh(high);
}, []);
return (
<Slider
style={styles.slider}
min={30}
max={100}
step={1}
renderThumb={renderThumb}
renderRail={renderRail}
renderRailSelected={renderRailSelected}
renderLabel={renderLabel}
renderNotch={renderNotch}
onValueChanged={handleValueChange}
/>
);
};
export default CustomRangeSlider;
const styles = StyleSheet.create({
slider: {
width: SCREEN_WIDTH - moderateScale(16),
marginTop: moderateScale(5),
backgroundColor: colors.white,
justifyContent: 'center',
height: moderateScale(45),
},
});