From b23bd19270ba9900c35037fd4e39006c2d8b844c Mon Sep 17 00:00:00 2001 From: Julia Friesel Date: Fri, 7 Dec 2018 14:00:51 +0100 Subject: [PATCH 1/3] Add cervix setting --- components/settings/index.js | 2 ++ components/settings/use-cervix.js | 48 +++++++++++++++++++++++++++++++ i18n/en/settings.js | 5 ++++ local-storage/index.js | 11 +++++++ 4 files changed, 66 insertions(+) create mode 100644 components/settings/use-cervix.js diff --git a/components/settings/index.js b/components/settings/index.js index bfddbc7..b91acbc 100644 --- a/components/settings/index.js +++ b/components/settings/index.js @@ -13,6 +13,7 @@ import TempSlider from './temp-slider' import openImportDialogAndImport from './import-dialog' import openShareDialogAndExport from './export-dialog' import PasswordSetting from './password' +import UseCervixSetting from './use-cervix' export default class Settings extends Component { constructor(props) { @@ -24,6 +25,7 @@ export default class Settings extends Component { return ( + {labels.tempScale.segmentTitle} diff --git a/components/settings/use-cervix.js b/components/settings/use-cervix.js new file mode 100644 index 0000000..668a0e8 --- /dev/null +++ b/components/settings/use-cervix.js @@ -0,0 +1,48 @@ +import React, { Component } from 'react' +import { + View, + TouchableOpacity, + Switch +} from 'react-native' +import AppText from '../app-text' +import { + useCervixObservable, + saveUseCervix +} from '../../local-storage' +import styles from '../../styles/index' +import { settings as labels } from '../../i18n/en/settings' + +export default class UseCervixSetting extends Component { + constructor() { + super() + this.state = {useCervix: useCervixObservable.value} + } + + render() { + return ( + + + {labels.useCervix.title} + + + + {this.state.useCervix ? + {labels.useCervix.cervixModeOn} + : + {labels.useCervix.cervixModeOff} + } + + { + this.setState({ useCervix: bool }) + saveUseCervix(bool) + }} + /> + + + ) + } +} diff --git a/i18n/en/settings.js b/i18n/en/settings.js index 7b23f67..2d8fad8 100644 --- a/i18n/en/settings.js +++ b/i18n/en/settings.js @@ -46,6 +46,11 @@ export const settings = { reminderText: '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.` }, + useCervix: { + title: 'Secondary symptom', + cervixModeOn: 'Cervix values are being used for symptothermal fertility detection', + cervixModeOff: 'Mucus values are being used for symptothermal fertility detection' + }, passwordSettings: { title: 'App password', explainerDisabled: "Encrypt the app's database with a password. You need to enter the password every time the app is started.", diff --git a/local-storage/index.js b/local-storage/index.js index 5f4af70..cf3fcea 100644 --- a/local-storage/index.js +++ b/local-storage/index.js @@ -44,6 +44,15 @@ export async function savePeriodReminder(reminder) { periodReminderObservable.set(reminder) } +export const useCervixObservable = Observable() +setObvWithInitValue('useCervix', useCervixObservable, false) + +export async function saveUseCervix(bool) { + console.log('saving cervix to', bool) + await AsyncStorage.setItem('useCervix', JSON.stringify(bool)) + useCervixObservable.set(bool) +} + export const hasEncryptionObservable = Observable() setObvWithInitValue('hasEncryption', hasEncryptionObservable, false) @@ -54,6 +63,8 @@ export async function saveEncryptionFlag(bool) { async function setObvWithInitValue(key, obv, defaultValue) { const result = await AsyncStorage.getItem(key) + console.log('result from db for key') + console.log(result) let value if (result) { value = JSON.parse(result) From 709bae231921e364bee1d7981c89f659bc7e2741 Mon Sep 17 00:00:00 2001 From: Julia Friesel Date: Sat, 8 Dec 2018 09:22:49 +0100 Subject: [PATCH 2/3] Use nfp mode setting in sympto adapter --- lib/sympto-adapter.js | 3 +++ local-storage/index.js | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/sympto-adapter.js b/lib/sympto-adapter.js index 821e7c5..628ea2b 100644 --- a/lib/sympto-adapter.js +++ b/lib/sympto-adapter.js @@ -1,6 +1,7 @@ import getFertilityStatus from './sympto' import cycleModule from './cycle' import { fertilityStatus } from '../i18n/en/labels' +import { useCervixObservable } from '../local-storage' export function getFertilityStatusForDay(dateString) { const status = getCycleStatusForDay(dateString) @@ -48,6 +49,8 @@ export function getCycleStatusForDay(dateString, opts = {}) { } } + cycleInfo.secondarySymptom = useCervixObservable.value ? 'cervix' : 'mucus' + return getFertilityStatus(cycleInfo) } diff --git a/local-storage/index.js b/local-storage/index.js index cf3fcea..89b37d9 100644 --- a/local-storage/index.js +++ b/local-storage/index.js @@ -48,7 +48,6 @@ export const useCervixObservable = Observable() setObvWithInitValue('useCervix', useCervixObservable, false) export async function saveUseCervix(bool) { - console.log('saving cervix to', bool) await AsyncStorage.setItem('useCervix', JSON.stringify(bool)) useCervixObservable.set(bool) } @@ -63,8 +62,6 @@ export async function saveEncryptionFlag(bool) { async function setObvWithInitValue(key, obv, defaultValue) { const result = await AsyncStorage.getItem(key) - console.log('result from db for key') - console.log(result) let value if (result) { value = JSON.parse(result) From f9ca0c62d80e3a9c5d2227ee30ed5dc17678eb0e Mon Sep 17 00:00:00 2001 From: Julia Friesel Date: Sat, 8 Dec 2018 17:27:12 +0100 Subject: [PATCH 3/3] Improve switch label wording --- i18n/en/settings.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/i18n/en/settings.js b/i18n/en/settings.js index 2d8fad8..eef6615 100644 --- a/i18n/en/settings.js +++ b/i18n/en/settings.js @@ -48,8 +48,8 @@ export const settings = { }, useCervix: { title: 'Secondary symptom', - cervixModeOn: 'Cervix values are being used for symptothermal fertility detection', - cervixModeOff: 'Mucus values are being used for symptothermal fertility detection' + cervixModeOn: 'Cervix values are being used for symptothermal fertility detection. You can switch here to use mucus values for symptothermal fertility detection', + cervixModeOff: 'By default, mucus values are being used for symptothermal fertility detection. You can switch here to use cervix values for symptothermal fertility detection' }, passwordSettings: { title: 'App password',