This commit is contained in:
Julia Friesel
2019-05-26 12:37:51 +02:00
parent 018ec3bcda
commit 6c56b6f83c
8 changed files with 45 additions and 77 deletions
Binary file not shown.
-13
View File
@@ -18,19 +18,6 @@ export default function AppText(props) {
)
}
export function ActionHint(props) {
if(props.isVisible) {
return (
<AppText
style={[styles.actionHint, props.style]}>
{props.children}
</AppText>
)
} else {
return null
}
}
export function SymptomSectionHeader(props) {
return (
<AppText style={styles.symptomViewHeading}>
@@ -24,13 +24,6 @@ export default class SymptomView extends Component {
this.autoSave()
}
// TODO where is this needed now?
async handleBackButtonPressOnSymptomView() {
// every specific symptom view provides their own onBackButtonPress method
const stopHere = await this.onBackButtonPress()
if (!stopHere) this.globalBackhandler()
}
saveSymptomEntry(entry) {
saveSymptom(this.symptomName, this.date, entry)
}
@@ -59,8 +52,7 @@ export default class SymptomView extends Component {
<Header
title={headerTitles[this.symptomName].toLowerCase()}
date={this.date}
// TODO what to put here instead?
goBack={this.handleBackButtonPressOnSymptomView.bind(this)}
goBack={this.props.handleBackButtonPress}
deleteIconActive={this.isDeleteIconActive()}
deleteEntry={() => {
Alert.alert(
+30 -44
View File
@@ -3,7 +3,6 @@ import {
View,
Switch,
Keyboard,
Alert,
ScrollView
} from 'react-native'
import DateTimePicker from 'react-native-modal-datetime-picker-nevo'
@@ -35,7 +34,6 @@ export default class Temp extends SymptomView {
exclude: temp ? temp.exclude : false,
time: temp ? temp.time : LocalTime.now().truncatedTo(minutes).toString(),
isTimePickerVisible: false,
outOfRange: null,
note: temp ? temp.note : null
}
@@ -44,6 +42,7 @@ export default class Temp extends SymptomView {
if (temp.value === Math.floor(temp.value)) {
this.state.temperature = `${this.state.temperature}.0`
}
this.state.outOfRangeWarning = makeOutOfRangeWarningMessage(this.state.temperature)
} else {
const prevTemp = getPreviousTemperature(props.date)
if (prevTemp) {
@@ -79,43 +78,13 @@ export default class Temp extends SymptomView {
this.saveSymptomEntry(dataToSave)
}
warnUserIfTempOutOfRange = async () => {
const value = Number(this.state.temperature)
const { min, max } = config.temperatureScale
const range = { min, max }
const scale = scaleObservable.value
let warningMsg
if (value < range.min || value > range.max) {
warningMsg = labels.outOfAbsoluteRangeWarning
} else if (value < scale.min || value > scale.max) {
warningMsg = labels.outOfRangeWarning
}
// RN alert runs asynchronously but doesn't provide a callback, so wrap
// it in a promise
return new Promise(resolve => {
if (warningMsg) {
// we set this so the time picker doesn't open at the same time
this.warningAlertOpen = true
Alert.alert(
sharedLabels.warning,
warningMsg,
[
{ text: sharedLabels.ok, onPress: () => {
this.warningAlertOpen = false
}}
]
)
} else {
resolve(true)
}
})
}
setTemperature = (temperature) => {
if (isNaN(Number(temperature))) return
this.setState({ temperature, isSuggestion: false })
this.setState({
temperature, isSuggestion: false,
outOfRangeWarning: makeOutOfRangeWarningMessage(temperature)
})
}
setNote = (note) => {
@@ -146,10 +115,14 @@ export default class Temp extends SymptomView {
onChangeText={this.setTemperature}
keyboardType='numeric'
maxLength={5}
onBlur={this.warnUserIfTempOutOfRange}
/>
<AppText style={{ marginLeft: 5 }}>°C</AppText>
</View>
{this.state.outOfRangeWarning &&
<AppText style={styles.hint}>
{this.state.outOfRangeWarning}
</AppText>
}
</SymptomSection>
<SymptomSection
header={labels.time}
@@ -157,13 +130,7 @@ export default class Temp extends SymptomView {
<View style={styles.framedSegmentInlineChildren}>
<AppTextInput
style={[styles.temperatureTextInput]}
onFocus={() => {
if (this.warningAlertOpen) {
Keyboard.dismiss()
} else {
this.showTimePicker()
}
}}
onFocus={this.showTimePicker}
value={this.state.time}
/>
<DateTimePicker
@@ -207,3 +174,22 @@ export default class Temp extends SymptomView {
)
}
}
function makeOutOfRangeWarningMessage(temperature) {
if (temperature === '') return
const value = Number(temperature)
const { min, max } = config.temperatureScale
const range = { min, max }
const scale = scaleObservable.value
let warningMsg
if (value < range.min || value > range.max) {
warningMsg = labels.outOfAbsoluteRangeWarning
} else if (value < scale.min || value > scale.max) {
warningMsg = labels.outOfRangeWarning
} else {
warningMsg = null
}
return warningMsg
}
+10 -6
View File
@@ -72,6 +72,7 @@
E43EF009AC8C4698AB322190 /* NodeMobile.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C225FC4966694B9FBD32E946 /* NodeMobile.framework */; };
E4584E55EEC24302A3E84A23 /* nodejs-project in Resources */ = {isa = PBXBuildFile; fileRef = 6466AE2461BE4FA88B8372F0 /* nodejs-project */; };
77500FAD5ADD402AAD2D9972 /* AntDesign.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 3102FB76D69C42938E0E126D /* AntDesign.ttf */; };
AA800A96BB73482AA90E29B8 /* OpenSans-LightItalic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 885BDE0B3896402F99D0C860 /* OpenSans-LightItalic.ttf */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -516,6 +517,7 @@
F59A471BDE4144A1A41D4B52 /* Feather.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Feather.ttf; path = "../node_modules/react-native-vector-icons/Fonts/Feather.ttf"; sourceTree = "<group>"; };
F992F2D99E614DD79FAD6565 /* libRNNodeJsMobile.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNNodeJsMobile.a; sourceTree = "<group>"; };
3102FB76D69C42938E0E126D /* AntDesign.ttf */ = {isa = PBXFileReference; name = "AntDesign.ttf"; path = "../node_modules/react-native-vector-icons/Fonts/AntDesign.ttf"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; };
885BDE0B3896402F99D0C860 /* OpenSans-LightItalic.ttf */ = {isa = PBXFileReference; name = "OpenSans-LightItalic.ttf"; path = "../assets/fonts/OpenSans-LightItalic.ttf"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -608,6 +610,7 @@
673C016DDDD74C2F89050279 /* OpenSans-Light.ttf */,
644690BCCEBF41789960B9A2 /* OpenSans-SemiBold.ttf */,
3102FB76D69C42938E0E126D /* AntDesign.ttf */,
885BDE0B3896402F99D0C860 /* OpenSans-LightItalic.ttf */,
);
name = Resources;
sourceTree = "<group>";
@@ -951,9 +954,9 @@
13B07F8E1A680F5B00A75B9A /* Resources */,
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
2B572382D4504B8FB4B9D251 /* Embed Frameworks */,
6A61F9B7BEB149D1894D6AB5 /* Build NodeJS Mobile Native Modules */,
53E84D10AC6B4045A1DBAB0C /* Sign NodeJS Mobile Native Modules */,
F43CB3783FD9405C8198826C /* Remove NodeJS Mobile Framework Simulator Strips */,
D6AE48E8124449EE863F342D /* Build NodeJS Mobile Native Modules */,
7D43D3729FAE42C0859CDC36 /* Sign NodeJS Mobile Native Modules */,
54483AF1DA474A71931D6D6A /* Remove NodeJS Mobile Framework Simulator Strips */,
);
buildRules = (
);
@@ -1513,6 +1516,7 @@
5D921C348AC14944835A4D82 /* OpenSans-Light.ttf in Resources */,
71D0BCE4666A4AB8A0874B5A /* OpenSans-SemiBold.ttf in Resources */,
77500FAD5ADD402AAD2D9972 /* AntDesign.ttf in Resources */,
AA800A96BB73482AA90E29B8 /* OpenSans-LightItalic.ttf in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1562,7 +1566,7 @@
shellPath = /bin/sh;
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh";
};
6A61F9B7BEB149D1894D6AB5 /* Build NodeJS Mobile Native Modules */ = {
D6AE48E8124449EE863F342D /* Build NodeJS Mobile Native Modules */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
@@ -1630,7 +1634,7 @@ fi
popd
";
};
53E84D10AC6B4045A1DBAB0C /* Sign NodeJS Mobile Native Modules */ = {
7D43D3729FAE42C0859CDC36 /* Sign NodeJS Mobile Native Modules */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
@@ -1690,7 +1694,7 @@ find \"$CODESIGNING_FOLDER_PATH/nodejs-project/\" -path \"*/*.framework/*\" -del
find \"$CODESIGNING_FOLDER_PATH/nodejs-project/\" -name \"*.framework\" -type d -delete
";
};
F43CB3783FD9405C8198826C /* Remove NodeJS Mobile Framework Simulator Strips */ = {
54483AF1DA474A71931D6D6A /* Remove NodeJS Mobile Framework Simulator Strips */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
+1
View File
@@ -87,6 +87,7 @@
<string>OpenSans-Regular.ttf</string>
<string>OpenSans-SemiBold.ttf</string>
<string>AntDesign.ttf</string>
<string>OpenSans-LightItalic.ttf</string>
</array>
</dict>
</plist>
+3 -5
View File
@@ -17,6 +17,7 @@ const headerFont = 'Prompt-ExtraLight'
const textFont = 'OpenSans-Light'
const textFontBold = 'OpenSans-SemiBold'
const textFontItalic = 'OpenSans-LightItalic'
const regularSize = 16
const hintSize = 14
@@ -43,12 +44,9 @@ export default StyleSheet.create({
fontSize: regularSize,
letterSpacing: 0.5
},
actionHint: {
color: secondaryColor,
fontFamily: textFont,
hint: {
fontFamily: textFontItalic,
fontSize: hintSize,
fontWeight: 'bold',
margin: defaultIndentation
},
paragraph: {
marginBottom: defaultBottomMargin