Disable/hide TemperatureSlider if temperature category turned off
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import React, { useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
|
import { Alert, Pressable } from 'react-native'
|
||||||
|
|
||||||
import AppPage from '../../common/app-page'
|
import AppPage from '../../common/app-page'
|
||||||
import AppSwitch from '../../common/app-switch'
|
import AppSwitch from '../../common/app-switch'
|
||||||
@@ -108,6 +109,14 @@ const Settings = () => {
|
|||||||
? labels.useCervix.cervixModeOn
|
? labels.useCervix.cervixModeOn
|
||||||
: labels.useCervix.cervixModeOff
|
: labels.useCervix.cervixModeOff
|
||||||
|
|
||||||
|
const sliderDisabledPrompt = () => {
|
||||||
|
if (!isTemperatureTrackingCategoryEnabled) {
|
||||||
|
Alert.alert(
|
||||||
|
labels.tempScale.disabled.title,
|
||||||
|
labels.tempScale.disabled.message
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<AppPage title={'Customization'}>
|
<AppPage title={'Customization'}>
|
||||||
<Segment title={'Tracking categories'}>
|
<Segment title={'Tracking categories'}>
|
||||||
@@ -158,10 +167,19 @@ const Settings = () => {
|
|||||||
/>
|
/>
|
||||||
</Segment>
|
</Segment>
|
||||||
|
|
||||||
<Segment title={labels.tempScale.segmentTitle}>
|
<Pressable onPress={sliderDisabledPrompt}>
|
||||||
<AppText>{labels.tempScale.segmentExplainer}</AppText>
|
<Segment title={labels.tempScale.segmentTitle}>
|
||||||
<TemperatureSlider />
|
{isTemperatureTrackingCategoryEnabled && (
|
||||||
</Segment>
|
<>
|
||||||
|
<AppText>{labels.tempScale.segmentExplainer}</AppText>
|
||||||
|
<TemperatureSlider />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{!isTemperatureTrackingCategoryEnabled && (
|
||||||
|
<AppText>{labels.tempScale.disabled.message}</AppText>
|
||||||
|
)}
|
||||||
|
</Segment>
|
||||||
|
</Pressable>
|
||||||
|
|
||||||
<Segment title={labels.useCervix.title}>
|
<Segment title={labels.useCervix.title}>
|
||||||
<AppSwitch
|
<AppSwitch
|
||||||
|
|||||||
@@ -37,6 +37,11 @@ export default {
|
|||||||
max: 'Max',
|
max: 'Max',
|
||||||
loadError: 'Could not load saved temperature scale settings',
|
loadError: 'Could not load saved temperature scale settings',
|
||||||
saveError: 'Could not save temperature scale settings',
|
saveError: 'Could not save temperature scale settings',
|
||||||
|
disabled: {
|
||||||
|
title: 'Temperature scale turned off',
|
||||||
|
message:
|
||||||
|
'To use the temperature scale slider please first enable the temperature tracking category in the customization settings.',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
tempReminder: {
|
tempReminder: {
|
||||||
title: 'Temperature reminder',
|
title: 'Temperature reminder',
|
||||||
|
|||||||
Reference in New Issue
Block a user