forked from ptomasroos/react-native-multi-slider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DefaultLabel.js
65 lines (54 loc) · 1.7 KB
/
DefaultLabel.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
import React from 'react';
import PropTypes from 'prop-types';
import { View, Text, StyleSheet, Platform, TouchableHighlight } from 'react-native';
const ViewPropTypes = require('react-native').ViewPropTypes || ViewPropTypes;
export default class DefaultLabel extends React.Component {
static propTypes = {
leftDiff: PropTypes.number,
labelStyle: ViewPropTypes.style,
labelTextStyle: ViewPropTypes.style,
oneMarkerValue: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number
]),
twoMarkerValue: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number
]),
oneMarkerLeftPosition: PropTypes.number,
twoMarkerLeftPosition: PropTypes.number
};
static defaultProps = {
leftDiff: 0,
labelStyle: {},
labelTextStyle: {}
};
render() {
const {leftDiff, labelStyle, labelTextStyle, oneMarkerValue, twoMarkerValue, oneMarkerLeftPosition, twoMarkerLeftPosition} = this.props;
return (
<View style={{position: 'relative'}}>
<View style={[styles.sliderLabel, {left: (oneMarkerLeftPosition - leftDiff)}, labelStyle]}>
<Text style={[styles.sliderLabelText, labelTextStyle]}>{oneMarkerValue}</Text>
</View>
<View style={[styles.sliderLabel, {left: (twoMarkerLeftPosition - leftDiff)}, labelStyle]}>
<Text style={[styles.sliderLabelText, labelTextStyle]}>{twoMarkerValue}</Text>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
sliderLabel: {
position: 'absolute',
top: -24,
minWidth: 51,
padding: 8,
backgroundColor: '#fff',
},
sliderLabelText: {
alignItems: 'center',
textAlign: 'center',
fontStyle: 'normal',
fontSize: 11
},
});