-
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.
Update app version to 1.6, fix user slice import, and customize empty…
… list component
- Loading branch information
1 parent
308dbf3
commit 00978a2
Showing
9 changed files
with
78 additions
and
81 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,60 @@ | ||
import * as React from 'react'; | ||
import React, { useEffect } from 'react'; | ||
import { NavigationContainer } from '@react-navigation/native'; | ||
import { createNativeStackNavigator } from '@react-navigation/native-stack'; | ||
import { useSelector, useDispatch } from 'react-redux'; | ||
import { onAuthStateChanged } from 'firebase/auth'; | ||
import { setUser } from '../redux/slices/user'; | ||
import { auth } from '../config/firebase'; | ||
import HomeScreen from '../screens/HomeScreen'; | ||
import { useSelector } from 'react-redux'; | ||
import AddTripScreen from '../screens/AddTripScreen'; | ||
import AddExpenseScreen from '../screens/AddExpenseScreen'; | ||
import TripExpense from '../screens/TripExpense'; | ||
import WelcomeScreen from '../screens/WelcomeScreen'; | ||
import SignupScreen from '../screens/SignupScreen'; | ||
import SigninScreen from '../screens/SigninScreen'; | ||
import EditExpense from '../screens/EditExpense'; | ||
import { store } from '../redux/store'; | ||
import {user} from '../redux/slices/user' | ||
import { onAuthStateChanged } from 'firebase/auth'; | ||
import { useDispatch } from 'react-redux'; | ||
import { setUser } from '../redux/slices/user'; | ||
import { auth } from '../config/firebase'; | ||
import ExpenseSummary from '../screens/ExpenseSummary'; | ||
|
||
const Stack = createNativeStackNavigator(); | ||
export default function AppNavigation() { | ||
const { user } = useSelector(state => state.user) | ||
|
||
export default function AppNavigation() { | ||
const { user } = useSelector(state => state.user); | ||
const dispatch = useDispatch(); | ||
|
||
onAuthStateChanged(auth, u => { | ||
console.log('got user: ', u) | ||
dispatch(setUser(u)) | ||
}) | ||
if (user) { | ||
return ( | ||
<NavigationContainer> | ||
<Stack.Navigator initialRouteName='Home'> | ||
|
||
<Stack.Screen name="Home" component={HomeScreen} options={{ headerShown: false }} /> | ||
|
||
<Stack.Screen name="AddTrip" component={AddTripScreen} options={{ headerShown: false }} /> | ||
<Stack.Screen name="AddExpense" component={AddExpenseScreen} options={{ headerShown: false }} /> | ||
<Stack.Screen name="TripExpense" component={TripExpense} options={{ headerShown: false }} /> | ||
<Stack.Screen name="EditExpense" component={EditExpense} options={{ headerShown: false }} /> | ||
<Stack.Screen name="ExpenseSummary" component={ExpenseSummary} options={{ headerShown: false }} /> | ||
</Stack.Navigator> | ||
</NavigationContainer> | ||
); | ||
} else { | ||
return ( | ||
<NavigationContainer> | ||
<Stack.Navigator initialRouteName='Welcome'> | ||
useEffect(() => { | ||
const unsubscribe = onAuthStateChanged(auth, user => { | ||
console.log('got user:', user); | ||
if (user) { | ||
dispatch(setUser(user)); | ||
} else { | ||
dispatch(setUser(null)); | ||
} | ||
}); | ||
|
||
<Stack.Screen name="Welcome" component={WelcomeScreen} options={{ headerShown: false }} /> | ||
<Stack.Screen name="SignIn" component={SigninScreen} options={{ headerShown: false, presentation: 'modal' }} /> | ||
<Stack.Screen name="SignUp" component={SignupScreen} options={{ headerShown: false, presentation: 'modal' }} /> | ||
|
||
</Stack.Navigator> | ||
</NavigationContainer> | ||
); | ||
} | ||
// Clean up subscription on unmount | ||
return unsubscribe; | ||
}, [dispatch]); | ||
|
||
} | ||
return ( | ||
<NavigationContainer> | ||
<Stack.Navigator initialRouteName={user ? 'Home' : 'Welcome'}> | ||
{user ? ( | ||
<> | ||
<Stack.Screen name="Home" component={HomeScreen} options={{ headerShown: false }} /> | ||
<Stack.Screen name="AddTrip" component={AddTripScreen} options={{ headerShown: false }} /> | ||
<Stack.Screen name="AddExpense" component={AddExpenseScreen} options={{ headerShown: false }} /> | ||
<Stack.Screen name="TripExpense" component={TripExpense} options={{ headerShown: false }} /> | ||
<Stack.Screen name="EditExpense" component={EditExpense} options={{ headerShown: false }} /> | ||
<Stack.Screen name="ExpenseSummary" component={ExpenseSummary} options={{ headerShown: false }} /> | ||
</> | ||
) : ( | ||
<> | ||
<Stack.Screen name="Welcome" component={WelcomeScreen} options={{ headerShown: false }} /> | ||
<Stack.Screen name="SignIn" component={SigninScreen} options={{ headerShown: false, presentation: 'modal' }} /> | ||
<Stack.Screen name="SignUp" component={SignupScreen} options={{ headerShown: false, presentation: 'modal' }} /> | ||
</> | ||
)} | ||
</Stack.Navigator> | ||
</NavigationContainer> | ||
); | ||
} |
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,28 +1,23 @@ | ||
|
||
import { createSlice } from '@reduxjs/toolkit' | ||
|
||
import { createSlice } from '@reduxjs/toolkit'; | ||
|
||
const initialState = { | ||
value:0, | ||
} | ||
user: null, | ||
userLoading: false, | ||
}; | ||
|
||
const usersSlice = createSlice({ | ||
name: 'user', | ||
initialState:{ | ||
user:null, | ||
userLoading: false, | ||
const userSlice = createSlice({ | ||
name: 'user', | ||
initialState, | ||
reducers: { | ||
setUser: (state, action) => { | ||
state.user = action.payload; | ||
}, | ||
reducers: { | ||
setUser: (state, action) => { | ||
state.user = action.payload | ||
}, | ||
setUserLoading: (state, action) => { | ||
state.userLoading = action.payload | ||
}, | ||
setUserLoading: (state, action) => { | ||
state.userLoading = action.payload; | ||
}, | ||
}) | ||
}, | ||
}); | ||
|
||
export const { setUser, setUserLoading } = usersSlice.actions | ||
export const { setUser, setUserLoading } = userSlice.actions; | ||
|
||
export default usersSlice.reducer | ||
export default userSlice.reducer; |
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,10 +1,8 @@ | ||
import {configureStore} from '@reduxjs/toolkit' | ||
import user from './slices/user' | ||
import { configureStore } from '@reduxjs/toolkit'; | ||
import userReducer from './slices/user'; // Import the corrected user slice | ||
|
||
export const store = configureStore({ | ||
|
||
reducer: { | ||
user | ||
} | ||
|
||
}) | ||
reducer: { | ||
user: userReducer, // Include the user slice in the reducers object | ||
}, | ||
}); |
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