-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from One-Bit-Myanmar/develop
Develop
- Loading branch information
Showing
9 changed files
with
173 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,78 @@ | ||
import { useRouter } from 'expo-router' | ||
import React from 'react' | ||
import { ScrollView, StyleSheet, Text, View } from 'react-native' | ||
import { Colors } from '../../constants/Colors' | ||
import HomScreenHeader from '../screens/HomeScreen/HomeScreenHeader' | ||
import HomeScreenOrganizationList from '../screens/HomeScreen/HomeScreenOrganizationList' | ||
import HomeScreenRecord from '../screens/HomeScreen/HomeScreenRecord' | ||
import { useRouter } from 'expo-router'; | ||
import { collection, getDocs } from 'firebase/firestore'; | ||
import React, { useEffect, useState } from 'react'; | ||
import { ScrollView, StyleSheet, Text, View } from 'react-native'; | ||
import { Colors } from '../../constants/Colors'; | ||
import { db } from '../../firebaseConfig'; | ||
import HomScreenHeader from '../screens/HomeScreen/HomeScreenHeader'; | ||
import HomeScreenOrganizationList from '../screens/HomeScreen/HomeScreenOrganizationList'; | ||
import HomeScreenRecord from '../screens/HomeScreen/HomeScreenRecord'; | ||
export default function Home() { | ||
const router = useRouter(); | ||
const [organizationNames, setOrganizationNames] = useState([]); | ||
|
||
export default function home() { | ||
// fetch all usernames in firestore | ||
useEffect(() => { | ||
const fetchOrganizationNames = async () => { | ||
try { | ||
const querySnapshot = await getDocs(collection(db, "Users")); | ||
const names = querySnapshot.docs.map(doc => doc.data().name || "Unknown"); | ||
setOrganizationNames(names); | ||
} catch (error) { | ||
console.error("Error fetching organization names:", error); | ||
} | ||
}; | ||
fetchOrganizationNames(); | ||
}, []); | ||
|
||
const router = useRouter(); | ||
// Limit the number of organizations to display to 3 | ||
const limitedOrganizations = organizationNames.slice(0, 3); | ||
|
||
return ( | ||
// header section of the home page | ||
|
||
<View style={styles.container}> | ||
{/* Home Screen Header */} | ||
|
||
<HomScreenHeader /> | ||
|
||
<ScrollView> | ||
{/* Home Screen record section */} | ||
<HomeScreenRecord /> | ||
|
||
{/* Home Screen Organization List */} | ||
<View style={{ | ||
padding: 10, paddingHorizontal: 20, display: 'flex', | ||
flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', | ||
marginBottom: 10 | ||
}}> | ||
<Text style={{ color: Colors.Swan, fontWeight: '500', fontSize: 18, }}>Connect with others</Text> | ||
<Text style={{ color: Colors.Blue, fontWeight: '500', textDecorationLine: 'underline' }} | ||
onPress={() => router.push('/screens/OrgScreen/OrgListScreen')}>View all</Text> | ||
<View style={styles.sectionHeader}> | ||
<Text style={styles.headerText}>Connect with others</Text> | ||
<Text style={styles.viewAllText} onPress={() => router.push('/screens/OrgScreen/OrgListScreen')}>View all</Text> | ||
</View> | ||
|
||
<View style={{ paddingHorizontal: 15, }}> | ||
<HomeScreenOrganizationList /> | ||
<HomeScreenOrganizationList /> | ||
<HomeScreenOrganizationList /> | ||
<HomeScreenOrganizationList /> | ||
<View style={{ paddingHorizontal: 15 }}> | ||
{limitedOrganizations.map((name, index) => ( | ||
<HomeScreenOrganizationList key={index} name={name} /> | ||
))} | ||
</View> | ||
</ScrollView> | ||
|
||
</View> | ||
) | ||
); | ||
} | ||
|
||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
backgroundColor: Colors.white, | ||
marginTop: 30, | ||
}, | ||
|
||
textColor: { | ||
color: 'red' | ||
} | ||
}) | ||
sectionHeader: { | ||
padding: 10, | ||
paddingHorizontal: 20, | ||
flexDirection: 'row', | ||
justifyContent: 'space-between', | ||
alignItems: 'center', | ||
marginBottom: 10, | ||
}, | ||
headerText: { | ||
color: Colors.Swan, | ||
fontWeight: '500', | ||
fontSize: 18, | ||
}, | ||
viewAllText: { | ||
color: Colors.Blue, | ||
fontWeight: '500', | ||
textDecorationLine: 'underline', | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.