import React from 'react' import { ImageBackground, StyleSheet, View } from 'react-native' import AppPage from './common/app-page' import AppText from './common/app-text' import Segment from './common/segment' import Table from './common/table' import cycleModule from '../lib/cycle' import {getCycleLengthStats as getCycleInfo} from '../lib/cycle-length' import {stats as labels} from '../i18n/en/labels' import { Sizes, Spacing, Typography } from '../styles/redesign' const image = require('../assets/cycle-icon.png') const Stats = () => { const cycleLengths = cycleModule().getAllCycleLengths() const atLeastOneCycle = cycleLengths.length >= 1 const numberOfCycles = cycleLengths.length let cycleData if (atLeastOneCycle) { cycleData = getCycleInfo(cycleLengths) } const statsData = [ [atLeastOneCycle ? cycleData.minimum : 0, labels.minLabel], [atLeastOneCycle ? cycleData.maximum : 0, labels.maxLabel], [atLeastOneCycle && cycleData.stdDeviation ? cycleData.stdDeviation : '—', labels.stdLabel], [numberOfCycles, labels.basisOfStatsEnd] ] return ( {labels.cycleLengthExplainer} {!atLeastOneCycle && {labels.emptyStats}} {atLeastOneCycle && {cycleData.mean} {labels.daysLabel} {labels.averageLabel} } ) } const column = { flexDirection: 'column' } const styles = StyleSheet.create({ accentOrange: { ...Typography.accentOrange }, accentPurpleGiant: { ...Typography.accentPurpleGiant, marginVertical: Sizes.giant * (-0.5) }, accentPurpleHuge: { ...Typography.accentPurpleHuge, marginRight: Spacing.base }, container: { alignItems: 'center', flexDirection: 'row', justifyContent: 'space-between', }, columnLeft: { ...column, flex: 4 }, columnRight: { ...column, flex: 5 }, image: { height: Sizes.huge * 3, marginLeft: Sizes.huge / 2, resizeMode: 'contain', width: Sizes.huge * 3 }, imageContainter: { paddingTop: Sizes.huge, marginBottom: Sizes.huge / 4 }, pageContainer: { marginVertical: Spacing.large } }) export default Stats