|
|
@ -1,6 +1,12 @@
|
|
|
|
package com.example.what_the_fantasy.ui.navigations
|
|
|
|
package com.example.what_the_fantasy.ui.navigations
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.compose.foundation.layout.Box
|
|
|
|
|
|
|
|
import androidx.compose.foundation.layout.fillMaxSize
|
|
|
|
|
|
|
|
import androidx.compose.foundation.layout.padding
|
|
|
|
|
|
|
|
import androidx.compose.material3.Scaffold
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
|
|
|
|
import androidx.compose.ui.graphics.Color
|
|
|
|
import androidx.navigation.compose.NavHost
|
|
|
|
import androidx.navigation.compose.NavHost
|
|
|
|
import androidx.navigation.compose.composable
|
|
|
|
import androidx.navigation.compose.composable
|
|
|
|
import androidx.navigation.compose.rememberNavController
|
|
|
|
import androidx.navigation.compose.rememberNavController
|
|
|
@ -16,6 +22,7 @@ import com.example.what_the_fantasy.ui.screens.QuotePage
|
|
|
|
import com.example.what_the_fantasy.ui.screens.SearchPage
|
|
|
|
import com.example.what_the_fantasy.ui.screens.SearchPage
|
|
|
|
import com.example.what_the_fantasy.ui.screens.SignUpPage
|
|
|
|
import com.example.what_the_fantasy.ui.screens.SignUpPage
|
|
|
|
import com.example.what_the_fantasy.ui.screens.SubmitQuotePage
|
|
|
|
import com.example.what_the_fantasy.ui.screens.SubmitQuotePage
|
|
|
|
|
|
|
|
import com.example.what_the_fantasy.ui.theme.colorNavBar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sealed class Destination(val route: String) {
|
|
|
|
sealed class Destination(val route: String) {
|
|
|
@ -40,7 +47,6 @@ sealed class Destination(val route: String) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
data object Quiz : Destination("Quiz")
|
|
|
|
data object Quiz : Destination("Quiz")
|
|
|
|
data object QuizEnd : Destination("QuizEnd/{idQuiz}/{pts}") {
|
|
|
|
data object QuizEnd : Destination("QuizEnd/{idQuiz}/{pts}") {
|
|
|
|
// Ajout paramètres idQuiz et pts
|
|
|
|
|
|
|
|
fun createIdAndPts(idQuiz : Int, pts : Int) = "QuizEnd/$idQuiz/$pts"
|
|
|
|
fun createIdAndPts(idQuiz : Int, pts : Int) = "QuizEnd/$idQuiz/$pts"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -49,122 +55,131 @@ sealed class Destination(val route: String) {
|
|
|
|
fun AppNavigator() {
|
|
|
|
fun AppNavigator() {
|
|
|
|
val navController = rememberNavController()
|
|
|
|
val navController = rememberNavController()
|
|
|
|
val services = ServicesStub()
|
|
|
|
val services = ServicesStub()
|
|
|
|
NavHost(navController, startDestination = Destination.Login.route) {
|
|
|
|
|
|
|
|
composable(Destination.Login.route) {
|
|
|
|
Scaffold(
|
|
|
|
LoginPage(
|
|
|
|
modifier = Modifier.fillMaxSize(),
|
|
|
|
navControllerSignUp = {
|
|
|
|
containerColor = colorNavBar
|
|
|
|
navController.navigate(Destination.SignUp.route)
|
|
|
|
) { paddingValues ->
|
|
|
|
},
|
|
|
|
Box(modifier = Modifier.padding(paddingValues)) {
|
|
|
|
navControllerProfil = { userIndex ->
|
|
|
|
NavHost(navController, startDestination = Destination.Login.route) {
|
|
|
|
navController.navigate(Destination.Profil.createRoute(userIndex)) {
|
|
|
|
composable(Destination.Login.route) {
|
|
|
|
// Vider pile de navigation pour empêcher le retour à la page Login
|
|
|
|
LoginPage(
|
|
|
|
popUpTo(Destination.Login.route) { inclusive = true }
|
|
|
|
navControllerSignUp = {
|
|
|
|
}
|
|
|
|
navController.navigate(Destination.SignUp.route)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
services
|
|
|
|
navControllerProfil = { userIndex ->
|
|
|
|
)
|
|
|
|
navController.navigate(Destination.Profil.createRoute(userIndex)) {
|
|
|
|
}
|
|
|
|
popUpTo(Destination.Login.route) { inclusive = true }
|
|
|
|
composable(Destination.Accueil.route) { backStackEntry ->
|
|
|
|
}
|
|
|
|
val userIndex = backStackEntry.arguments?.getString("userIndex")?.toInt() ?: -1
|
|
|
|
},
|
|
|
|
AccueilPage(
|
|
|
|
services
|
|
|
|
index = userIndex,
|
|
|
|
)
|
|
|
|
navFavorite = { userIndex ->
|
|
|
|
|
|
|
|
navController.navigate(Destination.Favorite.createRoute(userIndex)) {
|
|
|
|
|
|
|
|
popUpTo(Destination.Accueil.createRoute(userIndex)) { inclusive = false }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
navQuiz = { userIndex ->
|
|
|
|
|
|
|
|
navController.navigate(Destination.QuizMenu.createRoute(userIndex)) {
|
|
|
|
|
|
|
|
popUpTo(Destination.Accueil.createRoute(userIndex)) { inclusive = false }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
navProfil = { userIndex ->
|
|
|
|
|
|
|
|
navController.navigate(Destination.Profil.createRoute(userIndex)) {
|
|
|
|
|
|
|
|
popUpTo(Destination.Accueil.createRoute(userIndex)) { inclusive = false }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
composable(Destination.Accueil.route) { backStackEntry ->
|
|
|
|
}
|
|
|
|
val userIndex = backStackEntry.arguments?.getString("userIndex")?.toInt() ?: -1
|
|
|
|
composable(Destination.Favorite.route) {
|
|
|
|
AccueilPage(
|
|
|
|
val userIndex = it.arguments?.getString("userIndex")?.toInt() ?: -1
|
|
|
|
index = userIndex,
|
|
|
|
FavoritePage(
|
|
|
|
navFavorite = { userIndex ->
|
|
|
|
index = userIndex,
|
|
|
|
navController.navigate(Destination.Favorite.createRoute(userIndex)) {
|
|
|
|
navAccueil ={ userIndex ->
|
|
|
|
popUpTo(Destination.Accueil.createRoute(userIndex)) { inclusive = false }
|
|
|
|
navController.navigate(Destination.Accueil.createRoute(userIndex)) // Passe l'index à Profil
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
navQuiz = { userIndex ->
|
|
|
|
navQuiz = { userIndex ->
|
|
|
|
navController.navigate(Destination.QuizMenu.createRoute(userIndex)) // Passe l'index à Profil
|
|
|
|
navController.navigate(Destination.QuizMenu.createRoute(userIndex)) {
|
|
|
|
},
|
|
|
|
popUpTo(Destination.Accueil.createRoute(userIndex)) { inclusive = false }
|
|
|
|
navProfil = { userIndex ->
|
|
|
|
}
|
|
|
|
navController.navigate(Destination.Profil.createRoute(userIndex)) // Passe l'index à Profil
|
|
|
|
},
|
|
|
|
|
|
|
|
navProfil = { userIndex ->
|
|
|
|
|
|
|
|
navController.navigate(Destination.Profil.createRoute(userIndex)) {
|
|
|
|
|
|
|
|
popUpTo(Destination.Accueil.createRoute(userIndex)) { inclusive = false }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
) }
|
|
|
|
composable(Destination.Favorite.route) {
|
|
|
|
composable(Destination.Profil.route) {
|
|
|
|
val userIndex = it.arguments?.getString("userIndex")?.toInt() ?: -1
|
|
|
|
// Récupère l'index passé dans la route
|
|
|
|
FavoritePage(
|
|
|
|
val userIndex = it.arguments?.getString("userIndex")?.toInt() ?: -1
|
|
|
|
index = userIndex,
|
|
|
|
ProfilPage(
|
|
|
|
navAccueil = { userIndex ->
|
|
|
|
index = userIndex,
|
|
|
|
navController.navigate(Destination.Accueil.createRoute(userIndex))
|
|
|
|
navFavorite = { userIndex ->
|
|
|
|
},
|
|
|
|
navController.navigate(Destination.Favorite.createRoute(userIndex)) // Passe l'index à Profil
|
|
|
|
navQuiz = { userIndex ->
|
|
|
|
},
|
|
|
|
navController.navigate(Destination.QuizMenu.createRoute(userIndex))
|
|
|
|
navAccueil ={ userIndex ->
|
|
|
|
},
|
|
|
|
navController.navigate(Destination.Accueil.createRoute(userIndex)) // Passe l'index à Profil
|
|
|
|
navProfil = { userIndex ->
|
|
|
|
},
|
|
|
|
navController.navigate(Destination.Profil.createRoute(userIndex))
|
|
|
|
navQuiz = { userIndex ->
|
|
|
|
},
|
|
|
|
navController.navigate(Destination.QuizMenu.createRoute(userIndex)) // Passe l'index à Profil
|
|
|
|
services
|
|
|
|
},
|
|
|
|
)
|
|
|
|
navUnLog = {
|
|
|
|
|
|
|
|
navController.navigate(Destination.Login.route) {
|
|
|
|
|
|
|
|
// Vider pile de navigation pour empêcher le retour à la page profil
|
|
|
|
|
|
|
|
popUpTo(Destination.Profil.route) { inclusive = true }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
services = services
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
composable(Destination.Quote.route) { QuotePage() }
|
|
|
|
|
|
|
|
composable(Destination.Search.route) { SearchPage() }
|
|
|
|
|
|
|
|
composable(Destination.SignUp.route) { SignUpPage(
|
|
|
|
|
|
|
|
navControllerLogin = {
|
|
|
|
|
|
|
|
navController.navigate(Destination.Login.route){
|
|
|
|
|
|
|
|
// Vider pile de navigation pour empêcher le retour à la page Sign up
|
|
|
|
|
|
|
|
popUpTo(Destination.Login.route) { inclusive = true }
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},services) }
|
|
|
|
composable(Destination.Profil.route) {
|
|
|
|
composable(Destination.SubmitQuote.route) { SubmitQuotePage() }
|
|
|
|
val userIndex = it.arguments?.getString("userIndex")?.toInt() ?: -1
|
|
|
|
|
|
|
|
ProfilPage(
|
|
|
|
composable(Destination.QuizMenu.route) {
|
|
|
|
index = userIndex,
|
|
|
|
val userIndex = it.arguments?.getString("userIndex")?.toInt() ?: -1
|
|
|
|
navFavorite = { userIndex ->
|
|
|
|
QuizMenu(
|
|
|
|
navController.navigate(Destination.Favorite.createRoute(userIndex))
|
|
|
|
index = userIndex,
|
|
|
|
},
|
|
|
|
navAccueil = { userIndex ->
|
|
|
|
navAccueil = { userIndex ->
|
|
|
|
navController.navigate(Destination.Accueil.createRoute(userIndex)) // Passe l'index à Profil
|
|
|
|
navController.navigate(Destination.Accueil.createRoute(userIndex))
|
|
|
|
},
|
|
|
|
},
|
|
|
|
navFavorite = { userIndex ->
|
|
|
|
navQuiz = { userIndex ->
|
|
|
|
navController.navigate(Destination.Favorite.createRoute(userIndex)) // Passe l'index à Profil
|
|
|
|
navController.navigate(Destination.QuizMenu.createRoute(userIndex))
|
|
|
|
},
|
|
|
|
},
|
|
|
|
navControllerQuiz = { navController.navigate(Destination.Quiz.route) },
|
|
|
|
navUnLog = {
|
|
|
|
navProfil = { userIndex ->
|
|
|
|
navController.navigate(Destination.Login.route) {
|
|
|
|
navController.navigate(Destination.Profil.createRoute(userIndex)) // Passe l'index à Profil
|
|
|
|
popUpTo(Destination.Profil.route) { inclusive = true }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
services = services
|
|
|
|
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
composable(Destination.Quote.route) { QuotePage() }
|
|
|
|
}
|
|
|
|
composable(Destination.Search.route) { SearchPage() }
|
|
|
|
composable(Destination.Quiz.route) {
|
|
|
|
composable(Destination.SignUp.route) {
|
|
|
|
QuizPage(
|
|
|
|
SignUpPage(
|
|
|
|
navControllerQuizEnd = { idQuiz, pts ->
|
|
|
|
navControllerLogin = {
|
|
|
|
navController.navigate(Destination.QuizEnd.createIdAndPts(idQuiz, pts))
|
|
|
|
navController.navigate(Destination.Login.route) {
|
|
|
|
},
|
|
|
|
popUpTo(Destination.Login.route) { inclusive = true }
|
|
|
|
navControllerQuizMenu = { navController.navigate(Destination.QuizMenu.route) }
|
|
|
|
}
|
|
|
|
)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
services
|
|
|
|
composable(Destination.QuizEnd.route) { backStackEntry ->
|
|
|
|
)
|
|
|
|
val idQuiz = backStackEntry.arguments?.getString("idQuiz")?.toInt() ?: 0
|
|
|
|
}
|
|
|
|
val pts = backStackEntry.arguments?.getString("pts")?.toInt() ?: 0
|
|
|
|
composable(Destination.SubmitQuote.route) { SubmitQuotePage() }
|
|
|
|
QuizEndPage(
|
|
|
|
composable(Destination.QuizMenu.route) {
|
|
|
|
idQuiz,
|
|
|
|
val userIndex = it.arguments?.getString("userIndex")?.toInt() ?: -1
|
|
|
|
pts,
|
|
|
|
QuizMenu(
|
|
|
|
navControllerQuizMenu = { navController.navigate(Destination.QuizMenu.route) }
|
|
|
|
index = userIndex,
|
|
|
|
)
|
|
|
|
navAccueil = { userIndex ->
|
|
|
|
|
|
|
|
navController.navigate(Destination.Accueil.createRoute(userIndex))
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
navFavorite = { userIndex ->
|
|
|
|
|
|
|
|
navController.navigate(Destination.Favorite.createRoute(userIndex))
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
navControllerQuiz = { navController.navigate(Destination.Quiz.route) },
|
|
|
|
|
|
|
|
navProfil = { userIndex ->
|
|
|
|
|
|
|
|
navController.navigate(Destination.Profil.createRoute(userIndex))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
composable(Destination.Quiz.route) {
|
|
|
|
|
|
|
|
QuizPage(
|
|
|
|
|
|
|
|
navControllerQuizEnd = { idQuiz, pts ->
|
|
|
|
|
|
|
|
navController.navigate(Destination.QuizEnd.createIdAndPts(idQuiz, pts))
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
navControllerQuizMenu = { navController.navigate(Destination.QuizMenu.route) }
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
composable(Destination.QuizEnd.route) { backStackEntry ->
|
|
|
|
|
|
|
|
val idQuiz = backStackEntry.arguments?.getString("idQuiz")?.toInt() ?: 0
|
|
|
|
|
|
|
|
val pts = backStackEntry.arguments?.getString("pts")?.toInt() ?: 0
|
|
|
|
|
|
|
|
QuizEndPage(
|
|
|
|
|
|
|
|
idQuiz,
|
|
|
|
|
|
|
|
pts,
|
|
|
|
|
|
|
|
navControllerQuizMenu = { navController.navigate(Destination.QuizMenu.route) }
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|