Merge branch '614/Use-translation-library-for-settings-menu' into 'main'
614 Use translation library for settings menu See merge request bloodyhealth/drip!529
This commit is contained in:
@@ -20,7 +20,7 @@ const SymptomBox = ({
|
|||||||
editedSymptom,
|
editedSymptom,
|
||||||
setEditedSymptom,
|
setEditedSymptom,
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation(null, { keyPrefix: 'cycleDay.symptomBox' })
|
||||||
const isSymptomEdited = editedSymptom === symptom
|
const isSymptomEdited = editedSymptom === symptom
|
||||||
const isSymptomDisabled = isDateInFuture(date) && symptom !== 'note'
|
const isSymptomDisabled = isDateInFuture(date) && symptom !== 'note'
|
||||||
const isExcluded = symptomData !== null ? symptomData.exclude : false
|
const isExcluded = symptomData !== null ? symptomData.exclude : false
|
||||||
@@ -62,9 +62,7 @@ const SymptomBox = ({
|
|||||||
size={Sizes.icon}
|
size={Sizes.icon}
|
||||||
/>
|
/>
|
||||||
<View style={styles.textContainer}>
|
<View style={styles.textContainer}>
|
||||||
<AppText style={symptomNameStyle}>
|
<AppText style={symptomNameStyle}>{t(symptom)}</AppText>
|
||||||
{t(`cycleDay.symptomBox.${symptom}`)}
|
|
||||||
</AppText>
|
|
||||||
{symptomDataToDisplay && (
|
{symptomDataToDisplay && (
|
||||||
<AppText style={textStyle} numberOfLines={4}>
|
<AppText style={textStyle} numberOfLines={4}>
|
||||||
{symptomDataToDisplay}
|
{symptomDataToDisplay}
|
||||||
|
|||||||
@@ -7,28 +7,28 @@ import {
|
|||||||
View,
|
View,
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
|
import AppText from '../common/app-text'
|
||||||
|
|
||||||
import AppIcon from '../common/app-icon'
|
import AppIcon from '../common/app-icon'
|
||||||
import CloseIcon from '../common/close-icon'
|
import CloseIcon from '../common/close-icon'
|
||||||
import MenuItem from './menu-item'
|
|
||||||
|
|
||||||
import { Colors, Sizes } from '../../styles'
|
import { Colors, Sizes, Typography } from '../../styles'
|
||||||
import settingsLabels from '../../i18n/en/settings'
|
|
||||||
import { HIT_SLOP } from '../../config'
|
import { HIT_SLOP } from '../../config'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
const { menuItems } = settingsLabels
|
|
||||||
|
|
||||||
const settingsMenuItems = [
|
const settingsMenuItems = [
|
||||||
{ name: menuItems.settings, component: 'SettingsMenu' },
|
{ labelKey: 'settings', componentName: 'SettingsMenu' },
|
||||||
{ name: menuItems.about, component: 'About' },
|
{ labelKey: 'about', componentName: 'About' },
|
||||||
{ name: menuItems.license, component: 'License' },
|
{ labelKey: 'license', componentName: 'License' },
|
||||||
{ name: menuItems.privacyPolicy, component: 'PrivacyPolicy' },
|
{ labelKey: 'privacyPolicy', componentName: 'PrivacyPolicy' },
|
||||||
]
|
]
|
||||||
|
|
||||||
const HamburgerMenu = ({ navigate }) => {
|
const HamburgerMenu = ({ navigate }) => {
|
||||||
const [isOpen, setIsOpen] = useState(false)
|
const [isOpen, setIsOpen] = useState(false)
|
||||||
const closeMenu = () => setIsOpen(false)
|
const closeMenu = () => setIsOpen(false)
|
||||||
|
|
||||||
|
const { t } = useTranslation(null, { keyPrefix: 'hamburgerMenu.menuMain' })
|
||||||
|
|
||||||
if (!isOpen)
|
if (!isOpen)
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity onPress={() => setIsOpen(true)} hitSlop={HIT_SLOP}>
|
<TouchableOpacity onPress={() => setIsOpen(true)} hitSlop={HIT_SLOP}>
|
||||||
@@ -36,23 +36,25 @@ const HamburgerMenu = ({ navigate }) => {
|
|||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
function onPress(componentName) {
|
||||||
|
closeMenu()
|
||||||
|
navigate(componentName)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal animationType="fade" onRequestClose={closeMenu} transparent={true}>
|
<Modal animationType="fade" onRequestClose={closeMenu} transparent>
|
||||||
<TouchableOpacity
|
<TouchableOpacity onPress={closeMenu} style={styles.blackBackground} />
|
||||||
onPress={closeMenu}
|
|
||||||
style={styles.blackBackground}
|
|
||||||
></TouchableOpacity>
|
|
||||||
<View style={styles.menu}>
|
<View style={styles.menu}>
|
||||||
<View style={styles.iconContainer}>
|
<View style={styles.iconContainer}>
|
||||||
<CloseIcon color={'black'} onClose={closeMenu} />
|
<CloseIcon color={'black'} onClose={closeMenu} />
|
||||||
</View>
|
</View>
|
||||||
{settingsMenuItems.map((item) => (
|
{settingsMenuItems.map(({ labelKey, componentName }) => (
|
||||||
<MenuItem
|
<TouchableOpacity
|
||||||
item={item}
|
onPress={() => onPress(componentName)}
|
||||||
key={item.name}
|
key={labelKey}
|
||||||
closeMenu={closeMenu}
|
>
|
||||||
navigate={navigate}
|
<AppText style={styles.menuItem}>{t(labelKey)}</AppText>
|
||||||
/>
|
</TouchableOpacity>
|
||||||
))}
|
))}
|
||||||
</View>
|
</View>
|
||||||
</Modal>
|
</Modal>
|
||||||
@@ -84,4 +86,5 @@ const styles = StyleSheet.create({
|
|||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
width: '60%',
|
width: '60%',
|
||||||
},
|
},
|
||||||
|
menuItem: Typography.subtitle,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
import React from 'react'
|
|
||||||
import { StyleSheet, TouchableOpacity } from 'react-native'
|
|
||||||
import PropTypes from 'prop-types'
|
|
||||||
|
|
||||||
import AppText from '../common/app-text'
|
|
||||||
|
|
||||||
import { Typography } from '../../styles'
|
|
||||||
|
|
||||||
const MenuItem = ({ item, navigate, closeMenu }) => {
|
|
||||||
const { component, name } = item
|
|
||||||
const onPress = () => {
|
|
||||||
closeMenu()
|
|
||||||
navigate(component)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<TouchableOpacity onPress={onPress}>
|
|
||||||
<AppText style={styles.text}>{name}</AppText>
|
|
||||||
</TouchableOpacity>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
MenuItem.propTypes = {
|
|
||||||
item: PropTypes.object.isRequired,
|
|
||||||
navigate: PropTypes.func.isRequired,
|
|
||||||
closeMenu: PropTypes.func.isRequired,
|
|
||||||
}
|
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
|
||||||
text: {
|
|
||||||
...Typography.subtitle,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
export default MenuItem
|
|
||||||
@@ -12,7 +12,7 @@ import links from '../../i18n/en/links'
|
|||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
const AboutSection = () => {
|
const AboutSection = () => {
|
||||||
const { t } = useTranslation(null, { keyPrefix: 'settings.about' })
|
const { t } = useTranslation(null, { keyPrefix: 'hamburgerMenu.about' })
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppPage title={t('title')}>
|
<AppPage title={t('title')}>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import AppLink from '../common/AppLink'
|
|||||||
import Segment from '../common/segment'
|
import Segment from '../common/segment'
|
||||||
|
|
||||||
const License = ({ children }) => {
|
const License = ({ children }) => {
|
||||||
const { t } = useTranslation(null, { keyPrefix: 'settings.license' })
|
const { t } = useTranslation(null, { keyPrefix: 'hamburgerMenu.license' })
|
||||||
const currentYear = new Date().getFullYear()
|
const currentYear = new Date().getFullYear()
|
||||||
const link = 'https://www.gnu.org/licenses/gpl-3.0.html'
|
const link = 'https://www.gnu.org/licenses/gpl-3.0.html'
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -7,18 +7,22 @@ import AppText from '../common/app-text'
|
|||||||
import Segment from '../common/segment'
|
import Segment from '../common/segment'
|
||||||
|
|
||||||
import { Colors, Containers, Sizes } from '../../styles'
|
import { Colors, Containers, Sizes } from '../../styles'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
const MenuItem = ({ item, last, navigate }) => {
|
const MenuItem = ({ item, last, navigate }) => {
|
||||||
|
const { t } = useTranslation(null, {
|
||||||
|
keyPrefix: 'hamburgerMenu.settings.menuItem',
|
||||||
|
})
|
||||||
return (
|
return (
|
||||||
<Segment last={last}>
|
<Segment last={last}>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={styles.container}
|
style={styles.container}
|
||||||
key={item.name}
|
key={item.label}
|
||||||
onPress={() => navigate(item.component)}
|
onPress={() => navigate(item.componentName)}
|
||||||
>
|
>
|
||||||
<View>
|
<View>
|
||||||
<AppText style={styles.title}>{item.name}</AppText>
|
<AppText style={styles.title}>{t(`${item.label}.name`)}</AppText>
|
||||||
{item.text.length > 0 && <AppText>{item.text}</AppText>}
|
{!!item.label && <AppText>{t(`${item.label}.text`)}</AppText>}
|
||||||
</View>
|
</View>
|
||||||
<AppIcon name="chevron-right" color={Colors.orange} />
|
<AppIcon name="chevron-right" color={Colors.orange} />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ import Segment from '../common/segment'
|
|||||||
import { Colors, Sizes } from '../../styles'
|
import { Colors, Sizes } from '../../styles'
|
||||||
|
|
||||||
const PrivacyPolicy = () => {
|
const PrivacyPolicy = () => {
|
||||||
const { t } = useTranslation(null, { keyPrefix: 'settings.privacyPolicy' })
|
const { t } = useTranslation(null, {
|
||||||
|
keyPrefix: 'hamburgerMenu.privacyPolicy',
|
||||||
|
})
|
||||||
const sections = ['intro', 'dataUse', 'permissions', 'transparency']
|
const sections = ['intro', 'dataUse', 'permissions', 'transparency']
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -4,21 +4,21 @@ import PropTypes from 'prop-types'
|
|||||||
import AppPage from '../common/app-page'
|
import AppPage from '../common/app-page'
|
||||||
import MenuItem from './menu-item'
|
import MenuItem from './menu-item'
|
||||||
|
|
||||||
import settingsLabels from '../../i18n/en/settings'
|
import { useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
const { menuItems } = settingsLabels
|
const menuItems = [
|
||||||
const menu = [
|
{ label: 'reminders', componentName: 'Reminders' },
|
||||||
{ ...menuItems.reminders, component: 'Reminders' },
|
{ label: 'nfpSettings', componentName: 'NfpSettings' },
|
||||||
{ ...menuItems.nfpSettings, component: 'NfpSettings' },
|
{ label: 'dataManagement', componentName: 'DataManagement' },
|
||||||
{ ...menuItems.dataManagement, component: 'DataManagement' },
|
{ label: 'password', componentName: 'Password' },
|
||||||
{ ...menuItems.password, component: 'Password' },
|
|
||||||
]
|
]
|
||||||
|
|
||||||
const SettingsMenu = ({ navigate }) => {
|
const SettingsMenu = ({ navigate }) => {
|
||||||
|
const { t } = useTranslation()
|
||||||
return (
|
return (
|
||||||
<AppPage title={settingsLabels.title}>
|
<AppPage title={t('hamburgerMenu.settings.title')}>
|
||||||
{menu.map((menuItem, i) => {
|
{menuItems.map((menuItem, i) => {
|
||||||
const last = menu.length === i + 1
|
const last = menuItems.length === i + 1
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MenuItem item={menuItem} key={i} last={last} navigate={navigate} />
|
<MenuItem item={menuItem} key={i} last={last} navigate={navigate} />
|
||||||
|
|||||||
+28
-1
@@ -26,7 +26,7 @@
|
|||||||
"ok": "OK"
|
"ok": "OK"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"settings": {
|
"hamburgerMenu": {
|
||||||
"about": {
|
"about": {
|
||||||
"credits": {
|
"credits": {
|
||||||
"title": "Credits",
|
"title": "Credits",
|
||||||
@@ -54,6 +54,12 @@
|
|||||||
"title": "drip. an open-source cycle tracking app",
|
"title": "drip. an open-source cycle tracking app",
|
||||||
"text": "Copyright (C) {{currentYear}} Heart of Code e.V.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details:"
|
"text": "Copyright (C) {{currentYear}} Heart of Code e.V.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details:"
|
||||||
},
|
},
|
||||||
|
"menuMain": {
|
||||||
|
"about": "About",
|
||||||
|
"license": "License",
|
||||||
|
"settings": "Settings",
|
||||||
|
"privacyPolicy": "Privacy Policy"
|
||||||
|
},
|
||||||
"privacyPolicy": {
|
"privacyPolicy": {
|
||||||
"title": "Privacy Policy",
|
"title": "Privacy Policy",
|
||||||
"intro": {
|
"intro": {
|
||||||
@@ -72,6 +78,27 @@
|
|||||||
"title": "Transparency",
|
"title": "Transparency",
|
||||||
"text": "You can read through the source code of drip. to ensure the given information is correct. The source code is like a recipe: It tells you how much and what kind of ingredients you need and how you prepare them to cook a tasty meal or program a funky app.\n\nBuon appetito!"
|
"text": "You can read through the source code of drip. to ensure the given information is correct. The source code is like a recipe: It tells you how much and what kind of ingredients you need and how you prepare them to cook a tasty meal or program a funky app.\n\nBuon appetito!"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"settings": {
|
||||||
|
"menuItem": {
|
||||||
|
"dataManagement": {
|
||||||
|
"name": "Data",
|
||||||
|
"text": "import, export or delete your data"
|
||||||
|
},
|
||||||
|
"nfpSettings": {
|
||||||
|
"name": "NFP settings",
|
||||||
|
"text": "define how you want to use NFP"
|
||||||
|
},
|
||||||
|
"password": {
|
||||||
|
"name": "Password",
|
||||||
|
"text": ""
|
||||||
|
},
|
||||||
|
"reminders": {
|
||||||
|
"name": "Reminders",
|
||||||
|
"text": "turn on/off reminders"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"title": "Settings"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"stats": {
|
"stats": {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import links from './links'
|
import links from './links'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'Settings',
|
|
||||||
menuItems: {
|
menuItems: {
|
||||||
reminders: {
|
reminders: {
|
||||||
name: 'Reminders',
|
name: 'Reminders',
|
||||||
@@ -19,10 +18,6 @@ export default {
|
|||||||
name: 'Password',
|
name: 'Password',
|
||||||
text: '',
|
text: '',
|
||||||
},
|
},
|
||||||
about: 'About',
|
|
||||||
license: 'License',
|
|
||||||
settings: 'Settings',
|
|
||||||
privacyPolicy: 'Privacy Policy',
|
|
||||||
},
|
},
|
||||||
export: {
|
export: {
|
||||||
errors: {
|
errors: {
|
||||||
|
|||||||
Reference in New Issue
Block a user