From ae3edb0a158c953233019ad4dc3603533df563a7 Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Tue, 23 Jan 2024 15:20:04 +0100 Subject: [PATCH 1/9] Add temperature toggle in customization and store value in local storage --- components/settings/customization/index.js | 17 +++++++++++++++++ local-storage.js | 8 ++++++++ 2 files changed, 25 insertions(+) diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index 537773c..ac37136 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -12,12 +12,14 @@ import { noteTrackingCategoryObservable, painTrackingCategoryObservable, sexTrackingCategoryObservable, + temperatureTrackingCategoryObservable, saveDesireTrackingCategory, saveMoodTrackingCategory, saveNoteTrackingCategory, savePainTrackingCategory, savePeriodPrediction, saveSexTrackingCategory, + saveTemperatureTrackingCategory, saveUseCervix, periodPredictionObservable, useCervixObservable, @@ -34,6 +36,10 @@ const Settings = () => { periodPredictionObservable.value ) + const [isTemperatureTrackingCategoryEnabled, setTemperatureTrackingCategory] = useState( + temperatureTrackingCategoryObservable.value + ) + const [isSexTrackingCategoryEnabled, setSexTrackingCategory] = useState( sexTrackingCategoryObservable.value ) @@ -57,6 +63,11 @@ const Settings = () => { const [isEnabled, setIsEnabled] = useState(false) const toggleSwitch = () => setIsEnabled((previousState) => !previousState) + const temperatureTrackingCategoryToggle = (value) => { + setTemperatureTrackingCategory(value) + saveTemperatureTrackingCategory(value) + } + const sexTrackingCategoryToggle = (value) => { setSexTrackingCategory(value) saveSexTrackingCategory(value) @@ -100,6 +111,12 @@ const Settings = () => { return ( + Date: Tue, 23 Jan 2024 15:20:48 +0100 Subject: [PATCH 2/9] On cycle day temp wont show if turned off --- components/cycle-day/cycle-day-overview.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/cycle-day/cycle-day-overview.js b/components/cycle-day/cycle-day-overview.js index 52dd3ec..a033135 100644 --- a/components/cycle-day/cycle-day-overview.js +++ b/components/cycle-day/cycle-day-overview.js @@ -15,6 +15,7 @@ import { noteTrackingCategoryObservable, painTrackingCategoryObservable, sexTrackingCategoryObservable, + temperatureTrackingCategoryObservable, } from '../../local-storage' import { Spacing } from '../../styles' import { SYMPTOMS } from '../../config' @@ -35,7 +36,9 @@ const CycleDayOverView = ({ date, setDate, isTemperatureEditView }) => { } const allEnabledSymptoms = SYMPTOMS.map((symptom) => { - if (symptom === 'sex') { + if (symptom === 'temperature') { + return temperatureTrackingCategoryObservable.value ? symptom : null + } else if (symptom === 'sex') { return sexTrackingCategoryObservable.value ? symptom : null } else if (symptom === 'desire') { return desireTrackingCategoryObservable.value ? symptom : null From 7dd01c0c9b09b11e9e1257036b7150fca2cca076 Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Tue, 23 Jan 2024 15:21:27 +0100 Subject: [PATCH 3/9] On chart temperature wont be displayed, also warning --- components/chart/chart.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/components/chart/chart.js b/components/chart/chart.js index c475ae2..b394129 100644 --- a/components/chart/chart.js +++ b/components/chart/chart.js @@ -21,6 +21,7 @@ import { noteTrackingCategoryObservable, painTrackingCategoryObservable, sexTrackingCategoryObservable, + temperatureTrackingCategoryObservable, } from '../../local-storage' import { makeColumnInfo } from '../helpers/chart' @@ -84,7 +85,11 @@ const CycleChart = ({ navigate, setDate }) => { } }) - const shouldShowTemperatureColumn = chartSymptoms.indexOf('temperature') > -1 + const isTemperatureEnabled = temperatureTrackingCategoryObservable.value + const shouldShowTemperatureColumn = + isTemperatureEnabled && chartSymptoms.indexOf('temperature') > -1 + const shouldShowNoDataWarning = + isTemperatureEnabled && chartSymptoms.indexOf('temperature') <= -1 const { width, height } = Dimensions.get('window') const numberOfColumnsToRender = Math.round(width / CHART_COLUMN_WIDTH) @@ -135,7 +140,7 @@ const CycleChart = ({ navigate, setDate }) => { > {shouldShowHint && } - {!shouldShowTemperatureColumn && } + {shouldShowNoDataWarning && } Date: Tue, 23 Jan 2024 15:23:19 +0100 Subject: [PATCH 4/9] Remove useless description and show only symptom name --- components/settings/customization/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index ac37136..46fb727 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -113,37 +113,37 @@ const Settings = () => { From a99e6952a1b24d29303362611d3ad46a62d35f2a Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Tue, 23 Jan 2024 15:27:33 +0100 Subject: [PATCH 5/9] Turn tempreminder off when temperature turned off --- local-storage.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/local-storage.js b/local-storage.js index 0d13a51..ece4355 100644 --- a/local-storage.js +++ b/local-storage.js @@ -98,6 +98,13 @@ setObvWithInitValue('temperature', temperatureTrackingCategoryObservable, true) export async function saveTemperatureTrackingCategory(bool) { await AsyncStorage.setItem('temperature', JSON.stringify(bool)) temperatureTrackingCategoryObservable.set(bool) + + if (!temperatureTrackingCategoryObservable.value) { + const result = await AsyncStorage.getItem('tempReminder') + if (JSON.parse(result).enabled) { + tempReminderObservable.set(false) + } + } } export const sexTrackingCategoryObservable = Observable() From fdb892ff6bbcacecac55c0a95eabfff7cb630e6b Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Tue, 23 Jan 2024 16:07:21 +0100 Subject: [PATCH 6/9] Disable tempReminder if temp is turned off --- components/settings/reminders/reminders.js | 17 ++++++++++++++--- .../settings/reminders/temperature-reminder.js | 2 ++ i18n/en/settings.js | 5 +++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/components/settings/reminders/reminders.js b/components/settings/reminders/reminders.js index 518886b..1279d29 100644 --- a/components/settings/reminders/reminders.js +++ b/components/settings/reminders/reminders.js @@ -9,6 +9,7 @@ import { periodReminderObservable, savePeriodReminder, periodPredictionObservable, + temperatureTrackingCategoryObservable, } from '../../../local-storage' import labels from '../../../i18n/en/settings' @@ -34,6 +35,14 @@ const Reminders = () => { } } + const tempReminderDisabledPrompt = () => { + if (!temperatureTrackingCategoryObservable.value) { + Alert.alert( + labels.tempReminder.alertNoTempReminder.title, + labels.tempReminder.alertNoTempReminder.message + ) + } + } return ( @@ -46,9 +55,11 @@ const Reminders = () => { /> - - - + + + + + ) } diff --git a/components/settings/reminders/temperature-reminder.js b/components/settings/reminders/temperature-reminder.js index d5fb874..5b06b19 100644 --- a/components/settings/reminders/temperature-reminder.js +++ b/components/settings/reminders/temperature-reminder.js @@ -7,6 +7,7 @@ import AppSwitch from '../../common/app-switch' import { saveTempReminder, tempReminderObservable, + temperatureTrackingCategoryObservable, } from '../../../local-storage' import padWithZeros from '../../helpers/pad-time-with-zeros' @@ -51,6 +52,7 @@ const TemperatureReminder = () => { onToggle={temperatureReminderToggle} text={tempReminderText} value={isEnabled} + disabled={!temperatureTrackingCategoryObservable.value} /> `Daily reminder set for ${time}`, notification: 'Record your morning temperature', + alertNoTempReminder: { + title: 'Temperature turned off', + message: + 'To use the temperature reminder please first enable the temperature tracking category in the customization settings.', + }, }, periodReminder: { title: 'Next period reminder', From 6a4d5c330ba0ad5d884e6d2c7bcd36a0c7222d3a Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Mon, 29 Jan 2024 13:40:30 +0100 Subject: [PATCH 7/9] Disable/hide TemperatureSlider if temperature category turned off --- components/settings/customization/index.js | 26 ++++++++++++++++++---- i18n/en/settings.js | 5 +++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index 46fb727..613b2e5 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -1,4 +1,5 @@ import React, { useState } from 'react' +import { Alert, Pressable } from 'react-native' import AppPage from '../../common/app-page' import AppSwitch from '../../common/app-switch' @@ -108,6 +109,14 @@ const Settings = () => { ? labels.useCervix.cervixModeOn : labels.useCervix.cervixModeOff + const sliderDisabledPrompt = () => { + if (!isTemperatureTrackingCategoryEnabled) { + Alert.alert( + labels.tempScale.disabled.title, + labels.tempScale.disabled.message + ) + } + } return ( @@ -158,10 +167,19 @@ const Settings = () => { /> - - {labels.tempScale.segmentExplainer} - - + + + {isTemperatureTrackingCategoryEnabled && ( + <> + {labels.tempScale.segmentExplainer} + + + )} + {!isTemperatureTrackingCategoryEnabled && ( + {labels.tempScale.disabled.message} + )} + + Date: Mon, 29 Jan 2024 18:21:53 +0100 Subject: [PATCH 8/9] Hide SecondarySymptom Switch if temperature category turned off --- components/settings/customization/index.js | 35 ++++++++++++---------- i18n/en/settings.js | 10 +++---- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index 613b2e5..a8decf4 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -37,9 +37,8 @@ const Settings = () => { periodPredictionObservable.value ) - const [isTemperatureTrackingCategoryEnabled, setTemperatureTrackingCategory] = useState( - temperatureTrackingCategoryObservable.value - ) + const [isTemperatureTrackingCategoryEnabled, setTemperatureTrackingCategory] = + useState(temperatureTrackingCategoryObservable.value) const [isSexTrackingCategoryEnabled, setSexTrackingCategory] = useState( sexTrackingCategoryObservable.value @@ -111,10 +110,7 @@ const Settings = () => { const sliderDisabledPrompt = () => { if (!isTemperatureTrackingCategoryEnabled) { - Alert.alert( - labels.tempScale.disabled.title, - labels.tempScale.disabled.message - ) + Alert.alert(labels.disabled.title, labels.disabled.message) } } return ( @@ -176,19 +172,26 @@ const Settings = () => { )} {!isTemperatureTrackingCategoryEnabled && ( - {labels.tempScale.disabled.message} + {labels.disabled.message} )} - - - + + + {isTemperatureTrackingCategoryEnabled && ( + + )} + {!isTemperatureTrackingCategoryEnabled && ( + {labels.disabled.message} + )} + + Date: Thu, 25 Jan 2024 12:03:51 +0100 Subject: [PATCH 9/9] Add symptom labels from config list --- components/settings/customization/index.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index a8decf4..a8e0ab2 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -27,6 +27,7 @@ import { } from '../../../local-storage' import { Colors } from '../../../styles' import labels from '../../../i18n/en/settings' +import { SYMPTOMS } from '../../../config' const Settings = () => { const [shouldUseCervix, setShouldUseCervix] = useState( @@ -118,37 +119,37 @@ const Settings = () => {