Add sexTrackingCategory as toggle
This commit is contained in:
@@ -11,6 +11,8 @@ import {
|
|||||||
savePeriodPrediction,
|
savePeriodPrediction,
|
||||||
useCervixObservable,
|
useCervixObservable,
|
||||||
saveUseCervix,
|
saveUseCervix,
|
||||||
|
saveSexTrackingCategory,
|
||||||
|
sexTrackingCategoryObservable,
|
||||||
} from '../../../local-storage'
|
} from '../../../local-storage'
|
||||||
import { Colors } from '../../../styles'
|
import { Colors } from '../../../styles'
|
||||||
import labels from '../../../i18n/en/settings'
|
import labels from '../../../i18n/en/settings'
|
||||||
@@ -24,9 +26,18 @@ const Settings = () => {
|
|||||||
periodPredictionObservable.value
|
periodPredictionObservable.value
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const [isSexTrackingCategoryEnabled, setSexTrackingCategory] = useState(
|
||||||
|
sexTrackingCategoryObservable.value
|
||||||
|
)
|
||||||
|
|
||||||
const [isEnabled, setIsEnabled] = useState(false)
|
const [isEnabled, setIsEnabled] = useState(false)
|
||||||
const toggleSwitch = () => setIsEnabled((previousState) => !previousState)
|
const toggleSwitch = () => setIsEnabled((previousState) => !previousState)
|
||||||
|
|
||||||
|
const sexTrackingCategoryToggle = (value) => {
|
||||||
|
setSexTrackingCategory(value)
|
||||||
|
saveSexTrackingCategory(value)
|
||||||
|
}
|
||||||
|
|
||||||
const onPeriodPredictionToggle = (value) => {
|
const onPeriodPredictionToggle = (value) => {
|
||||||
setPeriodPrediction(value)
|
setPeriodPrediction(value)
|
||||||
savePeriodPrediction(value)
|
savePeriodPrediction(value)
|
||||||
@@ -49,27 +60,9 @@ const Settings = () => {
|
|||||||
<AppPage title={'Customization'}>
|
<AppPage title={'Customization'}>
|
||||||
<Segment title={'Tracking categories'}>
|
<Segment title={'Tracking categories'}>
|
||||||
<AppSwitch
|
<AppSwitch
|
||||||
onToggle={toggleSwitch}
|
onToggle={sexTrackingCategoryToggle}
|
||||||
text={'temperature'}
|
text={"sex: when turned off it won't show"}
|
||||||
value={isEnabled}
|
value={isSexTrackingCategoryEnabled}
|
||||||
trackColor={{ true: Colors.turquoiseDark }}
|
|
||||||
/>
|
|
||||||
<AppSwitch
|
|
||||||
onToggle={toggleSwitch}
|
|
||||||
text={'cervical mucus'}
|
|
||||||
value={isEnabled}
|
|
||||||
trackColor={{ true: Colors.turquoiseDark }}
|
|
||||||
/>
|
|
||||||
<AppSwitch
|
|
||||||
onToggle={toggleSwitch}
|
|
||||||
text={'cervix'}
|
|
||||||
value={isEnabled}
|
|
||||||
trackColor={{ true: Colors.turquoiseDark }}
|
|
||||||
/>
|
|
||||||
<AppSwitch
|
|
||||||
onToggle={toggleSwitch}
|
|
||||||
text={'sex'}
|
|
||||||
value={isEnabled}
|
|
||||||
trackColor={{ true: Colors.turquoiseDark }}
|
trackColor={{ true: Colors.turquoiseDark }}
|
||||||
/>
|
/>
|
||||||
<AppSwitch
|
<AppSwitch
|
||||||
|
|||||||
@@ -92,6 +92,14 @@ export async function setChartFlag() {
|
|||||||
await AsyncStorage.setItem('isFirstChartView', JSON.stringify(false))
|
await AsyncStorage.setItem('isFirstChartView', JSON.stringify(false))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const sexTrackingCategoryObservable = Observable()
|
||||||
|
setObvWithInitValue('sex', sexTrackingCategoryObservable, true)
|
||||||
|
|
||||||
|
export async function saveSexTrackingCategory(bool) {
|
||||||
|
await AsyncStorage.setItem('sex', JSON.stringify(bool))
|
||||||
|
sexTrackingCategoryObservable.set(bool)
|
||||||
|
}
|
||||||
|
|
||||||
async function setObvWithInitValue(key, obv, defaultValue) {
|
async function setObvWithInitValue(key, obv, defaultValue) {
|
||||||
const result = await AsyncStorage.getItem(key)
|
const result = await AsyncStorage.getItem(key)
|
||||||
let value
|
let value
|
||||||
|
|||||||
Reference in New Issue
Block a user