parent
c35948e2e6
commit
38038c7939
@ -1,42 +1,60 @@
|
||||
package com.example.what_the_fantasy.ui.screens
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.example.what_the_fantasy.data.services.IServices
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.example.what_the_fantasy.data.local.QuoteStub
|
||||
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.theme.colorBackground
|
||||
|
||||
@Composable
|
||||
fun AccueilPage(
|
||||
index: Int,
|
||||
navFavorite:(Int) -> Unit,
|
||||
navFavorite: (Int) -> Unit,
|
||||
navQuiz: (Int) -> Unit,
|
||||
navProfil:(Int) -> Unit
|
||||
navProfil: (Int) -> Unit
|
||||
) {
|
||||
NavBar(onAccueil = true,
|
||||
var itemCount by remember { mutableStateOf(15) } // On affiche 15 quotes au début
|
||||
|
||||
val quotes = QuoteStub.allQuotes.take(itemCount)
|
||||
|
||||
NavBar(
|
||||
onAccueil = true,
|
||||
index = index,
|
||||
navControllerFavorite = navFavorite,
|
||||
navControllerAccueil = { },
|
||||
navControllerAccueil = { },
|
||||
navControllerProfil = navProfil,
|
||||
navControllerQuiz = navQuiz
|
||||
){
|
||||
Box(
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.background(colorBackground),
|
||||
contentAlignment = Alignment.Center
|
||||
){
|
||||
Column {
|
||||
Text("Accueil", color = Color.White, fontSize = 20.sp)
|
||||
.background(colorBackground)
|
||||
) {
|
||||
LazyColumn(modifier = Modifier.weight(1f)) {
|
||||
items(quotes) { quote ->
|
||||
QuoteLittle(quote)
|
||||
}
|
||||
|
||||
// Si on a encore des éléments à charger, on affiche le bouton
|
||||
if (itemCount < QuoteStub.allQuotes.size) {
|
||||
item {
|
||||
Box(modifier = Modifier.fillMaxWidth(), contentAlignment = Alignment.Center) {
|
||||
Button(onClick = { itemCount += 15 }) {
|
||||
Text("Charger plus")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in new issue