|
|
|
@ -1,14 +1,22 @@
|
|
|
|
|
package fr.iut.sciencequest.view.games
|
|
|
|
|
|
|
|
|
|
import android.widget.Toast
|
|
|
|
|
import androidx.compose.foundation.layout.Arrangement
|
|
|
|
|
import androidx.compose.foundation.layout.Column
|
|
|
|
|
import androidx.compose.foundation.layout.PaddingValues
|
|
|
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
|
|
import androidx.compose.foundation.lazy.grid.GridCells
|
|
|
|
|
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
|
|
|
|
import androidx.compose.material3.Button
|
|
|
|
|
import androidx.compose.material3.Text
|
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
|
import androidx.compose.ui.Alignment
|
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
|
import androidx.compose.ui.platform.LocalContext
|
|
|
|
|
import androidx.compose.ui.res.stringResource
|
|
|
|
|
import androidx.compose.ui.text.style.TextAlign
|
|
|
|
|
import androidx.compose.ui.tooling.preview.Preview
|
|
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
|
|
import fr.iut.sciencequest.R
|
|
|
|
|
import fr.iut.sciencequest.model.dto.question.QuestionWithSimpleResponseDTO
|
|
|
|
|
import fr.iut.sciencequest.model.dto.reponse.ReponseSimpleDTO
|
|
|
|
@ -39,19 +47,25 @@ fun KahootPlayerPreview(){
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun KahootPlayer(question: QuestionWithSimpleResponseDTO){
|
|
|
|
|
Column {
|
|
|
|
|
val context = LocalContext.current;
|
|
|
|
|
Column (horizontalAlignment = Alignment.CenterHorizontally){
|
|
|
|
|
KahootQuestion(question = question.question)
|
|
|
|
|
KahootReponses(reponses = question.reponses)
|
|
|
|
|
KahootReponses(reponses = question.reponses) {Toast.makeText(context, it.reponse, Toast.LENGTH_SHORT).show()}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun KahootReponses(reponses : List<ReponseSimpleDTO>) {
|
|
|
|
|
LazyVerticalGrid(columns = GridCells.Fixed(2)) {
|
|
|
|
|
fun KahootReponses(reponses : List<ReponseSimpleDTO>, action: (ReponseSimpleDTO)->Unit) {
|
|
|
|
|
LazyVerticalGrid(columns = GridCells.Fixed(2),
|
|
|
|
|
contentPadding = PaddingValues(12.dp),
|
|
|
|
|
verticalArrangement = Arrangement.spacedBy(10.dp),
|
|
|
|
|
horizontalArrangement = Arrangement.spacedBy(10.dp)) {
|
|
|
|
|
reponses.forEach {
|
|
|
|
|
item() {
|
|
|
|
|
Text(it.reponse)
|
|
|
|
|
Button(onClick = {action(it)}){
|
|
|
|
|
Text(it.reponse)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -59,5 +73,5 @@ fun KahootReponses(reponses : List<ReponseSimpleDTO>) {
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun KahootQuestion(question: String){
|
|
|
|
|
Text(question)
|
|
|
|
|
Text(question, textAlign = TextAlign.Center)
|
|
|
|
|
}
|