-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
106 lines (96 loc) · 2.76 KB
/
App.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import React from "react";
import Home from "./src/screens/Home";
import Search from "./src/screens/Search";
import VideoPlayer from "./src/screens/VideoPlayer";
import Explore from "./src/screens/Explore";
import Subscribe from "./src/screens/Subscribe";
import {
NavigationContainer,
DefaultTheme,
DarkTheme,
useTheme,
} from "@react-navigation/native";
import { createStackNavigator } from "@react-navigation/stack";
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
import { MaterialIcons } from "@expo/vector-icons";
import { Provider, useSelector } from "react-redux";
import { createStore, combineReducers } from "redux";
import { reducer } from "./src/reducers/reducer";
import { themeReducer } from "./src/reducers/themeReducer";
const customDarkTheme = {
...DarkTheme,
colors: {
...DarkTheme.colors,
headerColor: "#404040",
iconColor: "white",
tabIcon: "white",
},
};
const customDefaultTheme = {
...DefaultTheme,
colors: {
...DefaultTheme.colors,
headerColor: "white",
iconColor: "black",
tabIcon: "red",
},
};
const rootReducer = combineReducers({
cardData: reducer,
myDarkMode: themeReducer,
});
// const store = createStore(reducer);
const store = createStore(rootReducer);
const Stack = createStackNavigator();
const Tabs = createBottomTabNavigator();
const RootHome = () => {
const { colors } = useTheme();
return (
<Tabs.Navigator
screenOptions={({ route }) => ({
tabBarIcon: ({ color }) => {
let iconName;
if (route.name === "home") {
iconName = "home";
} else if (route.name === "explore") {
iconName = "explore";
} else if (route.name === "subscribe") {
iconName = "subscriptions";
}
return <MaterialIcons name={iconName} size={32} color={color} />;
},
})}
tabBarOptions={{
activeTintColor: colors.tabIcon,
inactiveTintColor: "gray",
}}
>
<Tabs.Screen name="home" component={Home} />
<Tabs.Screen name="explore" component={Explore} />
<Tabs.Screen name="subscribe" component={Subscribe} />
</Tabs.Navigator>
);
};
export default () => {
return (
<Provider store={store}>
<Navigation />
</Provider>
);
};
export function Navigation() {
let currentTheme = useSelector((state) => {
return state.myDarkMode;
});
return (
<NavigationContainer
theme={currentTheme ? customDarkTheme : customDefaultTheme}
>
<Stack.Navigator headerMode="none">
<Stack.Screen name="rootHome" component={RootHome} />
<Stack.Screen name="search" component={Search} />
<Stack.Screen name="videoplayer" component={VideoPlayer} />
</Stack.Navigator>
</NavigationContainer>
);
}