-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathStreakScreen.js
79 lines (78 loc) · 2.53 KB
/
StreakScreen.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
import { View, Text, Image, TouchableOpacity, StyleSheet } from 'react-native'
import React from 'react'
import { useState } from 'react'
import { update,ref,getDatabase,get } from 'firebase/database'
import { getAuth } from 'firebase/auth'
export default function StreakScreen(props) {
const [streak, setStreak] = useState(0)
const user = getAuth().currentUser
get(ref(getDatabase(), `/users/${user.uid}/dailyStreak`)).then(snapshot=>{
setStreak(snapshot.val())
}).catch(err=>console.log(err))
console.log(props.route.params)
return (
<>
{
props.route.params.streakStatus!=='broken'?
<View style={styles.container}>
<Image source={require('./assets/images/fire-streak-icon.png')} style={styles.fireImage}/>
<Text style={styles.streakText}>{`${streak} day streak!`}</Text>
<Text style={styles.subText}>You're on fire! Keep working out and be the best version of yourself</Text>
<TouchableOpacity style={styles.continueButton} onPress={()=>props.navigation.navigate('HomeScreen')}>
<Text style={styles.buttonText}>CONTINUE</Text>
</TouchableOpacity>
</View>:
<View style={styles.container}>
<Image source={require('./assets/images/grey-fire-streak-icon-removebg-preview.png')} style={styles.fireImage}/>
<Text style={styles.streakText}>You lost your streak 😔</Text>
<Text style={styles.subText}>Don't worry! Everyone has setbacks. Use this as an opportunity to bounce back stronger and continue your fitness journey.
</Text>
<TouchableOpacity style={styles.continueButton} onPress={()=>props.navigation.navigate('HomeScreen')}>
<Text style={styles.buttonText}>CONTINUE</Text>
</TouchableOpacity>
</View>
}
</>
)
}
const styles = StyleSheet.create({
container:{
flex:1,
justifyContent:'center',
alignItems:'center',
backgroundColor:'#151e25',
gap:10
},
fireImage:{
width:170,
height:170,
},
subText:{
textAlign:'center',
fontSize:15,
color:'white',
lineHeight:25,
marginBottom:40
},
streakText:{
fontSize:20,
fontWeight:600,
color:'white',
width:'100%',
textAlign:'center',
},
continueButton:{
height:40,
justifyContent:'center',
alignItems:'center',
backgroundColor:'#6740f4',
borderRadius:10,
width:'90%',
position:'absolute',
bottom:10
},
buttonText:{
color:'white',
fontWeight:600
}
})