-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp3.js
84 lines (75 loc) · 2.26 KB
/
App3.js
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
import { View, Text, Button } from "react-native";
import React from "react";
import { Ionicons } from "@expo/vector-icons";
import { NavigationContainer, DefaultTheme } from "@react-navigation/native";
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
import { createDrawerNavigator } from "@react-navigation/drawer";
function HomeScreen({ navigation }) {
return (
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
<Text>Home Screen</Text>
<Button
title="Go to setting"
onPress={() => navigation.navigate("Setting")}
/>
</View>
);
}
const Drawer = createDrawerNavigator();
const myTheme = {
...DefaultTheme,
colors: {
...DefaultTheme.colors,
primary: "rgb(255,45,85)",
},
};
function SettingScreen({ navigation }) {
return (
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
<Text>Setting Screen</Text>
<Button title="Go to home" onPress={() => navigation.navigate("Home")} />
</View>
);
}
const Tab = createBottomTabNavigator();
function MyTab() {
return (
<Tab.Navigator
screenOptions={({route})=>({
tabBarIcon: ({ focused, color, size }) => {
let iconName;
if(route.name === 'Home'){
iconName = focused
?'ios-information-circle'
:'ios-information-circle-outline'
} else if(route.name === 'Setting'){
iconName = focused ?'ios-list-box':'ios-list'
}
//you can return any component that you like here
return <Ionicons name = {iconName} size = {size} color = {color}/>;
},
tabBarActiveTintColor:'tomato',
tabBarActiveTintColor:'gray',
})}
>
<Tab.Screen name="Home" component={HomeScreen} />
<Tab.Screen name="Setting" component={SettingScreen} />
</Tab.Navigator>
);
}
function MyDrawer() {
return (
<Drawer.Navigator useLegacyImplementation>
<Drawer.Screen name="Home" component={MyTab} />
<Drawer.Screen name="Setting" component={SettingScreen} />
</Drawer.Navigator>
);
}
const App = () => {
return (
<NavigationContainer theme={myTheme}>
<MyDrawer />
</NavigationContainer>
);
};
export default App;