1
1
mirror of https://github.com/theoludwig/p61-project.git synced 2024-07-17 07:00:12 +02:00

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 <Tabs.Screen
name="newHabit" name="habits/new"
options={{ options={{
title: "New Habit", title: "New Habit",
tabBarIcon: ({ color }) => { tabBarIcon: ({ color }) => {
@ -40,7 +40,17 @@ const TabLayout: React.FC = () => {
}} }}
/> />
<Tabs.Screen <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={{ options={{
title: "History", title: "History",
tabBarIcon: ({ color }) => { tabBarIcon: ({ color }) => {
@ -49,7 +59,7 @@ const TabLayout: React.FC = () => {
}} }}
/> />
<Tabs.Screen <Tabs.Screen
name="settings" name="users/settings"
options={{ options={{
title: "Settings", title: "Settings",
tabBarIcon: ({ color }) => { tabBarIcon: ({ color }) => {
@ -58,7 +68,7 @@ const TabLayout: React.FC = () => {
}} }}
/> />
<Tabs.Screen <Tabs.Screen
name="login" name="authentication/login"
options={{ options={{
title: "Login", title: "Login",
tabBarIcon: ({ color }) => { tabBarIcon: ({ color }) => {
@ -67,7 +77,7 @@ const TabLayout: React.FC = () => {
}} }}
/> />
<Tabs.Screen <Tabs.Screen
name="register" name="authentication/register"
options={{ options={{
title: "Register", title: "Register",
tabBarIcon: ({ color }) => { 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 { import {
Button,
TextInput,
HelperText,
ActivityIndicator, ActivityIndicator,
Banner, Banner,
Button,
HelperText,
TextInput,
} from "react-native-paper" } from "react-native-paper"
import { SafeAreaView } from "react-native-safe-area-context" import { SafeAreaView } from "react-native-safe-area-context"
import * as React from "react"
const LoginPage: React.FC = () => { const LoginPage: React.FC = () => {
// Gérer l'état de votre formulaire ici : timeout, invalidité, etc. const [hasError, _sethasError] = useState<boolean>(true)
// Possible de changer le type comme string.
const [hasError, _sethasError] = React.useState<boolean>(true)
// Message d'erreur à afficher pour HelperText const [errorMessage, _setErrorMessage] = useState<string>("Error message")
const [errorMessage, _setErrorMessage] =
React.useState<string>("Error message")
// Affichage de l'indicateur de chargement const [isPerfomingLogin, _setIsPerfomingLogin] = useState<boolean>(true)
const [isPerfomingLogin, _setIsPerfomingLogin] = React.useState<boolean>(true)
return ( return (
<SafeAreaView style={styles.container}> <SafeAreaView style={styles.container}>
@ -28,9 +23,6 @@ const LoginPage: React.FC = () => {
actions={[ actions={[
{ {
label: "Report this problem", label: "Report this problem",
onPress: () => {
return console.log("Pressed")
},
}, },
]} ]}
icon={({ size }) => { icon={({ size }) => {
@ -54,15 +46,7 @@ const LoginPage: React.FC = () => {
<HelperText type="error" visible={hasError} style={styles.errorText}> <HelperText type="error" visible={hasError} style={styles.errorText}>
{errorMessage} {errorMessage}
</HelperText> </HelperText>
<Button <Button mode="contained">Login</Button>
mode="contained"
onPress={() => {
return console.log("Pressed")
// TODO: Implement login logic
}}
>
Login
</Button>
<ActivityIndicator <ActivityIndicator
animating={isPerfomingLogin} animating={isPerfomingLogin}
color="blue" color="blue"

View File

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

View File

@ -1,22 +1,13 @@
import { useState } from "react"
import { StyleSheet } from "react-native" import { StyleSheet } from "react-native"
import { Button } from "react-native-paper"
import { Calendar } from "react-native-calendars" import { Calendar } from "react-native-calendars"
import { SafeAreaView } from "react-native-safe-area-context" import { SafeAreaView } from "react-native-safe-area-context"
import { useState } from "react"
const History: React.FC = () => { const HistoryPage: React.FC = () => {
const [selected, setSelected] = useState("") const [selected, setSelected] = useState("")
return ( return (
<SafeAreaView style={styles.container}> <SafeAreaView style={styles.container}>
<Button
mode="contained"
onPress={() => {
return console.log("Pressed")
}}
>
Press me
</Button>
<Calendar <Calendar
onDayPress={(day) => { onDayPress={(day) => {
setSelected(day.dateString) 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 { StyleSheet } from "react-native"
import { Button } from "react-native-paper" import { Text } from "react-native-paper"
import { SafeAreaView } from "react-native-safe-area-context" import { SafeAreaView } from "react-native-safe-area-context"
const NewHabitPage: React.FC = () => { const NewHabitPage: React.FC = () => {
return ( return (
<SafeAreaView style={styles.container}> <SafeAreaView style={styles.container}>
<Button <Text>New Habit</Text>
mode="contained"
onPress={() => {
return console.log("Pressed")
}}
>
Press me
</Button>
</SafeAreaView> </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 { SafeAreaView } from "react-native-safe-area-context"
import { useHabitsTracker } from "@/contexts/HabitsTracker"
const HomePage: React.FC = () => { const HomePage: React.FC = () => {
const { habitsTrackerPresenterState } = useHabitsTracker()
const { habitsTracker } = habitsTrackerPresenterState
const { habitProgressHistories } = habitsTracker
return ( return (
<SafeAreaView style={styles.container}> <SafeAreaView style={styles.container}>
{habitProgressHistories.map((progressHistory) => { <Text>Home Page</Text>
const { habit } = progressHistory
return (
<View key={habit.id}>
<Text>{habit.name}</Text>
</View>
)
})}
</SafeAreaView> </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