-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStartExerciseList.js
More file actions
79 lines (73 loc) · 2.37 KB
/
StartExerciseList.js
File metadata and controls
79 lines (73 loc) · 2.37 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
78
import React from "react";
import "./CssComponents/Timer.css";
import FinalTraining from "./gifExercise/FinalTraining.png"
import RestPicture from "./gifExercise/RestPicture.jpg"
import { CountdownCircleTimer } from 'react-countdown-circle-timer';
class StartExerciseList extends React.Component {
constructor(props) {
super(props);
this.switchExercise = this.switchExercise.bind(this);
this.state = {
currentExercise: 0,
restTime: 6,
exercises: this.props.exercisesArray,
};
}
switchExercise() {
if (this.state.currentExercise < this.state.exercises.length) {
this.setState({
currentExercise: this.state.currentExercise + 1
});
}
return this.currentExercise;
}
render() {
return (
<div>
{(this.state.currentExercise < this.state.exercises.length) ? (
<div>
<div className="timer-wrapper">
<CountdownCircleTimer
key = {this.state.currentExercise}
duration={this.state.exercises[this.state.currentExercise].time}
onComplete={() => {
// do your stuff here
this.switchExercise();
return [false, 0]
}}
isPlaying={this.props.isPlaying}
colors={[
['#004777', 0.33],
['#F7B801', 0.33],
['#A30000', 0.33],
]}
>
{({ remainingTime }) =>
<div className="timer">
<div className="text">Remaining</div>
<div className="value">{remainingTime}</div>
<div className="text">seconds</div>
</div>
}
</CountdownCircleTimer>
</div>
<div className="slideshow-container">
<img
className = "gifExercise"
src={require(`./gifExercise/${(this.state.exercises[this.state.currentExercise].name).replace(/ |-/g,'')}.gif`).default}
alt="exercise image"
/>
</div>
</div>
) : (
<img
className="gifExercise"
src={FinalTraining}
alt="end of training"
/>
)}
</div>
);
}
}
export default StartExerciseList;