From 54f2e1741ef64e76421562537f44c216ba23184d Mon Sep 17 00:00:00 2001 From: brongniart Date: Wed, 12 Mar 2025 14:12:22 +0100 Subject: [PATCH] correction navigation vers QuotePage en cliquant sur une quoteLittle --- .../what_the_fantasy/ui/navigations/AppNavigator.kt | 10 ++++++---- .../example/what_the_fantasy/ui/screens/AccueilPage.kt | 10 ++++++++-- .../what_the_fantasy/ui/screens/FavoritePage.kt | 9 ++++++++- .../example/what_the_fantasy/ui/screens/QuizEndPage.kt | 3 +-- .../example/what_the_fantasy/ui/screens/QuizPage.kt | 3 +-- 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/navigations/AppNavigator.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/navigations/AppNavigator.kt index d4c6fb4..6f13ca9 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/navigations/AppNavigator.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/navigations/AppNavigator.kt @@ -37,7 +37,7 @@ data class Quiz(val userIndex: Int, val idQuiz: Int) data class QuizEnd(val userIndex: Int, val idQuiz: Int, val pts: Int) @Serializable -data class Quote(val quoteId: Int, val userIndex: Int) +data class OneQuote(val quoteId: Int, val userIndex: Int) @Serializable data object Search @@ -76,7 +76,8 @@ fun AppNavigator() { index = accueil.userIndex, navFavorite = { navController.navigate(Favorite(accueil.userIndex)) }, navQuiz = { navController.navigate(QuizMenu(accueil.userIndex)) }, - navProfil = { navController.navigate(Profil(accueil.userIndex)) } + navProfil = { navController.navigate(Profil(accueil.userIndex)) }, + navQuote = { quoteId -> navController.navigate(OneQuote(quoteId,accueil.userIndex)) } ) } composable { @@ -86,6 +87,7 @@ fun AppNavigator() { navAccueil = { navController.navigate(Accueil(favorite.userIndex)) }, navQuiz = { navController.navigate(QuizMenu(favorite.userIndex)) }, navProfil = { navController.navigate(Profil(favorite.userIndex)) }, + navQuote = { quoteId -> navController.navigate(OneQuote(quoteId,favorite.userIndex)) }, services = services ) } @@ -104,8 +106,8 @@ fun AppNavigator() { services = services ) } - composable { - val quote: Quote = it.toRoute() + composable { + val quote: OneQuote = it.toRoute() QuotePage( quoteId = quote.quoteId, index = quote.userIndex, diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/AccueilPage.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/AccueilPage.kt index 666e669..008a191 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/AccueilPage.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/AccueilPage.kt @@ -1,6 +1,7 @@ package com.example.what_the_fantasy.ui.screens import androidx.compose.foundation.background +import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items @@ -25,7 +26,8 @@ fun AccueilPage( index: Int, navFavorite: (Int) -> Unit, navQuiz: (Int) -> Unit, - navProfil: (Int) -> Unit + navProfil: (Int) -> Unit, + navQuote: (Int) -> Unit ) { var itemCount by remember { mutableStateOf(15) } val dailyQuote = DailyQuoteStub.dailyQuote @@ -70,7 +72,11 @@ fun AccueilPage( ) } items(quotes) { quote -> - QuoteLittle(quote) + Column(Modifier.clickable {navQuote(quote.id)} + ) { + QuoteLittle(quote) + Spacer(modifier = Modifier.height(16.dp)) + } } if (itemCount < QuoteStub.allQuotes.size) { item { diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/FavoritePage.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/FavoritePage.kt index 3ba32aa..08ce333 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/FavoritePage.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/FavoritePage.kt @@ -1,6 +1,7 @@ package com.example.what_the_fantasy.ui.screens import androidx.compose.foundation.background +import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items @@ -16,6 +17,7 @@ import com.example.what_the_fantasy.data.local.FavoriteStub import com.example.what_the_fantasy.data.services.IServices import com.example.what_the_fantasy.ui.components.NavBar import com.example.what_the_fantasy.ui.components.QuoteLittle +import com.example.what_the_fantasy.ui.navigations.OneQuote import com.example.what_the_fantasy.ui.theme.colorBackground @Composable @@ -24,6 +26,7 @@ fun FavoritePage( navAccueil: (Int) -> Unit, navQuiz: (Int) -> Unit, navProfil: (Int) -> Unit, + navQuote: (Int) -> Unit, services: IServices ) { val user = services.getUserById(index) ?: return @@ -55,7 +58,11 @@ fun FavoritePage( ) } items(quotes) { quote -> - QuoteLittle(quote) + Column (Modifier.clickable { navQuote( quote.id )} ){ + QuoteLittle(quote) + + Spacer(modifier = Modifier.height(16.dp)) + } } } } diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuizEndPage.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuizEndPage.kt index 6578b17..491db9a 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuizEndPage.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuizEndPage.kt @@ -44,8 +44,7 @@ fun QuizEndPage( navProfil:(Int) -> Unit, navQuiz: (Int) -> Unit, ) { - NavBar(onQuiz = true, - index = index, + NavBar(index = index, navControllerFavorite = navFavorite, navControllerAccueil = navAccueil, navControllerProfil = navProfil, diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuizPage.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuizPage.kt index e20a5f2..05fdf2f 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuizPage.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuizPage.kt @@ -61,8 +61,7 @@ fun QuizPage( if (idCurrentQuestion < questions.size - 1) idCurrentQuestion++ else navControllerQuizEnd(idQuiz, pts) // Retour menu } - NavBar(onQuiz = true, - index = index, + NavBar(index = index, navControllerFavorite = navFavorite, navControllerAccueil = navAccueil, navControllerProfil = navProfil,