-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
163 lines (153 loc) · 4.07 KB
/
App.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import React, { useState, useEffect } from 'react';
import { StyleSheet, Text, View, ImageBackground, Animated } from 'react-native';
const LaunchScreen = () => {
const [timeLeft, setTimeLeft] = useState(calculateTimeLeft());
useEffect(() => {
const timer = setTimeout(() => {
setTimeLeft(calculateTimeLeft());
}, 1000);
// Clear timeout if the component is unmounted
return () => clearTimeout(timer);
});
function calculateTimeLeft() {
const difference = +new Date('2023-11-01') - +new Date();
let timeLeft = {};
if (difference > 0) {
timeLeft = {
days: Math.floor(difference / (1000 * 60 * 60 * 24)),
hours: Math.floor((difference / (1000 * 60 * 60)) % 24),
minutes: Math.floor((difference / 1000 / 60) % 60),
seconds: Math.floor((difference / 1000) % 60),
};
}
return timeLeft;
}
function addLeadingZeros(value) {
value = String(value);
while (value.length < 2) {
value = '0' + value;
}
return value;
}
const { days, hours, minutes, seconds } = timeLeft;
return (
<ImageBackground source={require('./assets/bg.jpg')} style={styles.container}>
<View style={styles.contentContainer}>
<Text style={styles.title}>Nature CTL is Coming Soon!</Text>
<View style={styles.counterContainer}>
<View style={styles.counterBox}>
<Text style={styles.counterValue}>{addLeadingZeros(days)}</Text>
<Text style={styles.counterLabel}>DAYS</Text>
</View>
<Text style={styles.colon}>:</Text>
<View style={styles.counterBox}>
<Text style={styles.counterValue}>{addLeadingZeros(hours)}</Text>
<Text style={styles.counterLabel}>HOURS</Text>
</View>
<Text style={styles.colon}>:</Text>
<View style={styles.counterBox}>
<Text style={styles.counterValue}>{addLeadingZeros(minutes)}</Text>
<Text style={styles.counterLabel}>MINUTES</Text>
</View>
<Text style={styles.colon}>:</Text>
<View style={styles.counterBox}>
<Text style={styles.counterValue}>{addLeadingZeros(seconds)}</Text>
<Text style={styles.counterLabel}>SECONDS</Text>
</View>
</View>
</View>
</ImageBackground>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
resizeMode: 'cover',
justifyContent: 'center',
},
contentContainer: {
backgroundColor: 'rgba(255, 255, 255, 0.7)',
alignItems: 'center',
justifyContent: 'center',
shadowColor: '#000',
shadowOpacity: .0001,
shadowRadius: 3,
shadowOffset: {
width: 0,
height: 2,
},
},
title: {
color: '#254117',
fontSize: 40,
fontWeight: 'bold',
textAlign: 'center',
marginBottom: 30,
textShadowColor: '#fff',
textShadowOffset: {
width: 1,
height: 1,
},
textShadowRadius: 2,
},
counterContainer: {
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
marginTop: 20,
},
counterBox: {
backgroundColor: 'rgba(255, 255, 255, 0.7)',
borderRadius: 5,
marginHorizontal: 5,
paddingHorizontal: 10,
paddingVertical: 15,
shadowColor: '#000',
shadowOpacity: 0.3,
shadowRadius: 3,
shadowOffset: {
width: 0,
height: 2,
},
},
counterValue: {
color: '#254117',
fontSize: 50,
fontWeight: 'bold',
textAlign: 'center',
textShadowColor: '#000',
textShadowOffset: {
width: 1,
height: 1,
},
textShadowRadius: 2,
},
counterLabel: {
color: '#fff',
fontSize: 14,
fontWeight: 'bold',
textAlign: 'center',
marginTop: 5,
textShadowColor: '#000',
textShadowOffset: {
width: 1,
height: 1,
},
textShadowRadius: 2,
},
colon: {
color: '#fff',
fontSize: 50,
fontWeight: 'bold',
textAlign: 'center',
marginLeft: 5,
marginRight: 5,
textShadowColor: '#000',
textShadowOffset: {
width: 1,
height: 1,
},
textShadowRadius: 2,
},
});
export default LaunchScreen;