forked from driusan/brainviewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSegmentSlider.js
28 lines (26 loc) · 914 Bytes
/
SegmentSlider.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
import React from 'react';
import { View, Text, Dimensions } from 'react-native';
import Slider from '@react-native-community/slider';
export function SegmentSlider(props) {
// Calculate the width based on the screen dimensions
const { width } = Dimensions.get('window');
const sliderWidth = width * 0.9; // 70% of screen width
const label = props.label ? <View><Text>{props.label}</Text></View> : null;
return (
<View style={{flex: 1, flexDirection: 'column'}}>
{label}
<Slider
aria-label={label}
step={1}
value={props.val}
maximumValue={parseInt(props.max, 10)}
onValueChange={(newValue) => props.onSliderChange(newValue)}
style={{ width: sliderWidth }}
valueLabelDisplay="on"
/>
<View style={{flex: 1, flexDirection: 'row', justifyContent: 'center'}}>
<Text>{props.val}</Text>
</View>
</View>
);
}