-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.js
114 lines (109 loc) · 2.73 KB
/
menu.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
import React from "react";
import PropTypes from "prop-types";
import {
Dimensions,
StyleSheet,
ScrollView,
View,
Image,
Text,
AsyncStorage,
TouchableOpacity
} from "react-native";
import { Actions } from "react-native-router-flux";
const window = Dimensions.get("window");
const uri =
"https://pickaface.net/gallery/avatar/unr_hannah_180914_0056_cqgc.png";
const styles = StyleSheet.create({
menu: {
flex: 1,
width: window.width,
height: window.height,
backgroundColor: "#DCDCDC",
padding: 10
},
avatarContainer: {
marginBottom: 10,
marginTop: 10
},
avatar: {
width: 48,
height: 48,
borderRadius: 24,
flex: 1
},
name: {
position: "absolute",
left: 80,
top: 4,
fontSize: 30
},
item: {
fontSize: 20,
fontWeight: "300",
paddingTop: 15
},
categoryIcon: {
height: 50,
width: 50,
borderRadius: 70
},
categoryShow: {
width: 300,
paddingLeft: 10,
flexDirection: "row"
}
});
_removeData = async () => {
try {
await AsyncStorage.removeItem("username");
Actions.pop({ key: Actions.login() });
Actions.refresh({ key: Actions.login() });
} catch (exception) {
return false;
}
};
export default function Menu({ onItemSelected, username, categoryArr }) {
return (
<ScrollView scrollsToTop={false} style={styles.menu}>
<View style={styles.avatarContainer}>
<View style={{ flexDirection: "column", paddingLeft: 10 }}>
<Image style={styles.avatar} source={{ uri }} />
<TouchableOpacity style={{ paddingTop: 5 }} onPress={_removeData}>
<Text>LOGOUT</Text>
</TouchableOpacity>
</View>
<Text style={styles.name}>{username}</Text>
</View>
<Text onPress={() => onItemSelected("YourTimeline")} style={styles.item}>
Timeline
</Text>
<Text onPress={() => onItemSelected("MyUploades")} style={styles.item}>
My Uploades
</Text>
<Text onPress={() => onItemSelected("AddPost")} style={styles.item}>
Add Post
</Text>
<Text onPress={() => onItemSelected("AddCategory")} style={styles.item}>
Add Category
</Text>
<Text style={{ color: "black", fontSize: 25, padding: 20 }}>
Uploaded Category
</Text>
{categoryArr.map((x, index) => (
<View key={index} style={styles.categoryShow}>
<Image style={styles.categoryIcon} source={{ uri: x.img }} />
<Text
style={{ color: "black", padding: 15 }}
onPress={() => onItemSelected(x.category)}
>
{x.category.toUpperCase()}
</Text>
</View>
))}
</ScrollView>
);
}
Menu.propTypes = {
onItemSelected: PropTypes.func.isRequired
};