-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
153 lines (142 loc) · 4.42 KB
/
App.js
File metadata and controls
153 lines (142 loc) · 4.42 KB
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 from 'react';
import { View, StyleSheet, Platform } from 'react-native';
import { LinearGradient } from 'expo-linear-gradient';
import { BlurView } from 'expo-blur';
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { createStackNavigator } from '@react-navigation/stack';
import { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-context';
import { ExpenseProvider, useExpenseContext } from './src/contexts/ExpenseContext';
import { AuthProvider, useAuth } from './src/contexts/AuthContext';
import Login from './src/components/Auth/Login';
import ExpenseDetailScreen from './src/screens/ExpenseDetailScreen';
import Dashboard from './src/components/Dashboard/Dashboard';
import Records from './src/components/Records/Records';
import Categories from './src/components/Categories/Categories';
import Budget from './src/components/Budget/Budget';
import SettingsScreen from './src/components/Settings/Settings';
import { BarChart3, Calendar, CreditCard, Tag, Settings } from 'lucide-react-native';
const Tab = createBottomTabNavigator();
const Stack = createStackNavigator();
function TabNavigator() {
const { state } = useExpenseContext();
const isDark = state.theme === 'dark';
const insets = useSafeAreaInsets();
return (
<Tab.Navigator
screenOptions={({ route }) => ({
tabBarIcon: ({ focused, color, size }) => {
let IconComponent;
if (route.name === 'Dashboard') {
IconComponent = BarChart3;
} else if (route.name === 'Records') {
IconComponent = Calendar;
} else if (route.name === 'Budget') {
IconComponent = CreditCard;
} else if (route.name === 'Categories') {
IconComponent = Tag;
} else if (route.name === 'Settings') {
IconComponent = Settings;
}
return <IconComponent size={size} color={color} />;
},
tabBarActiveTintColor: '#007bff',
tabBarInactiveTintColor: isDark ? '#999' : '#666',
tabBarBackground: () => (
<BlurView
intensity={80}
tint={isDark ? 'dark' : 'light'}
style={{
position: 'absolute',
left: 0,
right: 0,
bottom: 0,
height: 60 + (insets.bottom > 0 ? insets.bottom : 0),
}}
/>
),
tabBarStyle: {
backgroundColor: 'transparent',
borderTopWidth: 0,
paddingBottom: insets.bottom > 0 ? insets.bottom : 5,
paddingTop: 5,
height: 60 + (insets.bottom > 0 ? insets.bottom : 0),
position: 'absolute',
bottom: 0,
left: 0,
right: 0,
elevation: 0,
shadowOpacity: 0,
borderTopColor: 'transparent',
},
headerShown: false,
})}
>
<Tab.Screen
name="Dashboard"
component={Dashboard}
options={{ title: 'Dashboard' }}
/>
<Tab.Screen
name="Records"
component={Records}
options={{ title: 'Records' }}
/>
<Tab.Screen
name="Budget"
component={Budget}
options={{ title: 'Budget' }}
/>
<Tab.Screen
name="Categories"
component={Categories}
options={{ title: 'Categories' }}
/>
<Tab.Screen
name="Settings"
component={SettingsScreen}
options={{ title: 'Settings' }}
/>
</Tab.Navigator>
);
}
function AppContent() {
const { user } = useAuth();
// Show login if user is not authenticated
if (!user) {
return <Login />;
}
return (
<NavigationContainer>
<Stack.Navigator screenOptions={{ headerShown: false }}>
<Stack.Screen name="Main" component={TabNavigator} />
<Stack.Screen
name="ExpenseDetail"
component={ExpenseDetailScreen}
options={{
headerShown: false,
presentation: 'modal'
}}
/>
</Stack.Navigator>
</NavigationContainer>
);
}
function App() {
return (
<SafeAreaProvider>
<AuthProvider>
<ExpenseProvider>
<AppContent />
</ExpenseProvider>
</AuthProvider>
</SafeAreaProvider>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#f5f5f5',
},
});
export default App;