diff --git a/components/stats.js b/components/stats.js index 51af03f..3e40998 100644 --- a/components/stats.js +++ b/components/stats.js @@ -1,7 +1,11 @@ -import React from 'react' -import { ImageBackground, View } from 'react-native' +import React, { useState } from 'react' +import { ImageBackground, SafeAreaView, ScrollView, View } from 'react-native' import { ScaledSheet } from 'react-native-size-matters' +import { useTranslation } from 'react-i18next' +import Button from './common/button' +import AppHelp from './common/AppHelp' +import AppModal from './common/app-modal' import AppText from './common/app-text' import StatsOverview from './common/StatsOverview' import StatsTable from './common/StatsTable' @@ -15,6 +19,10 @@ import { Containers, Sizes, Spacing, Typography } from '../styles' const image = require('../assets/cycle-icon.png') const Stats = () => { + const [isStatsVisible, setIsStatsVisible] = useState(false) + + const { t } = useTranslation(null, { keyPrefix: 'stats' }) + const cycleLengths = cycleModule().getAllCycleLengths() const numberOfCycles = cycleLengths.length const hasAtLeastOneCycle = numberOfCycles >= 1 @@ -22,48 +30,58 @@ const Stats = () => { ? getCycleInfo(cycleLengths) : { minimum: '—', maximum: '—', stdDeviation: '—' } const statsData = [ - [cycleData.minimum, labels.minLabel], - [cycleData.maximum, labels.maxLabel], - [cycleData.stdDeviation ? cycleData.stdDeviation : '—', labels.stdLabel], - [numberOfCycles, labels.basisOfStatsEnd], + [cycleData.minimum, t('min')], + [cycleData.maximum, t('max')], + [ + cycleData.stdDeviation ? cycleData.stdDeviation : '—', + t('standard_deviation'), + ], + [numberOfCycles, t('completed_cycles')], ] return ( - - - {labels.cycleLengthExplainer} - {!hasAtLeastOneCycle && {labels.emptyStats}} + + + {t('cycle_length_explainer')} + {!hasAtLeastOneCycle && {t('no_data')}} {hasAtLeastOneCycle && ( - - - - + + + - {cycleData.mean} - - - {labels.daysLabel} - - - - {labels.averageLabel} - + + {cycleData.mean} + + {t('days')} + + {t('average')} + + + + - - - - + + + )} - - - + + + {isStatsVisible && ( + setIsStatsVisible(false)}> + setIsStatsVisible(false)} /> + + )} + ) }