From 1c648972d59a196f1bae07f7aaf32b8551a254c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20LUDWIG?= Date: Sun, 24 Mar 2024 23:41:23 +0100 Subject: [PATCH] refactor: habits history component --- app/application/_layout.tsx | 6 ++ app/application/habits/[habitId]/_layout.tsx | 7 ++ app/application/habits/[habitId]/index.tsx | 22 ++++++ app/application/habits/history.tsx | 19 +++-- app/application/habits/index.tsx | 76 +++---------------- app/application/habits/new.tsx | 19 +++-- app/application/users/settings.tsx | 20 ++--- app/authentication/login.tsx | 8 +- app/authentication/register.tsx | 18 ++--- domain/use-cases/Authentication.ts | 17 ++--- presentation/presenters/Authentication.ts | 50 +++++++----- .../presenters/utils/ColorsPresenter.ts | 18 ----- presentation/presenters/utils/ZodPresenter.ts | 7 -- presentation/presenters/utils/colors.ts | 24 ++++++ presentation/presenters/utils/zod.ts | 7 ++ .../components/HabitsHistory/HabitHistory.tsx | 68 +++++++++++++++++ .../HabitsHistory/HabitsHistory.tsx | 30 ++++++++ presentation/react/components/TabBarIcon.tsx | 2 +- 18 files changed, 254 insertions(+), 164 deletions(-) create mode 100644 app/application/habits/[habitId]/_layout.tsx create mode 100644 app/application/habits/[habitId]/index.tsx delete mode 100644 presentation/presenters/utils/ColorsPresenter.ts delete mode 100644 presentation/presenters/utils/ZodPresenter.ts create mode 100644 presentation/presenters/utils/colors.ts create mode 100644 presentation/presenters/utils/zod.ts create mode 100644 presentation/react/components/HabitsHistory/HabitHistory.tsx create mode 100644 presentation/react/components/HabitsHistory/HabitsHistory.tsx diff --git a/app/application/_layout.tsx b/app/application/_layout.tsx index 8f2eb1b..1bf47a0 100644 --- a/app/application/_layout.tsx +++ b/app/application/_layout.tsx @@ -36,6 +36,12 @@ const TabLayout: React.FC = () => { }, }} /> + { + return +} + +export default HabitLayout diff --git a/app/application/habits/[habitId]/index.tsx b/app/application/habits/[habitId]/index.tsx new file mode 100644 index 0000000..aeaa0c2 --- /dev/null +++ b/app/application/habits/[habitId]/index.tsx @@ -0,0 +1,22 @@ +import { useLocalSearchParams } from "expo-router" +import { Text } from "react-native-paper" +import { SafeAreaView } from "react-native-safe-area-context" + +const HabitPage: React.FC = () => { + const { habitId } = useLocalSearchParams() + + return ( + + Habit Page {habitId} + + ) +} + +export default HabitPage diff --git a/app/application/habits/history.tsx b/app/application/habits/history.tsx index ffcae32..4513654 100644 --- a/app/application/habits/history.tsx +++ b/app/application/habits/history.tsx @@ -1,5 +1,4 @@ import { useState } from "react" -import { StyleSheet } from "react-native" import { Calendar } from "react-native-calendars" import { SafeAreaView } from "react-native-safe-area-context" @@ -7,7 +6,15 @@ const HistoryPage: React.FC = () => { const [selected, setSelected] = useState("") return ( - + { setSelected(day.dateString) @@ -37,12 +44,4 @@ const HistoryPage: React.FC = () => { ) } -const styles = StyleSheet.create({ - container: { - flex: 1, - alignItems: "center", - justifyContent: "center", - }, -}) - export default HistoryPage diff --git a/app/application/habits/index.tsx b/app/application/habits/index.tsx index 04ce75b..46a36e9 100644 --- a/app/application/habits/index.tsx +++ b/app/application/habits/index.tsx @@ -1,79 +1,23 @@ -import FontAwesome6 from "@expo/vector-icons/FontAwesome6" -import { FlatList, StyleSheet } from "react-native" -import { List } from "react-native-paper" import { SafeAreaView } from "react-native-safe-area-context" +import { HabitsHistory } from "@/presentation/react/components/HabitsHistory/HabitsHistory" import { useHabitsTracker } from "@/presentation/react/contexts/HabitsTracker" -import { colorsPresenter } from "@/presentation/presenters/utils/ColorsPresenter" const HabitsPage: React.FC = () => { const { habitsTracker } = useHabitsTracker() return ( - - - { - const { habit } = item - - return ( - { - return ( - - ) - }} - /> - ) - }} - /> - + + ) } -const styles = StyleSheet.create({ - container: { - flex: 1, - alignItems: "center", - }, - habitsList: { - width: "90%", - }, - habitItem: { - paddingVertical: 20, - paddingHorizontal: 10, - marginVertical: 10, - borderRadius: 10, - }, - habitItemIcon: { - width: 30, - }, -}) - export default HabitsPage diff --git a/app/application/habits/new.tsx b/app/application/habits/new.tsx index 5d6ac05..053a29a 100644 --- a/app/application/habits/new.tsx +++ b/app/application/habits/new.tsx @@ -1,21 +1,20 @@ -import { StyleSheet } from "react-native" import { Text } from "react-native-paper" import { SafeAreaView } from "react-native-safe-area-context" const NewHabitPage: React.FC = () => { return ( - + New Habit ) } -const styles = StyleSheet.create({ - container: { - flex: 1, - alignItems: "center", - justifyContent: "center", - }, -}) - export default NewHabitPage diff --git a/app/application/users/settings.tsx b/app/application/users/settings.tsx index dc59f25..1a4b9f9 100644 --- a/app/application/users/settings.tsx +++ b/app/application/users/settings.tsx @@ -1,4 +1,4 @@ -import { StyleSheet, Text } from "react-native" +import { Text } from "react-native" import { Button } from "react-native-paper" import { SafeAreaView } from "react-native-safe-area-context" @@ -12,7 +12,15 @@ const SettingsPage: React.FC = () => { } return ( - + Settings