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..eef6615 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. 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', explainerDisabled: "Encrypt the app's database with a password. You need to enter the password every time the app is started.", 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 5f4af70..89b37d9 100644 --- a/local-storage/index.js +++ b/local-storage/index.js @@ -44,6 +44,14 @@ export async function savePeriodReminder(reminder) { periodReminderObservable.set(reminder) } +export const useCervixObservable = Observable() +setObvWithInitValue('useCervix', useCervixObservable, false) + +export async function saveUseCervix(bool) { + await AsyncStorage.setItem('useCervix', JSON.stringify(bool)) + useCervixObservable.set(bool) +} + export const hasEncryptionObservable = Observable() setObvWithInitValue('hasEncryption', hasEncryptionObservable, false)