1
- import React from "react" ;
2
- import { View , StyleSheet } from "react-native" ;
1
+ import React , { useEffect , useState } from "react" ;
2
+ import { View , StyleSheet , Image } from "react-native" ;
3
3
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs" ;
4
4
import HomeScreen from "../screens/HomeScreen" ;
5
5
import SearchScreen from "../screens/SearchScreen" ;
6
6
import TicketScreen from "../screens/TicketScreen" ;
7
7
import HomeScreenConcert from "../screens/HomeScreenConcert" ;
8
8
import UserAccountScreen from "../screens/UserAccountScreen" ;
9
9
import { COLORS , FONTSIZE , SPACING } from "../theme/Theme" ;
10
- import {
11
- Entypo ,
12
- MaterialCommunityIcons ,
13
- Feather ,
14
- AntDesign ,
15
- Ionicons ,
16
- } from "@expo/vector-icons" ;
10
+ import { Ionicons , Feather , MaterialCommunityIcons } from "@expo/vector-icons" ;
11
+ import { getFirestore , doc , getDoc } from "firebase/firestore" ;
12
+ import { getAuth } from "firebase/auth" ;
13
+ import { initializeApp } from "firebase/app" ;
14
+ import { firebaseConfig } from "../../firebase-config" ;
15
+
16
+ const app = initializeApp ( firebaseConfig ) ;
17
+ const db = getFirestore ( app ) ;
18
+ const auth = getAuth ( ) ;
17
19
18
20
const Tab = createBottomTabNavigator ( ) ;
19
21
20
22
const TabNavigator = ( ) => {
23
+ const [ photoURL , setPhotoURL ] = useState < string | null > ( null ) ;
24
+
25
+ useEffect ( ( ) => {
26
+ const fetchUserProfile = async ( ) => {
27
+ const user = auth . currentUser ;
28
+ if ( user ) {
29
+ const userDoc = doc ( db , "users" , user . uid ) ;
30
+ const userSnapshot = await getDoc ( userDoc ) ;
31
+ if ( userSnapshot . exists ( ) ) {
32
+ const userData = userSnapshot . data ( ) ;
33
+ setPhotoURL ( userData . photoURL || null ) ;
34
+ }
35
+ }
36
+ } ;
37
+
38
+ fetchUserProfile ( ) ;
39
+ } , [ ] ) ;
40
+
21
41
return (
22
42
< Tab . Navigator
23
43
screenOptions = { {
@@ -45,7 +65,7 @@ const TabNavigator = () => {
45
65
< Ionicons
46
66
name = "home-sharp"
47
67
size = { FONTSIZE . size_30 }
48
- color = { focused ? COLORS . White : COLORS . White }
68
+ color = { COLORS . White }
49
69
/>
50
70
</ View >
51
71
) ,
@@ -66,7 +86,7 @@ const TabNavigator = () => {
66
86
< Feather
67
87
name = "search"
68
88
size = { FONTSIZE . size_30 }
69
- color = { focused ? COLORS . White : COLORS . White }
89
+ color = { COLORS . White }
70
90
/>
71
91
</ View >
72
92
) ,
@@ -87,7 +107,7 @@ const TabNavigator = () => {
87
107
< MaterialCommunityIcons
88
108
name = "ticket-confirmation-outline"
89
109
size = { FONTSIZE . size_30 }
90
- color = { focused ? COLORS . White : COLORS . White }
110
+ color = { COLORS . White }
91
111
/>
92
112
</ View >
93
113
) ,
@@ -105,11 +125,15 @@ const TabNavigator = () => {
105
125
focused ? { backgroundColor : COLORS . Green } : { } ,
106
126
] }
107
127
>
108
- < AntDesign
109
- name = "user"
110
- size = { FONTSIZE . size_30 }
111
- color = { focused ? COLORS . White : COLORS . White }
112
- />
128
+ { photoURL ? (
129
+ < Image source = { { uri : photoURL } } style = { styles . userImage } />
130
+ ) : (
131
+ < Ionicons
132
+ name = "person-circle"
133
+ size = { FONTSIZE . size_30 }
134
+ color = { COLORS . White }
135
+ />
136
+ ) }
113
137
</ View >
114
138
) ,
115
139
} }
@@ -124,8 +148,10 @@ const styles = StyleSheet.create({
124
148
padding : SPACING . space_18 ,
125
149
borderRadius : SPACING . space_18 * 10 ,
126
150
} ,
127
- tabBackground : {
128
- padding : SPACING . space_18 ,
151
+ userImage : {
152
+ width : FONTSIZE . size_30 ,
153
+ height : FONTSIZE . size_30 ,
154
+ borderRadius : FONTSIZE . size_16 , // make it circular
129
155
} ,
130
156
} ) ;
131
157
0 commit comments