-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
236 lines (216 loc) · 7.1 KB
/
App.js
File metadata and controls
236 lines (216 loc) · 7.1 KB
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
225
226
227
228
229
230
231
232
233
234
235
236
import React from 'react';
import {StyleSheet,Dimensions,TouchableHighlight, Text, View, ScrollView, Button, Image, ImageBackground, Easing} from 'react-native';
import {Avatar, Title, Caption, Paragraph, Drawer as DW, Text as TextD, TouchableRipple, Switch} from 'react-native-paper';
import {NavigationContainer, useIsFocused,getFocusedRouteNameFromRoute} from '@react-navigation/native';
import {createStackNavigator} from '@react-navigation/stack';
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
import {createMaterialBottomTabNavigator} from '@react-navigation/material-bottom-tabs';
import { createDrawerNavigator } from '@react-navigation/drawer';
//import Icon from 'react-native-ionicons';
//import find from './icons/find.png';
import Icon from 'react-native-vector-icons/FontAwesome';
import {DrawerContent} from './screens/Drawer';
import ProfileStackScreen from './screens/Profile';
import BookmarkStackScreen from './screens/Bookmark';
import FeedScreen from './screens/Feed';
//import {Ionicons} from '@expo/vector-icons';
const Stack = createStackNavigator();
const Tab = createMaterialBottomTabNavigator();//createBottomTabNavigator();
const HomeStack = createStackNavigator();
//const DetailsStack = createStackNavigator();
const Drawer = createDrawerNavigator();
//--FIRST FUNCTION THAT DOESN'T UPDATE TITLE-----//
const HomeScreen = ({navigation}) =>{
return (<View style={{
flex: 1,
justifyContent: "center",
alignItems: "center",
backgroundColor: 'rgb(52,50,70)'
}} >
<Text style={{color: 'lawngreen', fontFamily: "Arial",fontSize: 24}}>Home {"\n"}</Text>
<Button title="Go to Details screen"
color = 'orange'
onPress={()=>navigation.navigate('Details')}/>
</View>);
}
const HomeStackScreen = ({navigation}) =>{
return(
<Stack.Navigator name = "Home"
screenOptions = {{
headerStyle : { backgroundColor:'darkblue'},
headerTintColor : 'white',
headerTitleStyle: {fontFamily:'Baskerville Old Face',
fontWeight:'bold',
alignSelf:'flex-start',
}
}}
headerMode='float'
animation = 'fade' >
<Stack.Screen name = "Home" options={({route})=>({
title:'Home',
headerLeft : ()=>(
<Icon.Button name = "list" backgroundColor="blue" color="white"
onPress = {()=>{navigation.openDrawer()}} />
),
})}
component = {HomeScreen}/>
</Stack.Navigator>
);
}
const DetailsStackScreen = ({navigation}) =>{
return(
<Stack.Navigator initialRouteName = "Details"
screenOptions = {{
headerStyle : { shadowColor : 'violet', shadowOffset:3,backgroundColor:'darkgreen'},
headerTintColor : 'white',
headerTitleStyle: {fontFamily:'Impact',fontWeight:'bold'}
}}
headerMode='float'
animation = 'fade'
>
<Stack.Screen name = "Details" options={({route})=>({
title:'More on This',
headerLeft : ()=>(
<Icon.Button name = "list" backgroundColor="green" color="white"
onPress = {()=>{navigation.openDrawer()}} />
)
})} component = {DetailsScreen}/>
</Stack.Navigator>
);
}
const SettingsScreen = ({navigation}) =>{
const isFocused = useIsFocused();
return (<View style={{
flex: 1,
justifyContent: "center",
backgroundColor:'purple',
alignItems: "center"
}}><Text style={{color: isFocused? 'grey': 'green', fontSize: 24}}>Settings</Text>
<Text style={{color:'white'}}>{'\n'} Yet to be thought of {'\n'} </Text>
<Button title="Go Back" onPress={()=>navigation.goBack()}/>
</View>
);}
const DetailsScreen = (props)=>
(
<View style={{
flex: 1,
justifyContent: "center",
alignItems: "center"
}}><Text style={{color: 'darkblue', fontSize: 24}}>
Details
{"\n"}
</Text>
<Text style = {{flex:0, flexDirection:'row'}}>
{'\u2022'} This ain't much
{"\n"}
{'\u2022'} But it is honest work
</Text>
</View>
)
const HomeStackNavigator = ({navigation,route})=>{
return(
<HomeStack.Navigator /*screenOptions = {{headerShown: false}}/* not needed, as shouldHeaderBeShown already defined*/>
<HomeStack.Screen name = "Home" component={HomeScreen}/>
<HomeStack.Screen name = "Details" component={DetailsScreen}/>
</HomeStack.Navigator>
);
};
const HomeTabNavigator = ()=> (
<Tab.Navigator screenOptions={({route})=>({
tabBarIcon:({color,size})=>{
let iconName;
if(route.name=='Home')
{
iconName = 'home'
}
else if(route.name=='Feed')
{
iconName = 'rss'
}
else if(route.name=='Settings')
{
iconName = 'cog'
}
return <Icon name={iconName} size = {23} color={color} />
}
})}
activeColor= 'orange'
inactiveColor= 'white'
shifting = {true}
/*tabBarOptions={{
style: {backgroundColor : 'darkblue',borderTopColor:'darkblue'}
}}*/
>
<Tab.Screen name="Home" options = {{
tabBarLabel:'Home',
tabBarColor: 'darkblue'
}} component={HomeStackScreen}/>
<Tab.Screen name="Feed" options = {{
tabBarLabel:'Feed',
headerTitle:'Feed',
tabBarColor: 'rgb(50,50,50)'
}}component={FeedScreen}/>
<Tab.Screen name="Settings" options = {{
tabBarLabel:'Settings',
title:'Settings',
tabBarColor: 'rgb(94,68,121)'
}}component={SettingsScreen}/>
</Tab.Navigator>
);
function Drawer_Content(props){
return(
<View>
<Text>test Text</Text>
<Button title="Go to Details screen"
color = 'orange'
onPress={()=>props.navigation.navigate('Details')}/>
</View>
);
}
/*const ProfileScreen = () => {
return (
<View style={styles.container}>
<Text>Profile Screen</Text>
<Button
title="Click Here"
onPress={() => alert('Button Clicked!')}
/>
</View>
);
};
const ProfileStackScreen = ({navigation}) =>{
return(
<Stack.Navigator name = "Profile"
screenOptions = {{
headerStyle : { shadowColor : 'violet', shadowOffset:3,backgroundColor:'darkgreen'},
headerTintColor : 'white',
headerTitleStyle: {fontFamily:'Impact',fontWeight:'bold'}
}}
headerMode='float'
animation = 'fade'
>
<Stack.Screen name = "Profile" options={({route})=>({
title:'Profile',
headerLeft : ()=>(
<Icon.Button name = "list" backgroundColor="green" color="white"
onPress = {()=>{navigation.openDrawer()}} />
)
})} component = {ProfileScreen}/>
</Stack.Navigator>
);
}*/
const App= ({navigation}) => {
return(
<NavigationContainer >
<Drawer.Navigator initialRouteName="Home"
drawerContent = {({navigation})=><DrawerContent {...navigation} /> }
>
<Drawer.Screen name="Home" component={HomeTabNavigator/*HomeStackScreen*/}/>
<Drawer.Screen name="Details" component={DetailsStackScreen} />
<Drawer.Screen name="Profile" component={ProfileStackScreen} />
<Drawer.Screen name="Bookmark" component={BookmarkStackScreen} />
</Drawer.Navigator>
</NavigationContainer>
);
};
export default App;