-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgressBar.js
70 lines (67 loc) · 1.71 KB
/
ProgressBar.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
import React from "react";
import Slider from "@react-native-community/slider";
import { View, Text, StyleSheet } from "react-native";
export const ProgressBar = ({
currentTime,
duration,
onSlideCapture,
onSlideStart,
onSlideComplete
}) => {
function getMinutesFromSeconds(time) {
const minutes = time >= 60 ? Math.floor(time / 60) : 0;
const seconds = Math.floor(time - minutes * 60);
return `${minutes >= 10 ? minutes : "0" + minutes}:${
seconds >= 10 ? seconds : "0" + seconds
}`;
}
function handleOnSlide(time) {
onSlideCapture({ seekTime: parseInt(time) });
}
const position = getMinutesFromSeconds(currentTime);
const fullDuration = getMinutesFromSeconds(duration);
return (
<View style={styles.wrapper}>
<Slider
value={currentTime}
minimumValue={0}
maximumValue={duration}
step={1}
onValueChange={handleOnSlide}
onSlidingStart={onSlideStart}
onSlidingComplete={onSlideComplete}
minimumTrackTintColor={"#F44336"}
maximumTrackTintColor={"#FFFFFF"}
thumbTintColor={"#F44336"}
/>
{/* <View style={styles.timeWrapper}>
<Text style={styles.timeLeft}>{position}</Text>
<Text style={styles.timeRight}>{fullDuration}</Text>
</View> */}
</View>
);
};
const styles = StyleSheet.create({
wrapper: {
width: '100%'
},
timeWrapper: {
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
paddingHorizontal: 5
},
timeLeft: {
flex: 1,
fontSize: 16,
color: "#FFFFFF",
paddingLeft: 10
},
timeRight: {
flex: 1,
fontSize: 16,
color: "#FFFFFF",
textAlign: "right",
paddingRight: 10
}
});