From c7c905fd5fb28b4353ecd5c25423ae4ba03563a3 Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Fri, 5 Jan 2024 20:11:38 +0100 Subject: [PATCH 1/8] Add functionality to turn on/off period predictions --- components/settings/customization/index.js | 32 ++++++++++++++++------ i18n/en/settings.js | 5 ++++ local-storage.js | 10 +++++++ 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/components/settings/customization/index.js b/components/settings/customization/index.js index 373888c..9d0408c 100644 --- a/components/settings/customization/index.js +++ b/components/settings/customization/index.js @@ -6,7 +6,12 @@ import AppText from '../../common/app-text' import TemperatureSlider from './temperature-slider' import Segment from '../../common/segment' -import { useCervixObservable, saveUseCervix } from '../../../local-storage' +import { + periodPredictionObservable, + savePeriodPrediction, + useCervixObservable, + saveUseCervix, +} from '../../../local-storage' import { Colors } from '../../../styles' import labels from '../../../i18n/en/settings' @@ -15,9 +20,22 @@ const Settings = () => { useCervixObservable.value ) - const [isEnabled, setIsEnabled] = useState(true) + const [isPeriodPredictionEnabled, setPeriodPrediction] = useState( + periodPredictionObservable.value + ) + + const [isEnabled, setIsEnabled] = useState(false) const toggleSwitch = () => setIsEnabled((previousState) => !previousState) + const onPeriodPredictionToggle = (value) => { + setPeriodPrediction(value) + savePeriodPrediction(value) + } + + const periodPredictionText = isPeriodPredictionEnabled + ? labels.periodPrediction.on + : labels.periodPrediction.off + const onCervixToggle = (value) => { setShouldUseCervix(value) saveUseCervix(value) @@ -103,13 +121,11 @@ const Settings = () => { /> - + diff --git a/i18n/en/settings.js b/i18n/en/settings.js index e330edc..02ca54b 100644 --- a/i18n/en/settings.js +++ b/i18n/en/settings.js @@ -58,6 +58,11 @@ export default { 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', }, + periodPrediction: { + title: 'Period prediction', + on: 'drip predicts your 3 next menstrual bleedings based on the statistics of your previously tracked cycles, min 3 complete cycles.', + off: 'There are no predictions for menstrual cycles displayed. If turned on the calendar and on home period predictions will be displayed.', + }, passwordSettings: { title: 'App password', explainerDisabled: diff --git a/local-storage.js b/local-storage.js index ac19625..3f6950b 100644 --- a/local-storage.js +++ b/local-storage.js @@ -44,6 +44,16 @@ export async function savePeriodReminder(reminder) { periodReminderObservable.set(reminder) } +export const periodPredictionObservable = Observable() +setObvWithInitValue('periodPrediction', periodPredictionObservable, { + enabled: true, +}) + +export async function savePeriodPrediction(bool) { + await AsyncStorage.setItem('periodPrediction', JSON.stringify(bool)) + periodPredictionObservable.set(bool) +} + export const useCervixObservable = Observable() setObvWithInitValue('useCervix', useCervixObservable, false) From 791c0d345fcf146b841c53ec9c00b22607061843 Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Fri, 5 Jan 2024 20:17:24 +0100 Subject: [PATCH 2/8] Make periodPrediction on Calendar adjustable --- components/helpers/calendar.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/helpers/calendar.js b/components/helpers/calendar.js index e929255..4468115 100644 --- a/components/helpers/calendar.js +++ b/components/helpers/calendar.js @@ -2,6 +2,7 @@ import { LocalDate } from '@js-joda/core' import { verticalScale } from 'react-native-size-matters' import { Colors, Fonts, Sizes } from '../../styles' +import { periodPredictionObservable } from '../../local-storage' const { shades } = Colors.iconColors.bleeding @@ -26,6 +27,7 @@ export const toCalFormat = (bleedingDaysSortedByDate) => { } export const predictionToCalFormat = (predictedDays) => { + if (!periodPredictionObservable.value) return {} if (!predictedDays.length) return {} const todayDateString = LocalDate.now().toString() const middleIndex = (predictedDays[0].length - 1) / 2 From 5d62cbfffe8100fb20f96e196192b03232c346c9 Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Fri, 5 Jan 2024 20:17:47 +0100 Subject: [PATCH 3/8] Makes periodPrediction text on Home adjustable --- components/Home.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/components/Home.js b/components/Home.js index 820dc22..783d8c4 100644 --- a/components/Home.js +++ b/components/Home.js @@ -14,6 +14,7 @@ import { determinePredictionText, formatWithOrdinalSuffix, } from './helpers/home' +import { periodPredictionObservable } from '../local-storage' import { Colors, Fonts, Sizes, Spacing } from '../styles' import { LocalDate } from '@js-joda/core' @@ -32,6 +33,7 @@ const Home = ({ navigate, setDate }) => { const cycleDayNumber = getCycleDayNumber(todayDateString) const { status, phase, statusText } = getFertilityStatusForDay(todayDateString) + const isPeriodPredictionEnabled = periodPredictionObservable.value const prediction = determinePredictionText(getPredictedMenses(), t) const cycleDayText = cycleDayNumber @@ -65,9 +67,11 @@ const Home = ({ navigate, setDate }) => { )} - - {prediction} - + {isPeriodPredictionEnabled && ( + + {prediction} + + )} From 5787e96e53b7fef462b12a39997bf2e4aeb3c4b7 Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Wed, 10 Jan 2024 17:52:14 +0100 Subject: [PATCH 4/8] set periodReminder to false if periodPrediction is turned off --- local-storage.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/local-storage.js b/local-storage.js index 3f6950b..fb29e95 100644 --- a/local-storage.js +++ b/local-storage.js @@ -45,13 +45,18 @@ export async function savePeriodReminder(reminder) { } export const periodPredictionObservable = Observable() -setObvWithInitValue('periodPrediction', periodPredictionObservable, { - enabled: true, -}) +setObvWithInitValue('periodPrediction', periodPredictionObservable, true) export async function savePeriodPrediction(bool) { await AsyncStorage.setItem('periodPrediction', JSON.stringify(bool)) periodPredictionObservable.set(bool) + + if (!periodPredictionObservable.value) { + const result = await AsyncStorage.getItem('periodReminder') + if (JSON.parse(result).enabled) { + periodReminderObservable.set(false) + } + } } export const useCervixObservable = Observable() From 974a9735c52520997e16a1f83b02132e6e1ee4c1 Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Wed, 10 Jan 2024 18:00:01 +0100 Subject: [PATCH 5/8] Improve text for periodPrediction off --- i18n/en/settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n/en/settings.js b/i18n/en/settings.js index 02ca54b..a71feb4 100644 --- a/i18n/en/settings.js +++ b/i18n/en/settings.js @@ -61,7 +61,7 @@ export default { periodPrediction: { title: 'Period prediction', on: 'drip predicts your 3 next menstrual bleedings based on the statistics of your previously tracked cycles, min 3 complete cycles.', - off: 'There are no predictions for menstrual cycles displayed. If turned on the calendar and on home period predictions will be displayed.', + off: 'There are no predictions for menstrual cycles displayed. If turned on the calendar and the home screen will display period predictions.', }, passwordSettings: { title: 'App password', From b53be31868635f619c6832a8162b99b8a9cbe870 Mon Sep 17 00:00:00 2001 From: wunderfisch Date: Mon, 15 Jan 2024 18:05:54 +0100 Subject: [PATCH 6/8] functionality that disables the next-periode-reminder-switch if menstrual bleeding shall not be predicted (new customization feature). also an alert pops up when the user still tries to press the disabled toggle or the text area next to it --- components/common/app-switch.js | 4 ++- components/settings/reminders/reminders.js | 30 +++++++++++++++++----- i18n/en/settings.js | 5 ++++ 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/components/common/app-switch.js b/components/common/app-switch.js index ce835a6..3c100fe 100644 --- a/components/common/app-switch.js +++ b/components/common/app-switch.js @@ -6,7 +6,7 @@ import AppText from './app-text' import { Containers } from '../../styles' -const AppSwitch = ({ onToggle, text, value, trackColor }) => { +const AppSwitch = ({ onToggle, text, value, trackColor, disabled }) => { return ( @@ -17,6 +17,7 @@ const AppSwitch = ({ onToggle, text, value, trackColor }) => { style={styles.switch} value={value} trackColor={trackColor} + disabled={disabled} /> ) @@ -27,6 +28,7 @@ AppSwitch.propTypes = { text: PropTypes.string, value: PropTypes.bool, trackColor: PropTypes.string, + disabled: PropTypes.bool, } const styles = StyleSheet.create({ diff --git a/components/settings/reminders/reminders.js b/components/settings/reminders/reminders.js index 08e2451..65349f9 100644 --- a/components/settings/reminders/reminders.js +++ b/components/settings/reminders/reminders.js @@ -8,11 +8,15 @@ import TemperatureReminder from './temperature-reminder' import { periodReminderObservable, savePeriodReminder, + periodPredictionObservable, } from '../../../local-storage' import labels from '../../../i18n/en/settings' +import { Alert, Pressable } from 'react-native' const Reminders = () => { + const isPeriodPredictionDisabled = !periodPredictionObservable.value + const [isPeriodReminderEnabled, setIsPeriodReminderEnabled] = useState( periodReminderObservable.value.enabled ) @@ -21,15 +25,27 @@ const Reminders = () => { savePeriodReminder({ enabled: isEnabled }) } + const reminderDisabledPrompt = () => { + if (!periodPredictionObservable.value) { + Alert.alert( + labels.periodReminder.alertNoPeriodeReminder.title, + labels.periodReminder.alertNoPeriodeReminder.message + ) + } + } + return ( - - - + + + + + diff --git a/i18n/en/settings.js b/i18n/en/settings.js index a71feb4..efe88b7 100644 --- a/i18n/en/settings.js +++ b/i18n/en/settings.js @@ -50,6 +50,11 @@ export default { 'Get a notification 3 days before your next period is likely to start.', notification: (daysToEndOfPrediction) => `Your next period is likely to start in 3 to ${daysToEndOfPrediction} days.`, + alertNoPeriodeReminder: { + title: 'Periode Prediction switched off', + message: + 'To use the periode reminder please first enable periode prediction in the customization settings.', + }, }, useCervix: { title: 'Secondary symptom', From db93aa74bb573e3078a401271ab54b3f54a07141 Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Mon, 22 Jan 2024 15:07:16 +0100 Subject: [PATCH 7/8] Typo and other text corrections --- components/settings/reminders/reminders.js | 4 ++-- i18n/en/settings.js | 8 ++++---- i18n/en/symptom-info.js | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/components/settings/reminders/reminders.js b/components/settings/reminders/reminders.js index 65349f9..518886b 100644 --- a/components/settings/reminders/reminders.js +++ b/components/settings/reminders/reminders.js @@ -28,8 +28,8 @@ const Reminders = () => { const reminderDisabledPrompt = () => { if (!periodPredictionObservable.value) { Alert.alert( - labels.periodReminder.alertNoPeriodeReminder.title, - labels.periodReminder.alertNoPeriodeReminder.message + labels.periodReminder.alertNoPeriodReminder.title, + labels.periodReminder.alertNoPeriodReminder.message ) } } diff --git a/i18n/en/settings.js b/i18n/en/settings.js index efe88b7..15ea950 100644 --- a/i18n/en/settings.js +++ b/i18n/en/settings.js @@ -50,10 +50,10 @@ export default { 'Get a notification 3 days before your next period is likely to start.', notification: (daysToEndOfPrediction) => `Your next period is likely to start in 3 to ${daysToEndOfPrediction} days.`, - alertNoPeriodeReminder: { - title: 'Periode Prediction switched off', + alertNoPeriodReminder: { + title: 'Period predictions turned off', message: - 'To use the periode reminder please first enable periode prediction in the customization settings.', + 'To use the period reminder please first enable period predictions in the customization settings.', }, }, useCervix: { @@ -64,7 +64,7 @@ export default { 'By default, cervical mucus values are being used for symptothermal fertility detection. You can switch here to use cervix values for symptothermal fertility detection', }, periodPrediction: { - title: 'Period prediction', + title: 'Period predictions', on: 'drip predicts your 3 next menstrual bleedings based on the statistics of your previously tracked cycles, min 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.', }, diff --git a/i18n/en/symptom-info.js b/i18n/en/symptom-info.js index 3933c50..76f35b4 100644 --- a/i18n/en/symptom-info.js +++ b/i18n/en/symptom-info.js @@ -27,7 +27,7 @@ After tracking at least 3 menstrual cycles, drip. will give you an overview of · whether the length of your cycles varied significantly (in "stats" and in bleeding predictions) · and predict your next 3 cycles with a range of 3 or 5 days (on home screen and "calendar"). -The app allows you to track different intensities of bleeding. On the chart and on the calendar, bleeding values are colored in different shades of red. The darker, the more intense your bleeding. Every bleeding value that is not excluded is taken into account for fertility calculation and prediction for the start of next cycles. +The app allows you to track different intensities of bleeding. On the chart and on the calendar, bleeding values are colored in different shades of red. The darker, the more intense your bleeding. Every bleeding value that is not excluded is taken into account for fertility calculation and period predictions. Excluding bleeding values is for tracking bleeding when it's not marking the start of a new cycle or the continuation of menstrual bleeding the day(s) before, e.g. bleeding caused by ovulation or a miscarriage. From 62e3328113cd22e89d0542adc1f3ff52201a7e5c Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Mon, 22 Jan 2024 15:38:45 +0100 Subject: [PATCH 8/8] Remove double npm install --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f4ce2d9..102531a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,7 +9,6 @@ cache: test_async: script: - npm install npm@7.0.1 -g - - npm install - npm test variables: