revision of customization texts and refactoring behavior when disabled

This commit is contained in:
wunderfisch
2024-02-27 18:10:11 +01:00
parent 46a02560e8
commit 661abc8aee
3 changed files with 70 additions and 44 deletions
+18 -3
View File
@@ -7,12 +7,18 @@ import AppText from '../common/app-text'
import { Colors, Containers } from '../../styles' import { Colors, Containers } from '../../styles'
import labels from '../../i18n/en/settings' import labels from '../../i18n/en/settings'
export default function SelectTabGroup({ activeButton, buttons, onSelect }) { export default function SelectTabGroup({
// TODO https://gitlab.com/bloodyhealth/drip/-/issues/707 activeButton,
buttons,
onSelect,
disabled,
}) {
// TODO https://gitlab.com/bloodyhealth/drip/-/issues/707
const oneTimeTransformIntoNumber = const oneTimeTransformIntoNumber =
typeof activeButton === 'boolean' && Number(activeButton) typeof activeButton === 'boolean' && Number(activeButton)
const isSecondarySymptomSwitch = const isSecondarySymptomSwitch =
buttons[0]['label'] === labels.secondarySymptom.mucus buttons[0]['label'] === labels.secondarySymptom.mucus
return ( return (
<View style={styles.container}> <View style={styles.container}>
{buttons.map(({ label, value }, i) => { {buttons.map(({ label, value }, i) => {
@@ -23,16 +29,18 @@ export default function SelectTabGroup({ activeButton, buttons, onSelect }) {
isActive && styles.boxActive, isActive && styles.boxActive,
isSecondarySymptomSwitch && styles.purpleBox, isSecondarySymptomSwitch && styles.purpleBox,
isSecondarySymptomSwitch && isActive && styles.activePurpleBox, isSecondarySymptomSwitch && isActive && styles.activePurpleBox,
disabled && styles.inActiveBox,
] ]
const textStyle = [ const textStyle = [
styles.text, styles.text,
isSecondarySymptomSwitch && styles.purpleText, isSecondarySymptomSwitch && styles.purpleText,
isActive && styles.textActive, isActive && styles.textActive,
disabled && styles.greyText,
] ]
return ( return (
<TouchableOpacity <TouchableOpacity
onPress={() => onSelect(value)} onPress={() => !disabled && onSelect(value)}
key={i} key={i}
style={boxStyle} style={boxStyle}
> >
@@ -75,4 +83,11 @@ const styles = StyleSheet.create({
purpleText: { purpleText: {
color: Colors.purple, color: Colors.purple,
}, },
greyText: {
color: Colors.grey,
},
inActiveBox: {
borderColor: Colors.grey,
backgroundColor: Colors.turquoiseLight,
},
}) })
+46 -37
View File
@@ -143,6 +143,7 @@ const Settings = () => {
}, },
] ]
// NOTE: when disabled (!isFertilityTrackingEnabled) button press doesn't yet trigger alert
const onSelectTab = (value) => { const onSelectTab = (value) => {
if (isMucusTrackingCategoryEnabled && isCervixTrackingCategoryEnabled) { if (isMucusTrackingCategoryEnabled && isCervixTrackingCategoryEnabled) {
setUseCervixAsSecondarySymptom(value) setUseCervixAsSecondarySymptom(value)
@@ -178,7 +179,14 @@ const Settings = () => {
} }
const secondarySymptomDisabledPrompt = () => { const secondarySymptomDisabledPrompt = () => {
if (!isMucusTrackingCategoryEnabled == isCervixTrackingCategoryEnabled) { if (!isFertilityTrackingEnabled) {
Alert.alert(
labels.secondarySymptom.disabled.title,
labels.secondarySymptom.disabled.message
)
} else if (
!isMucusTrackingCategoryEnabled == isCervixTrackingCategoryEnabled
) {
Alert.alert( Alert.alert(
labels.secondarySymptom.disabled.title, labels.secondarySymptom.disabled.title,
labels.secondarySymptom.disabled.noSecondaryEnabled labels.secondarySymptom.disabled.noSecondaryEnabled
@@ -186,6 +194,10 @@ const Settings = () => {
} }
} }
const manageFertilityFeature =
isTemperatureTrackingCategoryEnabled &&
(isMucusTrackingCategoryEnabled || isCervixTrackingCategoryEnabled)
const cervixText = useCervixAsSecondarySymptom const cervixText = useCervixAsSecondarySymptom
? labels.secondarySymptom.cervixModeOn ? labels.secondarySymptom.cervixModeOn
: labels.secondarySymptom.cervixModeOff : labels.secondarySymptom.cervixModeOff
@@ -196,6 +208,14 @@ const Settings = () => {
} }
} }
const fertilityDisabledPrompt = () => {
if (!isFertilityTrackingEnabled) {
Alert.alert(labels.disabled.title, labels.fertilityTracking.disabled)
}
}
console.log('useCervixAsSecondarySymptom :>> ', useCervixAsSecondarySymptom)
return ( return (
<AppPage title={labels.customization.title}> <AppPage title={labels.customization.title}>
<Segment title={labels.customization.trackingCategories}> <Segment title={labels.customization.trackingCategories}>
@@ -244,53 +264,42 @@ const Settings = () => {
value={isNoteTrackingCategoryEnabled} value={isNoteTrackingCategoryEnabled}
/> />
</Segment> </Segment>
<Pressable onPress={sliderDisabledPrompt}> <Pressable onPress={fertilityDisabledPrompt}>
<Segment title={labels.fertilityTracking.title}> <Segment title={labels.fertilityTracking.title}>
{isTemperatureTrackingCategoryEnabled && <AppText>{labels.fertilityTracking.message}</AppText>
(isMucusTrackingCategoryEnabled || <AppSwitch
isCervixTrackingCategoryEnabled) ? ( onToggle={fertilityTrackingToggle}
<> text={fertilityTrackingText}
<AppText>{labels.fertilityTracking.message}</AppText> value={isFertilityTrackingEnabled}
<AppSwitch disabled={!manageFertilityFeature}
onToggle={fertilityTrackingToggle} />
text={fertilityTrackingText}
value={isFertilityTrackingEnabled}
/>
</>
) : (
<AppText>{labels.disabled.message}</AppText>
)}
</Segment> </Segment>
</Pressable> </Pressable>
{/* NOTE: still needs to be greyed out and not moveable */}
<Pressable onPress={sliderDisabledPrompt}> <Pressable onPress={sliderDisabledPrompt}>
<Segment title={labels.tempScale.segmentTitle}> <Segment title={labels.tempScale.segmentTitle}>
{isTemperatureTrackingCategoryEnabled && ( {/* {isTemperatureTrackingCategoryEnabled && (
<> <> */}
<AppText>{labels.tempScale.segmentExplainer}</AppText> <AppText>{labels.tempScale.segmentExplainer}</AppText>
<TemperatureSlider /> <TemperatureSlider />
</> {/* </>
)} )}
{!isTemperatureTrackingCategoryEnabled && ( {!isTemperatureTrackingCategoryEnabled && (
<AppText>{labels.disabled.message}</AppText> <AppText>{labels.disabled.message}</AppText>
)} )} */}
</Segment> </Segment>
</Pressable> </Pressable>
<Pressable onPress={secondarySymptomDisabledPrompt}> <Pressable onPress={secondarySymptomDisabledPrompt}>
<Segment title={labels.secondarySymptom.title}> <Segment title={labels.secondarySymptom.title}>
{!isFertilityTrackingEnabled ? ( <AppText>{cervixText}</AppText>
<AppText>{labels.secondarySymptom.disabled.message}</AppText> <SelectTabGroup
) : ( activeButton={useCervixAsSecondarySymptom}
<> buttons={secondarySymptomButtons}
<AppText>{cervixText}</AppText> onSelect={(value) => onSelectTab(value)}
<SelectTabGroup disabled={!isFertilityTrackingEnabled}
activeButton={useCervixAsSecondarySymptom} />
buttons={secondarySymptomButtons}
onSelect={(value) => onSelectTab(value)}
/>
</>
)}
</Segment> </Segment>
</Pressable> </Pressable>
+6 -4
View File
@@ -36,7 +36,7 @@ export default {
tempScale: { tempScale: {
segmentTitle: 'Temperature scale', segmentTitle: 'Temperature scale',
segmentExplainer: segmentExplainer:
'Change the minimum and maximum value for the temperature chart', 'Change the minimum and maximum value for the temperature chart.',
min: 'Min', min: 'Min',
max: 'Max', max: 'Max',
loadError: 'Could not load saved temperature scale settings', loadError: 'Could not load saved temperature scale settings',
@@ -72,6 +72,8 @@ export default {
}, },
fertilityTracking: { fertilityTracking: {
title: 'Fertility phases calculation', title: 'Fertility phases calculation',
disabled:
'To use this feature please enable temperature tracking and cervical mucus or cervix tracking.',
message: message:
'If you enter menstrual bleeding, temperature and cervical mucus or cervix data according to the sympto-thermal rules, drip will calculate cycle phases with the provided data.', 'If you enter menstrual bleeding, temperature and cervical mucus or cervix data according to the sympto-thermal rules, drip will calculate cycle phases with the provided data.',
on: 'If you switch this off, drip will not show fertility related information.', on: 'If you switch this off, drip will not show fertility related information.',
@@ -80,13 +82,13 @@ export default {
secondarySymptom: { secondarySymptom: {
title: 'Secondary symptom', title: 'Secondary symptom',
cervixModeOn: cervixModeOn:
'Cervix values are being used for symptothermal fertility detection. You can switch here to use cervical mucus values for symptothermal fertility detection', 'Cervix values are being used for fertility detection according to the sympto-thermal rules.',
cervixModeOff: cervixModeOff:
'By default, cervical mucus values are being used for symptothermal fertility detection. You can switch here to use cervix values for symptothermal fertility detection', 'Cervical mucus values are being used for fertility detection according to the sympto-thermal rules.',
disabled: { disabled: {
title: 'Disabled', title: 'Disabled',
message: message:
'To set a secondary symptom please first enable the temperature, cervical mucus or cervix tracking category as well as the fertility feature above.', 'To set a secondary symptom please first enable the cervical mucus or cervix tracking category as well as temperature and fertility phases calculation above.',
noSecondaryEnabled: noSecondaryEnabled:
'To switch the secondary symptom both cervical mucus and cervix need to be enabled above.', 'To switch the secondary symptom both cervical mucus and cervix need to be enabled above.',
}, },