From 5ba379ea9fac9803f0a6d76480ffec0985823e2f Mon Sep 17 00:00:00 2001 From: "kentin.brongniart" Date: Sun, 6 Apr 2025 12:44:18 +0200 Subject: [PATCH] test acceuil --- .../data/retrofit/ApiService.kt | 5 ++- .../data/services/ServicesAPI.kt | 5 ++- .../data/services/ServicesStub.kt | 2 +- .../ui/navigations/AppNavigator.kt | 2 +- .../ui/screens/AccueilPage.kt | 40 +++++++++++++------ 5 files changed, 36 insertions(+), 18 deletions(-) diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/retrofit/ApiService.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/retrofit/ApiService.kt index e301532..e168dd8 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/retrofit/ApiService.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/retrofit/ApiService.kt @@ -60,7 +60,10 @@ interface ApiService { ): Quote @GET("quote/{id}") - suspend fun getQuoteById(@Path("id")id : Int):Quote + suspend fun getQuoteById( + @Path("id")id : Int + ):Quote + @GET("quote/all") suspend fun getAllQuote( @Query("index") index: Int, diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/services/ServicesAPI.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/services/ServicesAPI.kt index 9c6222a..49f1b5c 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/services/ServicesAPI.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/services/ServicesAPI.kt @@ -271,8 +271,9 @@ class ServicesAPI : IServices { } override suspend fun getSomeQuotes(nb: Int, page: Int): MutableList { - val reponce = RetrofitInstance.api.getAllQuote(page,nb) - return reponce.items + val result = RetrofitInstance.api.getAllQuote(page,nb) + Log.d("test", result.toString()) + return result.items } @RequiresApi(Build.VERSION_CODES.O) diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/services/ServicesStub.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/services/ServicesStub.kt index aab0342..114244e 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/services/ServicesStub.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/services/ServicesStub.kt @@ -156,7 +156,7 @@ class ServicesStub : IServices { } override suspend fun getDalyQuote(langage: SrcLanguage): Quote { - TODO("Not yet implemented") + return quotes.first() } override suspend fun isFavorite(idQuote: Int, idUser: Int): Boolean { 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 be30590..55963ea 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 @@ -139,7 +139,7 @@ fun AppNavigator() { ) }, navSearch = { navController.navigate(Search(currentUserState.id))}, - services = services, + services = servicesStub, currentUserVM = currentUserVM, currentUserState = currentUserState, ) 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 d40ac8d..265e4a0 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 @@ -29,6 +29,7 @@ import com.example.what_the_fantasy.ui.components.QuoteLittle import com.example.what_the_fantasy.ui.states.CurrentUserState import com.example.what_the_fantasy.ui.viewModels.CurrentUserViewModel import com.example.what_the_fantasy.ui.theme.colorBackground +import kotlinx.coroutines.awaitAll import kotlinx.coroutines.delay import kotlinx.coroutines.launch @@ -46,11 +47,6 @@ fun AccueilPage( ) { - val coroutineScope = rememberCoroutineScope() - val dailyQuote = Quote(-1,"",0,SrcLanguage.vo,"","","",SrcType.Movie,0) - coroutineScope.launch { - val dailyQuote = services.getDalyQuote(currentUserState.langage) - } //val dailyQuote = DailyQuoteStub.dailyQuote val titleDalyQuote = stringResource(R.string.TitleHomeDailyQuote) @@ -65,6 +61,11 @@ fun AccueilPage( val fullyVisibleItemsInfo = visibleItemsInfo.toMutableList() val lastItem = if (fullyVisibleItemsInfo.isNotEmpty()) fullyVisibleItemsInfo.last() else null + val dailyQuote = DailyQuoteStub.dailyQuote + //var dailyQuote = remember{ Quote(-1,"",0,SrcLanguage.vo,"","","",SrcType.Movie,0) } + //LaunchedEffect(true){ + // dailyQuote = services.getDalyQuote(currentUserState.langage) + //} LaunchedEffect(page.intValue) { if (!isLoading.value) { @@ -114,19 +115,32 @@ fun AccueilPage( ) QuoteLittle(dailyQuote) } - - - Text( - text = titleSuggestion, - color = MaterialTheme.colorScheme.onBackground, - fontSize = 24.sp, + } + } + else{ + item { + Box( modifier = Modifier .fillMaxWidth() .padding(16.dp), - textAlign = TextAlign.Center - ) + contentAlignment = Alignment.Center + ) { + CircularProgressIndicator() + } } } + item { + Text( + text = titleSuggestion, + color = MaterialTheme.colorScheme.onBackground, + fontSize = 24.sp, + modifier = Modifier + .fillMaxWidth() + .padding(16.dp), + textAlign = TextAlign.Center + ) + } + items(quotes) { quote -> if (quote.language == currentUserState.langage) { Column(Modifier.clickable { navQuote(quote.id ) }) {