temperature screen styling update
This commit is contained in:
@@ -0,0 +1,25 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
|
import { TextInput } from 'react-native'
|
||||||
|
import styles from '../styles'
|
||||||
|
|
||||||
|
export default function AppTextInput({ style, ...props }) {
|
||||||
|
return (
|
||||||
|
<TextInput
|
||||||
|
style={[styles.textInputField, ...style]}
|
||||||
|
autoFocus={props.autoFocus}
|
||||||
|
onChangeText={props.onChangeText}
|
||||||
|
value={props.value}
|
||||||
|
placeholder={props.placeholder}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
AppTextInput.propTypes = {
|
||||||
|
secureTextEntry: PropTypes.bool
|
||||||
|
}
|
||||||
|
|
||||||
|
AppTextInput.defaultProps = {
|
||||||
|
style: []
|
||||||
|
}
|
||||||
@@ -20,9 +20,11 @@ export default class SymptomSection extends Component {
|
|||||||
flex={1}
|
flex={1}
|
||||||
alignItems={p.inline ? 'center' : null}
|
alignItems={p.inline ? 'center' : null}
|
||||||
>
|
>
|
||||||
<View flex={1}>
|
{ p.explainer && (
|
||||||
<AppText>{p.explainer}</AppText>
|
<View flex={1}>
|
||||||
</View>
|
<AppText>{p.explainer}</AppText>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
{p.children}
|
{p.children}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import {
|
import {
|
||||||
View,
|
View,
|
||||||
TextInput,
|
|
||||||
Switch,
|
Switch,
|
||||||
Keyboard,
|
Keyboard,
|
||||||
Alert,
|
Alert,
|
||||||
@@ -18,6 +17,8 @@ import { scaleObservable } from '../../../local-storage'
|
|||||||
import { shared as sharedLabels } from '../../../i18n/en/labels'
|
import { shared as sharedLabels } from '../../../i18n/en/labels'
|
||||||
import ActionButtonFooter from './action-button-footer'
|
import ActionButtonFooter from './action-button-footer'
|
||||||
import config from '../../../config'
|
import config from '../../../config'
|
||||||
|
import AppTextInput from '../../app-text-input'
|
||||||
|
import AppText from '../../app-text'
|
||||||
import SymptomSection from './symptom-section'
|
import SymptomSection from './symptom-section'
|
||||||
|
|
||||||
const minutes = ChronoUnit.MINUTES
|
const minutes = ChronoUnit.MINUTES
|
||||||
@@ -27,7 +28,6 @@ export default class Temp extends Component {
|
|||||||
super(props)
|
super(props)
|
||||||
const cycleDay = props.cycleDay
|
const cycleDay = props.cycleDay
|
||||||
this.temperature = cycleDay && cycleDay.temperature
|
this.temperature = cycleDay && cycleDay.temperature
|
||||||
this.makeActionButtons = props.makeActionButtons
|
|
||||||
|
|
||||||
const temp = this.temperature
|
const temp = this.temperature
|
||||||
|
|
||||||
@@ -66,14 +66,12 @@ export default class Temp extends Component {
|
|||||||
|
|
||||||
checkRangeAndSave = () => {
|
checkRangeAndSave = () => {
|
||||||
const value = Number(this.state.temperature)
|
const value = Number(this.state.temperature)
|
||||||
|
const { min, max } = config.temperatureScale
|
||||||
const absolute = {
|
const range = { min, max }
|
||||||
min: config.temperatureScale.min,
|
|
||||||
max: config.temperatureScale.max
|
|
||||||
}
|
|
||||||
const scale = scaleObservable.value
|
const scale = scaleObservable.value
|
||||||
let warningMsg
|
let warningMsg
|
||||||
if (value < absolute.min || value > absolute.max) {
|
|
||||||
|
if (value < range.min || value > range.max) {
|
||||||
warningMsg = labels.outOfAbsoluteRangeWarning
|
warningMsg = labels.outOfAbsoluteRangeWarning
|
||||||
} else if (value < scale.min || value > scale.max) {
|
} else if (value < scale.min || value > scale.max) {
|
||||||
warningMsg = labels.outOfRangeWarning
|
warningMsg = labels.outOfRangeWarning
|
||||||
@@ -91,36 +89,54 @@ export default class Temp extends Component {
|
|||||||
} else {
|
} else {
|
||||||
this.saveTemperature()
|
this.saveTemperature()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setTemperature = (temperature) => {
|
||||||
|
if (isNaN(Number(temperature))) return
|
||||||
|
this.setState({ temperature, isSuggestion: false })
|
||||||
|
}
|
||||||
|
|
||||||
|
setNote = (note) => {
|
||||||
|
this.setState({ note })
|
||||||
|
}
|
||||||
|
|
||||||
|
showTimePicker = () => {
|
||||||
|
Keyboard.dismiss()
|
||||||
|
this.setState({ isTimePickerVisible: true })
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const inputStyle = [styles.temperatureTextInput]
|
||||||
|
if (this.state.isSuggestion) {
|
||||||
|
inputStyle.push(styles.temperatureTextInputSuggestion)
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<View style={{ flex: 1 }}>
|
<View style={{ flex: 1 }}>
|
||||||
<ScrollView style={styles.page}>
|
<ScrollView style={styles.page}>
|
||||||
<View>
|
<SymptomSection
|
||||||
<SymptomSection
|
header={labels.temperature.header}
|
||||||
header={labels.temperature.header}
|
explainer={labels.temperature.explainer}
|
||||||
explainer={labels.temperature.explainer}
|
>
|
||||||
inline={true}
|
<View style={styles.framedSegmentInlineChildren}>
|
||||||
>
|
<AppTextInput
|
||||||
<TempInput
|
style={[inputStyle]}
|
||||||
|
autoFocus={true}
|
||||||
|
placeholder={this.state.temperature}
|
||||||
value={this.state.temperature}
|
value={this.state.temperature}
|
||||||
setState={(val) => this.setState(val)}
|
onChangeText={this.setTemperature}
|
||||||
isSuggestion={this.state.isSuggestion}
|
keyboardType='numeric'
|
||||||
|
onBlur={this.checkRange}
|
||||||
/>
|
/>
|
||||||
</SymptomSection>
|
<AppText style={{ marginLeft: 5 }}>°C</AppText>
|
||||||
<SymptomSection
|
</View>
|
||||||
header={labels.time}
|
</SymptomSection>
|
||||||
inline={true}
|
<SymptomSection
|
||||||
>
|
header={labels.time}
|
||||||
<TextInput
|
>
|
||||||
style={styles.temperatureTextInput}
|
<View style={styles.framedSegmentInlineChildren}>
|
||||||
onFocus={() => {
|
<AppTextInput
|
||||||
Keyboard.dismiss()
|
style={[styles.temperatureTextInput]}
|
||||||
this.setState({ isTimePickerVisible: true })
|
onFocus={this.showTimePicker}
|
||||||
}}
|
|
||||||
value={this.state.time}
|
value={this.state.time}
|
||||||
/>
|
/>
|
||||||
<DateTimePicker
|
<DateTimePicker
|
||||||
@@ -134,34 +150,32 @@ export default class Temp extends Component {
|
|||||||
}}
|
}}
|
||||||
onCancel={() => this.setState({ isTimePickerVisible: false })}
|
onCancel={() => this.setState({ isTimePickerVisible: false })}
|
||||||
/>
|
/>
|
||||||
</SymptomSection>
|
</View>
|
||||||
<SymptomSection
|
</SymptomSection>
|
||||||
header={labels.note.header}
|
<SymptomSection
|
||||||
explainer={labels.note.explainer}
|
header={labels.note.header}
|
||||||
>
|
explainer={labels.note.explainer}
|
||||||
<TextInput
|
>
|
||||||
multiline={true}
|
<AppTextInput
|
||||||
autoFocus={this.state.focusTextArea}
|
multiline={true}
|
||||||
placeholder={sharedLabels.enter}
|
autoFocus={this.state.focusTextArea}
|
||||||
value={this.state.note}
|
placeholder={sharedLabels.enter}
|
||||||
onChangeText={(val) => {
|
value={this.state.note}
|
||||||
this.setState({ note: val })
|
onChangeText={this.setNote}
|
||||||
}}
|
/>
|
||||||
/>
|
</SymptomSection>
|
||||||
</SymptomSection>
|
<SymptomSection
|
||||||
<SymptomSection
|
header={labels.exclude.header}
|
||||||
header={labels.exclude.header}
|
explainer={labels.exclude.explainer}
|
||||||
explainer={labels.exclude.explainer}
|
inline={true}
|
||||||
inline={true}
|
>
|
||||||
>
|
<Switch
|
||||||
<Switch
|
onValueChange={(val) => {
|
||||||
onValueChange={(val) => {
|
this.setState({ exclude: val })
|
||||||
this.setState({ exclude: val })
|
}}
|
||||||
}}
|
value={this.state.exclude}
|
||||||
value={this.state.exclude}
|
/>
|
||||||
/>
|
</SymptomSection>
|
||||||
</SymptomSection>
|
|
||||||
</View>
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
<ActionButtonFooter
|
<ActionButtonFooter
|
||||||
symptom='temperature'
|
symptom='temperature'
|
||||||
@@ -181,28 +195,6 @@ export default class Temp extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TempInput extends Component {
|
|
||||||
render() {
|
|
||||||
const style = [styles.temperatureTextInput]
|
|
||||||
if (this.props.isSuggestion) {
|
|
||||||
style.push(styles.temperatureTextInputSuggestion)
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<TextInput
|
|
||||||
style={style}
|
|
||||||
onChangeText={(val) => {
|
|
||||||
if (isNaN(Number(val))) return
|
|
||||||
this.props.setState({ temperature: val, isSuggestion: false })
|
|
||||||
}}
|
|
||||||
keyboardType='numeric'
|
|
||||||
value={this.props.value}
|
|
||||||
onBlur={this.checkRange}
|
|
||||||
autoFocus={true}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function isInvalidTime(timeString) {
|
function isInvalidTime(timeString) {
|
||||||
try {
|
try {
|
||||||
LocalTime.parse(timeString)
|
LocalTime.parse(timeString)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { View } from 'react-native'
|
|||||||
import AppText from './app-text'
|
import AppText from './app-text'
|
||||||
import styles from '../styles'
|
import styles from '../styles'
|
||||||
|
|
||||||
const FramedSegment = ({ children, ...props }) => {
|
const FramedSegment = ({children, ...props}) => {
|
||||||
const style = [styles.framedSegment, props.style]
|
const style = [styles.framedSegment, props.style]
|
||||||
if (props.last) style.push(styles.framedSegmentLast)
|
if (props.last) style.push(styles.framedSegmentLast)
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,19 +1,22 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { TextInput } from 'react-native'
|
import PropTypes from 'prop-types'
|
||||||
import styles, {secondaryColor} from '../../../styles'
|
import AppTextInput from '../../app-text-input'
|
||||||
|
|
||||||
|
import styles from '../../../styles'
|
||||||
|
|
||||||
export default function PasswordField(props) {
|
export default function PasswordField(props) {
|
||||||
return (
|
return (
|
||||||
<TextInput
|
<AppTextInput
|
||||||
style={styles.passwordField}
|
style={ styles.passwordField }
|
||||||
autoFocus={props.autoFocus === false ? false : true}
|
secureTextEntry
|
||||||
secureTextEntry={true}
|
{...props}
|
||||||
onChangeText={props.onChangeText}
|
|
||||||
value={props.value}
|
|
||||||
placeholder={props.placeholder}
|
|
||||||
borderWidth={1}
|
|
||||||
borderColor={secondaryColor}
|
|
||||||
borderStyle={'solid'}
|
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PasswordField.propTypes = {
|
||||||
|
placeholder: PropTypes.string,
|
||||||
|
value: PropTypes.string,
|
||||||
|
onChangeText: PropTypes.func,
|
||||||
|
autoFocus: PropTypes.bool
|
||||||
|
}
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ export const temperature = {
|
|||||||
outOfAbsoluteRangeWarning: 'This temperature value is too high or low to be shown on the temperature chart.',
|
outOfAbsoluteRangeWarning: 'This temperature value is too high or low to be shown on the temperature chart.',
|
||||||
saveAnyway: 'Save anyway',
|
saveAnyway: 'Save anyway',
|
||||||
temperature: {
|
temperature: {
|
||||||
header: "Temperature (°C)",
|
header: "Temperature",
|
||||||
explainer: 'Take your temperature right after waking up, before getting out of bed'
|
explainer: 'Take your temperature right after waking up, before getting out of bed'
|
||||||
},
|
},
|
||||||
time: "Time",
|
time: "Time",
|
||||||
|
|||||||
+15
-4
@@ -269,7 +269,8 @@ export default StyleSheet.create({
|
|||||||
temperatureTextInput: {
|
temperatureTextInput: {
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
color: 'black',
|
color: 'black',
|
||||||
textAlign: 'center'
|
textAlign: 'center',
|
||||||
|
width: '30%'
|
||||||
},
|
},
|
||||||
temperatureTextInputSuggestion: {
|
temperatureTextInputSuggestion: {
|
||||||
color: '#939393'
|
color: '#939393'
|
||||||
@@ -299,6 +300,10 @@ export default StyleSheet.create({
|
|||||||
fontWeight: 'bold',
|
fontWeight: 'bold',
|
||||||
fontFamily: textFontBold
|
fontFamily: textFontBold
|
||||||
},
|
},
|
||||||
|
framedSegmentInlineChildren: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
alignItems: 'center'
|
||||||
|
},
|
||||||
settingsButton: {
|
settingsButton: {
|
||||||
padding: 10,
|
padding: 10,
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
@@ -383,10 +388,16 @@ export default StyleSheet.create({
|
|||||||
marginTop: 1
|
marginTop: 1
|
||||||
},
|
},
|
||||||
passwordField: {
|
passwordField: {
|
||||||
padding: 10,
|
|
||||||
marginTop: 10,
|
|
||||||
marginHorizontal: 10,
|
marginHorizontal: 10,
|
||||||
backgroundColor: 'white'
|
marginTop: 10
|
||||||
|
},
|
||||||
|
textInputField: {
|
||||||
|
padding: 10,
|
||||||
|
marginVertical: 10,
|
||||||
|
backgroundColor: 'white',
|
||||||
|
borderColor: secondaryColor,
|
||||||
|
borderStyle: 'solid',
|
||||||
|
borderWidth: 1,
|
||||||
},
|
},
|
||||||
passwordPromptPage: {
|
passwordPromptPage: {
|
||||||
padding: 30,
|
padding: 30,
|
||||||
|
|||||||
Reference in New Issue
Block a user