2024-04-12 13:43:49 +02:00
|
|
|
import { SafeAreaView } from "react-native-safe-area-context"
|
|
|
|
import { Card, Text } from "react-native-paper"
|
2024-04-12 15:27:11 +02:00
|
|
|
import CircularProgress from "react-native-circular-progress-indicator"
|
|
|
|
import { ScrollView } from "react-native"
|
|
|
|
import { Calendar } from "react-native-calendars"
|
2024-04-12 13:43:49 +02:00
|
|
|
|
2024-04-12 15:27:11 +02:00
|
|
|
import type { HabitsTracker } from "@/domain/entities/HabitsTracker"
|
|
|
|
|
|
|
|
export interface StatsProps {
|
|
|
|
habitsTracker: HabitsTracker
|
|
|
|
}
|
|
|
|
|
|
|
|
export const Stats: React.FC<StatsProps> = (props) => {
|
|
|
|
const { habitsTracker } = props
|
|
|
|
|
|
|
|
const habitsHistory = habitsTracker.getAllHabitsHistory()
|
2024-04-12 13:43:49 +02:00
|
|
|
return (
|
|
|
|
<SafeAreaView>
|
2024-04-12 15:27:11 +02:00
|
|
|
<ScrollView>
|
|
|
|
<Calendar />
|
2024-04-12 13:43:49 +02:00
|
|
|
|
2024-04-12 15:27:11 +02:00
|
|
|
{habitsHistory.map((element) => {
|
|
|
|
if (element.habit.goal.frequency === "daily") {
|
|
|
|
return (
|
|
|
|
<Card key={element.habit.id} mode="outlined">
|
|
|
|
<Card.Title title="Sucess Week" />
|
|
|
|
<Card.Content>
|
|
|
|
<Text variant="bodyMedium">
|
|
|
|
nbDays Sucess dans la semaine
|
|
|
|
</Text>
|
|
|
|
<CircularProgress
|
|
|
|
value={91}
|
|
|
|
activeStrokeWidth={12}
|
|
|
|
progressValueColor={"#ecf0f1"}
|
|
|
|
circleBackgroundColor="black"
|
|
|
|
titleColor="white"
|
|
|
|
title="%"
|
|
|
|
/>
|
|
|
|
</Card.Content>
|
|
|
|
</Card>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
if (element.habit.goal.frequency === "weekly") {
|
|
|
|
return (
|
|
|
|
<Card key={element.habit.id} mode="outlined">
|
|
|
|
<Card.Title title="Sucess Month" />
|
|
|
|
<Card.Content>
|
|
|
|
<Text variant="bodyMedium">nbDays Sucess dans le mois</Text>
|
|
|
|
</Card.Content>
|
|
|
|
</Card>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
if (element.habit.goal.frequency === "monthly") {
|
|
|
|
return (
|
|
|
|
<Card key={element.habit.id} mode="outlined">
|
|
|
|
<Card.Title title="Sucess Month" />
|
|
|
|
<Card.Content>
|
|
|
|
<Text variant="bodyMedium">nbDays Sucess dans le mois</Text>
|
|
|
|
</Card.Content>
|
|
|
|
</Card>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
return null
|
|
|
|
})}
|
|
|
|
</ScrollView>
|
2024-04-12 13:43:49 +02:00
|
|
|
</SafeAreaView>
|
|
|
|
)
|
|
|
|
}
|