small changes on secondary symptom to make it work nicly with the button logic instead of the former switch and to display the correct texts

This commit is contained in:
wunderfisch
2024-02-19 12:13:58 +01:00
parent d23b5fe420
commit 5f55500831
2 changed files with 15 additions and 19 deletions
+14 -18
View File
@@ -121,6 +121,7 @@ const Settings = () => {
? labels.periodPrediction.on ? labels.periodPrediction.on
: labels.periodPrediction.off : labels.periodPrediction.off
// used to be onCervixToggle
const secondarySymptomButtons = [ const secondarySymptomButtons = [
{ {
label: labels.useCervix.secondarySymptomCervicalMucus, label: labels.useCervix.secondarySymptomCervicalMucus,
@@ -139,6 +140,7 @@ const Settings = () => {
} }
} }
// is needed so secondary symptom is set correct on load
useEffect(() => { useEffect(() => {
manageSecondarySymptom( manageSecondarySymptom(
cervixTrackingCategoryObservable.value, cervixTrackingCategoryObservable.value,
@@ -146,15 +148,16 @@ const Settings = () => {
) )
}, []) }, [])
// shoutUseCervix changed to 0/1 instead of false/true
const manageSecondarySymptom = (cervix, mucus) => { const manageSecondarySymptom = (cervix, mucus) => {
if (!cervix && mucus) { if (!cervix && mucus) {
setShouldUseCervix(false) setShouldUseCervix(0)
setIsSecondarySymptomDisabled(true) setIsSecondarySymptomDisabled(false)
} else if (cervix && mucus) { } else if (cervix && mucus) {
setIsSecondarySymptomDisabled(false) setIsSecondarySymptomDisabled(false)
} else if (cervix && !mucus) { } else if (cervix && !mucus) {
setShouldUseCervix(true) setShouldUseCervix(1)
setIsSecondarySymptomDisabled(true) setIsSecondarySymptomDisabled(false)
} else if (!cervix && !mucus) { } else if (!cervix && !mucus) {
setIsSecondarySymptomDisabled(true) setIsSecondarySymptomDisabled(true)
} }
@@ -166,15 +169,7 @@ const Settings = () => {
} }
const secSymptomDisabledPrompt = () => { const secSymptomDisabledPrompt = () => {
if (!isMucusTrackingCategoryEnabled && !isCervixTrackingCategoryEnabled) { if (!isMucusTrackingCategoryEnabled == isCervixTrackingCategoryEnabled) {
Alert.alert(
labels.useCervix.disabled.title,
labels.useCervix.disabled.message
)
} else if (
!isMucusTrackingCategoryEnabled ||
!isCervixTrackingCategoryEnabled
) {
Alert.alert( Alert.alert(
labels.useCervix.disabled.title, labels.useCervix.disabled.title,
labels.useCervix.disabled.noSecondaryEnabled labels.useCervix.disabled.noSecondaryEnabled
@@ -191,6 +186,7 @@ const Settings = () => {
Alert.alert(labels.disabled.title, labels.disabled.message) Alert.alert(labels.disabled.title, labels.disabled.message)
} }
} }
return ( return (
<AppPage title={'Customization'}> <AppPage title={'Customization'}>
<Segment title={'Tracking categories'}> <Segment title={'Tracking categories'}>
@@ -273,10 +269,13 @@ const Settings = () => {
</Segment> </Segment>
</Pressable> </Pressable>
{/* used to be switch for onCervixToggle */}
<Pressable onPress={secSymptomDisabledPrompt}> <Pressable onPress={secSymptomDisabledPrompt}>
<Segment title={labels.useCervix.title}> <Segment title={labels.useCervix.title}>
{/* noch condition adden like isSecondarySymptomDisabled */} {!isTemperatureTrackingCategoryEnabled ||
{isTemperatureTrackingCategoryEnabled && ( isSecondarySymptomDisabled ? (
<AppText>{labels.useCervix.disabled.message}</AppText>
) : (
<> <>
<AppText>{cervixText}</AppText> <AppText>{cervixText}</AppText>
<SelectTabGroup <SelectTabGroup
@@ -286,9 +285,6 @@ const Settings = () => {
/> />
</> </>
)} )}
{!isTemperatureTrackingCategoryEnabled && (
<AppText>{labels.disabled.message}</AppText>
)}
</Segment> </Segment>
</Pressable> </Pressable>
+1 -1
View File
@@ -75,7 +75,7 @@ export default {
disabled: { disabled: {
title: 'Disabled', title: 'Disabled',
message: message:
'To set the secondary symptom please first enable the temperature, cervical mucus or cervix tracking category as well as the fertility feature in the customization settings.', 'To set a secondary symptom please first enable the temperature, cervical mucus or cervix tracking category as well as the fertility feature in the customization settings.',
noSecondaryEnabled: noSecondaryEnabled:
'To switch the secondary symptom both cervical mucus an cervix need to be enabled in the customization settings.', 'To switch the secondary symptom both cervical mucus an cervix need to be enabled in the customization settings.',
}, },