Newer
Older
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 { Modal, StyleSheet, TouchableOpacity, View } from 'react-native'
import PropTypes from 'prop-types'
import AppIcon from '../common/app-icon'
import AppText from '../common/app-text'
import { connect } from 'react-redux'
import { navigate } from '../../slices/navigation'
import { Sizes, Typography } from '../../styles/redesign'
import settingsLabels from '../../i18n/en/settings'
const { menuItems } = settingsLabels
const settingsMenuItems = [
{name: menuItems.settings, component: 'SettingsMenu'},
{name: menuItems.about, component: 'About'},
{name: menuItems.license, component: 'License'},
]
const SideMenu = ({ navigate, onPress, shouldShowMenu }) => {
const navigateMenuItem = (page) => {
onPress()
navigate(page)
}
return(
<React.Fragment>
{!shouldShowMenu &&
<TouchableOpacity onPress={onPress}>
<AppIcon name={'dots-three-vertical'} isCTA/>
</TouchableOpacity>
}
{shouldShowMenu &&
<Modal
animationType='fade'
onRequestClose={onPress}
transparent={true}
visible={shouldShowMenu}
>
<View style={styles.blackBackground}></View>
<View style={styles.menu}>
<TouchableOpacity onPress={onPress} style={styles.iconContainer}>
<AppIcon name={'cross'}/>
</TouchableOpacity>
{settingsMenuItems.map(item =>
<MenuItem
item={item}
key={item.name}
navigate={navigateMenuItem}
/>
)}
</View>
</Modal>
}
</React.Fragment>
)
}
SideMenu.propTypes = {
navigate: PropTypes.func.isRequired,
onPress: PropTypes.func,
shouldShowMenu: PropTypes.bool.isRequired
}
const MenuItem = ({ item, navigate }) => {
return(
<View style={styles.menuItem}>
<TouchableOpacity onPress={() => navigate(item.component)}>
<AppText style={styles.text}>{item.name}</AppText>
</TouchableOpacity>
</View>
)
}
MenuItem.propTypes = {
item: PropTypes.object.isRequired,
navigate: PropTypes.func.isRequired,
}
const styles = StyleSheet.create({
blackBackground: {
backgroundColor: 'black',
flex: 1,
opacity: 0.65,
},
iconContainer: {
alignSelf: 'flex-end',
marginBottom: Sizes.base
},
menu: {
alignSelf: 'flex-end',
backgroundColor: 'white',
height: '100%',
padding: Sizes.base,
position: 'absolute',
width: '60%'
},
text: {
...Typography.subtitle
}
})
const mapDispatchToProps = (dispatch) => {
return({
navigate: (page) => dispatch(navigate(page)),
})
}
export default connect(
null,
mapDispatchToProps,
)(SideMenu)