-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRestScreen.js
More file actions
61 lines (55 loc) · 1.4 KB
/
Copy pathRestScreen.js
File metadata and controls
61 lines (55 loc) · 1.4 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
import { StyleSheet, Text, View, SafeAreaView, Image } from "react-native";
import React, { useState, useEffect } from "react";
import { useNavigation } from "@react-navigation/native";
const RestScreen = () => {
const navigation = useNavigation();
let timer = 0;
const [timeLeft, setTimeLeft] = useState(3);
const startTime = () => {
setTimeout(() => {
if (timeLeft <= 0) {
navigation.goBack();
clearTimeout(timer);
}
setTimeLeft(timeLeft - 1);
}, 1000);
};
useEffect(() => {
startTime();
//clean up
return () => clearTimeout(timer);
});
return (
<SafeAreaView>
<Image
// resizeMode="contain"
source={{
uri: "https://cdn-images.cure.fit/www-curefit-com/image/upload/fl_progressive,f_auto,q_auto:eco,w_500,ar_500:300,c_fit/dpr_2/image/carefit/bundle/CF01032_magazine_2.png",
}}
style={{ width: "100%", height: 420 }}
/>
<Text
style={{
fontSize: 30,
fontWeight: "900",
marginTop: 50,
textAlign: "center",
}}
>
TAKE A BREAK!
</Text>
<Text
style={{
fontSize: 40,
fontWeight: "800",
marginTop: 50,
textAlign: "center",
}}
>
{timeLeft}
</Text>
</SafeAreaView>
);
};
export default RestScreen;
const styles = StyleSheet.create({});