-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
198 lines (182 loc) · 5.74 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
import React from 'react'
import { Buffer } from 'buffer';
global.Buffer = Buffer; // very important
import { getFocusedRouteNameFromRoute, NavigationContainer } from '@react-navigation/native';
import { createStackNavigator, TransitionPresets } from '@react-navigation/stack';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { MaterialCommunityIcons, MaterialIcons } from 'react-native-vector-icons';
import Movies from './components/Movies';
import TvShows from './components/TvShows';
import ViewAllMovies from './components/ViewAllMovies';
import ViewAllTv from './components/ViewAllTv';
import IndividualMovie from './components/IndividualMovie';
import IndividualTv from './components/IndividualTv';
import CastInfo from './components/CastInfo';
import Search from './components/Search';
import { Button, Share, TouchableOpacity } from 'react-native';
import { Ionicons } from 'react-native-vector-icons'
import { DefaultTheme, DarkTheme } from '@react-navigation/native';
import { LogBox } from 'react-native';
LogBox.ignoreLogs([
'Non-serializable values were found in the navigation state',
]);
const Tab = createBottomTabNavigator();
function HomeStack() {
return (
<Tab.Navigator
screenOptions={({ route }) => ({
tabBarIcon: ({ focused, color, size }) => {
let iconName;
if (route.name === 'Movies') {
iconName = focused
? 'movie-open'
: 'movie-open-outline';
} else if (route.name === 'Tv Shows') {
iconName = focused ? 'live-tv' : 'live-tv';
} else if (route.name === 'Search') {
iconName = focused ? 'search' : 'search';
}
return (
route.name === 'Movies' ? (
<MaterialCommunityIcons name={iconName} size={size} color={color} />
) : (
<MaterialIcons name={iconName} size={size} color={color} />
)
);
},
})}
tabBarOptions={{
activeTintColor: 'black',
inactiveTintColor: 'gray',
}}
>
<Tab.Screen
name="Movies"
component={Movies}
/>
<Tab.Screen
name="Tv Shows"
component={TvShows}
/>
<Tab.Screen
name="Search"
component={Search}
/>
</Tab.Navigator>
);
}
const Stack = createStackNavigator();
function App() {
return (
<NavigationContainer>
{/* initialRouteName="Splash" */}
<Stack.Navigator>
<Stack.Screen
name="Home"
component={HomeStack}
options={({ route }) => ({
headerTitle: getHeaderTitle(route),
headerShown: getHeader(route),
headerLeft: null
})}
/>
<Stack.Screen
name="ViewAllMovies"
component={ViewAllMovies}
options={({ route }) => ({ title: route.params.name, ...TransitionPresets.SlideFromRightIOS, })}
/>
<Stack.Screen
name="ViewAllTv"
component={ViewAllTv}
options={({ route }) => ({ title: route.params.name, ...TransitionPresets.SlideFromRightIOS, })}
/>
<Stack.Screen
name="MovieDetails"
component={IndividualMovie}
options={({ route }) => ({
// title: route.params.MovieName,
headerRight: () => (
<TouchableOpacity
onPress={() => onShareForMovie(route)}
>
<Ionicons name="ios-share-social" color="white" size={25} style={{ marginRight: 15 }} />
</TouchableOpacity>
),
...TransitionPresets.SlideFromRightIOS,
headerBackTitleVisible: false,
headerTitle: false,
headerTransparent: true,
headerTintColor: '#fff'
})}
/>
<Stack.Screen
name="TvDetails"
component={IndividualTv}
options={({ route }) => ({
// title: route.params.TvShowName,
headerRight: () => (
<TouchableOpacity
onPress={() => onShareForTvShow(route)}
>
<Ionicons name="ios-share-social" color="white" size={25} style={{ marginRight: 15 }} />
</TouchableOpacity>
),
...TransitionPresets.SlideFromRightIOS,
headerBackTitleVisible: false,
headerTitle: false,
headerTransparent: true,
headerTintColor: '#fff'
})}
/>
<Stack.Screen
name="CastInfo"
component={CastInfo}
options={({ route }) => ({
// title: route.params.name,
...TransitionPresets.SlideFromRightIOS,
headerBackTitleVisible: false,
headerTitle: false,
headerTransparent: true,
headerTintColor: '#fff'
})}
/>
</Stack.Navigator>
</NavigationContainer>
)
}
export default App;
//Additional Functions
function getHeaderTitle(route) {
const routeName = getFocusedRouteNameFromRoute(route) ?? 'Movies'
switch (routeName) {
case 'Movies':
return 'Movies';
case 'Tv Shows':
return 'Tv Shows';
case 'Search':
return 'Search'
}
}
function getHeader(route) {
const routeName = getFocusedRouteNameFromRoute(route);
switch (routeName) {
case 'Movies':
return true;
case 'Tv Shows':
return true;
case 'Search':
return true;
}
}
const onShareForMovie = (route) => {
const url = route.params.movieURL["_W"]
Share.share({
message: `https://www.imdb.com/title/${url}`,
});
};
const onShareForTvShow = (route) => {
const url = route.params.TvShowName.toLowerCase().split(" ").join("-");
Share.share({
message: `http://www.tv.com/shows/${url}`,
});
};