Introduces bottom menu redesign (Menu component)

This commit is contained in:
mashazyu authored and Sofiya Tepikin committed 2020-08-22 13:05:17 +02:00
1 parent b9d85042ef
commit cec8dbaf38
7 files changed
+96 -58

No files matched your search

Binary file not shown.
+21
View File
@@ -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
+13 -33
View File
@@ -1,30 +1,23 @@
import React from 'react'
import { View } from 'react-native'
import PropTypes from 'prop-types'
import { StyleSheet, View } from 'react-native'
import MenuItem from './menu-item'
import { connect } from 'react-redux'
import { getNavigation, navigate } from '../../slices/navigation'
import { Containers } from '../../styles/redesign'
import { pages } from '../pages'
import styles from '../../styles'
const Menu = ({ navigate, navigation }) => {
const Menu = () => {
const menuItems = pages.filter(page => page.isInMenu)
return (
<View style={styles.menu}>
{ menuItems.map(({ icon, label, component, children }) => {
const isActive = (component === navigation.currentPage) ||
(children && children.indexOf(navigation.currentPage) !== -1)
<View style={styles.container}>
{ menuItems.map(({ icon, label, component }) => {
return (
<MenuItem
component={component}
icon={icon}
key={label}
label={label}
icon={icon}
active={isActive}
onPress={() => navigate(component)}
/>
)}
)}
@@ -32,24 +25,11 @@ const Menu = ({ navigate, navigation }) => {
)
}
Menu.propTypes = {
navigation: PropTypes.object,
navigate: PropTypes.func,
const styles = StyleSheet.create({
container: {
backgroundColor: 'white',
...Containers.rowContainer
}
const mapStateToProps = (state) => {
return({
navigation: getNavigation(state),
})
}
const mapDispatchToProps = (dispatch) => {
return({
navigate: (page) => dispatch(navigate(page)),
})
}
export default connect(
mapStateToProps,
mapDispatchToProps,
)(Menu)
export default Menu
+55 -19
View File
@@ -1,36 +1,72 @@
import React from 'react'
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 'react-native-vector-icons/MaterialCommunityIcons'
import Icon from '../common/menu-icon'
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) => {
acc[curr] = menuTitles[curr].toLowerCase()
return acc
}, {})
import { Colors, Containers, Fonts, Sizes, Spacing } from '../../styles/redesign'
export default function MenuItem({ active, icon, label, onPress }) {
const styleActive = active ? { color: secondaryColor } : null
const MenuItem = ({ component, icon, label, navigate, navigation }) => {
const isActive = (component === navigation.currentPage)
const textStyle = isActive ? styles.menuTextActive : styles.menuText
const testID = isActive ? 'activeMenuItem' : `menuItem${label}`
return (
<TouchableOpacity style={styles.menuItem} onPress={onPress} >
<Icon name={icon} {...iconStyles.menuIcon} {...styleActive} />
<Text
testID={active ? 'activeMenuItem' : `menuItem${label}`}
style={[styles.menuText, styleActive]}
<TouchableOpacity
style={styles.button}
onPress={() => navigate(component)}
>
{menuTitlesLowerCase[label]}
</Text>
<Icon name={icon} isActive={isActive}/>
<Text testID={testID} style={textStyle} >{label}</Text>
</TouchableOpacity>
)
}
MenuItem.propTypes = {
active: PropTypes.bool,
component: PropTypes.string.isRequired,
icon: 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
View File
@@ -19,26 +19,25 @@ export const pages = [
{
component: 'Home',
icon: 'home',
isInMenu: true,
label: 'Home',
},
{
component: 'Calendar',
icon: 'calendar-range',
icon: 'calendar',
isInMenu: true,
label: 'Calendar',
parent: 'Home',
},
{
component: 'Chart',
icon: 'chart-line',
icon: 'chart',
isInMenu: true,
label: 'Chart',
parent: 'Home',
},
{
component: 'Stats',
icon: 'chart-pie',
icon: 'statistics',
isInMenu: true,
label: 'Stats',
parent: 'Home',
@@ -47,7 +46,6 @@ export const pages = [
children: Object.keys(settingsViews),
component: 'SettingsMenu',
icon: 'settings',
isInMenu: true,
label: 'Settings',
parent: 'Home',
},
Executable
+1
View File
@@ -0,0 +1 @@
{"IcoMoonType":"selection","icons":[{"icon":{"paths":["M978.192 487.15c-3.642-2.692-8.217-3.808-12.7-3.108l-404.883 62.3c-6.692 1.025-12.15 5.917-13.892 12.458-1.75 6.542 0.533 13.5 5.817 17.725l319.775 255.833c7.367 5.892 18.108 4.7 24-2.658 60.858-75.458 93.9-169.558 93.558-266.5-0.008-21.708-1.642-43.392-4.9-64.85-0.683-4.483-3.117-8.517-6.775-11.2v0zM880.042 794.808l-275.883-220.65 349.217-53.725c1.558 14.2 2.342 28.475 2.358 42.767 0.308 83.333-26.233 164.542-75.692 231.608z","M492.717 553.217l-114.842-387.667c-1.283-4.35-4.25-8.008-8.225-10.167-3.983-2.158-8.667-2.65-13.008-1.358-149.65 44.225-263.183 166.675-295.983 319.233s20.367 310.85 138.608 412.675l-103.933 103.933h-95.333v34.133h102.4c4.525 0 8.867-1.8 12.067-5l111.633-111.633c184.242 135.142 442.283 100.867 584.875-77.667 5.892-7.367 4.7-18.108-2.667-24l-315.592-252.483zM475.525 952.442c-80.117 0.058-158.242-24.958-223.417-71.542l55.092-55.075v56.708l34.133-34.133v-80.4h-80.433l-34.133 34.133h56.708l-58.025 58.025c-105.542-89.675-154.825-229.1-129.1-365.183 25.733-136.083 122.525-247.883 253.517-292.833l109.583 369.425c0.983 3.275 2.933 6.175 5.6 8.325l300.933 240.642c-73.108 84.008-179.092 132.133-290.458 131.908z","M921.6 0c-4.525 0-8.867 1.8-12.067 5l-132.492 132.492c-104.008-68.267-232.842-87.167-352.083-51.667-9.042 2.675-14.2 12.175-11.517 21.217l116.358 392.742c2.142 7.233 8.783 12.2 16.333 12.217 0.875 0 1.75-0.067 2.608-0.208l404.908-62.292c9.3-1.433 15.692-10.133 14.267-19.433-17.025-108.425-75.267-206.083-162.575-272.592l123.325-123.342h95.333v-34.133h-102.4zM926.092 416.425l-366.575 56.325-105.358-355.283c101.033-25.342 208.033-8.283 296.175 47.208l-84.733 84.7v-56.708l-34.133 34.133v80.4h80.433l34.133-34.133h-56.708l89.15-89.125c76.158 56.675 128.717 139.458 147.617 232.483v0z","M938.667 51.2h85.333v34.133h-85.333z","M887.467 102.4h136.533v34.133h-136.533z","M989.867 153.6h34.133v34.133h-34.133z","M887.467 153.6h85.333v34.133h-85.333z","M0 938.667h85.333v34.133h-85.333z","M0 887.467h136.533v34.133h-136.533z","M0 836.267h34.133v34.133h-34.133z","M51.2 836.267h85.333v34.133h-85.333z"],"attrs":[{},{},{},{},{},{},{},{},{},{},{}],"isMulticolor":false,"isMulticolor2":false,"grid":0,"tags":["statistics"]},"attrs":[{},{},{},{},{},{},{},{},{},{},{}],"properties":{"order":2,"id":2,"name":"statistics","prevSize":32,"code":59648},"setIdx":0,"setId":2,"iconIdx":0},{"icon":{"paths":["M18.006 0c-9.322 0-16.88 7.558-16.88 16.88v187.092c0.002 9.322 7.558 16.88 16.88 16.88s16.88-7.558 16.88-16.88v-187.092c0-9.322-7.556-16.88-16.88-16.88z","M1005.996 990.24h-967.94c13.25-74.266 64.254-339.404 134.452-446.468 12.788 11.386 29.62 18.324 48.046 18.324 17.384 0 33.35-6.166 45.84-16.422 9.598 26.156 15.472 60.96 21.592 97.334 11.464 68.13 23.322 138.452 63.164 176.572-0.254 2.464-0.39 4.964-0.39 7.496 0 39.89 32.452 72.344 72.344 72.344 39.89 0 72.342-32.452 72.342-72.344 0-7.7-1.22-15.114-3.46-22.080 31.302-49.986 38.098-137.474 45.272-229.966 6.288-81.084 12.784-164.584 36.87-210.060 13.13 13.336 31.372 21.624 51.522 21.624 20.19 0 38.464-8.322 51.6-21.704 17.594 32.478 22.606 84.46 27.474 135.012 5.922 61.51 11.526 119.708 38.352 155.906-1.414 5.634-2.174 11.522-2.174 17.59 0 39.89 32.452 72.344 72.344 72.344s72.344-32.452 72.344-72.344c0-7.744-1.236-15.2-3.5-22.2 28.724-43.006 35.702-114.888 43.062-190.832 5.062-52.238 10.294-106.254 23.212-145.062 12.93-38.846 30.704-56.172 57.63-56.172 9.324 0 16.88-7.558 16.88-16.88s-7.556-16.88-16.88-16.88c-41.986 0-72.152 26.668-89.662 79.268-14.118 42.42-19.542 98.366-24.784 152.468-5.914 61.050-12.014 123.864-30.228 162.294-12.79-11.402-29.636-18.348-48.076-18.348-19.902 0-37.948 8.080-51.042 21.128-14.75-30.794-19.38-78.816-23.876-125.518-5.99-62.238-12.184-126.46-42.508-164.826 1.414-5.636 2.174-11.526 2.174-17.592 0-39.89-32.452-72.344-72.344-72.344s-72.344 32.452-72.344 72.344c0 5.964 0.74 11.754 2.106 17.302-36.906 48.862-44.162 142.184-51.814 240.864-5.892 75.98-11.968 154.218-32.7 200.42-12.756-11.256-29.488-18.106-47.796-18.106-23.846 0-45.026 11.602-58.212 29.452-24.506-33.326-34.206-90.86-43.616-146.78-7.982-47.44-15.566-92.416-32.324-124.136 2.546-7.38 3.946-15.286 3.946-23.518 0-39.89-32.452-72.344-72.342-72.344s-72.344 32.452-72.344 72.344c0 8.406 1.456 16.474 4.104 23.986-50.636 68.72-91.154 209.734-117.428 323.118v-565.372c0-9.322-7.558-16.88-16.88-16.88s-16.88 7.558-16.88 16.88v735.642c0 0.104 0.014 0.202 0.016 0.306 0.006 0.336 0.024 0.668 0.050 1 0.018 0.234 0.036 0.466 0.062 0.696 0.038 0.32 0.088 0.634 0.144 0.948 0.042 0.246 0.088 0.488 0.14 0.73 0.062 0.282 0.138 0.56 0.216 0.838 0.072 0.264 0.146 0.526 0.232 0.784 0.082 0.248 0.174 0.488 0.268 0.732 0.106 0.274 0.212 0.55 0.33 0.818 0.098 0.22 0.208 0.434 0.312 0.65 0.136 0.272 0.272 0.542 0.42 0.806 0.12 0.21 0.248 0.412 0.374 0.614 0.158 0.252 0.316 0.502 0.486 0.748 0.146 0.21 0.302 0.41 0.46 0.612 0.172 0.22 0.34 0.442 0.52 0.652s0.37 0.412 0.558 0.614c0.176 0.186 0.348 0.374 0.534 0.554 0.212 0.204 0.432 0.4 0.654 0.596 0.182 0.16 Line truncated
+3 -1
View File
@@ -7,9 +7,11 @@ export const fonts = {
}
export const sizes = {
small: 14,
base: 18,
subtitle: 22,
title: 24
title: 24,
icon: 40
}
const title = {