Add app text component and remove radio button dep

This commit is contained in:
Julia Friesel
2018-09-01 18:11:55 +02:00
parent ca8764aa4b
commit 8b37fa3ca4
17 changed files with 1626 additions and 1643 deletions
+23
View File
@@ -0,0 +1,23 @@
import React, { Component } from 'react'
import { Text } from 'react-native'
import styles from "../styles"
export class AppText extends Component {
render() {
return (
<Text style={[styles.appText, this.props.style]}>
{this.props.children}
</Text>
)
}
}
export class SymptomSectionHeader extends Component {
render() {
return (
<AppText style={styles.symptomViewHeading}>
{this.props.children}
</AppText>
)
}
}
+3 -2
View File
@@ -1,5 +1,5 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import { View, FlatList, Text } from 'react-native' import { View, FlatList } from 'react-native'
import range from 'date-range' import range from 'date-range'
import { LocalDate } from 'js-joda' import { LocalDate } from 'js-joda'
import { makeYAxisLabels, normalizeToScale, makeHorizontalGrid } from './y-axis' import { makeYAxisLabels, normalizeToScale, makeHorizontalGrid } from './y-axis'
@@ -9,6 +9,7 @@ import { getCycleDay, cycleDaysSortedByDate, getAmountOfCycleDays } from '../../
import styles from './styles' import styles from './styles'
import { scaleObservable } from '../../local-storage' import { scaleObservable } from '../../local-storage'
import config from '../../config' import config from '../../config'
import { AppText } from '../app-text'
export default class CycleChart extends Component { export default class CycleChart extends Component {
constructor(props) { constructor(props) {
@@ -100,7 +101,7 @@ export default class CycleChart extends Component {
> >
{!this.state.chartLoaded && {!this.state.chartLoaded &&
<View style={{width: '100%', justifyContent: 'center', alignItems: 'center'}}> <View style={{width: '100%', justifyContent: 'center', alignItems: 'center'}}>
<Text>Loading...</Text> <AppText>Loading...</AppText>
</View> </View>
} }
+4 -3
View File
@@ -1,8 +1,9 @@
import React from 'react' import React from 'react'
import { Text, View } from 'react-native' import { View } from 'react-native'
import config from '../../config' import config from '../../config'
import styles from './styles' import styles from './styles'
import { scaleObservable } from '../../local-storage' import { scaleObservable } from '../../local-storage'
import { AppText } from '../app-text'
export function makeYAxisLabels(columnHeight) { export function makeYAxisLabels(columnHeight) {
const units = config.temperatureScale.units const units = config.temperatureScale.units
@@ -15,11 +16,11 @@ export function makeYAxisLabels(columnHeight) {
// to reliably place the label vertically centered to the grid // to reliably place the label vertically centered to the grid
if (scaleMax - i * units === 37) console.log(y) if (scaleMax - i * units === 37) console.log(y)
return ( return (
<Text <AppText
style={[style, {top: y - 8}]} style={[style, {top: y - 8}]}
key={i}> key={i}>
{scaleMax - i * units} {scaleMax - i * units}
</Text> </AppText>
) )
}) })
} }
+3 -3
View File
@@ -2,7 +2,6 @@ import React, { Component } from 'react'
import { import {
ScrollView, ScrollView,
View, View,
Text,
TouchableOpacity, TouchableOpacity,
Dimensions Dimensions
} from 'react-native' } from 'react-native'
@@ -22,6 +21,7 @@ import {
cervixPosition as positionLabels, cervixPosition as positionLabels,
intensity as intensityLabels intensity as intensityLabels
} from './labels/labels' } from './labels/labels'
import { AppText } from '../app-text'
export default class CycleDayOverView extends Component { export default class CycleDayOverView extends Component {
constructor(props) { constructor(props) {
@@ -198,10 +198,10 @@ class SymptomBox extends Component {
name='thermometer' name='thermometer'
{...iconStyle} {...iconStyle}
/> />
<Text style={[textActive, disabledStyle]}>{this.props.title}</Text> <AppText style={[textActive, disabledStyle]}>{this.props.title}</AppText>
</View> </View>
<View style={[styles.symptomDataBox, disabledStyle]}> <View style={[styles.symptomDataBox, disabledStyle]}>
<Text style={styles.symptomDataText}>{this.props.data}</Text> <AppText style={styles.symptomDataText}>{this.props.data}</AppText>
</View> </View>
</TouchableOpacity> </TouchableOpacity>
) )
+3 -4
View File
@@ -1,10 +1,10 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import { import {
View, View,
Text,
TouchableOpacity, TouchableOpacity,
} from 'react-native' } from 'react-native'
import styles from '../../styles' import styles from '../../styles'
import { AppText } from '../app-text'
export default class RadioButton extends Component { export default class RadioButton extends Component {
render() { render() {
@@ -13,7 +13,6 @@ export default class RadioButton extends Component {
{ {
this.props.buttons.map(({ label, value }) => { this.props.buttons.map(({ label, value }) => {
const isActive = value === this.props.active const isActive = value === this.props.active
const circleStyle = [styles.radioButton]
return ( return (
<TouchableOpacity <TouchableOpacity
onPress={() => this.props.onSelect(value)} onPress={() => this.props.onSelect(value)}
@@ -21,11 +20,11 @@ export default class RadioButton extends Component {
activeOpacity={1} activeOpacity={1}
> >
<View style={styles.radioButtonTextGroup}> <View style={styles.radioButtonTextGroup}>
<View style={circleStyle}> <View style={styles.radioButton}>
{isActive ? {isActive ?
<View style={styles.radioButtonActiveDot}/> : null} <View style={styles.radioButtonActiveDot}/> : null}
</View> </View>
<Text>{label}</Text> <AppText>{label}</AppText>
</View> </View>
</TouchableOpacity> </TouchableOpacity>
) )
+2 -2
View File
@@ -1,10 +1,10 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import { import {
View, View,
Text,
TouchableOpacity, TouchableOpacity,
} from 'react-native' } from 'react-native'
import styles from '../../styles' import styles from '../../styles'
import { AppText } from '../app-text'
export default class SelectBox extends Component { export default class SelectBox extends Component {
render () { render () {
@@ -17,7 +17,7 @@ export default class SelectBox extends Component {
return ( return (
<TouchableOpacity onPress={this.props.onPress}> <TouchableOpacity onPress={this.props.onPress}>
<View style={style}> <View style={style}>
<Text style={textStyle}>{this.props.label}</Text> <AppText style={textStyle}>{this.props.label}</AppText>
</View> </View>
</TouchableOpacity> </TouchableOpacity>
) )
+12 -14
View File
@@ -1,15 +1,15 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import { import {
View, View,
Text,
Switch, Switch,
ScrollView ScrollView
} from 'react-native' } from 'react-native'
import RadioForm from 'react-native-simple-radio-button'
import styles from '../../../styles' import styles from '../../../styles'
import { saveSymptom } from '../../../db' import { saveSymptom } from '../../../db'
import { bleeding as labels } from '../labels/labels' import { bleeding as labels } from '../labels/labels'
import ActionButtonFooter from './action-button-footer' import ActionButtonFooter from './action-button-footer'
import RadioButtonGroup from '../radio-button-group'
import { SymptomSectionHeader, AppText } from '../../app-text'
export default class Bleeding extends Component { export default class Bleeding extends Component {
constructor(props) { constructor(props) {
@@ -37,20 +37,18 @@ export default class Bleeding extends Component {
<View style={{ flex: 1 }}> <View style={{ flex: 1 }}>
<ScrollView style={styles.page}> <ScrollView style={styles.page}>
<View> <View>
<View style={styles.radioButtonRow}> <SymptomSectionHeader>Heaviness</SymptomSectionHeader>
<RadioForm <AppText>How heavy is the bleeding?</AppText>
radio_props={bleedingRadioProps} <RadioButtonGroup
initial={this.state.currentValue} buttons={bleedingRadioProps}
formHorizontal={true} active={this.state.currentValue}
labelHorizontal={false} onSelect={val => this.setState({ currentValue: val })}
labelStyle={styles.radioButton}
onPress={(itemValue) => {
this.setState({ currentValue: itemValue })
}}
/> />
<SymptomSectionHeader>Exclude</SymptomSectionHeader>
<View flexDirection={'row'}>
<View flex={1}>
<AppText>You can exclude this value if it's not menstrual bleeding</AppText>
</View> </View>
<View style={styles.symptomViewRowInline}>
<Text style={styles.symptomViewHeading}>Exclude</Text>
<Switch <Switch
onValueChange={(val) => { onValueChange={(val) => {
this.setState({ exclude: val }) this.setState({ exclude: val })
+18 -39
View File
@@ -1,11 +1,9 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import { import {
View, View,
Text,
Switch, Switch,
ScrollView ScrollView
} from 'react-native' } from 'react-native'
import RadioForm from 'react-native-simple-radio-button'
import styles from '../../../styles' import styles from '../../../styles'
import { saveSymptom } from '../../../db' import { saveSymptom } from '../../../db'
import { import {
@@ -14,6 +12,8 @@ import {
cervixPosition as positionLabels cervixPosition as positionLabels
} from '../labels/labels' } from '../labels/labels'
import ActionButtonFooter from './action-button-footer' import ActionButtonFooter from './action-button-footer'
import RadioButtonGroup from '../radio-button-group'
import { SymptomSectionHeader } from '../../app-text'
export default class Cervix extends Component { export default class Cervix extends Component {
constructor(props) { constructor(props) {
@@ -53,47 +53,26 @@ export default class Cervix extends Component {
<View style={{ flex: 1 }}> <View style={{ flex: 1 }}>
<ScrollView style={styles.page}> <ScrollView style={styles.page}>
<View> <View>
<Text style={styles.symptomViewHeading}>Opening</Text> <SymptomSectionHeader>Opening</SymptomSectionHeader>
<View style={styles.radioButtonRow}> <RadioButtonGroup
<RadioForm buttons={cervixOpeningRadioProps}
radio_props={cervixOpeningRadioProps} active={this.state.opening}
initial={this.state.opening} onSelect={val => this.setState({ opening: val })}
formHorizontal={true}
labelHorizontal={false}
labelStyle={styles.radioButton}
onPress={(itemValue) => {
this.setState({ opening: itemValue })
}}
/> />
</View> <SymptomSectionHeader>Firmness</SymptomSectionHeader>
<Text style={styles.symptomViewHeading}>Firmness</Text> <RadioButtonGroup
<View style={styles.radioButtonRow}> buttons={cervixFirmnessRadioProps}
<RadioForm active={this.state.firmness}
radio_props={cervixFirmnessRadioProps} onSelect={val => this.setState({ firmness: val })}
initial={this.state.firmness}
formHorizontal={true}
labelHorizontal={false}
labelStyle={styles.radioButton}
onPress={(itemValue) => {
this.setState({ firmness: itemValue })
}}
/> />
</View> <SymptomSectionHeader>Position</SymptomSectionHeader>
<Text style={styles.symptomViewHeading}>Position</Text> <RadioButtonGroup
<View style={styles.radioButtonRow}> buttons={cervixPositionRadioProps}
<RadioForm active={this.state.position}
radio_props={cervixPositionRadioProps} onSelect={val => this.setState({ position: val })}
initial={this.state.position}
formHorizontal={true}
labelHorizontal={false}
labelStyle={styles.radioButton}
onPress={(itemValue) => {
this.setState({ position: itemValue })
}}
/> />
</View>
<View style={styles.symptomViewRowInline}> <View style={styles.symptomViewRowInline}>
<Text style={styles.symptomViewHeading}>Exclude</Text> <SymptomSectionHeader>Exclude</SymptomSectionHeader>
<Switch <Switch
onValueChange={(val) => { onValueChange={(val) => {
this.setState({ exclude: val }) this.setState({ exclude: val })
+5 -12
View File
@@ -3,11 +3,11 @@ import {
View, View,
ScrollView ScrollView
} from 'react-native' } from 'react-native'
import RadioForm from 'react-native-simple-radio-button'
import styles from '../../../styles' import styles from '../../../styles'
import { saveSymptom } from '../../../db' import { saveSymptom } from '../../../db'
import { intensity as labels } from '../labels/labels' import { intensity as labels } from '../labels/labels'
import ActionButtonFooter from './action-button-footer' import ActionButtonFooter from './action-button-footer'
import RadioButtonGroup from '../radio-button-group'
export default class Desire extends Component { export default class Desire extends Component {
constructor(props) { constructor(props) {
@@ -31,19 +31,12 @@ export default class Desire extends Component {
<View style={{ flex: 1 }}> <View style={{ flex: 1 }}>
<ScrollView style={styles.page}> <ScrollView style={styles.page}>
<View> <View>
<View style={styles.radioButtonRow}> <RadioButtonGroup
<RadioForm buttons={desireRadioProps}
radio_props={desireRadioProps} acitve={this.state.currentValue}
initial={this.state.currentValue} onSelect={val => this.setState({ currentValue: val })}
formHorizontal={true}
labelHorizontal={false}
labelStyle={styles.radioButton}
onPress={(itemValue) => {
this.setState({ currentValue: itemValue })
}}
/> />
</View> </View>
</View>
</ScrollView> </ScrollView>
<ActionButtonFooter <ActionButtonFooter
symptom='desire' symptom='desire'
+4 -8
View File
@@ -1,7 +1,6 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import { import {
View, View,
Text,
Switch, Switch,
ScrollView ScrollView
} from 'react-native' } from 'react-native'
@@ -14,6 +13,7 @@ import {
import computeSensiplanValue from '../../../lib/sensiplan-mucus' import computeSensiplanValue from '../../../lib/sensiplan-mucus'
import ActionButtonFooter from './action-button-footer' import ActionButtonFooter from './action-button-footer'
import RadioButtonGroup from '../radio-button-group' import RadioButtonGroup from '../radio-button-group'
import { SymptomSectionHeader } from '../../app-text'
export default class Mucus extends Component { export default class Mucus extends Component {
@@ -51,24 +51,20 @@ export default class Mucus extends Component {
<View style={{ flex: 1 }}> <View style={{ flex: 1 }}>
<ScrollView style={styles.page}> <ScrollView style={styles.page}>
<View> <View>
<Text style={styles.symptomViewHeading}>Feeling</Text> <SymptomSectionHeader>Feeling</SymptomSectionHeader>
<View style={styles.radioButtonRow}>
<RadioButtonGroup <RadioButtonGroup
buttons={mucusFeeling} buttons={mucusFeeling}
onSelect={val => this.setState({ feeling: val })} onSelect={val => this.setState({ feeling: val })}
active={this.state.feeling} active={this.state.feeling}
/> />
</View> <SymptomSectionHeader>Texture</SymptomSectionHeader>
<Text style={styles.symptomViewHeading}>Texture</Text>
<View style={styles.radioButtonRow}>
<RadioButtonGroup <RadioButtonGroup
buttons={mucusTexture} buttons={mucusTexture}
onSelect={val => this.setState({ texture: val })} onSelect={val => this.setState({ texture: val })}
active={this.state.texture} active={this.state.texture}
/> />
</View>
<View style={styles.symptomViewRowInline}> <View style={styles.symptomViewRowInline}>
<Text style={styles.symptomViewHeading}>Exclude</Text> <SymptomSectionHeader>Exclude</SymptomSectionHeader>
<Switch <Switch
onValueChange={(val) => { onValueChange={(val) => {
this.setState({ exclude: val }) this.setState({ exclude: val })
+3 -7
View File
@@ -1,6 +1,5 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import { import {
Text,
TextInput, TextInput,
View, View,
ScrollView ScrollView
@@ -13,6 +12,7 @@ import {
} from '../labels/labels' } from '../labels/labels'
import ActionButtonFooter from './action-button-footer' import ActionButtonFooter from './action-button-footer'
import SelectBox from '../select-box' import SelectBox from '../select-box'
import { SymptomSectionHeader } from '../../app-text'
const sexBoxes = [{ const sexBoxes = [{
label: activityLabels.solo, label: activityLabels.solo,
@@ -79,12 +79,9 @@ export default class Sex extends Component {
return ( return (
<View style={{ flex: 1 }}> <View style={{ flex: 1 }}>
<ScrollView style={styles.page}> <ScrollView style={styles.page}>
<Text style={styles.symptomViewHeading}>Activity</Text> <SymptomSectionHeader>Activity</SymptomSectionHeader>
<View style={styles.selectBoxSection}>
{this.makeSelectBoxes(sexBoxes)} {this.makeSelectBoxes(sexBoxes)}
</View> <SymptomSectionHeader>Contraceptives</SymptomSectionHeader>
<Text style={styles.symptomViewHeading}>Contraceptives</Text>
<View style={styles.selectBoxSection}>
{this.makeSelectBoxes(contraceptiveBoxes)} {this.makeSelectBoxes(contraceptiveBoxes)}
<SelectBox <SelectBox
value={this.state.other} value={this.state.other}
@@ -94,7 +91,6 @@ export default class Sex extends Component {
this.setState({ focusTextArea: true }) this.setState({ focusTextArea: true })
}} }}
/> />
</View>
{this.state.other && {this.state.other &&
<TextInput <TextInput
autoFocus={this.state.focusTextArea} autoFocus={this.state.focusTextArea}
+5 -7
View File
@@ -1,7 +1,6 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import { import {
View, View,
Text,
TextInput, TextInput,
Switch, Switch,
Keyboard, Keyboard,
@@ -18,6 +17,7 @@ import { scaleObservable } from '../../../local-storage'
import { shared } from '../../labels' import { shared } from '../../labels'
import ActionButtonFooter from './action-button-footer' import ActionButtonFooter from './action-button-footer'
import config from '../../../config' import config from '../../../config'
import { SymptomSectionHeader } from '../../app-text'
const minutes = ChronoUnit.MINUTES const minutes = ChronoUnit.MINUTES
@@ -99,7 +99,7 @@ export default class Temp extends Component {
<ScrollView style={styles.page}> <ScrollView style={styles.page}>
<View> <View>
<View style={styles.symptomViewRowInline}> <View style={styles.symptomViewRowInline}>
<Text style={styles.symptomViewHeading}>Temperature (°C)</Text> <SymptomSectionHeader>Temperature (°C)</SymptomSectionHeader>
<TempInput <TempInput
value={this.state.temperature} value={this.state.temperature}
setState={(val) => this.setState(val)} setState={(val) => this.setState(val)}
@@ -107,7 +107,7 @@ export default class Temp extends Component {
/> />
</View> </View>
<View style={styles.symptomViewRowInline}> <View style={styles.symptomViewRowInline}>
<Text style={styles.symptomViewHeading}>Time</Text> <SymptomSectionHeader>Time</SymptomSectionHeader>
<TextInput <TextInput
style={styles.temperatureTextInput} style={styles.temperatureTextInput}
onFocus={() => { onFocus={() => {
@@ -128,9 +128,7 @@ export default class Temp extends Component {
}} }}
onCancel={() => this.setState({ isTimePickerVisible: false })} onCancel={() => this.setState({ isTimePickerVisible: false })}
/> />
<View style={styles.symptomViewRowInline}> <SymptomSectionHeader>Note</SymptomSectionHeader>
<Text style={styles.symptomViewHeading}>Note</Text>
</View>
<View> <View>
<TextInput <TextInput
style={styles.temperatureTextInput} style={styles.temperatureTextInput}
@@ -144,7 +142,7 @@ export default class Temp extends Component {
/> />
</View> </View>
<View style={styles.symptomViewRowInline}> <View style={styles.symptomViewRowInline}>
<Text style={styles.symptomViewHeading}>Exclude</Text> <SymptomSectionHeader>Exlude</SymptomSectionHeader>
<Switch <Switch
onValueChange={(val) => { onValueChange={(val) => {
this.setState({ exclude: val }) this.setState({ exclude: val })
+20 -20
View File
@@ -4,7 +4,6 @@ import {
TouchableOpacity, TouchableOpacity,
ScrollView, ScrollView,
Alert, Alert,
Text,
Switch Switch
} from 'react-native' } from 'react-native'
import DateTimePicker from 'react-native-modal-datetime-picker-nevo' import DateTimePicker from 'react-native-modal-datetime-picker-nevo'
@@ -23,6 +22,7 @@ import {
tempReminderObservable, tempReminderObservable,
saveTempReminder saveTempReminder
} from '../local-storage' } from '../local-storage'
import { AppText } from './app-text'
export default class Settings extends Component { export default class Settings extends Component {
constructor(props) { constructor(props) {
@@ -35,36 +35,36 @@ export default class Settings extends Component {
<ScrollView> <ScrollView>
<TempReminderPicker/> <TempReminderPicker/>
<View style={styles.settingsSegment}> <View style={styles.settingsSegment}>
<Text style={styles.settingsSegmentTitle}> <AppText style={styles.settingsSegmentTitle}>
{labels.tempScale.segmentTitle} {labels.tempScale.segmentTitle}
</Text> </AppText>
<Text>{labels.tempScale.segmentExplainer}</Text> <AppText>{labels.tempScale.segmentExplainer}</AppText>
<TempSlider/> <TempSlider/>
</View> </View>
<View style={styles.settingsSegment}> <View style={styles.settingsSegment}>
<Text style={styles.settingsSegmentTitle}> <AppText style={styles.settingsSegmentTitle}>
{labels.export.button} {labels.export.button}
</Text> </AppText>
<Text>{labels.export.segmentExplainer}</Text> <AppText>{labels.export.segmentExplainer}</AppText>
<TouchableOpacity <TouchableOpacity
onPress={openShareDialogAndExport} onPress={openShareDialogAndExport}
style={styles.settingsButton}> style={styles.settingsButton}>
<Text style={styles.settingsButtonText}> <AppText style={styles.settingsButtonText}>
{labels.export.button} {labels.export.button}
</Text> </AppText>
</TouchableOpacity> </TouchableOpacity>
</View> </View>
<View style={styles.settingsSegment}> <View style={styles.settingsSegment}>
<Text style={styles.settingsSegmentTitle}> <AppText style={styles.settingsSegmentTitle}>
{labels.import.button} {labels.import.button}
</Text> </AppText>
<Text>{labels.import.segmentExplainer}</Text> <AppText>{labels.import.segmentExplainer}</AppText>
<TouchableOpacity <TouchableOpacity
onPress={openImportDialogAndImport} onPress={openImportDialogAndImport}
style={styles.settingsButton}> style={styles.settingsButton}>
<Text style={styles.settingsButtonText}> <AppText style={styles.settingsButtonText}>
{labels.import.button} {labels.import.button}
</Text> </AppText>
</TouchableOpacity> </TouchableOpacity>
</View> </View>
</ScrollView> </ScrollView>
@@ -84,15 +84,15 @@ class TempReminderPicker extends Component {
style={styles.settingsSegment} style={styles.settingsSegment}
onPress={() => this.setState({ isTimePickerVisible: true })} onPress={() => this.setState({ isTimePickerVisible: true })}
> >
<Text style={styles.settingsSegmentTitle}> <AppText style={styles.settingsSegmentTitle}>
{labels.tempReminder.title} {labels.tempReminder.title}
</Text> </AppText>
<View style={{ flexDirection: 'row', alignItems: 'center' }}> <View style={{ flexDirection: 'row', alignItems: 'center' }}>
<View style={{ flex: 1 }}> <View style={{ flex: 1 }}>
{this.state.time && this.state.enabled ? {this.state.time && this.state.enabled ?
<Text>{labels.tempReminder.timeSet(this.state.time)}</Text> <AppText>{labels.tempReminder.timeSet(this.state.time)}</AppText>
: :
<Text>{labels.tempReminder.noTimeSet}</Text> <AppText>{labels.tempReminder.noTimeSet}</AppText>
} }
</View> </View>
<Switch <Switch
@@ -160,8 +160,8 @@ class TempSlider extends Component {
render() { render() {
return ( return (
<View style={{ alignItems: 'center' }}> <View style={{ alignItems: 'center' }}>
<Text>{`${labels.tempScale.min} ${this.state.min}`}</Text> <AppText>{`${labels.tempScale.min} ${this.state.min}`}</AppText>
<Text>{`${labels.tempScale.max} ${this.state.max}`}</Text> <AppText>{`${labels.tempScale.max} ${this.state.max}`}</AppText>
<Slider <Slider
values={[this.state.min, this.state.max]} values={[this.state.min, this.state.max]}
min={config.temperatureScale.min} min={config.temperatureScale.min}
+14 -14
View File
@@ -1,6 +1,5 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import { import {
Text,
View, View,
ScrollView ScrollView
} from 'react-native' } from 'react-native'
@@ -9,6 +8,7 @@ import styles from '../styles/index'
import cycleModule from '../lib/cycle' import cycleModule from '../lib/cycle'
import {getCycleLengthStats as getCycleInfo} from '../lib/cycle-length' import {getCycleLengthStats as getCycleInfo} from '../lib/cycle-length'
import {stats as labels} from './labels' import {stats as labels} from './labels'
import { AppText } from './app-text'
export default class Stats extends Component { export default class Stats extends Component {
render() { render() {
@@ -28,32 +28,32 @@ export default class Stats extends Component {
<ScrollView> <ScrollView>
<View> <View>
{!atLeastOneCycle && {!atLeastOneCycle &&
<Text style={styles.statsIntro}>{labels.emptyStats}</Text> <AppText style={styles.statsIntro}>{labels.emptyStats}</AppText>
} }
{atLeastOneCycle && numberOfCycles === 1 && {atLeastOneCycle && numberOfCycles === 1 &&
<Text style={styles.statsIntro}> <AppText style={styles.statsIntro}>
{labels.oneCycleStats(cycleLengths[0])} {labels.oneCycleStats(cycleLengths[0])}
</Text> </AppText>
} }
{atLeastOneCycle && numberOfCycles > 1 && <View> {atLeastOneCycle && numberOfCycles > 1 && <View>
<Text style={styles.statsIntro}> <AppText style={styles.statsIntro}>
{labels.getBasisOfStats(numberOfCycles)} {labels.getBasisOfStats(numberOfCycles)}
</Text> </AppText>
<View style={styles.statsRow}> <View style={styles.statsRow}>
<Text style={styles.statsLabelLeft}>{labels.averageLabel}</Text> <AppText style={styles.statsLabelLeft}>{labels.averageLabel}</AppText>
<Text style={styles.statsLabelRight}>{cycleInfo.mean + ' ' + labels.daysLabel}</Text> <AppText style={styles.statsLabelRight}>{cycleInfo.mean + ' ' + labels.daysLabel}</AppText>
</View> </View>
<View style={styles.statsRow}> <View style={styles.statsRow}>
<Text style={styles.statsLabelLeft}>{labels.minLabel}</Text> <AppText style={styles.statsLabelLeft}>{labels.minLabel}</AppText>
<Text style={styles.statsLabelRight}>{cycleInfo.minimum + ' ' + labels.daysLabel}</Text> <AppText style={styles.statsLabelRight}>{cycleInfo.minimum + ' ' + labels.daysLabel}</AppText>
</View> </View>
<View style={styles.statsRow}> <View style={styles.statsRow}>
<Text style={styles.statsLabelLeft}>{labels.maxLabel}</Text> <AppText style={styles.statsLabelLeft}>{labels.maxLabel}</AppText>
<Text style={styles.statsLabelRight}>{cycleInfo.maximum + ' ' + labels.daysLabel}</Text> <AppText style={styles.statsLabelRight}>{cycleInfo.maximum + ' ' + labels.daysLabel}</AppText>
</View> </View>
<View style={styles.statsRow}> <View style={styles.statsRow}>
<Text style={styles.statsLabelLeft}>{labels.stdLabel}</Text> <AppText style={styles.statsLabelLeft}>{labels.stdLabel}</AppText>
<Text style={styles.statsLabelRight}>{cycleInfo.stdDeviation + ' ' + labels.daysLabel}</Text> <AppText style={styles.statsLabelRight}>{cycleInfo.stdDeviation + ' ' + labels.daysLabel}</AppText>
</View> </View>
</View>} </View>}
</View> </View>
+1467 -1472
View File
File diff suppressed because it is too large Load Diff
-1
View File
@@ -33,7 +33,6 @@
"react-native-modal-datetime-picker-nevo": "^4.11.0", "react-native-modal-datetime-picker-nevo": "^4.11.0",
"react-native-push-notification": "^3.1.1", "react-native-push-notification": "^3.1.1",
"react-native-share": "^1.1.0", "react-native-share": "^1.1.0",
"react-native-simple-radio-button": "^2.7.1",
"react-native-vector-icons": "^5.0.0", "react-native-vector-icons": "^5.0.0",
"react-navigation": "^2.0.4", "react-navigation": "^2.0.4",
"realm": "^2.7.1", "realm": "^2.7.1",
+14 -9
View File
@@ -5,6 +5,9 @@ export const secondaryColor = '#351c4d'
export const fontOnPrimaryColor = 'white' export const fontOnPrimaryColor = 'white'
export default StyleSheet.create({ export default StyleSheet.create({
appText: {
color: 'black'
},
welcome: { welcome: {
fontSize: 20, fontSize: 20,
margin: 30, margin: 30,
@@ -25,6 +28,8 @@ export default StyleSheet.create({
}, },
symptomViewHeading: { symptomViewHeading: {
fontSize: 20, fontSize: 20,
color: 'black',
marginBottom: 5
}, },
symptomBoxImage: { symptomBoxImage: {
width: 50, width: 50,
@@ -208,6 +213,9 @@ export default StyleSheet.create({
flexWrap: 'wrap', flexWrap: 'wrap',
marginVertical: 10, marginVertical: 10,
}, },
radioButtonGroup: {
marginTop: 10
},
radioButton: { radioButton: {
width: 20, width: 20,
height: 20, height: 20,
@@ -215,7 +223,8 @@ export default StyleSheet.create({
borderStyle: 'solid', borderStyle: 'solid',
borderWidth: 2, borderWidth: 2,
borderColor: secondaryColor, borderColor: secondaryColor,
marginBottom: 5, marginBottom: 3,
marginRight: 10,
alignItems: 'center', alignItems: 'center',
justifyContent: 'center' justifyContent: 'center'
}, },
@@ -225,17 +234,13 @@ export default StyleSheet.create({
borderRadius: 100, borderRadius: 100,
backgroundColor: secondaryColor backgroundColor: secondaryColor
}, },
radioButtonGroup: {
flexDirection: 'row',
flexWrap: 'wrap',
marginVertical: 10,
},
radioButtonTextGroup: { radioButtonTextGroup: {
alignItems: 'center', marginRight: 10,
marginHorizontal: 10 flexDirection: 'row',
marginBottom: 10
}, },
page: { page: {
padding: 10 marginHorizontal: 10
} }
}) })