Introduces SettingsMenu component redesign
This commit is contained in:
@@ -0,0 +1,34 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
|
import { StyleSheet } from 'react-native'
|
||||||
|
import Icon from 'react-native-vector-icons/Entypo'
|
||||||
|
|
||||||
|
import { Colors, Sizes } from '../../styles/redesign'
|
||||||
|
|
||||||
|
const AppIcon = ({ isCTA, name }) => {
|
||||||
|
const style = isCTA ? styles.iconCTA : styles.icon
|
||||||
|
|
||||||
|
return <Icon name={name} style={style}/>
|
||||||
|
}
|
||||||
|
|
||||||
|
AppIcon.propTypes = {
|
||||||
|
isCTA: PropTypes.bool,
|
||||||
|
name: PropTypes.string.isRequired
|
||||||
|
}
|
||||||
|
|
||||||
|
AppIcon.defaultProps = {
|
||||||
|
isCTA: true
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
icon: {
|
||||||
|
color: 'black',
|
||||||
|
fontSize: Sizes.subtitle
|
||||||
|
},
|
||||||
|
iconCTA: {
|
||||||
|
color: Colors.orange,
|
||||||
|
fontSize: Sizes.subtitle
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
export default AppIcon
|
||||||
@@ -4,7 +4,7 @@ import { StyleSheet, View } from 'react-native'
|
|||||||
|
|
||||||
import AppText from './app-text'
|
import AppText from './app-text'
|
||||||
|
|
||||||
import { Colors, Spacing, Sizes, Typography } from '../../styles/redesign'
|
import { Containers, Spacing, Sizes, Typography } from '../../styles/redesign'
|
||||||
|
|
||||||
const Segment = ({ children, last, title }) => {
|
const Segment = ({ children, last, title }) => {
|
||||||
const containerStyle = last ? styles.containerLast : styles.container
|
const containerStyle = last ? styles.containerLast : styles.container
|
||||||
@@ -23,13 +23,6 @@ Segment.propTypes = {
|
|||||||
title: PropTypes.string
|
title: PropTypes.string
|
||||||
}
|
}
|
||||||
|
|
||||||
const bottomBorder = {
|
|
||||||
borderStyle: 'solid',
|
|
||||||
borderBottomWidth: 2,
|
|
||||||
borderBottomColor: Colors.grey,
|
|
||||||
paddingBottom: Spacing.base
|
|
||||||
}
|
|
||||||
|
|
||||||
const segmentContainer = {
|
const segmentContainer = {
|
||||||
marginHorizontal: Spacing.base,
|
marginHorizontal: Spacing.base,
|
||||||
marginBottom: Spacing.base,
|
marginBottom: Spacing.base,
|
||||||
@@ -38,7 +31,7 @@ const segmentContainer = {
|
|||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
...segmentContainer,
|
...segmentContainer,
|
||||||
...bottomBorder
|
...Containers.bottomBorder
|
||||||
},
|
},
|
||||||
containerLast: {
|
containerLast: {
|
||||||
...segmentContainer
|
...segmentContainer
|
||||||
|
|||||||
+7
-7
@@ -2,7 +2,7 @@ import symptomViews from './cycle-day/symptoms'
|
|||||||
import settingsViews from './settings'
|
import settingsViews from './settings'
|
||||||
|
|
||||||
import settingsLabels from '../i18n/en/settings'
|
import settingsLabels from '../i18n/en/settings'
|
||||||
const labels = settingsLabels.menuTitles
|
const labels = settingsLabels.menuItems
|
||||||
|
|
||||||
const symptomsPages = Object.keys(symptomViews).map(symptomView => ({
|
const symptomsPages = Object.keys(symptomViews).map(symptomView => ({
|
||||||
component: symptomView,
|
component: symptomView,
|
||||||
@@ -53,32 +53,32 @@ export const pages = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: 'Reminders',
|
component: 'Reminders',
|
||||||
label: labels.reminders,
|
label: labels.reminders.name,
|
||||||
parent: 'SettingsMenu',
|
parent: 'SettingsMenu',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: 'NfpSettings',
|
component: 'NfpSettings',
|
||||||
label: labels.nfpSettings,
|
label: labels.nfpSettings.name,
|
||||||
parent: 'SettingsMenu',
|
parent: 'SettingsMenu',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: 'DataManagement',
|
component: 'DataManagement',
|
||||||
label: labels.dataManagement,
|
label: labels.dataManagement.name,
|
||||||
parent: 'SettingsMenu',
|
parent: 'SettingsMenu',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: 'Password',
|
component: 'Password',
|
||||||
label: labels.password,
|
label: labels.password.name,
|
||||||
parent: 'SettingsMenu',
|
parent: 'SettingsMenu',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: 'About',
|
component: 'About',
|
||||||
label: labels.about,
|
label: 'About',
|
||||||
parent: 'SettingsMenu',
|
parent: 'SettingsMenu',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: 'License',
|
component: 'License',
|
||||||
label: labels.license,
|
label: 'License',
|
||||||
parent: 'SettingsMenu',
|
parent: 'SettingsMenu',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,51 +1,83 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import { TouchableOpacity, ScrollView } from 'react-native'
|
import { StyleSheet, TouchableOpacity, View } from 'react-native'
|
||||||
import { connect } from 'react-redux'
|
|
||||||
|
|
||||||
import { navigate } from '../../slices/navigation'
|
|
||||||
|
|
||||||
import styles from '../../styles/index'
|
|
||||||
|
|
||||||
import settingsLabels from '../../i18n/en/settings'
|
|
||||||
|
|
||||||
|
import AppIcon from '../common/app-icon'
|
||||||
|
import AppPage from '../common/app-page'
|
||||||
import AppText from '../common/app-text'
|
import AppText from '../common/app-text'
|
||||||
|
|
||||||
const labels = settingsLabels.menuTitles
|
import { connect } from 'react-redux'
|
||||||
|
import { navigate } from '../../slices/navigation'
|
||||||
|
|
||||||
|
import { Colors, Containers, Sizes, Spacing } from '../../styles/redesign'
|
||||||
|
import settingsLabels from '../../i18n/en/settings'
|
||||||
|
|
||||||
|
const { menuItems } = settingsLabels
|
||||||
const menu = [
|
const menu = [
|
||||||
{title: labels.reminders, component: 'Reminders'},
|
{ ...menuItems.reminders, component: 'Reminders'},
|
||||||
{title: labels.nfpSettings, component: 'NfpSettings'},
|
{ ...menuItems.nfpSettings, component: 'NfpSettings'},
|
||||||
{title: labels.dataManagement, component: 'DataManagement'},
|
{ ...menuItems.dataManagement, component: 'DataManagement'},
|
||||||
{title: labels.password, component: 'Password'},
|
{ ...menuItems.password, component: 'Password'}
|
||||||
{title: labels.about, component: 'About'},
|
|
||||||
{title: labels.license, component: 'License'}
|
|
||||||
]
|
]
|
||||||
|
|
||||||
const SettingsMenu = ({ navigate }) => {
|
const SettingsMenu = ({ navigate }) => {
|
||||||
return (
|
return (
|
||||||
<ScrollView>
|
<AppPage title={settingsLabels.title}>
|
||||||
{ menu.map(menuItem)}
|
{menu.map((menuItem, i) =>
|
||||||
</ScrollView>
|
<MenuItem item={menuItem} i={i} navigate={navigate} key={i}/>
|
||||||
|
)}
|
||||||
|
</AppPage>
|
||||||
)
|
)
|
||||||
|
|
||||||
function menuItem(item) {
|
|
||||||
return (
|
|
||||||
<TouchableOpacity
|
|
||||||
style={styles.framedSegment}
|
|
||||||
key={item.title}
|
|
||||||
onPress={() => navigate(item.component)}
|
|
||||||
>
|
|
||||||
<AppText>{item.title.toLowerCase()}</AppText>
|
|
||||||
</TouchableOpacity>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsMenu.propTypes = {
|
SettingsMenu.propTypes = {
|
||||||
navigate: PropTypes.func.isRequired
|
navigate: PropTypes.func.isRequired
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const MenuItem = ({ i, item, navigate }) => {
|
||||||
|
const isLast = (menu.length === i + 1)
|
||||||
|
const containerStyle = isLast ? styles.containerLast : styles.container
|
||||||
|
|
||||||
|
return (
|
||||||
|
<TouchableOpacity
|
||||||
|
style={containerStyle}
|
||||||
|
key={item.name}
|
||||||
|
onPress={() => navigate(item.component)}
|
||||||
|
>
|
||||||
|
<View>
|
||||||
|
<AppText style={styles.title}>{item.name}</AppText>
|
||||||
|
{item.text.length > 0 && <AppText>{item.text}</AppText>}
|
||||||
|
</View>
|
||||||
|
<AppIcon name={'chevron-right'} isCTA/>
|
||||||
|
</TouchableOpacity>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
MenuItem.propTypes = {
|
||||||
|
i: PropTypes.number.isRequired,
|
||||||
|
item: PropTypes.object.isRequired,
|
||||||
|
navigate: PropTypes.func.isRequired
|
||||||
|
}
|
||||||
|
|
||||||
|
const menuItemContainer = {
|
||||||
|
margin: Spacing.base,
|
||||||
|
...Containers.rowContainer
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
...menuItemContainer,
|
||||||
|
...Containers.bottomBorder
|
||||||
|
},
|
||||||
|
containerLast: {
|
||||||
|
...menuItemContainer
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
color: Colors.purple,
|
||||||
|
fontSize: Sizes.subtitle
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => {
|
const mapDispatchToProps = (dispatch) => {
|
||||||
return({
|
return({
|
||||||
navigate: (page) => dispatch(navigate(page)),
|
navigate: (page) => dispatch(navigate(page)),
|
||||||
|
|||||||
+7
-7
@@ -1,5 +1,5 @@
|
|||||||
import labels from './settings'
|
import labels from './settings'
|
||||||
const settingsTitles = labels.menuTitles
|
const settingsTitles = labels.menuItems
|
||||||
|
|
||||||
export const shared = {
|
export const shared = {
|
||||||
cancel: 'Cancel',
|
cancel: 'Cancel',
|
||||||
@@ -27,12 +27,12 @@ export const headerTitles = {
|
|||||||
Chart: 'Chart',
|
Chart: 'Chart',
|
||||||
Stats: 'Statistics',
|
Stats: 'Statistics',
|
||||||
SettingsMenu: 'Settings',
|
SettingsMenu: 'Settings',
|
||||||
Reminders: settingsTitles.reminders,
|
Reminders: settingsTitles.reminders.name,
|
||||||
NfpSettings: settingsTitles.nfpSettings,
|
NfpSettings: settingsTitles.nfpSettings.name,
|
||||||
DataManagement: settingsTitles.dataManagement,
|
DataManagement: settingsTitles.dataManagement.name,
|
||||||
Password: settingsTitles.password,
|
Password: settingsTitles.password.name,
|
||||||
About: settingsTitles.about,
|
About: 'About',
|
||||||
License: settingsTitles.license,
|
License: 'License',
|
||||||
bleeding: 'Bleeding',
|
bleeding: 'Bleeding',
|
||||||
temperature: 'Temperature',
|
temperature: 'Temperature',
|
||||||
mucus: 'Cervical Mucus',
|
mucus: 'Cervical Mucus',
|
||||||
|
|||||||
+18
-7
@@ -3,13 +3,24 @@ import links from './links'
|
|||||||
const currentYear = new Date().getFullYear()
|
const currentYear = new Date().getFullYear()
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
menuTitles: {
|
title: 'Settings',
|
||||||
reminders: 'Reminders',
|
menuItems: {
|
||||||
dataManagement: 'Manage your data',
|
reminders: {
|
||||||
nfpSettings: 'NFP settings',
|
name: 'Reminders',
|
||||||
password: 'Password',
|
text: 'turn on/off reminders'
|
||||||
about: 'About',
|
},
|
||||||
license: 'License'
|
nfpSettings: {
|
||||||
|
name:'NFP settings',
|
||||||
|
text: 'define how you want to use NFP',
|
||||||
|
},
|
||||||
|
dataManagement: {
|
||||||
|
name: 'Data',
|
||||||
|
text: 'import, export or delete your data'
|
||||||
|
},
|
||||||
|
password: {
|
||||||
|
name:'Password',
|
||||||
|
text: ''
|
||||||
|
}
|
||||||
},
|
},
|
||||||
export: {
|
export: {
|
||||||
errors: {
|
errors: {
|
||||||
|
|||||||
@@ -1,4 +1,13 @@
|
|||||||
|
import Colors from './colors'
|
||||||
|
import Spacing from './spacing'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
bottomBorder: {
|
||||||
|
borderStyle: 'solid',
|
||||||
|
borderBottomWidth: 2,
|
||||||
|
borderBottomColor: Colors.grey,
|
||||||
|
paddingBottom: Spacing.base
|
||||||
|
},
|
||||||
centerItems: {
|
centerItems: {
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
flex: 1,
|
flex: 1,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
export default {
|
export default {
|
||||||
|
small: 10,
|
||||||
base: 16,
|
base: 16,
|
||||||
large: 20
|
large: 20
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user