From e11acbab7847c3c08ea5bd812942283a7658620c Mon Sep 17 00:00:00 2001 From: wunderfisch Date: Sun, 4 Feb 2024 17:12:42 +0100 Subject: [PATCH 01/48] Disable and switch secondary symptom depending on cervical mucus and cervix turned on or off. --- components/chart/chart.js | 6 + components/cycle-day/cycle-day-overview.js | 6 + components/settings/customization/index.js | 125 ++++++++++++++++++--- local-storage.js | 16 +++ 4 files changed, 137 insertions(+), 16 deletions(-) diff --git a/components/chart/chart.js b/components/chart/chart.js index b394129..5cc54b3 100644 --- a/components/chart/chart.js +++ b/components/chart/chart.js @@ -22,6 +22,8 @@ import { painTrackingCategoryObservable, sexTrackingCategoryObservable, temperatureTrackingCategoryObservable, + mucusTrackingCategoryObservable, + cervixTrackingCategoryObservable, } from '../../local-storage' import { makeColumnInfo } from '../helpers/chart' @@ -72,6 +74,10 @@ const CycleChart = ({ navigate, setDate }) => { const symptomRowEnabledSymptoms = symptomRowSymptoms.filter((symptom) => { if (symptom === 'sex') { return sexTrackingCategoryObservable.value ? symptom : null + } else if (symptom === 'mucus') { + return mucusTrackingCategoryObservable.value ? symptom : null + } else if (symptom === 'cervix') { + return cervixTrackingCategoryObservable.value ? symptom : null } else if (symptom === 'desire') { return desireTrackingCategoryObservable.value ? symptom : null } else if (symptom === 'pain') { diff --git a/components/cycle-day/cycle-day-overview.js b/components/cycle-day/cycle-day-overview.js index a033135..7f999f9 100644 --- a/components/cycle-day/cycle-day-overview.js +++ b/components/cycle-day/cycle-day-overview.js @@ -16,6 +16,8 @@ import { painTrackingCategoryObservable, sexTrackingCategoryObservable, temperatureTrackingCategoryObservable, + mucusTrackingCategoryObservable, + cervixTrackingCategoryObservable, } from '../../local-storage' import { Spacing } from '../../styles' import { SYMPTOMS } from '../../config' @@ -40,6 +42,10 @@ const CycleDayOverView = ({ date, setDate, isTemperatureEditView }) => { return temperatureTrackingCategoryObservable.value ? symptom : null } else if (symptom === 'sex') { return sexTrackingCategoryObservable.value ? symptom : null + } else if (symptom === 'mucus') { + return mucusTrackingCategoryObservable.value ? symptom : null + } else if (symptom === 'cervix') { + return cervixTrackingCategoryObservable.value ? symptom : null } else if (symptom === 'desire') { return desireTrackingCategoryObservable.value ? symptom : null } else if (symptom === 'pain') { diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index a8e0ab2..83dfb28 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -1,4 +1,4 @@ -import React, { useState } from 'react' +import React, { useEffect, useState } from 'react' import { Alert, Pressable } from 'react-native' import AppPage from '../../common/app-page' @@ -14,10 +14,14 @@ import { painTrackingCategoryObservable, sexTrackingCategoryObservable, temperatureTrackingCategoryObservable, + mucusTrackingCategoryObservable, + cervixTrackingCategoryObservable, saveDesireTrackingCategory, saveMoodTrackingCategory, saveNoteTrackingCategory, savePainTrackingCategory, + saveMucusTrackingCategory, + saveCervixTrackingCategory, savePeriodPrediction, saveSexTrackingCategory, saveTemperatureTrackingCategory, @@ -41,6 +45,14 @@ const Settings = () => { const [isTemperatureTrackingCategoryEnabled, setTemperatureTrackingCategory] = useState(temperatureTrackingCategoryObservable.value) + const [isMucusTrackingCategoryEnabled, setMucusTrackingCategory] = useState( + mucusTrackingCategoryObservable.value + ) + + const [isCervixTrackingCategoryEnabled, setCervixTrackingCategory] = useState( + cervixTrackingCategoryObservable.value + ) + const [isSexTrackingCategoryEnabled, setSexTrackingCategory] = useState( sexTrackingCategoryObservable.value ) @@ -61,6 +73,9 @@ const Settings = () => { noteTrackingCategoryObservable.value ) + const [isSecondarySymptomDisabled, setIsSecondarySymptomDisabled] = + useState(false) + const [isEnabled, setIsEnabled] = useState(false) const toggleSwitch = () => setIsEnabled((previousState) => !previousState) @@ -69,11 +84,44 @@ const Settings = () => { saveTemperatureTrackingCategory(value) } + const mucusTrackingCategoryToggle = (value) => { + if (!cervixTrackingCategoryObservable.value && value) { + setShouldUseCervix(false) + setIsSecondarySymptomDisabled(true) + } else if (cervixTrackingCategoryObservable.value && value) { + setIsSecondarySymptomDisabled(false) + } else if (cervixTrackingCategoryObservable.value && !value) { + setShouldUseCervix(true) + setIsSecondarySymptomDisabled(true) + } else if (!cervixTrackingCategoryObservable.value && !value) { + setIsSecondarySymptomDisabled(true) + } + setMucusTrackingCategory(value) + saveMucusTrackingCategory(value) + saveUseCervix(shouldUseCervix) + } + + const cervixTrackingCategoryToggle = (value) => { + if (!mucusTrackingCategoryObservable.value && value) { + setShouldUseCervix(true) + setIsSecondarySymptomDisabled(true) + } else if (mucusTrackingCategoryObservable.value && value) { + setIsSecondarySymptomDisabled(false) + } else if (mucusTrackingCategoryObservable.value && !value) { + setShouldUseCervix(false) + setIsSecondarySymptomDisabled(true) + } else if (!mucusTrackingCategoryObservable.value && !value) { + setIsSecondarySymptomDisabled(true) + } + setCervixTrackingCategory(value) + saveCervixTrackingCategory(value) + saveUseCervix(shouldUseCervix) + } + const sexTrackingCategoryToggle = (value) => { setSexTrackingCategory(value) saveSexTrackingCategory(value) } - const desireTrackingCategoryToggle = (value) => { setDesireTrackingCategory(value) saveDesireTrackingCategory(value) @@ -90,12 +138,10 @@ const Settings = () => { setNoteTrackingCategory(value) saveNoteTrackingCategory(value) } - const onPeriodPredictionToggle = (value) => { setPeriodPrediction(value) savePeriodPrediction(value) } - const periodPredictionText = isPeriodPredictionEnabled ? labels.periodPrediction.on : labels.periodPrediction.off @@ -105,6 +151,41 @@ const Settings = () => { saveUseCervix(value) } + useEffect(() => { + if ( + !mucusTrackingCategoryObservable.value && + cervixTrackingCategoryObservable.value + ) { + setShouldUseCervix(true) + setIsSecondarySymptomDisabled(false) + } else if ( + mucusTrackingCategoryObservable.value && + cervixTrackingCategoryObservable.value + ) { + setIsSecondarySymptomDisabled(false) + } else if ( + mucusTrackingCategoryObservable.value && + !cervixTrackingCategoryObservable.value + ) { + setShouldUseCervix(false) + setIsSecondarySymptomDisabled(false) + } else if ( + !mucusTrackingCategoryObservable.value && + !cervixTrackingCategoryObservable.value + ) { + setIsSecondarySymptomDisabled(true) + } + }, []) + + const secSymptomDisabledPrompt = () => { + if (isSecondarySymptomDisabled) { + Alert.alert( + labels.periodReminder.alertNoPeriodReminder.title, + labels.periodReminder.alertNoPeriodReminder.message + ) + } + } + const cervixText = shouldUseCervix ? labels.useCervix.cervixModeOn : labels.useCervix.cervixModeOff @@ -121,6 +202,22 @@ const Settings = () => { onToggle={temperatureTrackingCategoryToggle} text={SYMPTOMS[1]} value={isTemperatureTrackingCategoryEnabled} + /> + + { + mucusTrackingCategoryToggle(enabled) + }} + text={'mucus'} + value={isMucusTrackingCategoryEnabled} + trackColor={{ true: Colors.turquoiseDark }} + /> + { + cervixTrackingCategoryToggle(enabled) + }} + text={'cervix'} + value={isCervixTrackingCategoryEnabled} trackColor={{ true: Colors.turquoiseDark }} /> { - + - {isTemperatureTrackingCategoryEnabled && ( - - )} - {!isTemperatureTrackingCategoryEnabled && ( - {labels.disabled.message} - )} + diff --git a/local-storage.js b/local-storage.js index ece4355..7b9477a 100644 --- a/local-storage.js +++ b/local-storage.js @@ -107,6 +107,22 @@ export async function saveTemperatureTrackingCategory(bool) { } } +export const mucusTrackingCategoryObservable = Observable() +setObvWithInitValue('mucus', mucusTrackingCategoryObservable, true) + +export async function saveMucusTrackingCategory(bool) { + await AsyncStorage.setItem('mucus', JSON.stringify(bool)) + mucusTrackingCategoryObservable.set(bool) +} + +export const cervixTrackingCategoryObservable = Observable() +setObvWithInitValue('cervix', cervixTrackingCategoryObservable, true) + +export async function saveCervixTrackingCategory(bool) { + await AsyncStorage.setItem('cervix', JSON.stringify(bool)) + cervixTrackingCategoryObservable.set(bool) +} + export const sexTrackingCategoryObservable = Observable() setObvWithInitValue('sex', sexTrackingCategoryObservable, true) From 8a8b3217fa65c35e2830f75cced073f772f5b09b Mon Sep 17 00:00:00 2001 From: wunderfisch Date: Mon, 12 Feb 2024 16:05:49 +0100 Subject: [PATCH 02/48] small changes on Secondary Symptom disable function --- components/settings/customization/index.js | 20 +++++++++++++++----- i18n/en/settings.js | 7 +++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index 83dfb28..b3c6086 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -178,10 +178,18 @@ const Settings = () => { }, []) const secSymptomDisabledPrompt = () => { - if (isSecondarySymptomDisabled) { + if (!isMucusTrackingCategoryEnabled && !isCervixTrackingCategoryEnabled) { Alert.alert( - labels.periodReminder.alertNoPeriodReminder.title, - labels.periodReminder.alertNoPeriodReminder.message + labels.useCervix.disabled.title, + labels.useCervix.disabled.message + ) + } else if ( + !isMucusTrackingCategoryEnabled || + !isCervixTrackingCategoryEnabled + ) { + Alert.alert( + labels.useCervix.disabled.title, + labels.useCervix.disabled.noSecondaryEnabled ) } } @@ -208,18 +216,20 @@ const Settings = () => { onToggle={(enabled) => { mucusTrackingCategoryToggle(enabled) }} - text={'mucus'} + text={SYMPTOMS[2]} value={isMucusTrackingCategoryEnabled} trackColor={{ true: Colors.turquoiseDark }} /> + { cervixTrackingCategoryToggle(enabled) }} - text={'cervix'} + text={SYMPTOMS[3]} value={isCervixTrackingCategoryEnabled} trackColor={{ true: Colors.turquoiseDark }} /> + Date: Tue, 13 Feb 2024 11:52:33 +0100 Subject: [PATCH 03/48] fix: disabling the secondary symptom toggle when not both categories are enabled, didn't work before after new save --- components/settings/customization/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index b3c6086..db88296 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -147,8 +147,10 @@ const Settings = () => { : labels.periodPrediction.off const onCervixToggle = (value) => { - setShouldUseCervix(value) - saveUseCervix(value) + if (isMucusTrackingCategoryEnabled && isCervixTrackingCategoryEnabled) { + setShouldUseCervix(value) + saveUseCervix(value) + } } useEffect(() => { From d7f1eb81fbe8788196c0c114c1b4049e0018af58 Mon Sep 17 00:00:00 2001 From: wunderfisch Date: Tue, 13 Feb 2024 15:46:04 +0100 Subject: [PATCH 04/48] centralizing code to set the Secondary Symptom from different actions in one function --- components/settings/customization/index.js | 70 +++++++--------------- 1 file changed, 22 insertions(+), 48 deletions(-) diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index db88296..ff81683 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -85,37 +85,11 @@ const Settings = () => { } const mucusTrackingCategoryToggle = (value) => { - if (!cervixTrackingCategoryObservable.value && value) { - setShouldUseCervix(false) - setIsSecondarySymptomDisabled(true) - } else if (cervixTrackingCategoryObservable.value && value) { - setIsSecondarySymptomDisabled(false) - } else if (cervixTrackingCategoryObservable.value && !value) { - setShouldUseCervix(true) - setIsSecondarySymptomDisabled(true) - } else if (!cervixTrackingCategoryObservable.value && !value) { - setIsSecondarySymptomDisabled(true) - } - setMucusTrackingCategory(value) - saveMucusTrackingCategory(value) - saveUseCervix(shouldUseCervix) + manageSecondarySymptom(cervixTrackingCategoryObservable.value, value) } const cervixTrackingCategoryToggle = (value) => { - if (!mucusTrackingCategoryObservable.value && value) { - setShouldUseCervix(true) - setIsSecondarySymptomDisabled(true) - } else if (mucusTrackingCategoryObservable.value && value) { - setIsSecondarySymptomDisabled(false) - } else if (mucusTrackingCategoryObservable.value && !value) { - setShouldUseCervix(false) - setIsSecondarySymptomDisabled(true) - } else if (!mucusTrackingCategoryObservable.value && !value) { - setIsSecondarySymptomDisabled(true) - } - setCervixTrackingCategory(value) - saveCervixTrackingCategory(value) - saveUseCervix(shouldUseCervix) + manageSecondarySymptom(value, mucusTrackingCategoryObservable.value) } const sexTrackingCategoryToggle = (value) => { @@ -154,30 +128,30 @@ const Settings = () => { } useEffect(() => { - if ( - !mucusTrackingCategoryObservable.value && - cervixTrackingCategoryObservable.value - ) { - setShouldUseCervix(true) - setIsSecondarySymptomDisabled(false) - } else if ( - mucusTrackingCategoryObservable.value && - cervixTrackingCategoryObservable.value - ) { - setIsSecondarySymptomDisabled(false) - } else if ( - mucusTrackingCategoryObservable.value && - !cervixTrackingCategoryObservable.value - ) { + manageSecondarySymptom( + cervixTrackingCategoryObservable.value, + mucusTrackingCategoryObservable.value + ) + }, []) + + const manageSecondarySymptom = (cervix, mucus) => { + if (!cervix && mucus) { setShouldUseCervix(false) + setIsSecondarySymptomDisabled(true) + } else if (cervix && mucus) { setIsSecondarySymptomDisabled(false) - } else if ( - !mucusTrackingCategoryObservable.value && - !cervixTrackingCategoryObservable.value - ) { + } else if (cervix && !mucus) { + setShouldUseCervix(true) + setIsSecondarySymptomDisabled(true) + } else if (!cervix && !mucus) { setIsSecondarySymptomDisabled(true) } - }, []) + setMucusTrackingCategory(mucus) + saveMucusTrackingCategory(mucus) + setCervixTrackingCategory(cervix) + saveCervixTrackingCategory(cervix) + saveUseCervix(shouldUseCervix) + } const secSymptomDisabledPrompt = () => { if (!isMucusTrackingCategoryEnabled && !isCervixTrackingCategoryEnabled) { From a59dfa83367dca2dd5513cfca34b68eee3ae3cf4 Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Tue, 13 Feb 2024 12:18:44 +0100 Subject: [PATCH 05/48] Add SelectTabGroup for secondary Symptom Switch --- components/settings/customization/index.js | 46 ++++++++++++++++++---- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index ff81683..4454667 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -6,6 +6,7 @@ import AppSwitch from '../../common/app-switch' import AppText from '../../common/app-text' import TemperatureSlider from './temperature-slider' import Segment from '../../common/segment' +import SelectTabGroup from '../../cycle-day/select-tab-group' import { desireTrackingCategoryObservable, @@ -120,7 +121,16 @@ const Settings = () => { ? labels.periodPrediction.on : labels.periodPrediction.off - const onCervixToggle = (value) => { + // old + // const onCervixToggle = (value) => { + // if (isMucusTrackingCategoryEnabled && isCervixTrackingCategoryEnabled) { + // setShouldUseCervix(value) + // saveUseCervix(value) + // } + // } + + // new + const onSelectTab = (value) => { if (isMucusTrackingCategoryEnabled && isCervixTrackingCategoryEnabled) { setShouldUseCervix(value) saveUseCervix(value) @@ -170,6 +180,18 @@ const Settings = () => { } } + //new + const secondarySymptomButtons = [ + { + label: 'cervical mucus', + value: 0, + }, + { + label: 'cervix', + value: 1, + }, + ] + const cervixText = shouldUseCervix ? labels.useCervix.cervixModeOn : labels.useCervix.cervixModeOff @@ -263,13 +285,21 @@ const Settings = () => { - + {/* hier war vorher der AppSwitch */} + {/* noch condition adden */} + {isTemperatureTrackingCategoryEnabled && ( + <> + {cervixText} + onSelectTab(value)} + /> + + )} + {!isTemperatureTrackingCategoryEnabled && ( + {labels.disabled.message} + )} From 1662bb29f07638f2c98e7e7deac9f524bd91659f Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Tue, 13 Feb 2024 12:39:08 +0100 Subject: [PATCH 06/48] Change prop Type to value instead of bool for saveUseCervix --- local-storage.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/local-storage.js b/local-storage.js index 7b9477a..431137f 100644 --- a/local-storage.js +++ b/local-storage.js @@ -60,11 +60,11 @@ export async function savePeriodPrediction(bool) { } export const useCervixObservable = Observable() -setObvWithInitValue('useCervix', useCervixObservable, false) +setObvWithInitValue('useCervix', useCervixObservable, 0) -export async function saveUseCervix(bool) { - await AsyncStorage.setItem('useCervix', JSON.stringify(bool)) - useCervixObservable.set(bool) +export async function saveUseCervix(value) { + await AsyncStorage.setItem('useCervix', JSON.stringify(value)) + useCervixObservable.set(value) } export const hasEncryptionObservable = Observable() From ebbfd8aba573fb6b820f7403aafcff20d174d120 Mon Sep 17 00:00:00 2001 From: wunderfisch Date: Wed, 14 Feb 2024 10:26:13 +0100 Subject: [PATCH 07/48] merging work on secondary symptom logic and buttons --- components/settings/customization/index.js | 34 ++++++++-------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index 4454667..60b7304 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -121,15 +121,17 @@ const Settings = () => { ? labels.periodPrediction.on : labels.periodPrediction.off - // old - // const onCervixToggle = (value) => { - // if (isMucusTrackingCategoryEnabled && isCervixTrackingCategoryEnabled) { - // setShouldUseCervix(value) - // saveUseCervix(value) - // } - // } + const secondarySymptomButtons = [ + { + label: 'cervical mucus', + value: 0, + }, + { + label: 'cervix', + value: 1, + }, + ] - // new const onSelectTab = (value) => { if (isMucusTrackingCategoryEnabled && isCervixTrackingCategoryEnabled) { setShouldUseCervix(value) @@ -180,18 +182,6 @@ const Settings = () => { } } - //new - const secondarySymptomButtons = [ - { - label: 'cervical mucus', - value: 0, - }, - { - label: 'cervix', - value: 1, - }, - ] - const cervixText = shouldUseCervix ? labels.useCervix.cervixModeOn : labels.useCervix.cervixModeOff @@ -285,11 +275,11 @@ const Settings = () => { - {/* hier war vorher der AppSwitch */} - {/* noch condition adden */} + {/* noch condition adden like isSecondarySymptomDisabled */} {isTemperatureTrackingCategoryEnabled && ( <> {cervixText} + Date: Tue, 13 Feb 2024 12:18:44 +0100 Subject: [PATCH 08/48] Add SelectTabGroup for secondary Symptom Switch --- components/settings/customization/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index 60b7304..41a5cf5 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -279,7 +279,6 @@ const Settings = () => { {isTemperatureTrackingCategoryEnabled && ( <> {cervixText} - Date: Wed, 14 Feb 2024 15:10:28 +0100 Subject: [PATCH 09/48] Replace hard coded text --- components/settings/customization/index.js | 4 ++-- i18n/en/settings.js | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index 41a5cf5..49a65ff 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -123,11 +123,11 @@ const Settings = () => { const secondarySymptomButtons = [ { - label: 'cervical mucus', + label: labels.useCervix.secondarySymptomCervicalMucus, value: 0, }, { - label: 'cervix', + label: labels.useCervix.secondarySymptomCervix, value: 1, }, ] diff --git a/i18n/en/settings.js b/i18n/en/settings.js index 200ebd6..d4b307a 100644 --- a/i18n/en/settings.js +++ b/i18n/en/settings.js @@ -79,6 +79,8 @@ export default { noSecondaryEnabled: 'To switch the secondary symptom both cervical mucus an cervix need to be enabled in the customization settings.', }, + secondarySymptomCervicalMucus: 'cervical mucus', + secondarySymptomCervix: 'cervix', }, periodPrediction: { title: 'Period predictions', From 311cee0e17b842b412ddbc5fe6945819c9a630a9 Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Wed, 14 Feb 2024 15:11:00 +0100 Subject: [PATCH 10/48] Adapt color for secondarySymptom Boxes --- components/cycle-day/select-tab-group.js | 25 ++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/components/cycle-day/select-tab-group.js b/components/cycle-day/select-tab-group.js index b298cbd..ef9ae03 100644 --- a/components/cycle-day/select-tab-group.js +++ b/components/cycle-day/select-tab-group.js @@ -5,14 +5,26 @@ import { StyleSheet, TouchableOpacity, View } from 'react-native' import AppText from '../common/app-text' import { Colors, Containers } from '../../styles' +import labels from '../../i18n/en/settings' export default function SelectTabGroup({ activeButton, buttons, onSelect }) { + const isSecondarySymptomSwitch = + buttons[0]['label'] === labels.useCervix.secondarySymptomCervicalMucus return ( {buttons.map(({ label, value }, i) => { const isActive = value === activeButton - const boxStyle = [styles.box, isActive && styles.boxActive] - const textStyle = [styles.text, isActive && styles.textActive] + const boxStyle = [ + styles.box, + isActive && styles.boxActive, + isSecondarySymptomSwitch && styles.purpleBox, + isSecondarySymptomSwitch && isActive && styles.activePurpleBox, + ] + const textStyle = [ + styles.text, + isSecondarySymptomSwitch && styles.purpleText, + isActive && styles.textActive, + ] return ( Date: Wed, 14 Feb 2024 15:36:06 +0100 Subject: [PATCH 11/48] Add oneTimeTransformIntoNumber for secondarySymptom Switch --- components/cycle-day/select-tab-group.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/cycle-day/select-tab-group.js b/components/cycle-day/select-tab-group.js index ef9ae03..0548977 100644 --- a/components/cycle-day/select-tab-group.js +++ b/components/cycle-day/select-tab-group.js @@ -8,12 +8,15 @@ import { Colors, Containers } from '../../styles' import labels from '../../i18n/en/settings' export default function SelectTabGroup({ activeButton, buttons, onSelect }) { + const oneTimeTransformIntoNumber = + typeof activeButton === 'boolean' && Number(activeButton) const isSecondarySymptomSwitch = buttons[0]['label'] === labels.useCervix.secondarySymptomCervicalMucus return ( {buttons.map(({ label, value }, i) => { - const isActive = value === activeButton + const isActive = + value === activeButton || value === oneTimeTransformIntoNumber const boxStyle = [ styles.box, isActive && styles.boxActive, From 5f5550083174e4061549eaffd305e22b1ceeb9ed Mon Sep 17 00:00:00 2001 From: wunderfisch Date: Mon, 19 Feb 2024 12:13:58 +0100 Subject: [PATCH 12/48] 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 --- components/settings/customization/index.js | 32 ++++++++++------------ i18n/en/settings.js | 2 +- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index 49a65ff..386225a 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -121,6 +121,7 @@ const Settings = () => { ? labels.periodPrediction.on : labels.periodPrediction.off + // used to be onCervixToggle const secondarySymptomButtons = [ { label: labels.useCervix.secondarySymptomCervicalMucus, @@ -139,6 +140,7 @@ const Settings = () => { } } + // is needed so secondary symptom is set correct on load useEffect(() => { manageSecondarySymptom( cervixTrackingCategoryObservable.value, @@ -146,15 +148,16 @@ const Settings = () => { ) }, []) + // shoutUseCervix changed to 0/1 instead of false/true const manageSecondarySymptom = (cervix, mucus) => { if (!cervix && mucus) { - setShouldUseCervix(false) - setIsSecondarySymptomDisabled(true) + setShouldUseCervix(0) + setIsSecondarySymptomDisabled(false) } else if (cervix && mucus) { setIsSecondarySymptomDisabled(false) } else if (cervix && !mucus) { - setShouldUseCervix(true) - setIsSecondarySymptomDisabled(true) + setShouldUseCervix(1) + setIsSecondarySymptomDisabled(false) } else if (!cervix && !mucus) { setIsSecondarySymptomDisabled(true) } @@ -166,15 +169,7 @@ const Settings = () => { } const secSymptomDisabledPrompt = () => { - if (!isMucusTrackingCategoryEnabled && !isCervixTrackingCategoryEnabled) { - Alert.alert( - labels.useCervix.disabled.title, - labels.useCervix.disabled.message - ) - } else if ( - !isMucusTrackingCategoryEnabled || - !isCervixTrackingCategoryEnabled - ) { + if (!isMucusTrackingCategoryEnabled == isCervixTrackingCategoryEnabled) { Alert.alert( labels.useCervix.disabled.title, labels.useCervix.disabled.noSecondaryEnabled @@ -191,6 +186,7 @@ const Settings = () => { Alert.alert(labels.disabled.title, labels.disabled.message) } } + return ( @@ -273,10 +269,13 @@ const Settings = () => { + {/* used to be switch for onCervixToggle */} - {/* noch condition adden like isSecondarySymptomDisabled */} - {isTemperatureTrackingCategoryEnabled && ( + {!isTemperatureTrackingCategoryEnabled || + isSecondarySymptomDisabled ? ( + {labels.useCervix.disabled.message} + ) : ( <> {cervixText} { /> )} - {!isTemperatureTrackingCategoryEnabled && ( - {labels.disabled.message} - )} diff --git a/i18n/en/settings.js b/i18n/en/settings.js index d4b307a..7afa9be 100644 --- a/i18n/en/settings.js +++ b/i18n/en/settings.js @@ -75,7 +75,7 @@ export default { disabled: { title: 'Disabled', 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: 'To switch the secondary symptom both cervical mucus an cervix need to be enabled in the customization settings.', }, From 7fa130f9e119125592f459731c5e58b6de484eb1 Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Mon, 19 Feb 2024 17:13:40 +0100 Subject: [PATCH 13/48] Rename to useCervixAsSecondarySymptomObservable --- components/settings/customization/index.js | 4 ++-- lib/sympto-adapter.js | 4 ++-- local-storage.js | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index 386225a..7ff147a 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -28,7 +28,7 @@ import { saveTemperatureTrackingCategory, saveUseCervix, periodPredictionObservable, - useCervixObservable, + useCervixAsSecondarySymptomObservable, } from '../../../local-storage' import { Colors } from '../../../styles' import labels from '../../../i18n/en/settings' @@ -36,7 +36,7 @@ import { SYMPTOMS } from '../../../config' const Settings = () => { const [shouldUseCervix, setShouldUseCervix] = useState( - useCervixObservable.value + useCervixAsSecondarySymptomObservable.value ) const [isPeriodPredictionEnabled, setPeriodPrediction] = useState( diff --git a/lib/sympto-adapter.js b/lib/sympto-adapter.js index aac2807..ef3b8fb 100644 --- a/lib/sympto-adapter.js +++ b/lib/sympto-adapter.js @@ -1,6 +1,6 @@ import getFertilityStatus from 'sympto' import cycleModule from './cycle' -import { useCervixObservable } from '../local-storage' +import { useCervixAsSecondarySymptomObservable } from '../local-storage' import { fertilityStatus as labels } from '../i18n/en/labels' export function getFertilityStatusForDay(dateString) { @@ -57,7 +57,7 @@ export function getCycleStatusForDay(dateString, opts = {}) { } } - cycleInfo.secondarySymptom = useCervixObservable.value ? 'cervix' : 'mucus' + cycleInfo.secondarySymptom = useCervixAsSecondarySymptomObservable.value ? 'cervix' : 'mucus' return getFertilityStatus(cycleInfo) } diff --git a/local-storage.js b/local-storage.js index 431137f..175a7d4 100644 --- a/local-storage.js +++ b/local-storage.js @@ -59,12 +59,12 @@ export async function savePeriodPrediction(bool) { } } -export const useCervixObservable = Observable() -setObvWithInitValue('useCervix', useCervixObservable, 0) +export const useCervixAsSecondarySymptomObservable = Observable() +setObvWithInitValue('useCervix', useCervixAsSecondarySymptomObservable, 0) export async function saveUseCervix(value) { await AsyncStorage.setItem('useCervix', JSON.stringify(value)) - useCervixObservable.set(value) + useCervixAsSecondarySymptomObservable.set(value) } export const hasEncryptionObservable = Observable() From 63bc8a1daf9c3e7e7ba37aaf4f1b597ec25bc670 Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Mon, 19 Feb 2024 17:48:37 +0100 Subject: [PATCH 14/48] Rename to useCervixAsSecondarySymptom --- components/cycle-day/select-tab-group.js | 2 +- components/settings/customization/index.js | 22 +++++++++++----------- i18n/en/settings.js | 6 +++--- local-storage.js | 13 ++++++++++--- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/components/cycle-day/select-tab-group.js b/components/cycle-day/select-tab-group.js index 0548977..91e87e9 100644 --- a/components/cycle-day/select-tab-group.js +++ b/components/cycle-day/select-tab-group.js @@ -11,7 +11,7 @@ export default function SelectTabGroup({ activeButton, buttons, onSelect }) { const oneTimeTransformIntoNumber = typeof activeButton === 'boolean' && Number(activeButton) const isSecondarySymptomSwitch = - buttons[0]['label'] === labels.useCervix.secondarySymptomCervicalMucus + buttons[0]['label'] === labels.useCervixAsSecondarySymptom.mucus return ( {buttons.map(({ label, value }, i) => { diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index 7ff147a..59e5151 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -26,7 +26,7 @@ import { savePeriodPrediction, saveSexTrackingCategory, saveTemperatureTrackingCategory, - saveUseCervix, + saveUseCervixAsSecondarySymptom, periodPredictionObservable, useCervixAsSecondarySymptomObservable, } from '../../../local-storage' @@ -124,11 +124,11 @@ const Settings = () => { // used to be onCervixToggle const secondarySymptomButtons = [ { - label: labels.useCervix.secondarySymptomCervicalMucus, + label: labels.useCervixAsSecondarySymptom.mucus, value: 0, }, { - label: labels.useCervix.secondarySymptomCervix, + label: labels.useCervixAsSecondarySymptom.cervix, value: 1, }, ] @@ -136,7 +136,7 @@ const Settings = () => { const onSelectTab = (value) => { if (isMucusTrackingCategoryEnabled && isCervixTrackingCategoryEnabled) { setShouldUseCervix(value) - saveUseCervix(value) + saveUseCervixAsSecondarySymptom(value) } } @@ -165,21 +165,21 @@ const Settings = () => { saveMucusTrackingCategory(mucus) setCervixTrackingCategory(cervix) saveCervixTrackingCategory(cervix) - saveUseCervix(shouldUseCervix) + saveUseCervixAsSecondarySymptom(shouldUseCervix) } const secSymptomDisabledPrompt = () => { if (!isMucusTrackingCategoryEnabled == isCervixTrackingCategoryEnabled) { Alert.alert( - labels.useCervix.disabled.title, - labels.useCervix.disabled.noSecondaryEnabled + labels.useCervixAsSecondarySymptom.disabled.title, + labels.useCervixAsSecondarySymptom.disabled.noSecondaryEnabled ) } } const cervixText = shouldUseCervix - ? labels.useCervix.cervixModeOn - : labels.useCervix.cervixModeOff + ? labels.useCervixAsSecondarySymptom.cervixModeOn + : labels.useCervixAsSecondarySymptom.cervixModeOff const sliderDisabledPrompt = () => { if (!isTemperatureTrackingCategoryEnabled) { @@ -271,10 +271,10 @@ const Settings = () => { {/* used to be switch for onCervixToggle */} - + {!isTemperatureTrackingCategoryEnabled || isSecondarySymptomDisabled ? ( - {labels.useCervix.disabled.message} + {labels.useCervixAsSecondarySymptom.disabled.message} ) : ( <> {cervixText} diff --git a/i18n/en/settings.js b/i18n/en/settings.js index 7afa9be..918ce5a 100644 --- a/i18n/en/settings.js +++ b/i18n/en/settings.js @@ -66,7 +66,7 @@ export default { 'To use the period reminder please first enable period predictions in the customization settings.', }, }, - useCervix: { + useCervixAsSecondarySymptom: { title: 'Secondary symptom', cervixModeOn: 'Cervix values are being used for symptothermal fertility detection. You can switch here to use cervical mucus values for symptothermal fertility detection', @@ -79,8 +79,8 @@ export default { noSecondaryEnabled: 'To switch the secondary symptom both cervical mucus an cervix need to be enabled in the customization settings.', }, - secondarySymptomCervicalMucus: 'cervical mucus', - secondarySymptomCervix: 'cervix', + mucus: 'cervical mucus', + cervix: 'cervix', }, periodPrediction: { title: 'Period predictions', diff --git a/local-storage.js b/local-storage.js index 175a7d4..84b680d 100644 --- a/local-storage.js +++ b/local-storage.js @@ -60,10 +60,17 @@ export async function savePeriodPrediction(bool) { } export const useCervixAsSecondarySymptomObservable = Observable() -setObvWithInitValue('useCervix', useCervixAsSecondarySymptomObservable, 0) +setObvWithInitValue( + 'useCervixAsSecondarySymptom', + useCervixAsSecondarySymptomObservable, + 0 +) -export async function saveUseCervix(value) { - await AsyncStorage.setItem('useCervix', JSON.stringify(value)) +export async function saveUseCervixAsSecondarySymptom(value) { + await AsyncStorage.setItem( + 'useCervixAsSecondarySymptom', + JSON.stringify(value) + ) useCervixAsSecondarySymptomObservable.set(value) } From dc304afe75d20faebca5a39b78565253ac967852 Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Mon, 19 Feb 2024 18:01:57 +0100 Subject: [PATCH 15/48] Rename labels to more neutral 'secondarySymptom' --- components/cycle-day/select-tab-group.js | 2 +- components/settings/customization/index.js | 16 ++++++++-------- i18n/en/settings.js | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/components/cycle-day/select-tab-group.js b/components/cycle-day/select-tab-group.js index 91e87e9..8c98f78 100644 --- a/components/cycle-day/select-tab-group.js +++ b/components/cycle-day/select-tab-group.js @@ -11,7 +11,7 @@ export default function SelectTabGroup({ activeButton, buttons, onSelect }) { const oneTimeTransformIntoNumber = typeof activeButton === 'boolean' && Number(activeButton) const isSecondarySymptomSwitch = - buttons[0]['label'] === labels.useCervixAsSecondarySymptom.mucus + buttons[0]['label'] === labels.secondarySymptom.mucus return ( {buttons.map(({ label, value }, i) => { diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index 59e5151..1d9445c 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -124,11 +124,11 @@ const Settings = () => { // used to be onCervixToggle const secondarySymptomButtons = [ { - label: labels.useCervixAsSecondarySymptom.mucus, + label: labels.secondarySymptom.mucus, value: 0, }, { - label: labels.useCervixAsSecondarySymptom.cervix, + label: labels.secondarySymptom.cervix, value: 1, }, ] @@ -171,15 +171,15 @@ const Settings = () => { const secSymptomDisabledPrompt = () => { if (!isMucusTrackingCategoryEnabled == isCervixTrackingCategoryEnabled) { Alert.alert( - labels.useCervixAsSecondarySymptom.disabled.title, - labels.useCervixAsSecondarySymptom.disabled.noSecondaryEnabled + labels.secondarySymptom.disabled.title, + labels.secondarySymptom.disabled.noSecondaryEnabled ) } } const cervixText = shouldUseCervix - ? labels.useCervixAsSecondarySymptom.cervixModeOn - : labels.useCervixAsSecondarySymptom.cervixModeOff + ? labels.secondarySymptom.cervixModeOn + : labels.secondarySymptom.cervixModeOff const sliderDisabledPrompt = () => { if (!isTemperatureTrackingCategoryEnabled) { @@ -271,10 +271,10 @@ const Settings = () => { {/* used to be switch for onCervixToggle */} - + {!isTemperatureTrackingCategoryEnabled || isSecondarySymptomDisabled ? ( - {labels.useCervixAsSecondarySymptom.disabled.message} + {labels.secondarySymptom.disabled.message} ) : ( <> {cervixText} diff --git a/i18n/en/settings.js b/i18n/en/settings.js index 918ce5a..bf26203 100644 --- a/i18n/en/settings.js +++ b/i18n/en/settings.js @@ -66,7 +66,7 @@ export default { 'To use the period reminder please first enable period predictions in the customization settings.', }, }, - useCervixAsSecondarySymptom: { + secondarySymptom: { title: 'Secondary symptom', cervixModeOn: 'Cervix values are being used for symptothermal fertility detection. You can switch here to use cervical mucus values for symptothermal fertility detection', From 69c546f684784a8212ce8f65d65d0667d14feb68 Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Mon, 19 Feb 2024 18:05:20 +0100 Subject: [PATCH 16/48] Rename shouldUseCervix to useCervixAsSecondarySymptom --- components/settings/customization/index.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index 1d9445c..ad9881a 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -35,9 +35,8 @@ import labels from '../../../i18n/en/settings' import { SYMPTOMS } from '../../../config' const Settings = () => { - const [shouldUseCervix, setShouldUseCervix] = useState( - useCervixAsSecondarySymptomObservable.value - ) + const [useCervixAsSecondarySymptom, setUseCervixAsSecondarySymptom] = + useState(useCervixAsSecondarySymptomObservable.value) const [isPeriodPredictionEnabled, setPeriodPrediction] = useState( periodPredictionObservable.value @@ -135,7 +134,7 @@ const Settings = () => { const onSelectTab = (value) => { if (isMucusTrackingCategoryEnabled && isCervixTrackingCategoryEnabled) { - setShouldUseCervix(value) + setUseCervixAsSecondarySymptom(value) saveUseCervixAsSecondarySymptom(value) } } @@ -151,12 +150,12 @@ const Settings = () => { // shoutUseCervix changed to 0/1 instead of false/true const manageSecondarySymptom = (cervix, mucus) => { if (!cervix && mucus) { - setShouldUseCervix(0) + setUseCervixAsSecondarySymptom(0) setIsSecondarySymptomDisabled(false) } else if (cervix && mucus) { setIsSecondarySymptomDisabled(false) } else if (cervix && !mucus) { - setShouldUseCervix(1) + setUseCervixAsSecondarySymptom(1) setIsSecondarySymptomDisabled(false) } else if (!cervix && !mucus) { setIsSecondarySymptomDisabled(true) @@ -165,7 +164,7 @@ const Settings = () => { saveMucusTrackingCategory(mucus) setCervixTrackingCategory(cervix) saveCervixTrackingCategory(cervix) - saveUseCervixAsSecondarySymptom(shouldUseCervix) + saveUseCervixAsSecondarySymptom(useCervixAsSecondarySymptom) } const secSymptomDisabledPrompt = () => { @@ -177,7 +176,7 @@ const Settings = () => { } } - const cervixText = shouldUseCervix + const cervixText = useCervixAsSecondarySymptom ? labels.secondarySymptom.cervixModeOn : labels.secondarySymptom.cervixModeOff @@ -279,7 +278,7 @@ const Settings = () => { <> {cervixText} onSelectTab(value)} /> From d66e5f36e53ed1e8e0193aef00f85a80e234ea53 Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Mon, 19 Feb 2024 18:10:57 +0100 Subject: [PATCH 17/48] Rename to secondarySymptomDisabledPrompt --- components/settings/customization/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index ad9881a..7fa9dd7 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -167,7 +167,7 @@ const Settings = () => { saveUseCervixAsSecondarySymptom(useCervixAsSecondarySymptom) } - const secSymptomDisabledPrompt = () => { + const secondarySymptomDisabledPrompt = () => { if (!isMucusTrackingCategoryEnabled == isCervixTrackingCategoryEnabled) { Alert.alert( labels.secondarySymptom.disabled.title, @@ -269,7 +269,7 @@ const Settings = () => { {/* used to be switch for onCervixToggle */} - + {!isTemperatureTrackingCategoryEnabled || isSecondarySymptomDisabled ? ( From e69ca933828fbb1907d028b3b880f26d23515c30 Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Thu, 22 Feb 2024 13:29:16 +0000 Subject: [PATCH 18/48] Remove idle code --- components/settings/customization/index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index e2f4f9e..c2fc692 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -200,7 +200,6 @@ const Settings = () => { }} text={SYMPTOMS[2]} value={isMucusTrackingCategoryEnabled} - trackColor={{ true: Colors.turquoiseDark }} /> { }} text={SYMPTOMS[3]} value={isCervixTrackingCategoryEnabled} - trackColor={{ true: Colors.turquoiseDark }} /> Date: Fri, 23 Feb 2024 12:16:32 +0100 Subject: [PATCH 19/48] fix saving of secondary symptom --- components/settings/customization/index.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index c2fc692..a0ee520 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -82,15 +82,12 @@ const Settings = () => { setTemperatureTrackingCategory(value) saveTemperatureTrackingCategory(value) } - const mucusTrackingCategoryToggle = (value) => { manageSecondarySymptom(cervixTrackingCategoryObservable.value, value) } - const cervixTrackingCategoryToggle = (value) => { manageSecondarySymptom(value, mucusTrackingCategoryObservable.value) } - const sexTrackingCategoryToggle = (value) => { setSexTrackingCategory(value) saveSexTrackingCategory(value) @@ -119,7 +116,6 @@ const Settings = () => { ? labels.periodPrediction.on : labels.periodPrediction.off - // used to be onCervixToggle const secondarySymptomButtons = [ { label: labels.secondarySymptom.mucus, @@ -146,15 +142,16 @@ const Settings = () => { ) }, []) - // shoutUseCervix changed to 0/1 instead of false/true const manageSecondarySymptom = (cervix, mucus) => { if (!cervix && mucus) { setUseCervixAsSecondarySymptom(0) + saveUseCervixAsSecondarySymptom(0) setIsSecondarySymptomDisabled(false) } else if (cervix && mucus) { setIsSecondarySymptomDisabled(false) } else if (cervix && !mucus) { setUseCervixAsSecondarySymptom(1) + saveUseCervixAsSecondarySymptom(1) setIsSecondarySymptomDisabled(false) } else if (!cervix && !mucus) { setIsSecondarySymptomDisabled(true) @@ -163,7 +160,6 @@ const Settings = () => { saveMucusTrackingCategory(mucus) setCervixTrackingCategory(cervix) saveCervixTrackingCategory(cervix) - saveUseCervixAsSecondarySymptom(useCervixAsSecondarySymptom) } const secondarySymptomDisabledPrompt = () => { From 092b5573964b177e049520dc521faf79e08122ec Mon Sep 17 00:00:00 2001 From: wunderfisch Date: Fri, 23 Feb 2024 12:39:31 +0100 Subject: [PATCH 20/48] make second symptom buttons show alert if switched off --- components/settings/customization/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index a0ee520..4f202de 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -131,6 +131,8 @@ const Settings = () => { if (isMucusTrackingCategoryEnabled && isCervixTrackingCategoryEnabled) { setUseCervixAsSecondarySymptom(value) saveUseCervixAsSecondarySymptom(value) + } else { + secondarySymptomDisabledPrompt() } } From e395730d981e7ce9ebdc3c2aaddccbfd284620e9 Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Wed, 14 Feb 2024 17:48:50 +0100 Subject: [PATCH 21/48] First step for fertilityTracking Toggle --- components/settings/customization/index.js | 25 ++++++++++++++++------ i18n/en/settings.js | 5 +++++ local-storage.js | 8 +++++++ 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index 4f202de..bd20433 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -10,6 +10,7 @@ import SelectTabGroup from '../../cycle-day/select-tab-group' import { desireTrackingCategoryObservable, + fertilityTrackingObservable, moodTrackingCategoryObservable, noteTrackingCategoryObservable, painTrackingCategoryObservable, @@ -18,6 +19,7 @@ import { mucusTrackingCategoryObservable, cervixTrackingCategoryObservable, saveDesireTrackingCategory, + saveFertilityTrackingEnabled, saveMoodTrackingCategory, saveNoteTrackingCategory, savePainTrackingCategory, @@ -75,8 +77,13 @@ const Settings = () => { const [isSecondarySymptomDisabled, setIsSecondarySymptomDisabled] = useState(false) - const [isEnabled, setIsEnabled] = useState(false) - const toggleSwitch = () => setIsEnabled((previousState) => !previousState) + const [isFertilityTrackingEnabled, setFertilityTrackingEnabled] = useState( + fertilityTrackingObservable.value + ) + const fertilityTrackingToggle = (value) => { + setFertilityTrackingEnabled(value) + saveFertilityTrackingEnabled(value) + } const temperatureTrackingCategoryToggle = (value) => { setTemperatureTrackingCategory(value) @@ -112,6 +119,11 @@ const Settings = () => { setPeriodPrediction(value) savePeriodPrediction(value) } + + const fertilityTrackingText = isFertilityTrackingEnabled + ? labels.fertilityTracking.on + : labels.fertilityTracking.off + const periodPredictionText = isPeriodPredictionEnabled ? labels.periodPrediction.on : labels.periodPrediction.off @@ -234,12 +246,11 @@ const Settings = () => { value={isNoteTrackingCategoryEnabled} /> - - + diff --git a/i18n/en/settings.js b/i18n/en/settings.js index bf26203..eec5ea8 100644 --- a/i18n/en/settings.js +++ b/i18n/en/settings.js @@ -66,6 +66,11 @@ export default { 'To use the period reminder please first enable period predictions in the customization settings.', }, }, + fertilityTracking: { + title: 'Fertility phases calculation', + on: 'The quick brown fox jumps over the lazy dog', + off: 'No no', + }, secondarySymptom: { title: 'Secondary symptom', cervixModeOn: diff --git a/local-storage.js b/local-storage.js index 84b680d..7f2de93 100644 --- a/local-storage.js +++ b/local-storage.js @@ -170,6 +170,14 @@ export async function saveNoteTrackingCategory(bool) { noteTrackingCategoryObservable.set(bool) } +export const fertilityTrackingObservable = Observable() +setObvWithInitValue('fertilityTracking', fertilityTrackingObservable, true) + +export async function saveFertilityTrackingEnabled(bool) { + await AsyncStorage.setItem('fertilityTracking', JSON.stringify(bool)) + fertilityTrackingObservable.set(bool) +} + async function setObvWithInitValue(key, obv, defaultValue) { const result = await AsyncStorage.getItem(key) let value From faad51f4f191ae627cbdbc8b15f9adbaf4a8ace3 Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Wed, 14 Feb 2024 17:49:16 +0100 Subject: [PATCH 22/48] Check for FertilityTrackingEnabled on home --- components/Home.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/components/Home.js b/components/Home.js index 783d8c4..af02576 100644 --- a/components/Home.js +++ b/components/Home.js @@ -14,7 +14,10 @@ import { determinePredictionText, formatWithOrdinalSuffix, } from './helpers/home' -import { periodPredictionObservable } from '../local-storage' +import { + fertilityTrackingObservable, + periodPredictionObservable, +} from '../local-storage' import { Colors, Fonts, Sizes, Spacing } from '../styles' import { LocalDate } from '@js-joda/core' @@ -28,11 +31,12 @@ const Home = ({ navigate, setDate }) => { navigate('CycleDay') } + const isFertilityTrackingEnabled = fertilityTrackingObservable.value const todayDateString = LocalDate.now().toString() const { getCycleDayNumber, getPredictedMenses } = cycleModule() const cycleDayNumber = getCycleDayNumber(todayDateString) const { status, phase, statusText } = - getFertilityStatusForDay(todayDateString) + isFertilityTrackingEnabled && getFertilityStatusForDay(todayDateString) const isPeriodPredictionEnabled = periodPredictionObservable.value const prediction = determinePredictionText(getPredictedMenses(), t) @@ -55,7 +59,7 @@ const Home = ({ navigate, setDate }) => { )} - {phase && ( + {isFertilityTrackingEnabled && phase && ( {formatWithOrdinalSuffix(phase)} From 31888c3331518a1ad54dd7b7f568eaa2104bd6e3 Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Wed, 14 Feb 2024 17:49:34 +0100 Subject: [PATCH 23/48] Check for FertilityTrackingEnabled on chart --- components/helpers/chart.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/components/helpers/chart.js b/components/helpers/chart.js index ba25223..245123f 100644 --- a/components/helpers/chart.js +++ b/components/helpers/chart.js @@ -1,6 +1,10 @@ import { LocalDate } from '@js-joda/core' -import { scaleObservable, unitObservable } from '../../local-storage' +import { + fertilityTrackingObservable, + scaleObservable, + unitObservable, +} from '../../local-storage' import { getCycleStatusForDay } from '../../lib/sympto-adapter' import { getCycleDay, getAmountOfCycleDays } from '../../db' @@ -270,7 +274,8 @@ export function nfpLines() { if (dateString < cycle.startDate) updateCurrentCycle(dateString) if (cycle.noMoreCycles) return ret - const tempShift = cycle.status.temperatureShift + const tempShift = + fertilityTrackingObservable.value && cycle.status.temperatureShift if (tempShift) { if (tempShift.firstHighMeasurementDay.date === dateString) { From c037c630d392f6b8541917f3b7457ce0e284a5c6 Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Thu, 22 Feb 2024 16:40:28 +0100 Subject: [PATCH 24/48] Check for FertilityTrackingEnabled in sympto-adapter --- lib/sympto-adapter.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/sympto-adapter.js b/lib/sympto-adapter.js index ef3b8fb..44e3d18 100644 --- a/lib/sympto-adapter.js +++ b/lib/sympto-adapter.js @@ -1,9 +1,15 @@ import getFertilityStatus from 'sympto' import cycleModule from './cycle' -import { useCervixAsSecondarySymptomObservable } from '../local-storage' +import { fertilityTrackingObservable, useCervixAsSecondarySymptomObservable } from '../local-storage' import { fertilityStatus as labels } from '../i18n/en/labels' +const isFertilityTrackingEnabled = fertilityTrackingObservable.value + export function getFertilityStatusForDay(dateString) { + if (!isFertilityTrackingEnabled) { + return + } + const status = getCycleStatusForDay(dateString) if (!status) return { status: labels.fertile, @@ -34,6 +40,10 @@ export function getFertilityStatusForDay(dateString) { } export function getCycleStatusForDay(dateString, opts = {}) { + if (!isFertilityTrackingEnabled) { + return + } + const { getCycleForDay, getCyclesBefore, From 29c3b9b10885cea154d4771b0ec74130e367a9b7 Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Fri, 23 Feb 2024 13:12:27 +0100 Subject: [PATCH 25/48] Disable fertility tracking switch depending on temp, mucus or cervix --- components/settings/customization/index.js | 27 ++++++++++++++++------ 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index bd20433..6fd93df 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -246,13 +246,26 @@ const Settings = () => { value={isNoteTrackingCategoryEnabled} /> - - - + + + + {isTemperatureTrackingCategoryEnabled && + isMucusTrackingCategoryEnabled || + isCervixTrackingCategoryEnabled ? + ( + <> + + + ) : + ( + {labels.disabled.message} + )} + + From d0d691c6afa0f1f774342e61ea991fa77e508781 Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Fri, 23 Feb 2024 13:13:12 +0100 Subject: [PATCH 26/48] Turn fertility tracking off when temperature tracking is off --- local-storage.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/local-storage.js b/local-storage.js index 7f2de93..3647683 100644 --- a/local-storage.js +++ b/local-storage.js @@ -107,8 +107,15 @@ export async function saveTemperatureTrackingCategory(bool) { temperatureTrackingCategoryObservable.set(bool) if (!temperatureTrackingCategoryObservable.value) { - const result = await AsyncStorage.getItem('tempReminder') - if (JSON.parse(result).enabled) { + // if temperature tracking is turned off, the fertility tracking gets disabled + const fertilityTrackingResult = await AsyncStorage.getItem('fertilityTracking') + if (fertilityTrackingResult) { + saveFertilityTrackingEnabled(false) + } + + // if temperature tracking is turned off, the temperature reminder gets disabled + const tempReminderResult = await AsyncStorage.getItem('tempReminder') + if (JSON.parse(tempReminderResult).enabled) { tempReminderObservable.set(false) } } From 3c0ea9b208a5b6b4532fae2b990fd87ee802bb8c Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Fri, 23 Feb 2024 13:13:46 +0100 Subject: [PATCH 27/48] Turn fertility tracking off when mucus and cervix tracking are off --- local-storage.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/local-storage.js b/local-storage.js index 3647683..1c1759e 100644 --- a/local-storage.js +++ b/local-storage.js @@ -127,6 +127,14 @@ setObvWithInitValue('mucus', mucusTrackingCategoryObservable, true) export async function saveMucusTrackingCategory(bool) { await AsyncStorage.setItem('mucus', JSON.stringify(bool)) mucusTrackingCategoryObservable.set(bool) + + // if mucus and cervix tracking is turned off, the fertility tracking gets disabled + if (!mucusTrackingCategoryObservable.value && !cervixTrackingCategoryObservable.value) { + const fertilityTrackingResult = await AsyncStorage.getItem('fertilityTracking') + if (fertilityTrackingResult) { + saveFertilityTrackingEnabled(false) + } + } } export const cervixTrackingCategoryObservable = Observable() @@ -135,6 +143,14 @@ setObvWithInitValue('cervix', cervixTrackingCategoryObservable, true) export async function saveCervixTrackingCategory(bool) { await AsyncStorage.setItem('cervix', JSON.stringify(bool)) cervixTrackingCategoryObservable.set(bool) + + // if cervix and mucus tracking is turned off, the fertility tracking gets disabled + if (!cervixTrackingCategoryObservable.value && !mucusTrackingCategoryObservable.value) { + const fertilityTrackingResult = await AsyncStorage.getItem('fertilityTracking') + if (fertilityTrackingResult) { + saveFertilityTrackingEnabled(false) + } + } } export const sexTrackingCategoryObservable = Observable() From 8150b791edc8fae0cca18da552d552730e0aba3b Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Fri, 23 Feb 2024 13:14:21 +0100 Subject: [PATCH 28/48] Only check if fertility tracking enabled for display of secondary Symptom --- components/settings/customization/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index 6fd93df..1782104 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -284,8 +284,7 @@ const Settings = () => { {/* used to be switch for onCervixToggle */} - {!isTemperatureTrackingCategoryEnabled || - isSecondarySymptomDisabled ? ( + {!isFertilityTrackingEnabled ? ( {labels.secondarySymptom.disabled.message} ) : ( <> From 27bb25e6da4082cb49c6ecbae960488b83474149 Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Fri, 23 Feb 2024 13:22:56 +0100 Subject: [PATCH 29/48] Add check for if tempReminder is null --- local-storage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/local-storage.js b/local-storage.js index 1c1759e..2081547 100644 --- a/local-storage.js +++ b/local-storage.js @@ -115,7 +115,7 @@ export async function saveTemperatureTrackingCategory(bool) { // if temperature tracking is turned off, the temperature reminder gets disabled const tempReminderResult = await AsyncStorage.getItem('tempReminder') - if (JSON.parse(tempReminderResult).enabled) { + if (tempReminderResult && JSON.parse(tempReminderResult).enabled) { tempReminderObservable.set(false) } } From 5855ea0a348df47338066ce3c03c1a1806f63f30 Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Fri, 23 Feb 2024 16:38:11 +0100 Subject: [PATCH 30/48] Move temp off turns fertility off logic out of local storage --- components/settings/customization/index.js | 4 ++++ local-storage.js | 6 ------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index 1782104..a941e64 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -88,6 +88,10 @@ const Settings = () => { const temperatureTrackingCategoryToggle = (value) => { setTemperatureTrackingCategory(value) saveTemperatureTrackingCategory(value) + if (!value) { + setFertilityTrackingEnabled(false) + saveFertilityTrackingEnabled(false) + } } const mucusTrackingCategoryToggle = (value) => { manageSecondarySymptom(cervixTrackingCategoryObservable.value, value) diff --git a/local-storage.js b/local-storage.js index 2081547..b7ad678 100644 --- a/local-storage.js +++ b/local-storage.js @@ -107,12 +107,6 @@ export async function saveTemperatureTrackingCategory(bool) { temperatureTrackingCategoryObservable.set(bool) if (!temperatureTrackingCategoryObservable.value) { - // if temperature tracking is turned off, the fertility tracking gets disabled - const fertilityTrackingResult = await AsyncStorage.getItem('fertilityTracking') - if (fertilityTrackingResult) { - saveFertilityTrackingEnabled(false) - } - // if temperature tracking is turned off, the temperature reminder gets disabled const tempReminderResult = await AsyncStorage.getItem('tempReminder') if (tempReminderResult && JSON.parse(tempReminderResult).enabled) { From 1c7350947361f76b00fd2e87d633fedd7d36d893 Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Fri, 23 Feb 2024 16:38:44 +0100 Subject: [PATCH 31/48] Move cervix & mucus off turn fertility off logic out of local storage --- components/settings/customization/index.js | 2 ++ local-storage.js | 16 ---------------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index a941e64..5a0caf8 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -173,6 +173,8 @@ const Settings = () => { setIsSecondarySymptomDisabled(false) } else if (!cervix && !mucus) { setIsSecondarySymptomDisabled(true) + setFertilityTrackingEnabled(false) + saveFertilityTrackingEnabled(false) } setMucusTrackingCategory(mucus) saveMucusTrackingCategory(mucus) diff --git a/local-storage.js b/local-storage.js index b7ad678..66ce305 100644 --- a/local-storage.js +++ b/local-storage.js @@ -121,14 +121,6 @@ setObvWithInitValue('mucus', mucusTrackingCategoryObservable, true) export async function saveMucusTrackingCategory(bool) { await AsyncStorage.setItem('mucus', JSON.stringify(bool)) mucusTrackingCategoryObservable.set(bool) - - // if mucus and cervix tracking is turned off, the fertility tracking gets disabled - if (!mucusTrackingCategoryObservable.value && !cervixTrackingCategoryObservable.value) { - const fertilityTrackingResult = await AsyncStorage.getItem('fertilityTracking') - if (fertilityTrackingResult) { - saveFertilityTrackingEnabled(false) - } - } } export const cervixTrackingCategoryObservable = Observable() @@ -137,14 +129,6 @@ setObvWithInitValue('cervix', cervixTrackingCategoryObservable, true) export async function saveCervixTrackingCategory(bool) { await AsyncStorage.setItem('cervix', JSON.stringify(bool)) cervixTrackingCategoryObservable.set(bool) - - // if cervix and mucus tracking is turned off, the fertility tracking gets disabled - if (!cervixTrackingCategoryObservable.value && !mucusTrackingCategoryObservable.value) { - const fertilityTrackingResult = await AsyncStorage.getItem('fertilityTracking') - if (fertilityTrackingResult) { - saveFertilityTrackingEnabled(false) - } - } } export const sexTrackingCategoryObservable = Observable() From 405e27bdbe136639fd19bc6ade21fa614e11e3c9 Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Fri, 23 Feb 2024 16:50:30 +0100 Subject: [PATCH 32/48] Remove isSecondarySymptomDisabled; because maybe we don't need it anymore with fertilityTracking taking its job --- components/settings/customization/index.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index 5a0caf8..e292e16 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -74,9 +74,6 @@ const Settings = () => { noteTrackingCategoryObservable.value ) - const [isSecondarySymptomDisabled, setIsSecondarySymptomDisabled] = - useState(false) - const [isFertilityTrackingEnabled, setFertilityTrackingEnabled] = useState( fertilityTrackingObservable.value ) @@ -164,15 +161,11 @@ const Settings = () => { if (!cervix && mucus) { setUseCervixAsSecondarySymptom(0) saveUseCervixAsSecondarySymptom(0) - setIsSecondarySymptomDisabled(false) } else if (cervix && mucus) { - setIsSecondarySymptomDisabled(false) } else if (cervix && !mucus) { setUseCervixAsSecondarySymptom(1) saveUseCervixAsSecondarySymptom(1) - setIsSecondarySymptomDisabled(false) } else if (!cervix && !mucus) { - setIsSecondarySymptomDisabled(true) setFertilityTrackingEnabled(false) saveFertilityTrackingEnabled(false) } From 37152b3fec4d20948ed91042460d9d4ed9fadcfe Mon Sep 17 00:00:00 2001 From: wunderfisch Date: Fri, 23 Feb 2024 15:34:09 +0100 Subject: [PATCH 33/48] small changes in styling. more space beween switch lines, smaller switches in iOS (testing please), less bottom margin for segments --- components/common/app-switch.js | 7 ++++++- styles/containers.js | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/components/common/app-switch.js b/components/common/app-switch.js index d45758f..5e74bb5 100644 --- a/components/common/app-switch.js +++ b/components/common/app-switch.js @@ -4,7 +4,7 @@ import PropTypes from 'prop-types' import AppText from './app-text' -import { Colors, Containers } from '../../styles' +import { Colors, Containers, Spacing } from '../../styles' const AppSwitch = ({ onToggle, text, value, disabled }) => { const trackColor = { true: Colors.turquoiseDark } @@ -37,6 +37,11 @@ const styles = StyleSheet.create({ }, switch: { flex: 1, + marginBottom: Spacing.tiny, + transform: + Platform.OS === 'ios' + ? [{ scaleX: 0.8 }, { scaleY: 0.8 }] + : [{ scaleX: 1 }, { scaleY: 1 }], }, textContainer: { flex: 4, diff --git a/styles/containers.js b/styles/containers.js index 8560d10..c169fec 100644 --- a/styles/containers.js +++ b/styles/containers.js @@ -36,6 +36,6 @@ export default { }, segmentContainer: { marginHorizontal: Spacing.base, - marginBottom: Spacing.base, + marginBottom: Spacing.tiny, }, } From 4fc11d2f7e25ab18f6338c0ab5e83c3d7b5e3754 Mon Sep 17 00:00:00 2001 From: wunderfisch Date: Mon, 26 Feb 2024 13:28:43 +0100 Subject: [PATCH 34/48] changes in customization texts and small changes to styling --- components/common/app-switch.js | 2 +- components/settings/customization/index.js | 26 ++++++++++------------ i18n/en/settings.js | 14 +++++++----- styles/containers.js | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/components/common/app-switch.js b/components/common/app-switch.js index 5e74bb5..78ab610 100644 --- a/components/common/app-switch.js +++ b/components/common/app-switch.js @@ -34,10 +34,10 @@ AppSwitch.propTypes = { const styles = StyleSheet.create({ container: { ...Containers.rowContainer, + marginTop: Spacing.tiny, }, switch: { flex: 1, - marginBottom: Spacing.tiny, transform: Platform.OS === 'ios' ? [{ scaleX: 0.8 }, { scaleY: 0.8 }] diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index e292e16..fffcd7d 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -246,23 +246,21 @@ const Settings = () => { /> - {isTemperatureTrackingCategoryEnabled && - isMucusTrackingCategoryEnabled || - isCervixTrackingCategoryEnabled ? - ( - <> - - - ) : - ( + (isMucusTrackingCategoryEnabled || + isCervixTrackingCategoryEnabled) ? ( + <> + {labels.fertilityTracking.message} + + + ) : ( {labels.disabled.message} - )} + )} diff --git a/i18n/en/settings.js b/i18n/en/settings.js index eec5ea8..5a7a2e0 100644 --- a/i18n/en/settings.js +++ b/i18n/en/settings.js @@ -41,7 +41,7 @@ export default { disabled: { title: 'This feature is turned off', message: - 'Please first enable the temperature tracking category in the customization settings.', + 'To use the temperature scale please first enable the temperature tracking category above.', }, tempReminder: { title: 'Temperature reminder', @@ -68,8 +68,10 @@ export default { }, fertilityTracking: { title: 'Fertility phases calculation', - on: 'The quick brown fox jumps over the lazy dog', - off: 'No no', + 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.', + on: 'If you switch this off, drip will not show fertility related information.', + off: 'If you switch this on, drip will show fertility related information.', }, secondarySymptom: { title: 'Secondary symptom', @@ -80,16 +82,16 @@ export default { disabled: { title: 'Disabled', message: - '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.', + 'To set a secondary symptom please first enable the temperature, cervical mucus or cervix tracking category as well as the fertility feature above.', 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 and cervix need to be enabled above.', }, mucus: 'cervical mucus', cervix: 'cervix', }, periodPrediction: { title: 'Period predictions', - on: 'drip predicts your 3 next menstrual bleedings based on the statistics of your previously tracked cycles, min 3 complete cycles.', + on: 'drip predicts your 3 next menstrual bleedings based on statistics if you previously tracked at least 3 complete cycles.', off: 'There are no predictions for menstrual cycles displayed. If turned on the calendar and the home screen will display period predictions.', }, passwordSettings: { diff --git a/styles/containers.js b/styles/containers.js index c169fec..8560d10 100644 --- a/styles/containers.js +++ b/styles/containers.js @@ -36,6 +36,6 @@ export default { }, segmentContainer: { marginHorizontal: Spacing.base, - marginBottom: Spacing.tiny, + marginBottom: Spacing.base, }, } From ef4095d61c96672b5237f70893328f8e6cc2aeac Mon Sep 17 00:00:00 2001 From: wunderfisch Date: Mon, 26 Feb 2024 15:28:11 +0100 Subject: [PATCH 35/48] fixing issue import and empty statement --- components/common/app-switch.js | 2 +- components/settings/customization/index.js | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/components/common/app-switch.js b/components/common/app-switch.js index 78ab610..dfa8dfe 100644 --- a/components/common/app-switch.js +++ b/components/common/app-switch.js @@ -1,5 +1,5 @@ import React from 'react' -import { StyleSheet, Switch, View } from 'react-native' +import { Platform, StyleSheet, Switch, View } from 'react-native' import PropTypes from 'prop-types' import AppText from './app-text' diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index fffcd7d..607a4e6 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -161,7 +161,6 @@ const Settings = () => { if (!cervix && mucus) { setUseCervixAsSecondarySymptom(0) saveUseCervixAsSecondarySymptom(0) - } else if (cervix && mucus) { } else if (cervix && !mucus) { setUseCervixAsSecondarySymptom(1) saveUseCervixAsSecondarySymptom(1) @@ -202,7 +201,6 @@ const Settings = () => { text={SYMPTOMS[1]} value={isTemperatureTrackingCategoryEnabled} /> - { mucusTrackingCategoryToggle(enabled) @@ -210,7 +208,6 @@ const Settings = () => { text={SYMPTOMS[2]} value={isMucusTrackingCategoryEnabled} /> - { cervixTrackingCategoryToggle(enabled) @@ -218,7 +215,6 @@ const Settings = () => { text={SYMPTOMS[3]} value={isCervixTrackingCategoryEnabled} /> - { - {/* used to be switch for onCervixToggle */} {!isFertilityTrackingEnabled ? ( From 72823ef95c736a3acaca76378933d956048d0b7f Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Mon, 26 Feb 2024 17:17:27 +0100 Subject: [PATCH 36/48] Generalize title of symptom labels --- components/cycle-day/symptom-box.js | 2 +- i18n/en.json | 22 ++++++++++------------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/components/cycle-day/symptom-box.js b/components/cycle-day/symptom-box.js index f9fcd0c..1d78f02 100644 --- a/components/cycle-day/symptom-box.js +++ b/components/cycle-day/symptom-box.js @@ -20,7 +20,7 @@ const SymptomBox = ({ editedSymptom, setEditedSymptom, }) => { - const { t } = useTranslation(null, { keyPrefix: 'cycleDay.symptomBox' }) + const { t } = useTranslation(null, { keyPrefix: 'symptoms' }) const isSymptomEdited = editedSymptom === symptom const isSymptomDisabled = isDateInFuture(date) && symptom !== 'note' const isExcluded = symptomData !== null ? symptomData.exclude : false diff --git a/i18n/en.json b/i18n/en.json index 436ca79..6467b64 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -7,18 +7,16 @@ "chart": { "tutorial": "You can swipe the chart to view more dates." }, - "cycleDay": { - "symptomBox": { - "bleeding": "bleeding", - "temperature": "temperature", - "mucus": "cervical mucus", - "cervix": "cervix", - "note": "note", - "desire": "desire", - "sex": "sex", - "pain": "pain", - "mood": "mood" - } + "symptoms": { + "bleeding": "bleeding", + "temperature": "temperature", + "mucus": "cervical mucus", + "cervix": "cervix", + "note": "note", + "desire": "desire", + "sex": "sex", + "pain": "pain", + "mood": "mood" }, "labels": { "bleedingPrediction": { From 8a65c081a8d09f830d911cf8af8a104c5832ba7b Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Mon, 26 Feb 2024 17:17:49 +0100 Subject: [PATCH 37/48] Use translation for customization tracking categories --- components/settings/customization/index.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index 607a4e6..f57dc4a 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -1,5 +1,6 @@ import React, { useEffect, useState } from 'react' import { Alert, Pressable } from 'react-native' +import { useTranslation } from 'react-i18next' import AppPage from '../../common/app-page' import AppSwitch from '../../common/app-switch' @@ -36,6 +37,8 @@ import labels from '../../../i18n/en/settings' import { SYMPTOMS } from '../../../config' const Settings = () => { + const { t } = useTranslation(null, { keyPrefix: 'symptoms' }) + const [useCervixAsSecondarySymptom, setUseCervixAsSecondarySymptom] = useState(useCervixAsSecondarySymptomObservable.value) @@ -198,46 +201,46 @@ const Settings = () => { { mucusTrackingCategoryToggle(enabled) }} - text={SYMPTOMS[2]} + text={t(SYMPTOMS[2])} value={isMucusTrackingCategoryEnabled} /> { cervixTrackingCategoryToggle(enabled) }} - text={SYMPTOMS[3]} + text={t(SYMPTOMS[3])} value={isCervixTrackingCategoryEnabled} /> From 9ec52b78cfeb77c4bc28b89d1bee9f3295a8459b Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Mon, 26 Feb 2024 16:51:29 +0000 Subject: [PATCH 38/48] Add comment for future TODO linking gitlab issue --- components/cycle-day/select-tab-group.js | 1 + 1 file changed, 1 insertion(+) diff --git a/components/cycle-day/select-tab-group.js b/components/cycle-day/select-tab-group.js index 8c98f78..f2839d7 100644 --- a/components/cycle-day/select-tab-group.js +++ b/components/cycle-day/select-tab-group.js @@ -8,6 +8,7 @@ import { Colors, Containers } from '../../styles' import labels from '../../i18n/en/settings' export default function SelectTabGroup({ activeButton, buttons, onSelect }) { +// TODO https://gitlab.com/bloodyhealth/drip/-/issues/707 const oneTimeTransformIntoNumber = typeof activeButton === 'boolean' && Number(activeButton) const isSecondarySymptomSwitch = From 46a02560e82b48cf6d44e2a50cc615fe64138595 Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Mon, 26 Feb 2024 18:23:04 +0100 Subject: [PATCH 39/48] Add title labels to customization --- components/settings/customization/index.js | 4 ++-- i18n/en/settings.js | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index f57dc4a..1d6cc3f 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -197,8 +197,8 @@ const Settings = () => { } return ( - - + + Date: Tue, 27 Feb 2024 18:10:11 +0100 Subject: [PATCH 40/48] revision of customization texts and refactoring behavior when disabled --- components/cycle-day/select-tab-group.js | 21 +++++- components/settings/customization/index.js | 83 ++++++++++++---------- i18n/en/settings.js | 10 +-- 3 files changed, 70 insertions(+), 44 deletions(-) diff --git a/components/cycle-day/select-tab-group.js b/components/cycle-day/select-tab-group.js index f2839d7..22c0c88 100644 --- a/components/cycle-day/select-tab-group.js +++ b/components/cycle-day/select-tab-group.js @@ -7,12 +7,18 @@ import AppText from '../common/app-text' import { Colors, Containers } from '../../styles' import labels from '../../i18n/en/settings' -export default function SelectTabGroup({ activeButton, buttons, onSelect }) { -// TODO https://gitlab.com/bloodyhealth/drip/-/issues/707 +export default function SelectTabGroup({ + activeButton, + buttons, + onSelect, + disabled, +}) { + // TODO https://gitlab.com/bloodyhealth/drip/-/issues/707 const oneTimeTransformIntoNumber = typeof activeButton === 'boolean' && Number(activeButton) const isSecondarySymptomSwitch = buttons[0]['label'] === labels.secondarySymptom.mucus + return ( {buttons.map(({ label, value }, i) => { @@ -23,16 +29,18 @@ export default function SelectTabGroup({ activeButton, buttons, onSelect }) { isActive && styles.boxActive, isSecondarySymptomSwitch && styles.purpleBox, isSecondarySymptomSwitch && isActive && styles.activePurpleBox, + disabled && styles.inActiveBox, ] const textStyle = [ styles.text, isSecondarySymptomSwitch && styles.purpleText, isActive && styles.textActive, + disabled && styles.greyText, ] return ( onSelect(value)} + onPress={() => !disabled && onSelect(value)} key={i} style={boxStyle} > @@ -75,4 +83,11 @@ const styles = StyleSheet.create({ purpleText: { color: Colors.purple, }, + greyText: { + color: Colors.grey, + }, + inActiveBox: { + borderColor: Colors.grey, + backgroundColor: Colors.turquoiseLight, + }, }) diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index 1d6cc3f..5614bd4 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -143,6 +143,7 @@ const Settings = () => { }, ] + // NOTE: when disabled (!isFertilityTrackingEnabled) button press doesn't yet trigger alert const onSelectTab = (value) => { if (isMucusTrackingCategoryEnabled && isCervixTrackingCategoryEnabled) { setUseCervixAsSecondarySymptom(value) @@ -178,7 +179,14 @@ const Settings = () => { } const secondarySymptomDisabledPrompt = () => { - if (!isMucusTrackingCategoryEnabled == isCervixTrackingCategoryEnabled) { + if (!isFertilityTrackingEnabled) { + Alert.alert( + labels.secondarySymptom.disabled.title, + labels.secondarySymptom.disabled.message + ) + } else if ( + !isMucusTrackingCategoryEnabled == isCervixTrackingCategoryEnabled + ) { Alert.alert( labels.secondarySymptom.disabled.title, labels.secondarySymptom.disabled.noSecondaryEnabled @@ -186,6 +194,10 @@ const Settings = () => { } } + const manageFertilityFeature = + isTemperatureTrackingCategoryEnabled && + (isMucusTrackingCategoryEnabled || isCervixTrackingCategoryEnabled) + const cervixText = useCervixAsSecondarySymptom ? labels.secondarySymptom.cervixModeOn : 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 ( @@ -244,53 +264,42 @@ const Settings = () => { value={isNoteTrackingCategoryEnabled} /> - + - {isTemperatureTrackingCategoryEnabled && - (isMucusTrackingCategoryEnabled || - isCervixTrackingCategoryEnabled) ? ( - <> - {labels.fertilityTracking.message} - - - ) : ( - {labels.disabled.message} - )} + {labels.fertilityTracking.message} + + {/* NOTE: still needs to be greyed out and not moveable */} - {isTemperatureTrackingCategoryEnabled && ( - <> - {labels.tempScale.segmentExplainer} - - - )} - {!isTemperatureTrackingCategoryEnabled && ( - {labels.disabled.message} - )} + {/* {isTemperatureTrackingCategoryEnabled && ( + <> */} + {labels.tempScale.segmentExplainer} + + {/* + )} + {!isTemperatureTrackingCategoryEnabled && ( + {labels.disabled.message} + )} */} - {!isFertilityTrackingEnabled ? ( - {labels.secondarySymptom.disabled.message} - ) : ( - <> - {cervixText} - onSelectTab(value)} - /> - - )} + {cervixText} + onSelectTab(value)} + disabled={!isFertilityTrackingEnabled} + /> diff --git a/i18n/en/settings.js b/i18n/en/settings.js index 6f4ae40..aec4513 100644 --- a/i18n/en/settings.js +++ b/i18n/en/settings.js @@ -36,7 +36,7 @@ export default { tempScale: { segmentTitle: 'Temperature scale', segmentExplainer: - 'Change the minimum and maximum value for the temperature chart', + 'Change the minimum and maximum value for the temperature chart.', min: 'Min', max: 'Max', loadError: 'Could not load saved temperature scale settings', @@ -72,6 +72,8 @@ export default { }, fertilityTracking: { title: 'Fertility phases calculation', + disabled: + 'To use this feature please enable temperature tracking and cervical mucus or cervix tracking.', 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.', on: 'If you switch this off, drip will not show fertility related information.', @@ -80,13 +82,13 @@ export default { secondarySymptom: { title: 'Secondary symptom', 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: - '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: { title: 'Disabled', 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: 'To switch the secondary symptom both cervical mucus and cervix need to be enabled above.', }, From ffe8fab822333c3ee6935495a0413ec25543540e Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Wed, 28 Feb 2024 12:27:59 +0100 Subject: [PATCH 41/48] Add colored tracking icons to customization toggles --- components/common/tracking-category-switch.js | 63 +++++++++++++++++++ components/settings/customization/index.js | 25 +++++--- styles/colors.js | 6 +- 3 files changed, 85 insertions(+), 9 deletions(-) create mode 100644 components/common/tracking-category-switch.js diff --git a/components/common/tracking-category-switch.js b/components/common/tracking-category-switch.js new file mode 100644 index 0000000..aef5824 --- /dev/null +++ b/components/common/tracking-category-switch.js @@ -0,0 +1,63 @@ +import React from 'react' +import { Platform, StyleSheet, Switch, View } from 'react-native' +import PropTypes from 'prop-types' + +import AppText from './app-text' + +import DripIcon from '../../assets/drip-icons' +import { Colors, Containers, Sizes, Spacing } from '../../styles' + +const TrackingCategorySwitch = ({ onToggle, symptom, text, value }) => { + const trackColor = { true: Colors.turquoiseDark } + const iconColor = value ? Colors.iconColors[symptom].color : Colors.grey + + return ( + + + + + + {text} + + + + ) +} + +TrackingCategorySwitch.propTypes = { + onToggle: PropTypes.func.isRequired, + symptom: PropTypes.string, + text: PropTypes.string, + value: PropTypes.bool, +} + +const styles = StyleSheet.create({ + container: { + ...Containers.rowContainer, + marginVertical: Spacing.tiny, + }, + iconContainer: { + marginRight: Spacing.tiny, + flex: 1, + }, + textContainer: { + flex: 5, + }, + appSwitch: { + flex: 2, + transform: + Platform.OS === 'ios' + ? [{ scaleX: 0.8 }, { scaleY: 0.8 }] + : [{ scaleX: 1 }, { scaleY: 1 }], + }, +}) +export default TrackingCategorySwitch diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index 1d6cc3f..6b236a5 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -7,6 +7,7 @@ import AppSwitch from '../../common/app-switch' import AppText from '../../common/app-text' import TemperatureSlider from './temperature-slider' import Segment from '../../common/segment' +import TrackingCategorySwitch from '../../common/tracking-category-switch' import SelectTabGroup from '../../cycle-day/select-tab-group' import { @@ -199,49 +200,57 @@ const Settings = () => { return ( - - { mucusTrackingCategoryToggle(enabled) }} text={t(SYMPTOMS[2])} value={isMucusTrackingCategoryEnabled} + symptom={SYMPTOMS[2]} /> - { cervixTrackingCategoryToggle(enabled) }} text={t(SYMPTOMS[3])} value={isCervixTrackingCategoryEnabled} + symptom={SYMPTOMS[3]} /> - - - - - diff --git a/styles/colors.js b/styles/colors.js index f091d02..7baf8cd 100644 --- a/styles/colors.js +++ b/styles/colors.js @@ -18,6 +18,7 @@ const shadesOfPink = ['#c485a6', '#b15c89', pinkColor] // light to dark const lightGreenColor = '#bccd67' const orangeColor = '#bc6642' const mintColor = '#6ca299' +const turquoiseDark = '#69CBC1' export default { greyDark: '#555', @@ -27,7 +28,7 @@ export default { orange: '#F38337', purple: '#3A2671', purpleLight: '#938EB2', - turquoiseDark: '#69CBC1', + turquoiseDark: turquoiseDark, turquoise: '#CFECEA', turquoiseLight: '#E9F2ED', iconColors: { @@ -35,6 +36,9 @@ export default { color: redColor, shades: shadesOfRed, }, + temperature: { + color: turquoiseDark, + }, mucus: { color: violetColor, shades: shadesOfViolet, From ad47b4bee092a0e330312df5ed6bcc60c1e44203 Mon Sep 17 00:00:00 2001 From: wunderfisch Date: Wed, 28 Feb 2024 13:06:25 +0100 Subject: [PATCH 42/48] enabling alert for disabled button in tab group --- components/cycle-day/select-tab-group.js | 16 ++++++++++++++-- components/settings/customization/index.js | 5 +++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/components/cycle-day/select-tab-group.js b/components/cycle-day/select-tab-group.js index 22c0c88..3800fa4 100644 --- a/components/cycle-day/select-tab-group.js +++ b/components/cycle-day/select-tab-group.js @@ -1,6 +1,6 @@ import React from 'react' import PropTypes from 'prop-types' -import { StyleSheet, TouchableOpacity, View } from 'react-native' +import { Alert, StyleSheet, TouchableOpacity, View } from 'react-native' import AppText from '../common/app-text' @@ -19,6 +19,16 @@ export default function SelectTabGroup({ const isSecondarySymptomSwitch = buttons[0]['label'] === labels.secondarySymptom.mucus + // Disable is only used for secondarySymptom in customization, if more come up maybe consider more tidy solution + const showDisableAlert = (label) => { + if (label === 'cervix' || 'mucus') { + Alert.alert( + labels.secondarySymptom.disabled.title, + labels.secondarySymptom.disabled.message + ) + } + } + return ( {buttons.map(({ label, value }, i) => { @@ -40,7 +50,9 @@ export default function SelectTabGroup({ return ( !disabled && onSelect(value)} + onPress={() => + !disabled ? onSelect(value) : showDisableAlert(label) + } key={i} style={boxStyle} > diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index 5614bd4..9e06407 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -148,7 +148,12 @@ const Settings = () => { if (isMucusTrackingCategoryEnabled && isCervixTrackingCategoryEnabled) { setUseCervixAsSecondarySymptom(value) saveUseCervixAsSecondarySymptom(value) + console.log('show SecSymp value :>> ', value) + } else if (!isFertilityTrackingEnabled) { + console.log('2 show SecSymp value :>> ', value) + secondarySymptomDisabledPrompt() } else { + console.log('3 show SecSymp value :>> ', value) secondarySymptomDisabledPrompt() } } From 610383a1035a31886bd72f15e12e5ccd5fee7d83 Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Wed, 28 Feb 2024 12:50:31 +0100 Subject: [PATCH 43/48] Unify the spelling of "sympto-thermal" --- CONTRIBUTING.md | 6 +++--- i18n/en/settings.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b03cccc..eedb19a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -33,9 +33,10 @@ We are an open source project and we highly appreciate contributions. At the sam - 🔮 open source - 🩸 feminist and gender inclusive - 🔒 secure: data entered stays with that person/on their device - - 🔬 science based: we implemented the symptothermal method - + - 🔬 science based: we implemented the sympto-thermal method + This means that we will never implement anything that contradicts these core values. Some examples: We will never build a cloud integration, we will never make an ovulation prediction. + - If you would like to make a sustainable contribution to the project, we would be happy to join the game. ### Reporting Bugs or Making Suggestions @@ -48,7 +49,6 @@ If you found a bug or have suggestions, please :one: first review the [list of e - If you want to open a merge request, yeah :tada: exciting! We are using a template for merge requests to make sure we explain what we have done and why. - Keep in mind that people who will review your merge request are more motivated to do so when the merge request is well explained and ideally not too big. - ### Thank you ![](https://media.giphy.com/media/kPA88elN9kYco/giphy.gif) diff --git a/i18n/en/settings.js b/i18n/en/settings.js index 6f4ae40..0e5f5a1 100644 --- a/i18n/en/settings.js +++ b/i18n/en/settings.js @@ -80,9 +80,9 @@ export default { secondarySymptom: { title: 'Secondary symptom', 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 sympto-thermal fertility detection. You can switch here to use cervical mucus values for sympto-thermal fertility detection', 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', + 'By default, cervical mucus values are being used for sympto-thermal fertility detection. You can switch here to use cervix values for sympto-thermal fertility detection', disabled: { title: 'Disabled', message: @@ -139,6 +139,6 @@ Making any changes to your password setting will keep your data as it was before }, preOvu: { title: 'Infertile days at cycle start', - note: `drip. applies the sympto-thermal method for calculating infertile days at the start of the cycle (see ${links.wiki.url} for more info). However, drip. does not currently apply the so called 20-day-rule, which determines infertile days at the cycle start from past cycle lengths in case no past symptothermal info is available.`, + note: `drip. applies the sympto-thermal method for calculating infertile days at the start of the cycle (see ${links.wiki.url} for more info). However, drip. does not currently apply the so called 20-day-rule, which determines infertile days at the cycle start from past cycle lengths in case no past sympto-thermal info is available.`, }, } From 24df5cea31a78e1869c08437064f93b403cf51d9 Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Thu, 29 Feb 2024 10:35:22 +0000 Subject: [PATCH 44/48] Spell "science-based" --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index eedb19a..cc1e829 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -33,7 +33,7 @@ We are an open source project and we highly appreciate contributions. At the sam - 🔮 open source - 🩸 feminist and gender inclusive - 🔒 secure: data entered stays with that person/on their device - - 🔬 science based: we implemented the sympto-thermal method + - 🔬 science-based: we implemented the sympto-thermal method This means that we will never implement anything that contradicts these core values. Some examples: We will never build a cloud integration, we will never make an ovulation prediction. From 3e8f15e04e74eeb18ea28e4ec6b107c3cb565a3a Mon Sep 17 00:00:00 2001 From: wunderfisch Date: Thu, 29 Feb 2024 17:46:56 +0100 Subject: [PATCH 45/48] disable temperature slider when fertility or temperature turned off --- .../disabled-temperature-slider.js | 62 +++++++++++++++++++ components/settings/customization/index.js | 37 +++++------ i18n/en/settings.js | 9 ++- 3 files changed, 81 insertions(+), 27 deletions(-) create mode 100644 components/settings/customization/disabled-temperature-slider.js diff --git a/components/settings/customization/disabled-temperature-slider.js b/components/settings/customization/disabled-temperature-slider.js new file mode 100644 index 0000000..44e8147 --- /dev/null +++ b/components/settings/customization/disabled-temperature-slider.js @@ -0,0 +1,62 @@ +import React from 'react' +import { StyleSheet, View } from 'react-native' +import Slider from '@ptomasroos/react-native-multi-slider' + +import SliderLabel from './slider-label' + +import { scaleObservable } from '../../../local-storage' +import { Colors, Sizes } from '../../../styles' + +import { TEMP_MIN, TEMP_MAX, TEMP_SLIDER_STEP } from '../../../config' + +const DisabledTemperatureSlider = () => { + const savedValue = scaleObservable.value + const minTemperature = savedValue.min + const maxTemperature = savedValue.max + + return ( + + + + ) +} + +export default DisabledTemperatureSlider + +const styles = StyleSheet.create({ + container: { + alignItems: 'center', + paddingTop: Sizes.base, + }, + marker: { + backgroundColor: Colors.grey, + borderRadius: 50, + elevation: 4, + height: Sizes.subtitle, + width: Sizes.subtitle, + }, + slider: { + borderRadius: 25, + height: Sizes.small, + }, + sliderAccentBackground: { + backgroundColor: Colors.grey, + }, + sliderBackground: { + backgroundColor: Colors.greyLight, + }, +}) diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index 9e06407..f147a41 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -19,6 +19,8 @@ import { temperatureTrackingCategoryObservable, mucusTrackingCategoryObservable, cervixTrackingCategoryObservable, + periodPredictionObservable, + useCervixAsSecondarySymptomObservable, saveDesireTrackingCategory, saveFertilityTrackingEnabled, saveMoodTrackingCategory, @@ -30,11 +32,10 @@ import { saveSexTrackingCategory, saveTemperatureTrackingCategory, saveUseCervixAsSecondarySymptom, - periodPredictionObservable, - useCervixAsSecondarySymptomObservable, } from '../../../local-storage' import labels from '../../../i18n/en/settings' import { SYMPTOMS } from '../../../config' +import DisabledTemperatureSlider from './disabled-temperature-slider' const Settings = () => { const { t } = useTranslation(null, { keyPrefix: 'symptoms' }) @@ -143,17 +144,11 @@ const Settings = () => { }, ] - // NOTE: when disabled (!isFertilityTrackingEnabled) button press doesn't yet trigger alert const onSelectTab = (value) => { if (isMucusTrackingCategoryEnabled && isCervixTrackingCategoryEnabled) { setUseCervixAsSecondarySymptom(value) saveUseCervixAsSecondarySymptom(value) - console.log('show SecSymp value :>> ', value) - } else if (!isFertilityTrackingEnabled) { - console.log('2 show SecSymp value :>> ', value) - secondarySymptomDisabledPrompt() } else { - console.log('3 show SecSymp value :>> ', value) secondarySymptomDisabledPrompt() } } @@ -208,8 +203,8 @@ const Settings = () => { : labels.secondarySymptom.cervixModeOff const sliderDisabledPrompt = () => { - if (!isTemperatureTrackingCategoryEnabled) { - Alert.alert(labels.disabled.title, labels.disabled.message) + if (!isFertilityTrackingEnabled) { + Alert.alert(labels.tempScale.disabled, labels.tempScale.disabledMessage) } } @@ -219,8 +214,6 @@ const Settings = () => { } } - console.log('useCervixAsSecondarySymptom :>> ', useCervixAsSecondarySymptom) - return ( @@ -280,19 +273,19 @@ const Settings = () => { /> - - {/* NOTE: still needs to be greyed out and not moveable */} + {/* Not ideal to have a extra DisabledTemperatureSlider but right now hard to have always the correct state of fertilityTrackingObservable in TemperatureSlider */} - {/* {isTemperatureTrackingCategoryEnabled && ( - <> */} {labels.tempScale.segmentExplainer} - - {/* - )} - {!isTemperatureTrackingCategoryEnabled && ( - {labels.disabled.message} - )} */} + {isTemperatureTrackingCategoryEnabled & isFertilityTrackingEnabled ? ( + <> + + + ) : ( + <> + + + )} diff --git a/i18n/en/settings.js b/i18n/en/settings.js index aec4513..119f887 100644 --- a/i18n/en/settings.js +++ b/i18n/en/settings.js @@ -41,12 +41,11 @@ export default { max: 'Max', loadError: 'Could not load saved temperature scale settings', saveError: 'Could not save temperature scale settings', + disabled: 'Disabled', + disabledMessage: + 'To use the temperature scale please first enable both temperature tracking and fertility phase calculation above.', }, - disabled: { - title: 'This feature is turned off', - message: - 'To use the temperature scale please first enable the temperature tracking category above.', - }, + tempReminder: { title: 'Temperature reminder', noTimeSet: 'Set a time for a daily reminder to take your temperature', From b65b5f3561c89a1edb8a1cb90a35fc713279549a Mon Sep 17 00:00:00 2001 From: wunderfisch Date: Thu, 7 Mar 2024 18:58:37 +0100 Subject: [PATCH 46/48] refactoring disable function of temperature slider --- components/cycle-day/select-tab-group.js | 3 +- .../disabled-temperature-slider.js | 62 ------------------- components/settings/customization/index.js | 23 +++---- .../customization/temperature-slider.js | 28 ++++++++- i18n/en/settings.js | 5 +- 5 files changed, 39 insertions(+), 82 deletions(-) delete mode 100644 components/settings/customization/disabled-temperature-slider.js diff --git a/components/cycle-day/select-tab-group.js b/components/cycle-day/select-tab-group.js index 3800fa4..9794561 100644 --- a/components/cycle-day/select-tab-group.js +++ b/components/cycle-day/select-tab-group.js @@ -21,7 +21,7 @@ export default function SelectTabGroup({ // Disable is only used for secondarySymptom in customization, if more come up maybe consider more tidy solution const showDisableAlert = (label) => { - if (label === 'cervix' || 'mucus') { + if (label === 'cervix' || label === 'mucus') { Alert.alert( labels.secondarySymptom.disabled.title, labels.secondarySymptom.disabled.message @@ -68,6 +68,7 @@ SelectTabGroup.propTypes = { activeButton: PropTypes.number, buttons: PropTypes.array.isRequired, onSelect: PropTypes.func.isRequired, + disabled: PropTypes.bool, } const styles = StyleSheet.create({ diff --git a/components/settings/customization/disabled-temperature-slider.js b/components/settings/customization/disabled-temperature-slider.js deleted file mode 100644 index 44e8147..0000000 --- a/components/settings/customization/disabled-temperature-slider.js +++ /dev/null @@ -1,62 +0,0 @@ -import React from 'react' -import { StyleSheet, View } from 'react-native' -import Slider from '@ptomasroos/react-native-multi-slider' - -import SliderLabel from './slider-label' - -import { scaleObservable } from '../../../local-storage' -import { Colors, Sizes } from '../../../styles' - -import { TEMP_MIN, TEMP_MAX, TEMP_SLIDER_STEP } from '../../../config' - -const DisabledTemperatureSlider = () => { - const savedValue = scaleObservable.value - const minTemperature = savedValue.min - const maxTemperature = savedValue.max - - return ( - - - - ) -} - -export default DisabledTemperatureSlider - -const styles = StyleSheet.create({ - container: { - alignItems: 'center', - paddingTop: Sizes.base, - }, - marker: { - backgroundColor: Colors.grey, - borderRadius: 50, - elevation: 4, - height: Sizes.subtitle, - width: Sizes.subtitle, - }, - slider: { - borderRadius: 25, - height: Sizes.small, - }, - sliderAccentBackground: { - backgroundColor: Colors.grey, - }, - sliderBackground: { - backgroundColor: Colors.greyLight, - }, -}) diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index f147a41..ddb2db9 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -35,7 +35,6 @@ import { } from '../../../local-storage' import labels from '../../../i18n/en/settings' import { SYMPTOMS } from '../../../config' -import DisabledTemperatureSlider from './disabled-temperature-slider' const Settings = () => { const { t } = useTranslation(null, { keyPrefix: 'symptoms' }) @@ -81,6 +80,7 @@ const Settings = () => { const [isFertilityTrackingEnabled, setFertilityTrackingEnabled] = useState( fertilityTrackingObservable.value ) + const fertilityTrackingToggle = (value) => { setFertilityTrackingEnabled(value) saveFertilityTrackingEnabled(value) @@ -203,14 +203,17 @@ const Settings = () => { : labels.secondarySymptom.cervixModeOff const sliderDisabledPrompt = () => { - if (!isFertilityTrackingEnabled) { + if (!isTemperatureTrackingCategoryEnabled) { Alert.alert(labels.tempScale.disabled, labels.tempScale.disabledMessage) } } const fertilityDisabledPrompt = () => { - if (!isFertilityTrackingEnabled) { - Alert.alert(labels.disabled.title, labels.fertilityTracking.disabled) + if (!manageFertilityFeature) { + Alert.alert( + labels.fertilityTracking.disabledTitle, + labels.fertilityTracking.disabled + ) } } @@ -273,19 +276,11 @@ const Settings = () => { /> - {/* Not ideal to have a extra DisabledTemperatureSlider but right now hard to have always the correct state of fertilityTrackingObservable in TemperatureSlider */} + {labels.tempScale.segmentExplainer} - {isTemperatureTrackingCategoryEnabled & isFertilityTrackingEnabled ? ( - <> - - - ) : ( - <> - - - )} + diff --git a/components/settings/customization/temperature-slider.js b/components/settings/customization/temperature-slider.js index 2019d55..7d91f7a 100644 --- a/components/settings/customization/temperature-slider.js +++ b/components/settings/customization/temperature-slider.js @@ -1,5 +1,6 @@ import React, { useState } from 'react' import { StyleSheet, View } from 'react-native' +import PropTypes from 'prop-types' import Slider from '@ptomasroos/react-native-multi-slider' import alertError from '../common/alert-error' @@ -10,7 +11,7 @@ import { Colors, Sizes } from '../../../styles' import labels from '../../../i18n/en/settings' import { TEMP_MIN, TEMP_MAX, TEMP_SLIDER_STEP } from '../../../config' -const TemperatureSlider = () => { +const TemperatureSlider = ({ disabled }) => { const savedValue = scaleObservable.value const [minTemperature, setMinTemperature] = useState(savedValue.min) const [maxTemperature, setMaxTemperature] = useState(savedValue.max) @@ -25,6 +26,14 @@ const TemperatureSlider = () => { } } + const sliderAccentBackground = disabled + ? styles.disabledSliderAccentBackground + : styles.sliderAccentBackground + + const sliderBackground = disabled + ? styles.disabledSliderBackground + : styles.sliderBackground + return ( { max={TEMP_MAX} min={TEMP_MIN} onValuesChange={onTemperatureSliderChange} - selectedStyle={styles.sliderAccentBackground} step={TEMP_SLIDER_STEP} trackStyle={styles.slider} - unselectedStyle={styles.sliderBackground} values={[minTemperature, maxTemperature]} + enabledOne={!disabled} + enabledTwo={!disabled} + selectedStyle={sliderAccentBackground} + unselectedStyle={sliderBackground} /> ) @@ -47,6 +58,10 @@ const TemperatureSlider = () => { export default TemperatureSlider +TemperatureSlider.propTypes = { + disabled: PropTypes.bool, +} + const styles = StyleSheet.create({ container: { alignItems: 'center', @@ -54,6 +69,7 @@ const styles = StyleSheet.create({ }, marker: { backgroundColor: Colors.turquoiseDark, + borderRadius: 50, elevation: 4, height: Sizes.subtitle, @@ -66,7 +82,13 @@ const styles = StyleSheet.create({ sliderAccentBackground: { backgroundColor: Colors.turquoiseDark, }, + disabledSliderAccentBackground: { + backgroundColor: Colors.grey, + }, sliderBackground: { backgroundColor: Colors.turquoise, }, + disabledSliderBackground: { + backgroundColor: Colors.greyLight, + }, }) diff --git a/i18n/en/settings.js b/i18n/en/settings.js index 119f887..fdd3a88 100644 --- a/i18n/en/settings.js +++ b/i18n/en/settings.js @@ -43,7 +43,7 @@ export default { saveError: 'Could not save temperature scale settings', disabled: 'Disabled', disabledMessage: - 'To use the temperature scale please first enable both temperature tracking and fertility phase calculation above.', + 'To use the temperature scale please first enable temperature tracking above.', }, tempReminder: { @@ -71,8 +71,9 @@ export default { }, fertilityTracking: { title: 'Fertility phases calculation', + disabledTitle: 'Disabled', disabled: - 'To use this feature please enable temperature tracking and cervical mucus or cervix tracking.', + 'To use fertility phases calculation please enable temperature tracking and cervical mucus or cervix tracking above.', 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.', on: 'If you switch this off, drip will not show fertility related information.', From f5894c028e637f2b4ae22bd376e5b24e0f2adb1e Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Thu, 14 Mar 2024 10:54:18 +0000 Subject: [PATCH 47/48] renaming --- components/cycle-day/select-tab-group.js | 4 ++-- i18n/en/settings.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/cycle-day/select-tab-group.js b/components/cycle-day/select-tab-group.js index 9794561..195c6e7 100644 --- a/components/cycle-day/select-tab-group.js +++ b/components/cycle-day/select-tab-group.js @@ -20,7 +20,7 @@ export default function SelectTabGroup({ buttons[0]['label'] === labels.secondarySymptom.mucus // Disable is only used for secondarySymptom in customization, if more come up maybe consider more tidy solution - const showDisableAlert = (label) => { + const showDisabledAlert = (label) => { if (label === 'cervix' || label === 'mucus') { Alert.alert( labels.secondarySymptom.disabled.title, @@ -51,7 +51,7 @@ export default function SelectTabGroup({ return ( - !disabled ? onSelect(value) : showDisableAlert(label) + !disabled ? onSelect(value) : showDisabledAlert(label) } key={i} style={boxStyle} diff --git a/i18n/en/settings.js b/i18n/en/settings.js index f20e024..5748d02 100644 --- a/i18n/en/settings.js +++ b/i18n/en/settings.js @@ -75,16 +75,16 @@ export default { disabled: 'To use fertility phases calculation please enable temperature tracking and cervical mucus or cervix tracking above.', 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 method, drip will calculate cycle phases with the provided data.', on: 'If you switch this off, drip will not show fertility related information.', off: 'If you switch this on, drip will show fertility related information.', }, secondarySymptom: { title: 'Secondary symptom', cervixModeOn: - 'Cervix values are being used for fertility detection according to the sympto-thermal rules.', + 'Cervix values are being used for fertility detection according to the sympto-thermal method.', cervixModeOff: - 'Cervical mucus values are being used for fertility detection according to the sympto-thermal rules.', + 'Cervical mucus values are being used for fertility detection according to the sympto-thermal method.', disabled: { title: 'Disabled', message: From eaf01e98d5f9ffd1251d4a55a8e0b001d95137f7 Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Thu, 14 Mar 2024 10:58:56 +0000 Subject: [PATCH 48/48] renaming --- components/cycle-day/select-tab-group.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/cycle-day/select-tab-group.js b/components/cycle-day/select-tab-group.js index 195c6e7..25db72a 100644 --- a/components/cycle-day/select-tab-group.js +++ b/components/cycle-day/select-tab-group.js @@ -39,7 +39,7 @@ export default function SelectTabGroup({ isActive && styles.boxActive, isSecondarySymptomSwitch && styles.purpleBox, isSecondarySymptomSwitch && isActive && styles.activePurpleBox, - disabled && styles.inActiveBox, + disabled && styles.disabledBox, ] const textStyle = [ styles.text, @@ -99,7 +99,7 @@ const styles = StyleSheet.create({ greyText: { color: Colors.grey, }, - inActiveBox: { + disabledBox: { borderColor: Colors.grey, backgroundColor: Colors.turquoiseLight, },