diff --git a/components/cycle-day/action-buttons.js b/components/cycle-day/action-buttons.js
deleted file mode 100644
index 9ddb036..0000000
--- a/components/cycle-day/action-buttons.js
+++ /dev/null
@@ -1,48 +0,0 @@
-import React from 'react'
-import {
- View,
- Button,
-} from 'react-native'
-import { saveSymptom } from '../../db'
-
-const dayView = 'DayView'
-
-export default function (showView) {
- return function ({ symptom, cycleDay, saveAction, saveDisabled}) {
- const buttons = [
- {
- title: 'Cancel',
- action: () => showView(dayView)
- },
- {
- title: 'Delete',
- action: () => {
- saveSymptom(symptom, cycleDay)
- showView(dayView)
- }
- }, {
- title: 'Save',
- action: async () => {
- await saveAction()
- showView(dayView)
- },
- disabledCondition: saveDisabled
- }
- ]
-
- return buttons.map(({ title, action, disabledCondition }, i) => {
- const style = { flex: 1, marginHorizontal: 10 }
- if (i === 0) style.marginLeft = 0
- if (i === buttons.length - 1) style.marginRight = 0
- return (
-
-
-
- )
- })
- }
-}
\ No newline at end of file
diff --git a/components/cycle-day/labels/labels.js b/components/cycle-day/labels/labels.js
index 910e6c9..6650e33 100644
--- a/components/cycle-day/labels/labels.js
+++ b/components/cycle-day/labels/labels.js
@@ -29,5 +29,6 @@ export const fertilityStatus = {
export const temperature = {
outOfRangeWarning: 'This temperature value is out of the current range for the temperature chart. You can change the range in the settings.',
+ outOfAbsoluteRangeWarning: 'This temperature value is too high or low to be shown on the temperature chart.',
saveAnyway: 'Save anyway'
}
diff --git a/components/cycle-day/symptoms/action-button-footer.js b/components/cycle-day/symptoms/action-button-footer.js
index a153496..dac39a6 100644
--- a/components/cycle-day/symptoms/action-button-footer.js
+++ b/components/cycle-day/symptoms/action-button-footer.js
@@ -8,7 +8,14 @@ import styles, {iconStyles} from '../../../styles'
export default class ActionButtonFooter extends Component {
render() {
- const { symptom, cycleDay, saveAction, saveDisabled, navigate} = this.props
+ const {
+ symptom,
+ cycleDay,
+ saveAction,
+ saveDisabled,
+ navigate,
+ autoShowDayView = true}
+ = this.props
const navigateToOverView = () => navigate('CycleDay', {cycleDay})
const buttons = [
{
@@ -28,7 +35,7 @@ export default class ActionButtonFooter extends Component {
title: 'Save',
action: () => {
saveAction()
- navigateToOverView()
+ if (autoShowDayView) navigateToOverView()
},
disabledCondition: saveDisabled,
icon: 'content-save-outline'
diff --git a/components/cycle-day/symptoms/temperature.js b/components/cycle-day/symptoms/temperature.js
index fda5200..11ee7da 100644
--- a/components/cycle-day/symptoms/temperature.js
+++ b/components/cycle-day/symptoms/temperature.js
@@ -17,6 +17,7 @@ import { temperature as tempLabels } from '../labels/labels'
import { scaleObservable } from '../../../local-storage'
import { shared } from '../../labels'
import ActionButtonFooter from './action-button-footer'
+import config from '../../../config'
const minutes = ChronoUnit.MINUTES
@@ -49,6 +50,47 @@ export default class Temp extends Component {
}
}
+ saveTemperature = () => {
+ const dataToSave = {
+ value: Number(this.state.temperature),
+ exclude: this.state.exclude,
+ time: this.state.time
+ }
+ saveSymptom('temperature', this.cycleDay, dataToSave)
+ this.props.navigate('CycleDay', {cycleDay: this.cycleDay})
+ }
+
+ checkRangeAndSave = () => {
+ const value = Number(this.state.temperature)
+
+ const absolute = {
+ min: config.temperatureScale.min,
+ max: config.temperatureScale.max
+ }
+ const scale = scaleObservable.value
+ let warningMsg
+ if (value < absolute.min || value > absolute.max) {
+ warningMsg = tempLabels.outOfAbsoluteRangeWarning
+ } else if (value < scale.min || value > scale.max) {
+ warningMsg = tempLabels.outOfRangeWarning
+ }
+
+ if (warningMsg) {
+ Alert.alert(
+ shared.warning,
+ warningMsg,
+ [
+ { text: shared.cancel },
+ { text: shared.save, onPress: this.saveTemperature}
+ ]
+ )
+ } else {
+ this.saveTemperature()
+ }
+
+ }
+
+
render() {
return (
@@ -98,20 +140,14 @@ export default class Temp extends Component {
{
- const dataToSave = {
- value: Number(this.state.temperature),
- exclude: this.state.exclude,
- time: this.state.time
- }
- saveSymptom('temperature', this.cycleDay, dataToSave)
- }}
+ saveAction={() => this.checkRangeAndSave()}
saveDisabled={
this.state.temperature === '' ||
isNaN(Number(this.state.temperature)) ||
isInvalidTime(this.state.time)
}
navigate={this.props.navigate}
+ autoShowDayView={false}
/>
)
@@ -119,18 +155,6 @@ export default class Temp extends Component {
}
class TempInput extends Component {
- checkRange = () => {
- const value = Number(this.props.value)
- if (isNaN(value)) return
- const scale = scaleObservable.value
- if (value < scale.min || value > scale.max) {
- Alert.alert(
- shared.warning,
- tempLabels.outOfRangeWarning,
- )
- }
- }
-
render() {
const style = [styles.temperatureTextInput]
if (this.props.isSuggestion) {
diff --git a/components/labels.js b/components/labels.js
index 28cd393..b249e37 100644
--- a/components/labels.js
+++ b/components/labels.js
@@ -1,5 +1,6 @@
export const shared = {
cancel: 'Cancel',
+ save: 'Save',
errorTitle: 'Error',
successTitle: 'Success',
warning: 'Warning'