parent
c35948e2e6
commit
38038c7939
@ -1,42 +1,60 @@
|
|||||||
package com.example.what_the_fantasy.ui.screens
|
package com.example.what_the_fantasy.ui.screens
|
||||||
|
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.lazy.items
|
||||||
|
import androidx.compose.material3.Button
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import com.example.what_the_fantasy.data.local.QuoteStub
|
||||||
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.NavBar
|
||||||
|
import com.example.what_the_fantasy.ui.components.QuoteLittle
|
||||||
import com.example.what_the_fantasy.ui.theme.colorBackground
|
import com.example.what_the_fantasy.ui.theme.colorBackground
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun AccueilPage(
|
fun AccueilPage(
|
||||||
index: Int,
|
index: Int,
|
||||||
navFavorite:(Int) -> Unit,
|
navFavorite: (Int) -> Unit,
|
||||||
navQuiz: (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,
|
index = index,
|
||||||
navControllerFavorite = navFavorite,
|
navControllerFavorite = navFavorite,
|
||||||
navControllerAccueil = { },
|
navControllerAccueil = { },
|
||||||
navControllerProfil = navProfil,
|
navControllerProfil = navProfil,
|
||||||
navControllerQuiz = navQuiz
|
navControllerQuiz = navQuiz
|
||||||
){
|
) {
|
||||||
Box(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.background(colorBackground),
|
.background(colorBackground)
|
||||||
contentAlignment = Alignment.Center
|
) {
|
||||||
){
|
LazyColumn(modifier = Modifier.weight(1f)) {
|
||||||
Column {
|
items(quotes) { quote ->
|
||||||
Text("Accueil", color = Color.White, fontSize = 20.sp)
|
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