-
Notifications
You must be signed in to change notification settings - Fork 21
/
VolumeSlider.js
88 lines (69 loc) · 1.9 KB
/
VolumeSlider.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
/* @flow */
'use strict';
import { requireNativeComponent, StyleSheet, Image } from 'react-native';
import React, { Component } from 'react';
import PropTypes from 'prop-types'
type Event = Object;
class VolumeSlider extends Component {
static propTypes = {
/**
* The color used for the thumb.
*/
thumbTintColor: PropTypes.string,
/**
* The image for the thumb
*/
thumbImage: Image.propTypes.source,
/**
* The size of the thumb area that allows moving the thumb.
* The default is {width: 23, height: 23}.
*/
thumbSize: PropTypes.shape({
width: PropTypes.number,
height: PropTypes.number
}),
/**
* The color used for the track to the left of the button. Overrides the
* default blue gradient image.
*/
minimumTrackTintColor: PropTypes.string,
/**
* The color used for the track to the right of the button. Overrides the
* default blue gradient image.
*/
maximumTrackTintColor: PropTypes.string,
/**
* Specifies whether or not to show the route button for airplay
*/
showsRouteButton: PropTypes.bool,
/**
* Callback continuously called while the user is dragging the slider.
*/
onValueChange: PropTypes.func
};
static defaultProps = {
thumbSize: { width: 23, height: 23 },
showsRouteButton: true
};
render() {
const onValueChange = this.props.onValueChange && ((event: Event) => {
this.props.onValueChange &&
this.props.onValueChange(event.nativeEvent.value);
});
const { style, ...rest } = this.props;
return (
<RNVolumeView
{...rest}
onValueChange={onValueChange}
style={[styles.slider, style]}
/>
);
}
}
const styles = StyleSheet.create({
slider: {
height: 23,
},
});
const RNVolumeView = requireNativeComponent('VolumeSlider', VolumeSlider);
export default VolumeSlider