Skip to content

Commit 1947a95

Browse files
committed
final commit of full code
0 parents  commit 1947a95

16 files changed

+7785
-0
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules/**/*
2+
.expo/*
3+
npm-debug.*
4+
*.jks
5+
*.p12
6+
*.key
7+
*.mobileprovision

.watchmanconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

App.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react';
2+
import { StyleSheet, Text, View } from 'react-native';
3+
4+
import DrawerNavigator from './navigation/DrawerNavigator'
5+
6+
export default class App extends React.Component {
7+
render() {
8+
return (
9+
<View style={styles.container}>
10+
<DrawerNavigator />
11+
</View>
12+
);
13+
}
14+
}
15+
16+
const styles = StyleSheet.create({
17+
container: {
18+
flex: 1,
19+
backgroundColor: '#fff',
20+
},
21+
});

app.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"expo": {
3+
"name": "react-navigation-menu-bar",
4+
"slug": "react-navigation-menu-bar",
5+
"privacy": "public",
6+
"sdkVersion": "31.0.0",
7+
"platforms": [
8+
"ios",
9+
"android"
10+
],
11+
"version": "1.0.0",
12+
"orientation": "portrait",
13+
"icon": "./assets/icon.png",
14+
"splash": {
15+
"image": "./assets/splash.png",
16+
"resizeMode": "contain",
17+
"backgroundColor": "#ffffff"
18+
},
19+
"updates": {
20+
"fallbackToCacheTimeout": 0
21+
},
22+
"assetBundlePatterns": [
23+
"**/*"
24+
],
25+
"ios": {
26+
"supportsTablet": true
27+
}
28+
}
29+
}

assets/hays-profile.jpg

19.3 KB
Loading

assets/icon.png

2.91 KB
Loading

assets/splash.png

7.01 KB
Loading

babel.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = function(api) {
2+
api.cache(true);
3+
return {
4+
presets: ['babel-preset-expo'],
5+
};
6+
};

components/MenuButton.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React from 'react'
2+
import { StyleSheet } from 'react-native'
3+
import { Ionicons } from '@expo/vector-icons'
4+
5+
export default class MenuButton extends React.Component {
6+
render() {
7+
return(
8+
<Ionicons
9+
name="md-menu"
10+
color="#000000"
11+
size={32}
12+
style={styles.menuIcon}
13+
onPress={() => this.props.navigation.toggleDrawer()}
14+
/>
15+
)
16+
}
17+
}
18+
19+
const styles = StyleSheet.create({
20+
menuIcon: {
21+
zIndex: 9,
22+
position: 'absolute',
23+
top: 40,
24+
left: 20,
25+
}
26+
})

components/MenuDrawer.js

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
import React from 'react';
2+
import {
3+
View,
4+
Text,
5+
Image,
6+
ScrollView,
7+
Platform,
8+
Dimensions,
9+
StyleSheet,
10+
TouchableOpacity,
11+
} from 'react-native';
12+
13+
const WIDTH = Dimensions.get('window').width
14+
const HEIGHT = Dimensions.get('window').height
15+
16+
export default class MenuDrawer extends React.Component {
17+
navLink(nav, text) {
18+
return(
19+
<TouchableOpacity style={{height: 50}} onPress={() => this.props.navigation.navigate(nav)}>
20+
<Text style={styles.link}>{text}</Text>
21+
</TouchableOpacity>
22+
)
23+
}
24+
25+
render() {
26+
return(
27+
<View style={styles.container}>
28+
<ScrollView style={styles.scroller}>
29+
<View style={styles.topLinks}>
30+
<View style={styles.profile}>
31+
<View style={styles.imgView}>
32+
<Image style={styles.img} source={require('../assets/hays-profile.jpg')} />
33+
</View>
34+
<View style={styles.profileText}>
35+
<Text style={styles.name}>Hays Stanford</Text>
36+
</View>
37+
</View>
38+
</View>
39+
<View style={styles.bottomLinks}>
40+
{this.navLink('Home', 'Home')}
41+
{this.navLink('Links', 'Links')}
42+
{this.navLink('Settings', 'Settings')}
43+
</View>
44+
</ScrollView>
45+
<View style={styles.footer}>
46+
<Text style={styles.description}>Menu Tutorial</Text>
47+
<Text style={styles.version}>v1.0</Text>
48+
</View>
49+
</View>
50+
)
51+
}
52+
}
53+
54+
const styles = StyleSheet.create({
55+
container: {
56+
flex: 1,
57+
backgroundColor: 'lightgray',
58+
},
59+
scroller: {
60+
flex: 1,
61+
},
62+
profile: {
63+
flex: 1,
64+
flexDirection: 'row',
65+
alignItems: 'center',
66+
paddingTop: 25,
67+
borderBottomWidth: 1,
68+
borderBottomColor: '#777777',
69+
},
70+
profileText: {
71+
flex: 3,
72+
flexDirection: 'column',
73+
justifyContent: 'center',
74+
},
75+
name: {
76+
fontSize: 20,
77+
paddingBottom: 5,
78+
color: 'white',
79+
textAlign: 'left',
80+
},
81+
imgView: {
82+
flex: 1,
83+
paddingLeft: 20,
84+
paddingRight: 20,
85+
},
86+
img: {
87+
height: 70,
88+
width: 70,
89+
borderRadius: 50,
90+
},
91+
topLinks:{
92+
height: 160,
93+
backgroundColor: 'black',
94+
},
95+
bottomLinks: {
96+
flex: 1,
97+
backgroundColor: 'white',
98+
paddingTop: 10,
99+
paddingBottom: 450,
100+
},
101+
link: {
102+
flex: 1,
103+
fontSize: 20,
104+
padding: 6,
105+
paddingLeft: 14,
106+
margin: 5,
107+
textAlign: 'left',
108+
},
109+
footer: {
110+
height: 50,
111+
flexDirection: 'row',
112+
alignItems: 'center',
113+
backgroundColor: 'white',
114+
borderTopWidth: 1,
115+
borderTopColor: 'lightgray'
116+
},
117+
version: {
118+
flex: 1,
119+
textAlign: 'right',
120+
marginRight: 20,
121+
color: 'gray'
122+
},
123+
description: {
124+
flex: 1,
125+
marginLeft: 20,
126+
fontSize: 16,
127+
}
128+
})

navigation/DrawerNavigator.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React from 'react';
2+
import { Platform, Dimensions } from 'react-native';
3+
import { createDrawerNavigator, createAppContainer } from 'react-navigation';
4+
5+
import HomeScreen from '../screens/HomeScreen';
6+
import LinksScreen from '../screens/LinksScreen';
7+
import SettingsScreen from '../screens/SettingsScreen';
8+
9+
import MenuDrawer from '../components/MenuDrawer';
10+
11+
const WIDTH = Dimensions.get('window').width;
12+
13+
const DrawerConfig = {
14+
drawerWidth: WIDTH*0.83,
15+
contentComponent: ({ navigation }) => {
16+
return(<MenuDrawer navigation={navigation} />)
17+
}
18+
}
19+
20+
const DrawerNavigator = createDrawerNavigator(
21+
{
22+
Home: {
23+
screen: HomeScreen
24+
},
25+
Links: {
26+
screen: LinksScreen
27+
},
28+
Settings: {
29+
screen: SettingsScreen
30+
}
31+
},
32+
DrawerConfig
33+
);
34+
35+
export default createAppContainer(DrawerNavigator);

0 commit comments

Comments
 (0)