refactor: pages routes

This commit is contained in:
Théo LUDWIG 2024-03-15 23:24:08 +01:00
parent f73dfbd3ef
commit 164b024e1f
Signed by: theoludwig
GPG Key ID: ADFE5A563D718F3B
9 changed files with 91 additions and 108 deletions

View File

@ -31,7 +31,7 @@ const TabLayout: React.FC = () => {
}}
/>
<Tabs.Screen
name="newHabit"
name="habits/new"
options={{
title: "New Habit",
tabBarIcon: ({ color }) => {
@ -40,7 +40,17 @@ const TabLayout: React.FC = () => {
}}
/>
<Tabs.Screen
name="history"
name="habits/index"
options={{
headerShown: false,
title: "Habits",
tabBarIcon: ({ color }) => {
return <TabBarIcon name="sticky-note" color={color} />
},
}}
/>
<Tabs.Screen
name="habits/history"
options={{
title: "History",
tabBarIcon: ({ color }) => {
@ -49,7 +59,7 @@ const TabLayout: React.FC = () => {
}}
/>
<Tabs.Screen
name="settings"
name="users/settings"
options={{
title: "Settings",
tabBarIcon: ({ color }) => {
@ -58,7 +68,7 @@ const TabLayout: React.FC = () => {
}}
/>
<Tabs.Screen
name="login"
name="authentication/login"
options={{
title: "Login",
tabBarIcon: ({ color }) => {
@ -67,7 +77,7 @@ const TabLayout: React.FC = () => {
}}
/>
<Tabs.Screen
name="register"
name="authentication/register"
options={{
title: "Register",
tabBarIcon: ({ color }) => {

View File

@ -1,25 +1,20 @@
import { StyleSheet, Image } from "react-native"
import { useState } from "react"
import { Image, StyleSheet } from "react-native"
import {
Button,
TextInput,
HelperText,
ActivityIndicator,
Banner,
Button,
HelperText,
TextInput,
} from "react-native-paper"
import { SafeAreaView } from "react-native-safe-area-context"
import * as React from "react"
const LoginPage: React.FC = () => {
// Gérer l'état de votre formulaire ici : timeout, invalidité, etc.
// Possible de changer le type comme string.
const [hasError, _sethasError] = React.useState<boolean>(true)
const [hasError, _sethasError] = useState<boolean>(true)
// Message d'erreur à afficher pour HelperText
const [errorMessage, _setErrorMessage] =
React.useState<string>("Error message")
const [errorMessage, _setErrorMessage] = useState<string>("Error message")
// Affichage de l'indicateur de chargement
const [isPerfomingLogin, _setIsPerfomingLogin] = React.useState<boolean>(true)
const [isPerfomingLogin, _setIsPerfomingLogin] = useState<boolean>(true)
return (
<SafeAreaView style={styles.container}>
@ -28,9 +23,6 @@ const LoginPage: React.FC = () => {
actions={[
{
label: "Report this problem",
onPress: () => {
return console.log("Pressed")
},
},
]}
icon={({ size }) => {
@ -54,15 +46,7 @@ const LoginPage: React.FC = () => {
<HelperText type="error" visible={hasError} style={styles.errorText}>
{errorMessage}
</HelperText>
<Button
mode="contained"
onPress={() => {
return console.log("Pressed")
// TODO: Implement login logic
}}
>
Login
</Button>
<Button mode="contained">Login</Button>
<ActivityIndicator
animating={isPerfomingLogin}
color="blue"

View File

@ -1,21 +1,14 @@
import { StyleSheet, Image } from "react-native"
import {
Button,
TextInput,
HelperText,
ActivityIndicator as _ActivityIndicator,
Banner,
} from "react-native-paper"
import { useState } from "react"
import { Image, StyleSheet } from "react-native"
import { Banner, Button, HelperText, TextInput } from "react-native-paper"
import { SafeAreaView } from "react-native-safe-area-context"
import * as React from "react"
const RegisterPage: React.FC = () => {
const regexEmail = /^[\w.-]+@[\d.A-Za-z-]+\.[A-Za-z]{2,4}$/
const [password, setPassword] = React.useState<string>("")
const [isPasswordCorrect, setIsPasswordCorrect] =
React.useState<boolean>(true)
const [isEmailValid, setIsEmailValid] = React.useState<boolean>(true)
const [password, setPassword] = useState<string>("")
const [isPasswordCorrect, setIsPasswordCorrect] = useState<boolean>(true)
const [isEmailValid, setIsEmailValid] = useState<boolean>(true)
return (
<SafeAreaView style={styles.container}>

View File

@ -1,22 +1,13 @@
import { useState } from "react"
import { StyleSheet } from "react-native"
import { Button } from "react-native-paper"
import { Calendar } from "react-native-calendars"
import { SafeAreaView } from "react-native-safe-area-context"
import { useState } from "react"
const History: React.FC = () => {
const HistoryPage: React.FC = () => {
const [selected, setSelected] = useState("")
return (
<SafeAreaView style={styles.container}>
<Button
mode="contained"
onPress={() => {
return console.log("Pressed")
}}
>
Press me
</Button>
<Calendar
onDayPress={(day) => {
setSelected(day.dateString)
@ -54,4 +45,4 @@ const styles = StyleSheet.create({
},
})
export default History
export default HistoryPage

View File

@ -0,0 +1,34 @@
import { StyleSheet, Text, View } from "react-native"
import { SafeAreaView } from "react-native-safe-area-context"
import { useHabitsTracker } from "@/contexts/HabitsTracker"
const HabitsPage: React.FC = () => {
const { habitsTrackerPresenterState } = useHabitsTracker()
const { habitsTracker } = habitsTrackerPresenterState
const { habitProgressHistories } = habitsTracker
return (
<SafeAreaView style={styles.container}>
{habitProgressHistories.map((progressHistory) => {
const { habit } = progressHistory
return (
<View key={habit.id}>
<Text>{habit.name}</Text>
</View>
)
})}
</SafeAreaView>
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: "center",
justifyContent: "center",
},
})
export default HabitsPage

View File

@ -1,18 +1,11 @@
import { StyleSheet } from "react-native"
import { Button } from "react-native-paper"
import { Text } from "react-native-paper"
import { SafeAreaView } from "react-native-safe-area-context"
const NewHabitPage: React.FC = () => {
return (
<SafeAreaView style={styles.container}>
<Button
mode="contained"
onPress={() => {
return console.log("Pressed")
}}
>
Press me
</Button>
<Text>New Habit</Text>
</SafeAreaView>
)
}

View File

@ -1,24 +1,10 @@
import { StyleSheet, Text, View } from "react-native"
import { StyleSheet, Text } from "react-native"
import { SafeAreaView } from "react-native-safe-area-context"
import { useHabitsTracker } from "@/contexts/HabitsTracker"
const HomePage: React.FC = () => {
const { habitsTrackerPresenterState } = useHabitsTracker()
const { habitsTracker } = habitsTrackerPresenterState
const { habitProgressHistories } = habitsTracker
return (
<SafeAreaView style={styles.container}>
{habitProgressHistories.map((progressHistory) => {
const { habit } = progressHistory
return (
<View key={habit.id}>
<Text>{habit.name}</Text>
</View>
)
})}
<Text>Home Page</Text>
</SafeAreaView>
)
}

View File

@ -1,28 +0,0 @@
import { StyleSheet } from "react-native"
import { Button } from "react-native-paper"
import { SafeAreaView } from "react-native-safe-area-context"
const Settings: React.FC = () => {
return (
<SafeAreaView style={styles.container}>
<Button
mode="contained"
onPress={() => {
return console.log("Pressed")
}}
>
Press me
</Button>
</SafeAreaView>
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: "center",
justifyContent: "center",
},
})
export default Settings

View File

@ -0,0 +1,20 @@
import { StyleSheet, Text } from "react-native"
import { SafeAreaView } from "react-native-safe-area-context"
const SettingsPage: React.FC = () => {
return (
<SafeAreaView style={styles.container}>
<Text>Settings</Text>
</SafeAreaView>
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: "center",
justifyContent: "center",
},
})
export default SettingsPage