|
|
@ -4,12 +4,13 @@ import androidx.compose.runtime.Composable
|
|
|
|
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
|
|
|
|
|
|
|
|
import com.example.what_the_fantasy.data.services.ServicesStub
|
|
|
|
import com.example.what_the_fantasy.ui.screens.AccueilPage
|
|
|
|
import com.example.what_the_fantasy.ui.screens.AccueilPage
|
|
|
|
import com.example.what_the_fantasy.ui.screens.FavoritePage
|
|
|
|
import com.example.what_the_fantasy.ui.screens.FavoritePage
|
|
|
|
import com.example.what_the_fantasy.ui.screens.LoginPage
|
|
|
|
import com.example.what_the_fantasy.ui.screens.LoginPage
|
|
|
|
import com.example.what_the_fantasy.ui.screens.ProfilPage
|
|
|
|
import com.example.what_the_fantasy.ui.screens.ProfilPage
|
|
|
|
import com.example.what_the_fantasy.ui.screens.QuizAccueil
|
|
|
|
|
|
|
|
import com.example.what_the_fantasy.ui.screens.QuizEndPage
|
|
|
|
import com.example.what_the_fantasy.ui.screens.QuizEndPage
|
|
|
|
|
|
|
|
import com.example.what_the_fantasy.ui.screens.QuizMenu
|
|
|
|
import com.example.what_the_fantasy.ui.screens.QuizPage
|
|
|
|
import com.example.what_the_fantasy.ui.screens.QuizPage
|
|
|
|
import com.example.what_the_fantasy.ui.screens.QuotePage
|
|
|
|
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
|
|
|
@ -17,11 +18,14 @@ 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sealed class Destination(val route: String) {
|
|
|
|
sealed class Destination(val route: String) {
|
|
|
|
data object Login : Destination("Login")
|
|
|
|
data object Login : Destination("Login")
|
|
|
|
data object Accueil : Destination("Accueil")
|
|
|
|
data object Accueil : Destination("Accueil/{userIndex}") { // Ajout du paramètre userIndex
|
|
|
|
data object Favorite : Destination("Favorite")
|
|
|
|
fun createRoute(userIndex: Int) = "Accueil/$userIndex" // Fonction pour créer la route avec l'index
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
data object Favorite : Destination("Favorite/{userIndex}") { // Ajout du paramètre userIndex
|
|
|
|
|
|
|
|
fun createRoute(userIndex: Int) = "Favorite/$userIndex" // Fonction pour créer la route avec l'index
|
|
|
|
|
|
|
|
}
|
|
|
|
data object Profil : Destination("Profil/{userIndex}") { // Ajout du paramètre userIndex
|
|
|
|
data object Profil : Destination("Profil/{userIndex}") { // Ajout du paramètre userIndex
|
|
|
|
fun createRoute(userIndex: Int) = "Profil/$userIndex" // Fonction pour créer la route avec l'index
|
|
|
|
fun createRoute(userIndex: Int) = "Profil/$userIndex" // Fonction pour créer la route avec l'index
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -31,37 +35,71 @@ sealed class Destination(val route: String) {
|
|
|
|
data object SignUp : Destination("SignUp")
|
|
|
|
data object SignUp : Destination("SignUp")
|
|
|
|
data object SubmitQuote : Destination("SubmitQuote")
|
|
|
|
data object SubmitQuote : Destination("SubmitQuote")
|
|
|
|
|
|
|
|
|
|
|
|
data object QuizAccueil : Destination("QuizAccueil")
|
|
|
|
data object QuizMenu : Destination("QuizMenu/{userIndex}") { // Ajout du paramètre userIndex
|
|
|
|
data object QuizPage : Destination("QuizPage")
|
|
|
|
fun createRoute(userIndex: Int) = "QuizMenu/$userIndex" // Fonction pour créer la route avec l'index
|
|
|
|
data object QuizEndPage : Destination("QuizEndPage")
|
|
|
|
}
|
|
|
|
|
|
|
|
data object Quiz : Destination("Quiz")
|
|
|
|
|
|
|
|
data object QuizEnd : Destination("QuizEnd/{idQuiz}/{pts}") {
|
|
|
|
|
|
|
|
// Ajout paramètres idQuiz et pts
|
|
|
|
|
|
|
|
fun createIdAndPts(idQuiz : Int, pts : Int) = "QuizEnd/$idQuiz/$pts"
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
@Composable
|
|
|
|
fun AppNavigator() {
|
|
|
|
fun AppNavigator() {
|
|
|
|
val navController = rememberNavController()
|
|
|
|
val navController = rememberNavController()
|
|
|
|
|
|
|
|
val services = ServicesStub()
|
|
|
|
NavHost(navController, startDestination = Destination.Accueil.route) {
|
|
|
|
NavHost(navController, startDestination = Destination.Login.route) {
|
|
|
|
composable(Destination.Login.route) { LoginPage(
|
|
|
|
composable(Destination.Login.route) { LoginPage(
|
|
|
|
navControllerSignUp = { navController.navigate(Destination.SignUp.route) },
|
|
|
|
navControllerSignUp = { navController.navigate(Destination.SignUp.route) },
|
|
|
|
navControllerProfil = { userIndex ->
|
|
|
|
navControllerProfil = { userIndex ->
|
|
|
|
navController.navigate(Destination.Profil.createRoute(userIndex)) // Passe l'index à Profil
|
|
|
|
navController.navigate(Destination.Profil.createRoute(userIndex)) // Passe l'index à Profil
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
services
|
|
|
|
) }
|
|
|
|
) }
|
|
|
|
composable(Destination.Accueil.route) { AccueilPage(
|
|
|
|
composable(Destination.Accueil.route) {
|
|
|
|
navFavorite = { navController.navigate(Destination.Favorite.route) },
|
|
|
|
val userIndex = it.arguments?.getString("userIndex")?.toInt() ?: -1
|
|
|
|
navQuiz = { navController.navigate(Destination.QuizAccueil.route) }
|
|
|
|
AccueilPage(
|
|
|
|
|
|
|
|
index = userIndex,
|
|
|
|
|
|
|
|
navFavorite = { userIndex ->
|
|
|
|
|
|
|
|
navController.navigate(Destination.Favorite.createRoute(userIndex)) // Passe l'index à Profil
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
navQuiz = { userIndex ->
|
|
|
|
|
|
|
|
navController.navigate(Destination.QuizMenu.createRoute(userIndex)) // Passe l'index à Profil
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
navProfil = { userIndex ->
|
|
|
|
|
|
|
|
navController.navigate(Destination.Profil.createRoute(userIndex)) // Passe l'index à Profil
|
|
|
|
|
|
|
|
}
|
|
|
|
) }
|
|
|
|
) }
|
|
|
|
composable(Destination.Favorite.route) { FavoritePage(
|
|
|
|
composable(Destination.Favorite.route) {
|
|
|
|
navAccueil = { navController.navigate(Destination.Accueil.route) },
|
|
|
|
val userIndex = it.arguments?.getString("userIndex")?.toInt() ?: -1
|
|
|
|
navQuiz = { navController.navigate(Destination.QuizAccueil.route) }
|
|
|
|
FavoritePage(
|
|
|
|
|
|
|
|
index = userIndex,
|
|
|
|
|
|
|
|
navAccueil ={ userIndex ->
|
|
|
|
|
|
|
|
navController.navigate(Destination.Accueil.createRoute(userIndex)) // Passe l'index à Profil
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
navQuiz = { userIndex ->
|
|
|
|
|
|
|
|
navController.navigate(Destination.QuizMenu.createRoute(userIndex)) // Passe l'index à Profil
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
navProfil = { userIndex ->
|
|
|
|
|
|
|
|
navController.navigate(Destination.Profil.createRoute(userIndex)) // Passe l'index à Profil
|
|
|
|
|
|
|
|
}
|
|
|
|
) }
|
|
|
|
) }
|
|
|
|
composable(Destination.Profil.route) { backStackEntry ->
|
|
|
|
composable(Destination.Profil.route) {
|
|
|
|
// Récupère l'index passé dans la route
|
|
|
|
// Récupère l'index passé dans la route
|
|
|
|
val userIndex = backStackEntry.arguments?.getString("userIndex")?.toInt() ?: -1
|
|
|
|
val userIndex = it.arguments?.getString("userIndex")?.toInt() ?: -1
|
|
|
|
ProfilPage(index = userIndex,
|
|
|
|
ProfilPage(
|
|
|
|
navController = navController,
|
|
|
|
index = userIndex,
|
|
|
|
|
|
|
|
navFavorite = { userIndex ->
|
|
|
|
|
|
|
|
navController.navigate(Destination.Favorite.createRoute(userIndex)) // Passe l'index à Profil
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
navAccueil ={ userIndex ->
|
|
|
|
|
|
|
|
navController.navigate(Destination.Accueil.createRoute(userIndex)) // Passe l'index à Profil
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
navQuiz = { userIndex ->
|
|
|
|
|
|
|
|
navController.navigate(Destination.QuizMenu.createRoute(userIndex)) // Passe l'index à Profil
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
services = services
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
composable(Destination.Quote.route) { QuotePage() }
|
|
|
|
composable(Destination.Quote.route) { QuotePage() }
|
|
|
@ -69,25 +107,35 @@ fun AppNavigator() {
|
|
|
|
composable(Destination.SignUp.route) { SignUpPage(navController) }
|
|
|
|
composable(Destination.SignUp.route) { SignUpPage(navController) }
|
|
|
|
composable(Destination.SubmitQuote.route) { SubmitQuotePage() }
|
|
|
|
composable(Destination.SubmitQuote.route) { SubmitQuotePage() }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
composable(Destination.QuizMenu.route) {
|
|
|
|
|
|
|
|
val userIndex = it.arguments?.getString("userIndex")?.toInt() ?: -1
|
|
|
|
composable(Destination.QuizAccueil.route) { QuizAccueil(
|
|
|
|
QuizMenu(
|
|
|
|
navFavorite = { navController.navigate(Destination.Favorite.route) },
|
|
|
|
index = userIndex,
|
|
|
|
navAccueil = { navController.navigate(Destination.Accueil.route) },
|
|
|
|
navAccueil = { navController.navigate(Destination.Accueil.route) },
|
|
|
|
|
|
|
|
navFavorite = { navController.navigate(Destination.Favorite.route) },
|
|
|
|
navControllerQuizPage = { navController.navigate(Destination.QuizPage.route) },
|
|
|
|
navControllerQuiz = { navController.navigate(Destination.Quiz.route) },
|
|
|
|
navControllerQuizEndPage = { navController.navigate(Destination.QuizEndPage.route) }
|
|
|
|
navProfil = { userIndex ->
|
|
|
|
) }
|
|
|
|
navController.navigate(Destination.Profil.createRoute(userIndex)) // Passe l'index à Profil
|
|
|
|
|
|
|
|
}
|
|
|
|
composable(Destination.QuizPage.route) { QuizPage(
|
|
|
|
)
|
|
|
|
navControllerQuiz = {navController.navigate(Destination.QuizAccueil.route)},
|
|
|
|
}
|
|
|
|
navControllerQuizEndPage = {navController.navigate(Destination.QuizEndPage.route)}
|
|
|
|
composable(Destination.Quiz.route) {
|
|
|
|
) }
|
|
|
|
QuizPage(
|
|
|
|
composable(Destination.QuizEndPage.route) { QuizEndPage(
|
|
|
|
navControllerQuizEnd = { idQuiz, pts ->
|
|
|
|
points = 5,
|
|
|
|
navController.navigate(Destination.QuizEnd.createIdAndPts(idQuiz, pts))
|
|
|
|
idQuiz = 1
|
|
|
|
},
|
|
|
|
) }
|
|
|
|
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) }
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|