Merge branch '683-ui-scaffold-for-customization' into 'main'
Resolve "UI scaffold for customization" Closes #683 See merge request bloodyhealth/drip!642
This commit is contained in:
@@ -6,13 +6,18 @@ import AppText from './app-text'
|
|||||||
|
|
||||||
import { Containers } from '../../styles'
|
import { Containers } from '../../styles'
|
||||||
|
|
||||||
const AppSwitch = ({ onToggle, text, value }) => {
|
const AppSwitch = ({ onToggle, text, value, trackColor }) => {
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<View style={styles.textContainer}>
|
<View style={styles.textContainer}>
|
||||||
<AppText>{text}</AppText>
|
<AppText>{text}</AppText>
|
||||||
</View>
|
</View>
|
||||||
<Switch onValueChange={onToggle} style={styles.switch} value={value} />
|
<Switch
|
||||||
|
onValueChange={onToggle}
|
||||||
|
style={styles.switch}
|
||||||
|
value={value}
|
||||||
|
trackColor={trackColor}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -21,6 +26,7 @@ AppSwitch.propTypes = {
|
|||||||
onToggle: PropTypes.func.isRequired,
|
onToggle: PropTypes.func.isRequired,
|
||||||
text: PropTypes.string,
|
text: PropTypes.string,
|
||||||
value: PropTypes.bool,
|
value: PropTypes.bool,
|
||||||
|
trackColor: PropTypes.string,
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
|
|||||||
+5
-1
@@ -37,13 +37,17 @@ export const pages = [
|
|||||||
parent: 'SettingsMenu',
|
parent: 'SettingsMenu',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: 'NfpSettings',
|
component: 'Customization',
|
||||||
parent: 'SettingsMenu',
|
parent: 'SettingsMenu',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: 'DataManagement',
|
component: 'DataManagement',
|
||||||
parent: 'SettingsMenu',
|
parent: 'SettingsMenu',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
component: 'Info',
|
||||||
|
parent: 'SettingsMenu',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
component: 'Password',
|
component: 'Password',
|
||||||
parent: 'SettingsMenu',
|
parent: 'SettingsMenu',
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import { StyleSheet, View } from 'react-native'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
|
import AppIcon from '../common/app-icon'
|
||||||
|
import AppPage from '../common/app-page'
|
||||||
|
import AppText from '../common/app-text'
|
||||||
|
import Segment from '../common/segment'
|
||||||
|
|
||||||
|
import { Colors, Spacing, Typography } from '../../styles'
|
||||||
|
import labels from '../../i18n/en/settings'
|
||||||
|
|
||||||
|
const Info = () => {
|
||||||
|
const { t } = useTranslation(null, { keyPrefix: 'hamburgerMenu.info' })
|
||||||
|
return (
|
||||||
|
<AppPage title={t('title')}>
|
||||||
|
<Segment last>
|
||||||
|
<View style={styles.line}>
|
||||||
|
<AppIcon
|
||||||
|
color={Colors.purple}
|
||||||
|
name="info-with-circle"
|
||||||
|
style={styles.icon}
|
||||||
|
/>
|
||||||
|
<AppText style={styles.title}>{labels.preOvu.title}</AppText>
|
||||||
|
</View>
|
||||||
|
<AppText>{labels.preOvu.note}</AppText>
|
||||||
|
</Segment>
|
||||||
|
</AppPage>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
Info.propTypes = {
|
||||||
|
children: PropTypes.node,
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Info
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
icon: {
|
||||||
|
marginRight: Spacing.base,
|
||||||
|
},
|
||||||
|
line: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
alignItems: 'center',
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
...Typography.subtitle,
|
||||||
|
},
|
||||||
|
})
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
import React, { useState } from 'react'
|
||||||
|
|
||||||
|
import AppPage from '../../common/app-page'
|
||||||
|
import AppSwitch from '../../common/app-switch'
|
||||||
|
import AppText from '../../common/app-text'
|
||||||
|
import TemperatureSlider from './temperature-slider'
|
||||||
|
import Segment from '../../common/segment'
|
||||||
|
|
||||||
|
import { useCervixObservable, saveUseCervix } from '../../../local-storage'
|
||||||
|
import { Colors } from '../../../styles'
|
||||||
|
import labels from '../../../i18n/en/settings'
|
||||||
|
|
||||||
|
const Settings = () => {
|
||||||
|
const [shouldUseCervix, setShouldUseCervix] = useState(
|
||||||
|
useCervixObservable.value
|
||||||
|
)
|
||||||
|
|
||||||
|
const [isEnabled, setIsEnabled] = useState(true)
|
||||||
|
const toggleSwitch = () => setIsEnabled((previousState) => !previousState)
|
||||||
|
|
||||||
|
const onCervixToggle = (value) => {
|
||||||
|
setShouldUseCervix(value)
|
||||||
|
saveUseCervix(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const cervixText = shouldUseCervix
|
||||||
|
? labels.useCervix.cervixModeOn
|
||||||
|
: labels.useCervix.cervixModeOff
|
||||||
|
|
||||||
|
return (
|
||||||
|
<AppPage title={'Customization'}>
|
||||||
|
<Segment title={'Tracking categories'}>
|
||||||
|
<AppSwitch
|
||||||
|
onToggle={toggleSwitch}
|
||||||
|
text={'temperature'}
|
||||||
|
value={isEnabled}
|
||||||
|
trackColor={{ true: Colors.turquoiseDark }}
|
||||||
|
/>
|
||||||
|
<AppSwitch
|
||||||
|
onToggle={toggleSwitch}
|
||||||
|
text={'cervical mucus'}
|
||||||
|
value={isEnabled}
|
||||||
|
trackColor={{ true: Colors.turquoiseDark }}
|
||||||
|
/>
|
||||||
|
<AppSwitch
|
||||||
|
onToggle={toggleSwitch}
|
||||||
|
text={'cervix'}
|
||||||
|
value={isEnabled}
|
||||||
|
trackColor={{ true: Colors.turquoiseDark }}
|
||||||
|
/>
|
||||||
|
<AppSwitch
|
||||||
|
onToggle={toggleSwitch}
|
||||||
|
text={'sex'}
|
||||||
|
value={isEnabled}
|
||||||
|
trackColor={{ true: Colors.turquoiseDark }}
|
||||||
|
/>
|
||||||
|
<AppSwitch
|
||||||
|
onToggle={toggleSwitch}
|
||||||
|
text={'desire'}
|
||||||
|
value={isEnabled}
|
||||||
|
trackColor={{ true: Colors.turquoiseDark }}
|
||||||
|
/>
|
||||||
|
<AppSwitch
|
||||||
|
onToggle={toggleSwitch}
|
||||||
|
text={'pain'}
|
||||||
|
value={isEnabled}
|
||||||
|
trackColor={{ true: Colors.turquoiseDark }}
|
||||||
|
/>
|
||||||
|
<AppSwitch
|
||||||
|
onToggle={toggleSwitch}
|
||||||
|
text={'mood'}
|
||||||
|
value={isEnabled}
|
||||||
|
trackColor={{ true: Colors.turquoiseDark }}
|
||||||
|
/>
|
||||||
|
<AppSwitch
|
||||||
|
onToggle={toggleSwitch}
|
||||||
|
text={'note'}
|
||||||
|
value={isEnabled}
|
||||||
|
trackColor={{ true: Colors.turquoiseDark }}
|
||||||
|
/>
|
||||||
|
</Segment>
|
||||||
|
|
||||||
|
<Segment title={'Fertility feature'}>
|
||||||
|
<AppSwitch
|
||||||
|
onToggle={toggleSwitch}
|
||||||
|
text={'If turned on ...'}
|
||||||
|
value={isEnabled}
|
||||||
|
trackColor={{ true: Colors.turquoiseDark }}
|
||||||
|
/>
|
||||||
|
</Segment>
|
||||||
|
|
||||||
|
<Segment title={labels.tempScale.segmentTitle}>
|
||||||
|
<AppText>{labels.tempScale.segmentExplainer}</AppText>
|
||||||
|
<TemperatureSlider />
|
||||||
|
</Segment>
|
||||||
|
|
||||||
|
<Segment title={labels.useCervix.title}>
|
||||||
|
<AppSwitch
|
||||||
|
onToggle={onCervixToggle}
|
||||||
|
text={cervixText}
|
||||||
|
value={shouldUseCervix}
|
||||||
|
trackColor={{ true: Colors.turquoiseDark }}
|
||||||
|
/>
|
||||||
|
</Segment>
|
||||||
|
|
||||||
|
<Segment title={'Period prediction'}>
|
||||||
|
<AppSwitch
|
||||||
|
onToggle={toggleSwitch}
|
||||||
|
text={
|
||||||
|
'If turned on drip will predict your next menstrual bleeding, after you have tracked 3 complete menstrual cycles.'
|
||||||
|
}
|
||||||
|
value={isEnabled}
|
||||||
|
trackColor={{ true: Colors.turquoiseDark }}
|
||||||
|
/>
|
||||||
|
</Segment>
|
||||||
|
</AppPage>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Settings
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import Reminders from './reminders/reminders'
|
import Reminders from './reminders/reminders'
|
||||||
import NfpSettings from './nfp-settings'
|
import Customization from './customization'
|
||||||
import DataManagement from './data-management/DataManagement'
|
import DataManagement from './data-management/DataManagement'
|
||||||
|
import Info from './Info'
|
||||||
import Password from './password'
|
import Password from './password'
|
||||||
import About from './About'
|
import About from './About'
|
||||||
import License from './License'
|
import License from './License'
|
||||||
@@ -8,8 +9,9 @@ import PrivacyPolicy from './privacy-policy'
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
Reminders,
|
Reminders,
|
||||||
NfpSettings,
|
Customization,
|
||||||
DataManagement,
|
DataManagement,
|
||||||
|
Info,
|
||||||
Password,
|
Password,
|
||||||
About,
|
About,
|
||||||
License,
|
License,
|
||||||
|
|||||||
@@ -1,73 +0,0 @@
|
|||||||
import React, { useState } from 'react'
|
|
||||||
import { Platform, StyleSheet, View } from 'react-native'
|
|
||||||
|
|
||||||
import AppIcon from '../../common/app-icon'
|
|
||||||
import AppPage from '../../common/app-page'
|
|
||||||
import AppSwitch from '../../common/app-switch'
|
|
||||||
import AppText from '../../common/app-text'
|
|
||||||
import TemperatureSlider from './temperature-slider'
|
|
||||||
import Segment from '../../common/segment'
|
|
||||||
|
|
||||||
import { useCervixObservable, saveUseCervix } from '../../../local-storage'
|
|
||||||
import { Colors, Spacing, Typography } from '../../../styles'
|
|
||||||
import labels from '../../../i18n/en/settings'
|
|
||||||
|
|
||||||
const Settings = () => {
|
|
||||||
const [shouldUseCervix, setShouldUseCervix] = useState(
|
|
||||||
useCervixObservable.value
|
|
||||||
)
|
|
||||||
|
|
||||||
const onCervixToggle = (value) => {
|
|
||||||
setShouldUseCervix(value)
|
|
||||||
saveUseCervix(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
const cervixText = shouldUseCervix
|
|
||||||
? labels.useCervix.cervixModeOn
|
|
||||||
: labels.useCervix.cervixModeOff
|
|
||||||
|
|
||||||
return (
|
|
||||||
<AppPage>
|
|
||||||
<Segment title={labels.useCervix.title}>
|
|
||||||
<AppSwitch
|
|
||||||
onToggle={onCervixToggle}
|
|
||||||
text={cervixText}
|
|
||||||
value={shouldUseCervix}
|
|
||||||
/>
|
|
||||||
</Segment>
|
|
||||||
{/* for iOS disabled temporarily, TODO https://gitlab.com/bloodyhealth/drip/-/issues/545 */}
|
|
||||||
{Platform.OS !== 'ios' && (
|
|
||||||
<Segment title={labels.tempScale.segmentTitle}>
|
|
||||||
<AppText>{labels.tempScale.segmentExplainer}</AppText>
|
|
||||||
<TemperatureSlider />
|
|
||||||
</Segment>
|
|
||||||
)}
|
|
||||||
<Segment last>
|
|
||||||
<View style={styles.line}>
|
|
||||||
<AppIcon
|
|
||||||
color={Colors.purple}
|
|
||||||
name="info-with-circle"
|
|
||||||
style={styles.icon}
|
|
||||||
/>
|
|
||||||
<AppText style={styles.title}>{labels.preOvu.title}</AppText>
|
|
||||||
</View>
|
|
||||||
<AppText>{labels.preOvu.note}</AppText>
|
|
||||||
</Segment>
|
|
||||||
</AppPage>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Settings
|
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
|
||||||
icon: {
|
|
||||||
marginRight: Spacing.base,
|
|
||||||
},
|
|
||||||
line: {
|
|
||||||
flexDirection: 'row',
|
|
||||||
alignItems: 'center',
|
|
||||||
},
|
|
||||||
title: {
|
|
||||||
...Typography.subtitle,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
@@ -7,10 +7,11 @@ import MenuItem from './menu-item'
|
|||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
const menuItems = [
|
const menuItems = [
|
||||||
|
{ label: 'customization', componentName: 'Customization' },
|
||||||
{ label: 'reminders', componentName: 'Reminders' },
|
{ label: 'reminders', componentName: 'Reminders' },
|
||||||
{ label: 'nfpSettings', componentName: 'NfpSettings' },
|
|
||||||
{ label: 'dataManagement', componentName: 'DataManagement' },
|
{ label: 'dataManagement', componentName: 'DataManagement' },
|
||||||
{ label: 'password', componentName: 'Password' },
|
{ label: 'password', componentName: 'Password' },
|
||||||
|
{ label: 'info', componentName: 'Info' },
|
||||||
]
|
]
|
||||||
|
|
||||||
const SettingsMenu = ({ navigate }) => {
|
const SettingsMenu = ({ navigate }) => {
|
||||||
|
|||||||
+10
-3
@@ -116,9 +116,9 @@
|
|||||||
"name": "Data",
|
"name": "Data",
|
||||||
"text": "import, export or delete your data"
|
"text": "import, export or delete your data"
|
||||||
},
|
},
|
||||||
"nfpSettings": {
|
"customization": {
|
||||||
"name": "NFP settings",
|
"name": "Customization",
|
||||||
"text": "define how you want to use NFP"
|
"text": "define how you want to use drip"
|
||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"name": "Password",
|
"name": "Password",
|
||||||
@@ -127,9 +127,16 @@
|
|||||||
"reminders": {
|
"reminders": {
|
||||||
"name": "Reminders",
|
"name": "Reminders",
|
||||||
"text": "turn on/off reminders"
|
"text": "turn on/off reminders"
|
||||||
|
},
|
||||||
|
"info": {
|
||||||
|
"name": "Info",
|
||||||
|
"text": "Learn more about how drip works"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"title": "Settings"
|
"title": "Settings"
|
||||||
|
},
|
||||||
|
"info": {
|
||||||
|
"title": "info"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"stats": {
|
"stats": {
|
||||||
|
|||||||
Reference in New Issue
Block a user