test acceuil

ConnectAPI
Kentin BRONGNIART 2 weeks ago
parent 73eac61726
commit 5ba379ea9f

@ -60,7 +60,10 @@ interface ApiService {
): Quote ): Quote
@GET("quote/{id}") @GET("quote/{id}")
suspend fun getQuoteById(@Path("id")id : Int):Quote suspend fun getQuoteById(
@Path("id")id : Int
):Quote
@GET("quote/all") @GET("quote/all")
suspend fun getAllQuote( suspend fun getAllQuote(
@Query("index") index: Int, @Query("index") index: Int,

@ -271,8 +271,9 @@ class ServicesAPI : IServices {
} }
override suspend fun getSomeQuotes(nb: Int, page: Int): MutableList<Quote> { override suspend fun getSomeQuotes(nb: Int, page: Int): MutableList<Quote> {
val reponce = RetrofitInstance.api.getAllQuote(page,nb) val result = RetrofitInstance.api.getAllQuote(page,nb)
return reponce.items Log.d("test", result.toString())
return result.items
} }
@RequiresApi(Build.VERSION_CODES.O) @RequiresApi(Build.VERSION_CODES.O)

@ -156,7 +156,7 @@ class ServicesStub : IServices {
} }
override suspend fun getDalyQuote(langage: SrcLanguage): Quote { override suspend fun getDalyQuote(langage: SrcLanguage): Quote {
TODO("Not yet implemented") return quotes.first()
} }
override suspend fun isFavorite(idQuote: Int, idUser: Int): Boolean { override suspend fun isFavorite(idQuote: Int, idUser: Int): Boolean {

@ -139,7 +139,7 @@ fun AppNavigator() {
) )
}, },
navSearch = { navController.navigate(Search(currentUserState.id))}, navSearch = { navController.navigate(Search(currentUserState.id))},
services = services, services = servicesStub,
currentUserVM = currentUserVM, currentUserVM = currentUserVM,
currentUserState = currentUserState, currentUserState = currentUserState,
) )

@ -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.states.CurrentUserState
import com.example.what_the_fantasy.ui.viewModels.CurrentUserViewModel import com.example.what_the_fantasy.ui.viewModels.CurrentUserViewModel
import com.example.what_the_fantasy.ui.theme.colorBackground import com.example.what_the_fantasy.ui.theme.colorBackground
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.launch 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 dailyQuote = DailyQuoteStub.dailyQuote
val titleDalyQuote = stringResource(R.string.TitleHomeDailyQuote) val titleDalyQuote = stringResource(R.string.TitleHomeDailyQuote)
@ -65,6 +61,11 @@ fun AccueilPage(
val fullyVisibleItemsInfo = visibleItemsInfo.toMutableList() val fullyVisibleItemsInfo = visibleItemsInfo.toMutableList()
val lastItem = if (fullyVisibleItemsInfo.isNotEmpty()) fullyVisibleItemsInfo.last() else null 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) { LaunchedEffect(page.intValue) {
if (!isLoading.value) { if (!isLoading.value) {
@ -114,19 +115,32 @@ fun AccueilPage(
) )
QuoteLittle(dailyQuote) QuoteLittle(dailyQuote)
} }
}
}
Text( else{
text = titleSuggestion, item {
color = MaterialTheme.colorScheme.onBackground, Box(
fontSize = 24.sp,
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(16.dp), .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 -> items(quotes) { quote ->
if (quote.language == currentUserState.langage) { if (quote.language == currentUserState.langage) {
Column(Modifier.clickable { navQuote(quote.id ) }) { Column(Modifier.clickable { navQuote(quote.id ) }) {

Loading…
Cancel
Save