|
1 | | -/** |
2 | | - * App的入口文件,这里作为渲染系统入口和登录的一个占位 |
3 | | - * @format |
| 1 | +/* |
| 2 | + * @Author: bugdr |
| 3 | + * @Date: 2022-07-09 22:07:01 |
| 4 | + * @LastEditors: bugdr |
| 5 | + * @LastEditTime: 2022-07-11 14:09:19 |
| 6 | + * @FilePath: \SunOfBeacheRN\App.tsx |
| 7 | + * @Description:App的入口文件,这里作为渲染系统入口和登录的一个占位 |
4 | 8 | */ |
5 | | - |
6 | | -import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'; |
7 | | -import { NavigationContainer } from '@react-navigation/native'; |
8 | | -import { createNativeStackNavigator } from '@react-navigation/native-stack'; |
9 | 9 | import React from 'react'; |
10 | | -import { Text, StyleSheet, View, Button } from 'react-native'; |
11 | | -import Ionicons from 'react-native-vector-icons/Ionicons'; |
12 | | -import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context'; // 安全区域的插件 |
13 | | - |
14 | | -function HomeScreen({ navigation }) { |
15 | | - return ( |
16 | | - <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}> |
17 | | - <Text>首页</Text> |
18 | | - <Button title="去登录页面" onPress={() => navigation.navigate('Login')} /> |
19 | | - </View> |
20 | | - ); |
21 | | -} |
22 | | - |
23 | | -function LoginScreen({ navigation }) { |
24 | | - return ( |
25 | | - <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}> |
26 | | - <Text>登录页面</Text> |
27 | | - <Button title="去首页" onPress={() => navigation.navigate('Home')} /> |
28 | | - </View> |
29 | | - ); |
30 | | -} |
31 | | - |
32 | | -// 创建一个路由栈 |
33 | | -const Stack = createNativeStackNavigator(); |
34 | | -// 底部导航栏 |
35 | | -const Tab = createBottomTabNavigator(); |
| 10 | +import Navigation from './src/navigation'; |
36 | 11 |
|
37 | 12 | const App = () => { |
38 | | - return ( |
39 | | - <> |
40 | | - <SafeAreaProvider style={styles.container}> |
41 | | - <NavigationContainer> |
42 | | - <Tab.Navigator |
43 | | - screenOptions={({ route }) => ({ |
44 | | - tabBarIcon: ({ focused, color, size }) => { |
45 | | - let iconName; |
46 | | - |
47 | | - if (route.name === 'Home') { |
48 | | - iconName = focused ? 'ios-information-circle' : 'ios-information-circle-outline'; |
49 | | - } else if (route.name === 'Login') { |
50 | | - iconName = focused ? 'ios-list-box' : 'ios-list'; |
51 | | - } |
52 | | - |
53 | | - // You can return any component that you like here! |
54 | | - return <Ionicons name={iconName} size={size} color={color} />; |
55 | | - }, |
56 | | - tabBarActiveTintColor: 'tomato', |
57 | | - tabBarInactiveTintColor: 'gray', |
58 | | - })} |
59 | | - > |
60 | | - <Tab.Screen name="Home" component={HomeScreen} options={{ tabBarBadge: 10 }} /> |
61 | | - <Tab.Screen name="Login" component={LoginScreen} /> |
62 | | - </Tab.Navigator> |
63 | | - </NavigationContainer> |
64 | | - </SafeAreaProvider> |
65 | | - </> |
66 | | - ); |
| 13 | + return <Navigation />; |
67 | 14 | }; |
68 | 15 |
|
69 | | -const styles = StyleSheet.create({ |
70 | | - container: { |
71 | | - flex: 1, |
72 | | - }, |
73 | | - baseText: { |
74 | | - fontFamily: 'Cochin', |
75 | | - }, |
76 | | - titleText: { |
77 | | - fontSize: 20, |
78 | | - fontWeight: 'bold', |
79 | | - }, |
80 | | -}); |
81 | | - |
82 | 16 | export default App; |
0 commit comments