-
Notifications
You must be signed in to change notification settings - Fork 0
/
faith.tsx
153 lines (140 loc) · 4.32 KB
/
faith.tsx
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
import React, { useState, useEffect } from 'react';
import { Text, View, ImageBackground, StyleSheet, StatusBar, TouchableOpacity } from 'react-native';
import { useRouter } from 'expo-router'; // Use useRouter for navigation
import { db } from '@/firebase/config'; // importing db
import { getFirestore, collection, getDocs } from 'firebase/firestore'; // Firebase Firestore
// Defining the structure of a verse
type Verse = {
number: number;
location: string;
theme: string;
verse: string;
};
// Importing the JSON file
const bibleVerses: Verse[] = require('@/assets/data/bible_verses.json');
export default function FaithScreen() {
const router = useRouter(); // Initialize router
const [currentVerse, setCurrentVerse] = useState<Verse | null>(null); // State to hold the current verse
const [faithVerses, setFaithVerses] = useState<Verse[]>([]); // State to hold all verses with the "Faith" theme
useEffect(() => {
// Filter verses with the theme "Faith"
const filteredVerses = bibleVerses.filter((verse: Verse) => verse.theme === "Faith");
setFaithVerses(filteredVerses);
// Set the initial verse
if (filteredVerses.length > 0) {
setCurrentVerse(filteredVerses[0]);
}
}, []);
// Function to shuffle to a random verse
const shuffleVerse = () => {
if (faithVerses.length > 0) {
const randomIndex = Math.floor(Math.random() * faithVerses.length);
setCurrentVerse(faithVerses[randomIndex]);
}
};
return (
<View style={styles.container}>
<StatusBar barStyle="light-content" backgroundColor="transparent" translucent={true} />
<ImageBackground
source={require('@/assets/images/bg.png')}
style={styles.background}
resizeMode="cover" // Ensuring the image covers the entire screen
>
<View style={styles.headerContainer}>
<TouchableOpacity onPress={() => router.push('/themes')} style={styles.backLink}>
<Text style={styles.headerText}>← Back</Text>
</TouchableOpacity>
</View>
{/* Main Section */}
<View style={styles.mainSection} pointerEvents="box-none">
{currentVerse && (
<>
<Text style={styles.themetitle}>Theme: Faith</Text>
<Text style={styles.location}>{currentVerse.location}</Text>
<Text style={styles.verse}>{currentVerse.verse}</Text>
</>
)}
{/* Save Verses Button */}
<TouchableOpacity style={styles.button}>
<Text style={styles.buttonText}>Save Verse</Text>
</TouchableOpacity>
{/* Shuffle Button */}
<TouchableOpacity style={styles.button} onPress={shuffleVerse}>
<Text style={styles.buttonText}>Shuffle Verses</Text>
</TouchableOpacity>
</View>
</ImageBackground>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1, // Ensures the container fills the whole screen
},
background: {
flex: 1, // Ensures the background image fills the entire container
justifyContent: 'center', // Center content if needed
alignItems: 'center',
},
headerContainer: {
position: 'absolute',
top: 60,
left: 10,
flexDirection: 'row', // Align items horizontally
alignItems: 'center', // Center items vertically
},
headerText: {
color: '#fff',
fontWeight: 'bold',
fontSize: 18,
},
backLink: {
backgroundColor: 'transparent',
borderWidth: 0,
},
mainSection: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
themetitle: {
color: '#fff',
fontSize: 28,
fontWeight: '800',
textAlign: 'center',
marginBottom: 20,
},
location: {
color: '#fff',
fontSize: 22,
fontWeight: 'bold',
textAlign: 'center',
marginBottom: 10,
},
verse: {
color: '#fff',
fontSize: 20,
textAlign: 'center',
marginBottom: 40,
marginLeft: 20,
marginRight: 20,
},
button: {
backgroundColor: '#132235', // Navy blue
paddingVertical: 15,
paddingHorizontal: 30,
borderRadius: 35,
marginBottom: 25,
alignItems: 'center',
shadowColor: '#000',
shadowOpacity: 0.6,
shadowRadius: 2,
shadowOffset: { width: 2, height: 2 },
},
buttonText: {
color: '#fff',
fontSize: 18,
fontWeight: '800',
textAlign: 'center',
},
});