Skip to content
Snippets Groups Projects
Commit 548b2826 authored by bl00dymarie's avatar bl00dymarie
Browse files

Merge branch '302-bug-stats-crash' into 'master'

Resolve "bug: stats crash"

Closes #302

See merge request bloodyhealth/drip!177
parents e42aa9bb 9b1d47be
No related branches found
No related tags found
No related merge requests found
...@@ -9,11 +9,12 @@ import cycleModule from '../lib/cycle' ...@@ -9,11 +9,12 @@ 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 '../i18n/en/labels' import {stats as labels} from '../i18n/en/labels'
import AppText from './app-text' import AppText from './app-text'
import FramedSegment from './framed-segment'
export default class Stats extends Component { export default class Stats extends Component {
render() { render() {
const cycleLengths = cycleModule().getAllCycleLengths() const cycleLengths = cycleModule().getAllCycleLengths()
const atLeastOneCycle = cycleLengths.length > 1 const atLeastOneCycle = cycleLengths.length >= 1
let numberOfCycles let numberOfCycles
let cycleInfo let cycleInfo
if (atLeastOneCycle) { if (atLeastOneCycle) {
...@@ -24,44 +25,53 @@ export default class Stats extends Component { ...@@ -24,44 +25,53 @@ export default class Stats extends Component {
} }
return ( return (
<ScrollView> <ScrollView>
<View style={[styles.textWrappingView]}> <FramedSegment
<AppText style={styles.title}>{labels.cycleLengthTitle}</AppText> style={styles.framedSegmentLast}
<AppText style={styles.paragraph}>{labels.cycleLengthExplainer}</AppText> title={labels.cycleLengthTitle}
>
<AppText style={styles.paragraph}>
{labels.cycleLengthExplainer}
</AppText>
{!atLeastOneCycle && {!atLeastOneCycle &&
<AppText>{labels.emptyStats}</AppText> <AppText>{labels.emptyStats}</AppText>
} }
{atLeastOneCycle && numberOfCycles === 1 && {atLeastOneCycle && numberOfCycles === 1 &&
<AppText> <View style={[styles.statsRow, styles.paragraph]}>
{labels.oneCycleStats} <AppText>{labels.oneCycleStats}</AppText>
<AppText style={styles.emphasis}> {cycleLengths[0]} </AppText> <AppText style={styles.emphasis}> {cycleLengths[0]} </AppText>
{labels.daysLabel + '.'} <AppText>{labels.daysLabel}.</AppText>
</AppText> </View>
} }
{atLeastOneCycle && numberOfCycles > 1 && <View> {atLeastOneCycle && numberOfCycles > 1 && <View>
<View style={styles.statsRow}> <View style={styles.paragraph}>
<AppText style={[styles.statsLabelLeft, styles.emphasis]}>{labels.averageLabel}</AppText> <AppText style={styles.emphasis}>
<AppText style={[styles.statsLabelRight, styles.emphasis]}>{cycleInfo.mean + ' ' + labels.daysLabel}</AppText> {labels.averageLabel}: {cycleInfo.mean} {labels.daysLabel}
</AppText>
</View> </View>
<View style={styles.statsRow}> <View>
<AppText style={styles.statsLabelLeft}>{labels.minLabel}</AppText> <AppText>
<AppText style={styles.statsLabelRight}>{cycleInfo.minimum + ' ' + labels.daysLabel}</AppText> {labels.minLabel}: {cycleInfo.minimum} {labels.daysLabel}
</AppText>
</View> </View>
<View style={styles.statsRow}> <View>
<AppText style={styles.statsLabelLeft}>{labels.maxLabel}</AppText> <AppText>
<AppText style={styles.statsLabelRight}>{cycleInfo.maximum + ' ' + labels.daysLabel}</AppText> {labels.maxLabel}: {cycleInfo.maximum} {labels.daysLabel}
</AppText>
</View> </View>
<View style={[styles.statsRow, styles.paragraph]}> <View style={styles.paragraph}>
<AppText style={styles.statsLabelLeft}>{labels.stdLabel}</AppText> <AppText>
<AppText style={styles.statsLabelRight}>{cycleInfo.stdDeviation + ' ' + labels.daysLabel}</AppText> {labels.stdLabel}: {cycleInfo.stdDeviation} {labels.daysLabel}
</AppText>
</View> </View>
<AppText> <View style={styles.statsRow}>
{labels.basisOfStatsBeginning} <AppText>{labels.basisOfStatsBeginning}</AppText>
<AppText style={styles.emphasis}> {numberOfCycles} </AppText> <AppText style={styles.emphasis}> {numberOfCycles} </AppText>
{labels.basisOfStatsEnd} <AppText>{labels.basisOfStatsEnd}</AppText>
</AppText> </View>
</View>} </View>}
</View> </FramedSegment>
</ScrollView> </ScrollView>
) )
} }
} }
\ No newline at end of file
...@@ -45,7 +45,8 @@ export default StyleSheet.create({ ...@@ -45,7 +45,8 @@ export default StyleSheet.create({
}, },
emphasis: { emphasis: {
fontWeight: 'bold', fontWeight: 'bold',
fontFamily: textFontBold fontFamily: textFontBold,
color: secondaryColor,
}, },
link: { link: {
color: cycleDayColor, color: cycleDayColor,
...@@ -308,17 +309,7 @@ export default StyleSheet.create({ ...@@ -308,17 +309,7 @@ export default StyleSheet.create({
}, },
statsRow: { statsRow: {
flexDirection: 'row', flexDirection: 'row',
width: '100%' flexWrap: 'wrap'
},
statsLabelLeft: {
width: '60%',
textAlign: 'left',
textAlignVertical: 'center',
marginLeft: 10
},
statsLabelRight: {
textAlign: 'left',
textAlignVertical: 'center'
}, },
menuLabel: { menuLabel: {
fontSize: 15, fontSize: 15,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment