-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
139 lines (124 loc) · 3.72 KB
/
Copy pathApp.tsx
File metadata and controls
139 lines (124 loc) · 3.72 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
import React, { useState } from 'react';
import { StatusBar } from 'expo-status-bar';
import { View, ActivityIndicator, StyleSheet } from 'react-native';
import { useFonts, Inter_400Regular, Inter_700Bold } from '@expo-google-fonts/inter';
import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context';
import { HomeScreen } from './src/screens/HomeScreen';
import { CategoriesScreen } from './src/screens/CategoriesScreen';
import { BrandsScreen } from './src/screens/BrandsScreen';
import { SearchScreen } from './src/screens/SearchScreen';
import { BottomNavigation } from './src/components/BottomNavigation';
type TabName = 'inicio' | 'categorias' | 'buscar' | 'marcas' | 'mais';
type ScreenName = 'home' | 'categories' | 'brands' | 'search' | 'productList' | 'productDetail';
export default function App() {
const [activeTab, setActiveTab] = useState<TabName>('inicio');
const [currentScreen, setCurrentScreen] = useState<ScreenName>('home');
const [screenParams, setScreenParams] = useState<any>(null);
let [fontsLoaded] = useFonts({
Inter_400Regular,
Inter_700Bold,
});
if (!fontsLoaded) {
return (
<View style={styles.loadingContainer}>
<ActivityIndicator size="large" color="#8B5CF6" />
</View>
);
}
const handleTabPress = (tab: TabName) => {
setActiveTab(tab);
switch (tab) {
case 'inicio':
setCurrentScreen('home');
break;
case 'categorias':
setCurrentScreen('categories');
break;
case 'buscar':
setCurrentScreen('search');
break;
case 'marcas':
setCurrentScreen('brands');
break;
case 'mais':
// TODO: Open drawer menu
break;
}
};
const navigateToHome = () => {
setCurrentScreen('home');
setActiveTab('inicio');
};
const handleCategoryPress = (categoryId: string) => {
setScreenParams({ categoryId });
// TODO: Navigate to product list
console.log('Category pressed:', categoryId);
};
const handleBrandPress = (brandId: string) => {
setScreenParams({ brandId });
// TODO: Navigate to product list
console.log('Brand pressed:', brandId);
};
const handleProductPress = (productId: string) => {
setScreenParams({ productId });
// TODO: Navigate to product detail
console.log('Product pressed:', productId);
};
const renderScreen = () => {
switch (currentScreen) {
case 'home':
return <HomeScreen onProductPress={handleProductPress} />;
case 'categories':
return (
<CategoriesScreen
onBack={navigateToHome}
onCategoryPress={handleCategoryPress}
/>
);
case 'brands':
return (
<BrandsScreen
onBack={navigateToHome}
onBrandPress={handleBrandPress}
/>
);
case 'search':
return (
<SearchScreen
onBack={navigateToHome}
onProductPress={handleProductPress}
/>
);
default:
return <HomeScreen onProductPress={handleProductPress} />;
}
};
return (
<SafeAreaProvider>
<SafeAreaView style={styles.safeArea} edges={['top']}>
<StatusBar style="dark" />
{/* Main Content */}
<View style={styles.content}>
{renderScreen()}
</View>
{/* Bottom Navigation */}
<BottomNavigation activeTab={activeTab} onTabPress={handleTabPress} />
</SafeAreaView>
</SafeAreaProvider>
);
}
const styles = StyleSheet.create({
loadingContainer: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: '#FFFFFF',
},
safeArea: {
flex: 1,
backgroundColor: '#FFFFFF',
},
content: {
flex: 1,
},
});