Adds info button to the body as alert

This commit is contained in:
emelko
2019-05-19 12:56:08 +02:00
parent 6811b5a692
commit ff1afcb8dc
7 changed files with 249 additions and 77 deletions
+30 -2
View File
@@ -1,11 +1,19 @@
import React from 'react' import React from 'react'
import { import {
Alert,
Switch, Switch,
ScrollView ScrollView,
TouchableOpacity,
View
} from 'react-native' } from 'react-native'
import styles from '../../../styles' import FeatherIcon from 'react-native-vector-icons/Feather'
import { bleeding } from '../../../i18n/en/cycle-day' import { bleeding } from '../../../i18n/en/cycle-day'
import infoLabels from '../../../i18n/en/symptom-info'
import styles, { iconStyles } from '../../../styles'
import SelectTabGroup from '../select-tab-group' import SelectTabGroup from '../select-tab-group'
import SymptomSection from './symptom-section' import SymptomSection from './symptom-section'
import SymptomView from './symptom-view' import SymptomView from './symptom-view'
@@ -22,6 +30,14 @@ export default class Bleeding extends SymptomView {
symptomName = 'bleeding' symptomName = 'bleeding'
showInfoBox(){
const symptomName = 'bleeding'
Alert.alert(
infoLabels[symptomName].title,
infoLabels[symptomName].text
)
}
onBackButtonPress() { onBackButtonPress() {
if (typeof this.state.currentValue != 'number') { if (typeof this.state.currentValue != 'number') {
this.deleteSymptomEntry() this.deleteSymptomEntry()
@@ -42,6 +58,7 @@ export default class Bleeding extends SymptomView {
] ]
return ( return (
<ScrollView style={styles.page}> <ScrollView style={styles.page}>
<View style={{ flexDirection: 'row' }}>
<SymptomSection <SymptomSection
header={bleeding.heaviness.header} header={bleeding.heaviness.header}
explainer={bleeding.heaviness.explainer} explainer={bleeding.heaviness.explainer}
@@ -52,6 +69,17 @@ export default class Bleeding extends SymptomView {
onSelect={val => this.setState({ currentValue: val })} onSelect={val => this.setState({ currentValue: val })}
/> />
</SymptomSection> </SymptomSection>
<View style={{ flex: 1 }}></View>
<TouchableOpacity
onPress={this.showInfoBox}
style={styles.infoButton}
>
<FeatherIcon
name="info"
style={iconStyles.symptomInfo}
/>
</TouchableOpacity>
</View>
<SymptomSection <SymptomSection
header={bleeding.exclude.header} header={bleeding.exclude.header}
explainer={bleeding.exclude.explainer} explainer={bleeding.exclude.explainer}
+30 -2
View File
@@ -1,11 +1,19 @@
import React from 'react' import React from 'react'
import { import {
Alert,
Switch, Switch,
ScrollView ScrollView,
TouchableOpacity,
View
} from 'react-native' } from 'react-native'
import styles from '../../../styles' import FeatherIcon from 'react-native-vector-icons/Feather'
import { cervix as labels } from '../../../i18n/en/cycle-day' import { cervix as labels } from '../../../i18n/en/cycle-day'
import infoLabels from '../../../i18n/en/symptom-info'
import styles, { iconStyles } from '../../../styles'
import SelectTabGroup from '../select-tab-group' import SelectTabGroup from '../select-tab-group'
import SymptomSection from './symptom-section' import SymptomSection from './symptom-section'
import SymptomView from './symptom-view' import SymptomView from './symptom-view'
@@ -19,6 +27,14 @@ export default class Cervix extends SymptomView {
symptomName = 'cervix' symptomName = 'cervix'
showInfoBox(){
const symptomName = 'cervix'
Alert.alert(
infoLabels[symptomName].title,
infoLabels[symptomName].text
)
}
onBackButtonPress() { onBackButtonPress() {
const nothingEntered = ['opening', 'firmness', 'position'].every(val => typeof this.state[val] != 'number') const nothingEntered = ['opening', 'firmness', 'position'].every(val => typeof this.state[val] != 'number')
if (nothingEntered) { if (nothingEntered) {
@@ -53,6 +69,7 @@ export default class Cervix extends SymptomView {
// const mandatoryNotCompleted = typeof this.state.opening != 'number' || typeof this.state.firmness != 'number' // const mandatoryNotCompleted = typeof this.state.opening != 'number' || typeof this.state.firmness != 'number'
return ( return (
<ScrollView style={styles.page}> <ScrollView style={styles.page}>
<View style={{ flexDirection: 'row' }}>
<SymptomSection <SymptomSection
header="Opening" header="Opening"
explainer={labels.opening.explainer} explainer={labels.opening.explainer}
@@ -63,6 +80,17 @@ export default class Cervix extends SymptomView {
onSelect={val => this.setState({ opening: val })} onSelect={val => this.setState({ opening: val })}
/> />
</SymptomSection> </SymptomSection>
<View style={{ flex: 1 }}></View>
<TouchableOpacity
onPress={this.showInfoBox}
style={styles.infoButton}
>
<FeatherIcon
name="info"
style={iconStyles.symptomInfo}
/>
</TouchableOpacity>
</View>
<SymptomSection <SymptomSection
header="Firmness" header="Firmness"
explainer={labels.firmness.explainer} explainer={labels.firmness.explainer}
+30 -2
View File
@@ -1,10 +1,18 @@
import React from 'react' import React from 'react'
import { import {
ScrollView Alert,
ScrollView,
TouchableOpacity,
View
} from 'react-native' } from 'react-native'
import styles from '../../../styles' import FeatherIcon from 'react-native-vector-icons/Feather'
import infoLabels from '../../../i18n/en/symptom-info'
import { intensity, desire } from '../../../i18n/en/cycle-day' import { intensity, desire } from '../../../i18n/en/cycle-day'
import styles, { iconStyles } from '../../../styles'
import SelectTabGroup from '../select-tab-group' import SelectTabGroup from '../select-tab-group'
import SymptomSection from './symptom-section' import SymptomSection from './symptom-section'
import SymptomView from './symptom-view' import SymptomView from './symptom-view'
@@ -19,6 +27,14 @@ export default class Desire extends SymptomView {
symptomName = 'desire' symptomName = 'desire'
showInfoBox(){
const symptomName = 'desire'
Alert.alert(
infoLabels[symptomName].title,
infoLabels[symptomName].text
)
}
onBackButtonPress() { onBackButtonPress() {
if (typeof this.state.currentValue != 'number') { if (typeof this.state.currentValue != 'number') {
this.deleteSymptomEntry() this.deleteSymptomEntry()
@@ -35,6 +51,7 @@ export default class Desire extends SymptomView {
] ]
return ( return (
<ScrollView style={styles.page}> <ScrollView style={styles.page}>
<View style={{ flexDirection: 'row' }}>
<SymptomSection <SymptomSection
header={desire.header} header={desire.header}
explainer={desire.explainer} explainer={desire.explainer}
@@ -45,6 +62,17 @@ export default class Desire extends SymptomView {
onSelect={val => this.setState({ currentValue: val })} onSelect={val => this.setState({ currentValue: val })}
/> />
</SymptomSection> </SymptomSection>
<View style={{ flex: 1 }}></View>
<TouchableOpacity
onPress={this.showInfoBox}
style={styles.infoButton}
>
<FeatherIcon
name="info"
style={iconStyles.symptomInfo}
/>
</TouchableOpacity>
</View>
</ScrollView> </ScrollView>
) )
} }
+31 -2
View File
@@ -1,12 +1,20 @@
import React from 'react' import React from 'react'
import { import {
Alert,
Switch, Switch,
ScrollView ScrollView,
TouchableOpacity,
View
} from 'react-native' } from 'react-native'
import styles from '../../../styles' import FeatherIcon from 'react-native-vector-icons/Feather'
import styles, { iconStyles } from '../../../styles'
import infoLabels from '../../../i18n/en/symptom-info'
import { mucus as labels } from '../../../i18n/en/cycle-day' import { mucus as labels } from '../../../i18n/en/cycle-day'
import computeNfpValue from '../../../lib/nfp-mucus' import computeNfpValue from '../../../lib/nfp-mucus'
import SelectTabGroup from '../select-tab-group' import SelectTabGroup from '../select-tab-group'
import SymptomSection from './symptom-section' import SymptomSection from './symptom-section'
import SymptomView from './symptom-view' import SymptomView from './symptom-view'
@@ -20,6 +28,14 @@ export default class Mucus extends SymptomView {
symptomName = 'mucus' symptomName = 'mucus'
showInfoBox(){
const symptomName = 'mucus'
Alert.alert(
infoLabels[symptomName].title,
infoLabels[symptomName].text
)
}
onBackButtonPress() { onBackButtonPress() {
const nothingEntered = ['feeling', 'texture'].every(val => typeof this.state[val] != 'number') const nothingEntered = ['feeling', 'texture'].every(val => typeof this.state[val] != 'number')
if (nothingEntered) { if (nothingEntered) {
@@ -53,6 +69,7 @@ export default class Mucus extends SymptomView {
// const mandatoryNotCompletedYet = typeof this.state.feeling != 'number' || typeof this.state.texture != 'number' // const mandatoryNotCompletedYet = typeof this.state.feeling != 'number' || typeof this.state.texture != 'number'
return ( return (
<ScrollView style={styles.page}> <ScrollView style={styles.page}>
<View style={{ flexDirection: 'row' }}>
<SymptomSection <SymptomSection
header='Feeling' header='Feeling'
explainer={labels.feeling.explainer} explainer={labels.feeling.explainer}
@@ -63,6 +80,18 @@ export default class Mucus extends SymptomView {
active={this.state.feeling} active={this.state.feeling}
/> />
</SymptomSection> </SymptomSection>
<View style={{ flex: 1 }}></View>
<TouchableOpacity
onPress={this.showInfoBox}
style={styles.infoButton}
>
<FeatherIcon
name="info"
style={iconStyles.symptomInfo}
/>
</TouchableOpacity>
</View>
<SymptomSection <SymptomSection
header='Texture' header='Texture'
explainer={labels.texture.explainer} explainer={labels.texture.explainer}
+28 -2
View File
@@ -1,13 +1,19 @@
import React from 'react' import React from 'react'
import { import {
Alert,
ScrollView, ScrollView,
TextInput, TextInput,
TouchableOpacity,
View
} from 'react-native' } from 'react-native'
import FeatherIcon from 'react-native-vector-icons/Feather'
import styles from '../../../styles' import infoLabels from '../../../i18n/en/symptom-info'
import SymptomSection from './symptom-section'
import { noteExplainer } from '../../../i18n/en/cycle-day' import { noteExplainer } from '../../../i18n/en/cycle-day'
import { shared as sharedLabels } from '../../../i18n/en/labels' import { shared as sharedLabels } from '../../../i18n/en/labels'
import styles, { iconStyles } from '../../../styles'
import SymptomSection from './symptom-section'
import SymptomView from './symptom-view' import SymptomView from './symptom-view'
export default class Note extends SymptomView { export default class Note extends SymptomView {
@@ -23,6 +29,14 @@ export default class Note extends SymptomView {
symptomName = 'note' symptomName = 'note'
showInfoBox(){
const symptomName = 'note'
Alert.alert(
infoLabels[symptomName].title,
infoLabels[symptomName].text
)
}
onBackButtonPress() { onBackButtonPress() {
if (!this.state.currentValue) { if (!this.state.currentValue) {
this.deleteSymptomEntry() this.deleteSymptomEntry()
@@ -36,6 +50,7 @@ export default class Note extends SymptomView {
renderContent() { renderContent() {
return ( return (
<ScrollView style={styles.page}> <ScrollView style={styles.page}>
<View style={{ flexDirection: 'row' }}>
<SymptomSection <SymptomSection
explainer={noteExplainer} explainer={noteExplainer}
> >
@@ -49,6 +64,17 @@ export default class Note extends SymptomView {
value={this.state.currentValue} value={this.state.currentValue}
/> />
</SymptomSection> </SymptomSection>
<View style={{ flex: 1 }}></View>
<TouchableOpacity
onPress={this.showInfoBox}
style={styles.infoButton}
>
<FeatherIcon
name="info"
style={iconStyles.symptomInfo}
/>
</TouchableOpacity>
</View>
</ScrollView> </ScrollView>
) )
} }
+31 -3
View File
@@ -1,12 +1,20 @@
import React from 'react' import React from 'react'
import { import {
Alert,
ScrollView,
TextInput, TextInput,
ScrollView TouchableOpacity,
View
} from 'react-native' } from 'react-native'
import styles from '../../../styles' import FeatherIcon from 'react-native-vector-icons/Feather'
import infoLabels from '../../../i18n/en/symptom-info'
import { sex as sexLabels, contraceptives as contraceptivesLabels } from '../../../i18n/en/cycle-day' import { sex as sexLabels, contraceptives as contraceptivesLabels } from '../../../i18n/en/cycle-day'
import { shared as sharedLabels } from '../../../i18n/en/labels' import { shared as sharedLabels } from '../../../i18n/en/labels'
import styles, { iconStyles } from '../../../styles'
import SelectBoxGroup from '../select-box-group' import SelectBoxGroup from '../select-box-group'
import SymptomSection from './symptom-section' import SymptomSection from './symptom-section'
import SymptomView from './symptom-view' import SymptomView from './symptom-view'
@@ -24,7 +32,15 @@ export default class Sex extends SymptomView {
if (this.state.note) this.state.other = true if (this.state.note) this.state.other = true
} }
symptomName = "sex" symptomName = 'sex'
showInfoBox(){
const symptomName = 'sex'
Alert.alert(
infoLabels[symptomName].title,
infoLabels[symptomName].text
)
}
onBackButtonPress() { onBackButtonPress() {
const nothingEntered = Object.values(this.state).every(val => !val) const nothingEntered = Object.values(this.state).every(val => !val)
@@ -51,6 +67,7 @@ export default class Sex extends SymptomView {
renderContent() { renderContent() {
return ( return (
<ScrollView style={styles.page}> <ScrollView style={styles.page}>
<View style={{ flexDirection: 'row' }}>
<SymptomSection <SymptomSection
header={sexLabels.header} header={sexLabels.header}
explainer={sexLabels.explainer} explainer={sexLabels.explainer}
@@ -61,6 +78,17 @@ export default class Sex extends SymptomView {
optionsState={this.state} optionsState={this.state}
/> />
</SymptomSection> </SymptomSection>
<View style={{ flex: 1 }}></View>
<TouchableOpacity
onPress={this.showInfoBox}
style={styles.infoButton}
>
<FeatherIcon
name="info"
style={iconStyles.symptomInfo}
/>
</TouchableOpacity>
</View>
<SymptomSection <SymptomSection
header={contraceptivesLabels.header} header={contraceptivesLabels.header}
explainer={contraceptivesLabels.explainer} explainer={contraceptivesLabels.explainer}
+5
View File
@@ -474,6 +474,11 @@ export const iconStyles = {
symptomBoxActive: { symptomBoxActive: {
color: fontOnPrimaryColor color: fontOnPrimaryColor
}, },
symptomInfo: {
color: secondaryColor,
marginHorizontal: 20,
fontSize: 25
},
menuIcon: { menuIcon: {
size: 20, size: 20,
color: fontOnPrimaryColor color: fontOnPrimaryColor