|
1 |
| -/** |
2 |
| - * Sample React Native App |
3 |
| - * https://github.com/facebook/react-native |
4 |
| - * |
5 |
| - * @format |
6 |
| - * @flow strict-local |
7 |
| - */ |
8 |
| - |
9 |
| -import React from 'react'; |
10 |
| -import type {Node} from 'react'; |
11 | 1 | import {
|
12 |
| - SafeAreaView, |
13 |
| - ScrollView, |
14 |
| - StatusBar, |
| 2 | + Image, |
15 | 3 | StyleSheet,
|
16 |
| - Text, |
17 |
| - useColorScheme, |
| 4 | + TouchableOpacity, |
18 | 5 | View,
|
| 6 | + Text, |
| 7 | + Pressable, |
19 | 8 | } from 'react-native';
|
20 | 9 |
|
21 |
| -import { |
22 |
| - Colors, |
23 |
| - DebugInstructions, |
24 |
| - Header, |
25 |
| - LearnMoreLinks, |
26 |
| - ReloadInstructions, |
27 |
| -} from 'react-native/Libraries/NewAppScreen'; |
| 10 | +import HomeScreen from './src/Screens/HomeScreen'; |
| 11 | +import Icon from 'react-native-vector-icons/Ionicons'; |
| 12 | +import {NavigationContainer} from '@react-navigation/native'; |
| 13 | +import React, {useState} from 'react'; |
| 14 | +import {createBottomTabNavigator} from '@react-navigation/bottom-tabs'; |
| 15 | +import {createStackNavigator} from '@react-navigation/stack'; |
| 16 | +import SplashScreen from './src/Screens/SplashScreen'; |
| 17 | +import Explore from './src/Screens/Explore'; |
| 18 | +import Player from './src/Screens/Player'; |
| 19 | +import ChannelScreen from './src/Screens/Channel'; |
| 20 | +import AboutScreen from './src/Screens/About'; |
| 21 | +import Videos from './src/Screens/Videos'; |
| 22 | +import {createMaterialTopTabNavigator} from '@react-navigation/material-top-tabs'; |
| 23 | +import UserScreen from './src/Screens/User'; |
| 24 | +import UserData from './src/Utils/User.json'; |
| 25 | +import TopScreen from './src/Screens/TopScreen'; |
| 26 | +import VideosScreen from './src/Screens/Videos'; |
28 | 27 |
|
29 |
| -const Section = ({children, title}): Node => { |
30 |
| - const isDarkMode = useColorScheme() === 'dark'; |
| 28 | +const Stack = createStackNavigator(); |
| 29 | +const Tab = createBottomTabNavigator(); |
| 30 | +const TopBar = createMaterialTopTabNavigator(); |
| 31 | + |
| 32 | +const MainTabs = () => { |
31 | 33 | return (
|
32 |
| - <View style={styles.sectionContainer}> |
33 |
| - <Text |
34 |
| - style={[ |
35 |
| - styles.sectionTitle, |
36 |
| - { |
37 |
| - color: isDarkMode ? Colors.white : Colors.black, |
38 |
| - }, |
39 |
| - ]}> |
40 |
| - {title} |
41 |
| - </Text> |
42 |
| - <Text |
43 |
| - style={[ |
44 |
| - styles.sectionDescription, |
45 |
| - { |
46 |
| - color: isDarkMode ? Colors.light : Colors.dark, |
47 |
| - }, |
48 |
| - ]}> |
49 |
| - {children} |
50 |
| - </Text> |
51 |
| - </View> |
| 34 | + <Tab.Navigator |
| 35 | + tabBarOptions={{ |
| 36 | + style: { |
| 37 | + position: 'absolute', |
| 38 | + elevation: 0, |
| 39 | + shadowOpacity: 0, |
| 40 | + borderTopWidth: 0.5, |
| 41 | + bottom: 0, |
| 42 | + height: 48, |
| 43 | + }, |
| 44 | + labelStyle: { |
| 45 | + fontFamily: 'Roboto-Light', |
| 46 | + fontSize: 12, |
| 47 | + }, |
| 48 | + activeTintColor: '#000', |
| 49 | + }} |
| 50 | + initialRouteName="SplashScreen" |
| 51 | + backBehavior="history"> |
| 52 | + <Tab.Screen |
| 53 | + name="Home" |
| 54 | + component={HomeScreen} |
| 55 | + options={{ |
| 56 | + tabBarLabel: 'Home', |
| 57 | + tabBarIcon: tabInfo => ( |
| 58 | + <Icon |
| 59 | + name={tabInfo.focused ? 'home' : 'home-outline'} |
| 60 | + size={25} |
| 61 | + color="#282828" |
| 62 | + /> |
| 63 | + ), |
| 64 | + }} |
| 65 | + /> |
| 66 | + <Tab.Screen |
| 67 | + name="Explore" |
| 68 | + component={Explore} |
| 69 | + options={{ |
| 70 | + tabBarLabel: 'Explore', |
| 71 | + tabBarIcon: tabInfo => ( |
| 72 | + <Icon |
| 73 | + name={tabInfo.focused ? 'compass' : 'compass-outline'} |
| 74 | + size={25} |
| 75 | + color="#282828" |
| 76 | + /> |
| 77 | + ), |
| 78 | + }} |
| 79 | + /> |
| 80 | + <Tab.Screen |
| 81 | + name="User" |
| 82 | + component={UserChannel} |
| 83 | + options={{ |
| 84 | + tabBarLabel: 'User', |
| 85 | + tabBarIcon: tabInfo => ( |
| 86 | + <Image source={{uri: UserData?.avtar}} style={styles.tabAvtar} /> |
| 87 | + ), |
| 88 | + }} |
| 89 | + /> |
| 90 | + </Tab.Navigator> |
52 | 91 | );
|
53 | 92 | };
|
54 | 93 |
|
55 |
| -const App: () => Node = () => { |
56 |
| - const isDarkMode = useColorScheme() === 'dark'; |
| 94 | +const ChannelStack = () => { |
| 95 | + return ( |
| 96 | + <TopBar.Navigator |
| 97 | + backBehavior="history" |
| 98 | + tabBarOptions={{ |
| 99 | + activeTintColor: '#040201', |
| 100 | + labelStyle: { |
| 101 | + fontFamily: 'Roboto-Medium', |
| 102 | + fontSize: 16, |
| 103 | + }, |
| 104 | + indicatorStyle: { |
| 105 | + backgroundColor: '#040201', |
| 106 | + }, |
| 107 | + }}> |
| 108 | + <TopBar.Screen name="Home" component={ChannelScreen} /> |
| 109 | + <TopBar.Screen name="Videos" component={Videos} /> |
| 110 | + <TopBar.Screen name="About" component={AboutScreen} /> |
| 111 | + </TopBar.Navigator> |
| 112 | + ); |
| 113 | +}; |
57 | 114 |
|
58 |
| - const backgroundStyle = { |
59 |
| - backgroundColor: isDarkMode ? Colors.darker : Colors.lighter, |
60 |
| - }; |
| 115 | +function UserChannel() { |
| 116 | + return ( |
| 117 | + <TopBar.Navigator |
| 118 | + lazy |
| 119 | + removeClippedSubviews={false} |
| 120 | + backBehavior="history" |
| 121 | + tabBarOptions={{ |
| 122 | + style: { |
| 123 | + borderBottomWidth: 0, |
| 124 | + }, |
| 125 | + }}> |
| 126 | + <TopBar.Screen name="User" component={UserScreen} /> |
| 127 | + <TopBar.Screen name="Video" component={VideosScreen} /> |
| 128 | + <TopBar.Screen name="About" component={AboutScreen} /> |
| 129 | + </TopBar.Navigator> |
| 130 | + ); |
| 131 | +} |
61 | 132 |
|
| 133 | +const App = props => { |
62 | 134 | return (
|
63 |
| - <SafeAreaView style={backgroundStyle}> |
64 |
| - <StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} /> |
65 |
| - <ScrollView |
66 |
| - contentInsetAdjustmentBehavior="automatic" |
67 |
| - style={backgroundStyle}> |
68 |
| - <Header /> |
69 |
| - <View |
70 |
| - style={{ |
71 |
| - backgroundColor: isDarkMode ? Colors.black : Colors.white, |
72 |
| - }}> |
73 |
| - <Section title="Step One"> |
74 |
| - Edit <Text style={styles.highlight}>App.js</Text> to change this |
75 |
| - screen and then come back to see your edits. |
76 |
| - </Section> |
77 |
| - <Section title="See Your Changes"> |
78 |
| - <ReloadInstructions /> |
79 |
| - </Section> |
80 |
| - <Section title="Debug"> |
81 |
| - <DebugInstructions /> |
82 |
| - </Section> |
83 |
| - <Section title="Learn More"> |
84 |
| - Read the docs to discover what to do next: |
85 |
| - </Section> |
86 |
| - <LearnMoreLinks /> |
87 |
| - </View> |
88 |
| - </ScrollView> |
89 |
| - </SafeAreaView> |
| 135 | + <NavigationContainer> |
| 136 | + <Stack.Navigator initialRouteName="Main"> |
| 137 | + <Stack.Screen |
| 138 | + name="SplashScreen" |
| 139 | + component={SplashScreen} |
| 140 | + options={{headerShown: false}} |
| 141 | + /> |
| 142 | + <Stack.Screen |
| 143 | + name="Main" |
| 144 | + component={MainTabs} |
| 145 | + options={({navigation, roue}) => ({ |
| 146 | + headerStyle: { |
| 147 | + height: 45, |
| 148 | + }, |
| 149 | + headerTitleAlign: 'left', |
| 150 | + headerTitle: () => ( |
| 151 | + <Image |
| 152 | + source={require('./assets/logo.png')} |
| 153 | + style={styles.logo} |
| 154 | + resizeMode="contain" |
| 155 | + /> |
| 156 | + ), |
| 157 | + headerRight: () => ( |
| 158 | + <View style={styles.homeRight}> |
| 159 | + <TouchableOpacity style={styles.rightButton}> |
| 160 | + <Icon |
| 161 | + name="notifications-outline" |
| 162 | + color="#282828" |
| 163 | + size={26} |
| 164 | + /> |
| 165 | + </TouchableOpacity> |
| 166 | + <TouchableOpacity style={styles.rightButton}> |
| 167 | + <Icon name="search-outline" color="#282828" size={26} /> |
| 168 | + </TouchableOpacity> |
| 169 | + <TouchableOpacity style={styles.rightButton}> |
| 170 | + <Image |
| 171 | + source={{ |
| 172 | + uri: 'https://avatars.githubusercontent.com/u/37410529?v=4', |
| 173 | + }} |
| 174 | + style={styles.channelAvtar} |
| 175 | + /> |
| 176 | + </TouchableOpacity> |
| 177 | + </View> |
| 178 | + ), |
| 179 | + })} |
| 180 | + /> |
| 181 | + <Stack.Screen |
| 182 | + name="Player" |
| 183 | + component={Player} |
| 184 | + options={{headerShown: false}} |
| 185 | + /> |
| 186 | + <Stack.Screen |
| 187 | + name="ChannelScreen" |
| 188 | + initialParams={{optionsModal: false}} |
| 189 | + component={ChannelStack} |
| 190 | + options={({navigation, route}) => ({ |
| 191 | + headerStyle: { |
| 192 | + height: 45, |
| 193 | + }, |
| 194 | + headerTitleAlign: 'left', |
| 195 | + headerTitle: () => ( |
| 196 | + <Text style={styles.channelName}> |
| 197 | + {route?.params.channelName} |
| 198 | + </Text> |
| 199 | + ), |
| 200 | + })} |
| 201 | + /> |
| 202 | + </Stack.Navigator> |
| 203 | + </NavigationContainer> |
90 | 204 | );
|
91 | 205 | };
|
92 | 206 |
|
93 | 207 | const styles = StyleSheet.create({
|
94 |
| - sectionContainer: { |
95 |
| - marginTop: 32, |
96 |
| - paddingHorizontal: 24, |
| 208 | + logo: { |
| 209 | + width: 90, |
| 210 | + }, |
| 211 | + homeRight: { |
| 212 | + flex: 1, |
| 213 | + flexDirection: 'row', |
| 214 | + alignItems: 'center', |
| 215 | + marginHorizontal: 10, |
| 216 | + justifyContent: 'space-around', |
| 217 | + }, |
| 218 | + channelAvtar: { |
| 219 | + width: 28, |
| 220 | + height: 28, |
| 221 | + borderRadius: 28 / 2, |
| 222 | + }, |
| 223 | + rightButton: { |
| 224 | + marginHorizontal: 8, |
| 225 | + width: 30, |
| 226 | + height: 30, |
| 227 | + borderRadius: 30 / 2, |
97 | 228 | },
|
98 |
| - sectionTitle: { |
99 |
| - fontSize: 24, |
100 |
| - fontWeight: '600', |
| 229 | + channelName: { |
| 230 | + fontFamily: 'Roboto-Medium', |
| 231 | + fontSize: 17.5, |
| 232 | + color: '#040201', |
101 | 233 | },
|
102 |
| - sectionDescription: { |
103 |
| - marginTop: 8, |
104 |
| - fontSize: 18, |
105 |
| - fontWeight: '400', |
| 234 | + channelButton: { |
| 235 | + marginHorizontal: 3, |
| 236 | + alignSelf: 'center', |
| 237 | + width: 30, |
| 238 | + height: 30, |
| 239 | + borderRadius: 30 / 2, |
106 | 240 | },
|
107 |
| - highlight: { |
108 |
| - fontWeight: '700', |
| 241 | + tabAvtar: { |
| 242 | + width: 20, |
| 243 | + height: 20, |
| 244 | + borderRadius: 10, |
109 | 245 | },
|
110 | 246 | });
|
111 | 247 |
|
|
0 commit comments