Merge branch '112-connect-cervix-mode-to-app' into 'master'
Resolve "Connect cervix mode to app" Closes #112 See merge request bloodyhealth/drip!126
This commit is contained in:
@@ -13,6 +13,7 @@ import TempSlider from './temp-slider'
|
|||||||
import openImportDialogAndImport from './import-dialog'
|
import openImportDialogAndImport from './import-dialog'
|
||||||
import openShareDialogAndExport from './export-dialog'
|
import openShareDialogAndExport from './export-dialog'
|
||||||
import PasswordSetting from './password'
|
import PasswordSetting from './password'
|
||||||
|
import UseCervixSetting from './use-cervix'
|
||||||
|
|
||||||
export default class Settings extends Component {
|
export default class Settings extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -24,6 +25,7 @@ export default class Settings extends Component {
|
|||||||
return (
|
return (
|
||||||
<ScrollView>
|
<ScrollView>
|
||||||
<TempReminderPicker/>
|
<TempReminderPicker/>
|
||||||
|
<UseCervixSetting/>
|
||||||
<View style={styles.settingsSegment}>
|
<View style={styles.settingsSegment}>
|
||||||
<AppText style={styles.settingsSegmentTitle}>
|
<AppText style={styles.settingsSegmentTitle}>
|
||||||
{labels.tempScale.segmentTitle}
|
{labels.tempScale.segmentTitle}
|
||||||
|
|||||||
@@ -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 (
|
||||||
|
<TouchableOpacity
|
||||||
|
style={styles.settingsSegment}
|
||||||
|
>
|
||||||
|
<AppText style={styles.settingsSegmentTitle}>
|
||||||
|
{labels.useCervix.title}
|
||||||
|
</AppText>
|
||||||
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||||
|
<View style={{ flex: 1 }}>
|
||||||
|
{this.state.useCervix ?
|
||||||
|
<AppText>{labels.useCervix.cervixModeOn}</AppText>
|
||||||
|
:
|
||||||
|
<AppText>{labels.useCervix.cervixModeOff}</AppText>
|
||||||
|
}
|
||||||
|
</View>
|
||||||
|
<Switch
|
||||||
|
value={this.state.useCervix}
|
||||||
|
onValueChange={bool => {
|
||||||
|
this.setState({ useCervix: bool })
|
||||||
|
saveUseCervix(bool)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
</TouchableOpacity>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -46,6 +46,11 @@ export const settings = {
|
|||||||
reminderText: 'Get a notification 3 days before your next period is likely to start.',
|
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.`
|
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: {
|
passwordSettings: {
|
||||||
title: 'App password',
|
title: 'App password',
|
||||||
explainerDisabled: "Encrypt the app's database with a password. You need to enter the password every time the app is started.",
|
explainerDisabled: "Encrypt the app's database with a password. You need to enter the password every time the app is started.",
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import getFertilityStatus from './sympto'
|
import getFertilityStatus from './sympto'
|
||||||
import cycleModule from './cycle'
|
import cycleModule from './cycle'
|
||||||
import { fertilityStatus } from '../i18n/en/labels'
|
import { fertilityStatus } from '../i18n/en/labels'
|
||||||
|
import { useCervixObservable } from '../local-storage'
|
||||||
|
|
||||||
export function getFertilityStatusForDay(dateString) {
|
export function getFertilityStatusForDay(dateString) {
|
||||||
const status = getCycleStatusForDay(dateString)
|
const status = getCycleStatusForDay(dateString)
|
||||||
@@ -48,6 +49,8 @@ export function getCycleStatusForDay(dateString, opts = {}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cycleInfo.secondarySymptom = useCervixObservable.value ? 'cervix' : 'mucus'
|
||||||
|
|
||||||
return getFertilityStatus(cycleInfo)
|
return getFertilityStatus(cycleInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,14 @@ export async function savePeriodReminder(reminder) {
|
|||||||
periodReminderObservable.set(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()
|
export const hasEncryptionObservable = Observable()
|
||||||
setObvWithInitValue('hasEncryption', hasEncryptionObservable, false)
|
setObvWithInitValue('hasEncryption', hasEncryptionObservable, false)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user