This repository has been archived by the owner on Feb 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
225 lines (210 loc) · 7.5 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
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
import * as React from 'react';
import { useState, useEffect } from "react";
import { CommonActions, DrawerActions, NavigationContainer, useLinkBuilder, useTheme } from '@react-navigation/native';
import { get, save, saveString } from './storage';
import { DrawerContentScrollView, DrawerItem, createDrawerNavigator } from '@react-navigation/drawer';
import Icon from 'react-native-vector-icons/Ionicons';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { Appearance, Dimensions, Pressable, StyleSheet, Switch, Text, TouchableOpacity, View } from 'react-native';
import 'react-native-gesture-handler';
import SearchBar from './Components/SearchBar';
import ScreenIndex from './Screens/MovieScreen/ScreenIndex';
import { light, dark } from './colors';
import HomeScreen from './Navigation/TopNavigation';
import ListingDetails from './Screens/InfoCards/NewsInfo';
import AnimeList from './Screens/InfoCards/AnimeList';
import RecommdatScreen from './Screens/Recommendation/RecommdatScreen';
var width = Dimensions.get('window').width; //full width
var height = Dimensions.get('window').height; //full height
const Drawer = createDrawerNavigator();
const Stack = createNativeStackNavigator();
function MovieScreen() {
return (
<Stack.Navigator
screenOptions={{ headerShown: false }}
initialRouteName="Home"
>
<Stack.Screen name="Home" component={ScreenIndex} />
<Stack.Screen
options={{ presentation: "modal" }}
name="Info"
component={ListingDetails}
/>
</Stack.Navigator>
);
}
function DarkToggle(props) {
const [isEnabled, setIsEnabled] = useState(false);
const { setTheme, theme } = React.useContext(ThemeContext);
const colorScheme = Appearance.getColorScheme();
const toggleSwitch = () => setIsEnabled(previousState => !previousState);
// const toggleSwitch = () => setIsEnabled(() => setTheme(theme === 'Light' ? 'Dark' : 'Light'));
useEffect(() => {
if (isEnabled === false) {
setTheme('Light');
save('Mode', false);
} else {
setTheme('Dark');
save('Mode', true);
}
}, [isEnabled])
const { state, descriptors, navigation } = props;
const buildLink = useLinkBuilder();
return (
<View style={{ flex: 1 }}>
<DrawerContentScrollView {...props}>
{state.routes.map((route, i) => {
const isHidden = descriptors[route.key].options?.hidden;
if (isHidden === true) return null;
const focused = i === state.index;
const {
title,
drawerLabel,
drawerIcon,
drawerActiveTintColor,
drawerInactiveTintColor,
drawerActiveBackgroundColor,
drawerInactiveBackgroundColor,
drawerLabelStyle,
drawerItemStyle,
} = descriptors[route.key].options;
return (
<DrawerItem
key={route.key}
label={drawerLabel !== undefined ? drawerLabel : title !== undefined ? title : route.name}
icon={drawerIcon}
focused={focused}
activeTintColor={drawerActiveTintColor}
inactiveTintColor={drawerInactiveTintColor}
activeBackgroundColor={drawerActiveBackgroundColor}
inactiveBackgroundColor={drawerInactiveBackgroundColor}
labelStyle={drawerLabelStyle}
style={drawerItemStyle}
to={buildLink(route.name, route.params)}
onPress={() => {
navigation.dispatch({
...(focused
? DrawerActions.closeDrawer()
: CommonActions.navigate(route.name)),
target: state.key,
});
}}
/>
);
})}
</DrawerContentScrollView>
<View style={styles.containerSwitch}>
<TouchableOpacity onPress={() => { }} style={{ paddingVertical: 15 }}>
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
<Text style={styles.switchText}>Light </Text>
<Switch
trackColor={{ false: "light", true: "dark" }}
thumbColor={isEnabled ? colorScheme == 'light' : colorScheme == 'dark'}
ios_backgroundColor="#3e3e3e"
onValueChange={toggleSwitch}
value={isEnabled}
/>
<Text>Dark</Text>
</View>
</TouchableOpacity>
</View>
</View>
);
}
export const ThemeContext = React.createContext();
function HomeView() {
const theme = useTheme();
return (
<Drawer.Navigator
screenOptions={({ navigation }) => ({
drawerActiveTintColor: theme.colors.Activetext,
// headerRight: (props) => (
// <View style={styles.IconBtncontainer}>
// {
// showSearchBar === false ? <Icon name='search' onPress={() => setShowSearchBar(!showSearchBar)} size={30} />
// :
// <SearchBar searchPhrase={searchPhrase} setSearchPhrase={setSearchPhrase} style={styles.detailsSearchBar} setShowSearchBar={setShowSearchBar}
// showSearchBar={showSearchBar} />
// }
// </View>
// ),
// headerLeft: (props) => (
// <Pressable android_ripple={{ color: '#666666', foreground: true, borderless: true, }} onPress={() => { navigation.openDrawer() }}>
// <View style={styles.detailsConatiner}>
// <Icon name='list-sharp' onPress={navigation.toggleDrawer} size={30} />
// </View>
// </Pressable>
// ),
drawerStyle: {
backgroundColor:theme.colors.headerStyle ,
width: 240,
},
headerStyle: {
height: 90,
backgroundColor: theme.colors.headerStyle
},
})}
initialRouteName="Feed"
drawerContent={(props) => <DarkToggle {...props} />}
>
<Drawer.Screen name="Feed" component={HomeScreen} />
<Drawer.Screen name="Movie" component={MovieScreen} />
<Drawer.Screen name="Settings" component={DarkToggle} options={{ drawerLabel: () => null, }} />
</Drawer.Navigator >
);
}
export default function App() {
const [theme, setTheme] = useState('Light');
const themeData = { theme, setTheme };
return (
<ThemeContext.Provider value={themeData}>
<NavigationContainer theme={theme === 'Light' ? light : dark}>
<Stack.Navigator
initialRouteName="Home"
>
<Stack.Screen options={{ headerShown: false }} name="Home" component={HomeView} />
<Stack.Screen name="Info" component={ListingDetails} />
<Stack.Screen name="Listing" component={ListingDetails} />
<Stack.Screen name="List" component={AnimeList} />
<Stack.Screen name="RecommdatScreen" component={RecommdatScreen} />
</Stack.Navigator>
</NavigationContainer>
</ThemeContext.Provider>
);
}
const styles = StyleSheet.create({
container: {
width: width / 1.2,
marginTop: 20
},
IconBtncontainer: {
flexDirection: "row",
justifyContent: "space-evenly",
padding: 10,
},
iconContainer: {
flexDirection: "row",
justifyContent: "space-evenly",
padding: 10,
},
detailsConatiner: {
alignItems: "center",
fontWeight: 'bold',
color: "red",
},
detailsSearchBar: {
width: width,
},
titleText: {
fontSize: 20,
fontWeight: 'bold',
color: "red",
},
containerSwitch: {
alignItems: 'center',
justifyContent: 'center',
},
switchText: {
flexDirection: "row",
}
});