Introduces bottom menu redesign (Menu component)
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,21 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
|
import { createIconSetFromIcoMoon } from 'react-native-vector-icons'
|
||||||
|
import iconConfig from '../../selection.json'
|
||||||
|
|
||||||
|
import { Colors, Sizes } from '../../styles/redesign'
|
||||||
|
|
||||||
|
const Icon = createIconSetFromIcoMoon(iconConfig, '', 'Menu')
|
||||||
|
|
||||||
|
const MenuIcon = ({ isActive, name }) => {
|
||||||
|
const color = isActive ? Colors.greyDark : Colors.grey
|
||||||
|
|
||||||
|
return <Icon name={name} size={Sizes.icon} color={color} />
|
||||||
|
}
|
||||||
|
|
||||||
|
MenuIcon.propTypes = {
|
||||||
|
isActive: PropTypes.bool,
|
||||||
|
name: PropTypes.string.isRequired
|
||||||
|
}
|
||||||
|
|
||||||
|
export default MenuIcon
|
||||||
+15
-35
@@ -1,30 +1,23 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { View } from 'react-native'
|
import { StyleSheet, View } from 'react-native'
|
||||||
import PropTypes from 'prop-types'
|
|
||||||
|
|
||||||
import MenuItem from './menu-item'
|
import MenuItem from './menu-item'
|
||||||
|
|
||||||
import { connect } from 'react-redux'
|
import { Containers } from '../../styles/redesign'
|
||||||
import { getNavigation, navigate } from '../../slices/navigation'
|
|
||||||
|
|
||||||
import { pages } from '../pages'
|
import { pages } from '../pages'
|
||||||
|
|
||||||
import styles from '../../styles'
|
const Menu = () => {
|
||||||
|
|
||||||
const Menu = ({ navigate, navigation }) => {
|
|
||||||
const menuItems = pages.filter(page => page.isInMenu)
|
const menuItems = pages.filter(page => page.isInMenu)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.menu}>
|
<View style={styles.container}>
|
||||||
{ menuItems.map(({ icon, label, component, children }) => {
|
{ menuItems.map(({ icon, label, component }) => {
|
||||||
const isActive = (component === navigation.currentPage) ||
|
|
||||||
(children && children.indexOf(navigation.currentPage) !== -1)
|
|
||||||
return (
|
return (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
|
component={component}
|
||||||
|
icon={icon}
|
||||||
key={label}
|
key={label}
|
||||||
label={label}
|
label={label}
|
||||||
icon={icon}
|
|
||||||
active={isActive}
|
|
||||||
onPress={() => navigate(component)}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
)}
|
)}
|
||||||
@@ -32,24 +25,11 @@ const Menu = ({ navigate, navigation }) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu.propTypes = {
|
const styles = StyleSheet.create({
|
||||||
navigation: PropTypes.object,
|
container: {
|
||||||
navigate: PropTypes.func,
|
backgroundColor: 'white',
|
||||||
}
|
...Containers.rowContainer
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const mapStateToProps = (state) => {
|
export default Menu
|
||||||
return({
|
|
||||||
navigation: getNavigation(state),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => {
|
|
||||||
return({
|
|
||||||
navigate: (page) => dispatch(navigate(page)),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export default connect(
|
|
||||||
mapStateToProps,
|
|
||||||
mapDispatchToProps,
|
|
||||||
)(Menu)
|
|
||||||
@@ -1,36 +1,72 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import { Text, TouchableOpacity } from 'react-native'
|
import { StyleSheet, Text, TouchableOpacity } from 'react-native'
|
||||||
|
|
||||||
import styles, { iconStyles, secondaryColor } from '../../styles'
|
import Icon from '../common/menu-icon'
|
||||||
import Icon from 'react-native-vector-icons/MaterialCommunityIcons'
|
|
||||||
|
|
||||||
import { menuTitles } from '../../i18n/en/labels'
|
import { connect } from 'react-redux'
|
||||||
|
import { getNavigation, navigate } from '../../slices/navigation'
|
||||||
|
|
||||||
const menuTitlesLowerCase = Object.keys(menuTitles).reduce((acc, curr) => {
|
import { Colors, Containers, Fonts, Sizes, Spacing } from '../../styles/redesign'
|
||||||
acc[curr] = menuTitles[curr].toLowerCase()
|
|
||||||
return acc
|
|
||||||
}, {})
|
|
||||||
|
|
||||||
export default function MenuItem({ active, icon, label, onPress }) {
|
const MenuItem = ({ component, icon, label, navigate, navigation }) => {
|
||||||
const styleActive = active ? { color: secondaryColor } : null
|
const isActive = (component === navigation.currentPage)
|
||||||
|
const textStyle = isActive ? styles.menuTextActive : styles.menuText
|
||||||
|
const testID = isActive ? 'activeMenuItem' : `menuItem${label}`
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity style={styles.menuItem} onPress={onPress} >
|
<TouchableOpacity
|
||||||
<Icon name={icon} {...iconStyles.menuIcon} {...styleActive} />
|
style={styles.button}
|
||||||
<Text
|
onPress={() => navigate(component)}
|
||||||
testID={active ? 'activeMenuItem' : `menuItem${label}`}
|
>
|
||||||
style={[styles.menuText, styleActive]}
|
<Icon name={icon} isActive={isActive}/>
|
||||||
>
|
<Text testID={testID} style={textStyle} >{label}</Text>
|
||||||
{menuTitlesLowerCase[label]}
|
|
||||||
</Text>
|
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuItem.propTypes = {
|
MenuItem.propTypes = {
|
||||||
active: PropTypes.bool,
|
component: PropTypes.string.isRequired,
|
||||||
icon: PropTypes.string.isRequired,
|
icon: PropTypes.string.isRequired,
|
||||||
label: PropTypes.string.isRequired,
|
label: PropTypes.string.isRequired,
|
||||||
onPress: PropTypes.func.isRequired
|
navigation: PropTypes.object,
|
||||||
|
navigate: PropTypes.func,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const text = {
|
||||||
|
fontFamily: Fonts.bold,
|
||||||
|
fontSize: Sizes.small,
|
||||||
|
textTransform: 'uppercase'
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
button: {
|
||||||
|
padding: Spacing.base,
|
||||||
|
...Containers.centerItems
|
||||||
|
},
|
||||||
|
menuText: {
|
||||||
|
color: Colors.grey,
|
||||||
|
...text
|
||||||
|
},
|
||||||
|
menuTextActive: {
|
||||||
|
color: Colors.orange,
|
||||||
|
...text
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const mapStateToProps = (state) => {
|
||||||
|
return({
|
||||||
|
navigation: getNavigation(state),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const mapDispatchToProps = (dispatch) => {
|
||||||
|
return({
|
||||||
|
navigate: (page) => dispatch(navigate(page)),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export default connect(
|
||||||
|
mapStateToProps,
|
||||||
|
mapDispatchToProps,
|
||||||
|
)(MenuItem)
|
||||||
|
|||||||
+3
-5
@@ -19,26 +19,25 @@ export const pages = [
|
|||||||
{
|
{
|
||||||
component: 'Home',
|
component: 'Home',
|
||||||
icon: 'home',
|
icon: 'home',
|
||||||
isInMenu: true,
|
|
||||||
label: 'Home',
|
label: 'Home',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: 'Calendar',
|
component: 'Calendar',
|
||||||
icon: 'calendar-range',
|
icon: 'calendar',
|
||||||
isInMenu: true,
|
isInMenu: true,
|
||||||
label: 'Calendar',
|
label: 'Calendar',
|
||||||
parent: 'Home',
|
parent: 'Home',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: 'Chart',
|
component: 'Chart',
|
||||||
icon: 'chart-line',
|
icon: 'chart',
|
||||||
isInMenu: true,
|
isInMenu: true,
|
||||||
label: 'Chart',
|
label: 'Chart',
|
||||||
parent: 'Home',
|
parent: 'Home',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: 'Stats',
|
component: 'Stats',
|
||||||
icon: 'chart-pie',
|
icon: 'statistics',
|
||||||
isInMenu: true,
|
isInMenu: true,
|
||||||
label: 'Stats',
|
label: 'Stats',
|
||||||
parent: 'Home',
|
parent: 'Home',
|
||||||
@@ -47,7 +46,6 @@ export const pages = [
|
|||||||
children: Object.keys(settingsViews),
|
children: Object.keys(settingsViews),
|
||||||
component: 'SettingsMenu',
|
component: 'SettingsMenu',
|
||||||
icon: 'settings',
|
icon: 'settings',
|
||||||
isInMenu: true,
|
|
||||||
label: 'Settings',
|
label: 'Settings',
|
||||||
parent: 'Home',
|
parent: 'Home',
|
||||||
},
|
},
|
||||||
|
|||||||
Executable
+1
File diff suppressed because one or more lines are too long
@@ -7,9 +7,11 @@ export const fonts = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const sizes = {
|
export const sizes = {
|
||||||
|
small: 14,
|
||||||
base: 18,
|
base: 18,
|
||||||
subtitle: 22,
|
subtitle: 22,
|
||||||
title: 24
|
title: 24,
|
||||||
|
icon: 40
|
||||||
}
|
}
|
||||||
|
|
||||||
const title = {
|
const title = {
|
||||||
|
|||||||
Reference in New Issue
Block a user