forked from tom.biard/ScienceQuest
commit
a839310455
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/ScienceQuest.iml" filepath="$PROJECT_DIR$/.idea/ScienceQuest.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="AppInsightsSettings">
|
||||||
|
<option name="selectedTabId" value="Android Vitals" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,36 @@
|
|||||||
|
package fr.iut.sciencequest.model.buisness.Scientifique
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
|
import fr.iut.sciencequest.model.buisness.createRequestService
|
||||||
|
import kotlinx.coroutines.flow.flow
|
||||||
|
import retrofit2.create
|
||||||
|
|
||||||
|
suspend fun fetchScientifiqueById(id: Int) = flow {
|
||||||
|
val serviceClient = createRequestService().create<ScientifiqueRequestService>()
|
||||||
|
try {
|
||||||
|
val response = serviceClient.getScientifique(id)
|
||||||
|
emit(response)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e("Requete API",e.message.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun fetchScientifiques(index: Int) = flow {
|
||||||
|
val serviceClient = createRequestService().create<ScientifiqueRequestService>()
|
||||||
|
try {
|
||||||
|
val response = serviceClient.getScientifiques(index)
|
||||||
|
emit(response)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e("Requete API",e.message.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun fetchScientifiquesInfos() = flow {
|
||||||
|
val serviceClient = createRequestService().create<ScientifiqueRequestService>()
|
||||||
|
try {
|
||||||
|
val response = serviceClient.getScientifiquesListInfos().page
|
||||||
|
emit(response)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e("Requete API",e.message.toString())
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package fr.iut.sciencequest.model.dto.ScientifiqueDTOs
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
open class ScientifiqueListInfosPageDTO(
|
||||||
|
@SerialName("totalElements")
|
||||||
|
val nbScientfiques: Int,
|
||||||
|
|
||||||
|
@SerialName("totalPages")
|
||||||
|
val nbPages: Int,
|
||||||
|
|
||||||
|
@SerialName("size")
|
||||||
|
val nbScientifiquesParPage: Int
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
open class ScientifiqueListInfosDTO (
|
||||||
|
val page: ScientifiqueListInfosPageDTO
|
||||||
|
)
|
@ -0,0 +1,95 @@
|
|||||||
|
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.runtime.collectAsState
|
||||||
|
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 androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
|
import fr.iut.sciencequest.R
|
||||||
|
import fr.iut.sciencequest.model.dto.extensions.ToModel
|
||||||
|
import fr.iut.sciencequest.model.dto.question.QuestionWithSimpleResponseDTO
|
||||||
|
import fr.iut.sciencequest.model.dto.reponse.ReponseSimpleDTO
|
||||||
|
import fr.iut.sciencequest.model.metier.question.QuestionWithSimpleReponse
|
||||||
|
import fr.iut.sciencequest.model.metier.reponse.ReponseSimple
|
||||||
|
import fr.iut.sciencequest.stub.StubQuestionWithReponses
|
||||||
|
import fr.iut.sciencequest.view.TopBar
|
||||||
|
import fr.iut.sciencequest.viewModels.KahootViewModel
|
||||||
|
import java.util.Timer
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun QuiScreen(viewModel: KahootViewModel = viewModel(),
|
||||||
|
goToAccount: () -> Unit,
|
||||||
|
goToHome: () -> Unit) {
|
||||||
|
val state = viewModel.uiState.collectAsState()
|
||||||
|
Column(modifier = Modifier.fillMaxWidth()) {
|
||||||
|
TopBar(goToAccount, goToHome, stringResource(id = R.string.kahoot))
|
||||||
|
QuiPlayer(state.value.question) {
|
||||||
|
viewModel.ajouterPoints(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Preview
|
||||||
|
@Composable
|
||||||
|
fun QuiScreenPreview(){
|
||||||
|
QuiScreen(goToAccount = {}, goToHome = {})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Preview
|
||||||
|
@Composable
|
||||||
|
fun QuiPlayerPreview(){
|
||||||
|
val i = 0
|
||||||
|
QuiPlayer(question = StubQuestionWithReponses.ToModel()) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun QuiPlayer(question: QuestionWithSimpleReponse,
|
||||||
|
sendReponse: (Long) -> Unit){
|
||||||
|
val context = LocalContext.current;
|
||||||
|
val currTime = System.currentTimeMillis()
|
||||||
|
Column (horizontalAlignment = Alignment.CenterHorizontally){
|
||||||
|
QuiQuestion(question = question.question)
|
||||||
|
QuiReponses(reponses = question.reponses) {
|
||||||
|
sendReponse(currTime - System.currentTimeMillis())
|
||||||
|
Toast.makeText(context, it.reponse, Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun QuiReponses(reponses : List<ReponseSimple>, action: (ReponseSimple)->Unit) {
|
||||||
|
LazyVerticalGrid(columns = GridCells.Fixed(2),
|
||||||
|
contentPadding = PaddingValues(12.dp),
|
||||||
|
verticalArrangement = Arrangement.spacedBy(10.dp),
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||||
|
reponses.forEach {
|
||||||
|
item() {
|
||||||
|
Button(onClick = {action(it)}){
|
||||||
|
Text(it.reponse)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun QuiQuestion(question: String){
|
||||||
|
Text(question, textAlign = TextAlign.Center)
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
Description dérive Qui-est-ce:
|
||||||
|
|
||||||
|
- Image flou du scientifique à trouver
|
||||||
|
- 1 seul indice au début en dessous de la photo exemple: femme - 1967
|
||||||
|
- 4 réponse possible comme kahoot, 1 seul essai
|
||||||
|
- maximum de point si la personne trouve du premier coup
|
||||||
|
- possibilité d'avoir + d'indice / diminution du flou mais gagne moins de points au fur et à mesure
|
||||||
|
- Plus simple à implémenter qu'un réel qui-est-ce.
|
Loading…
Reference in new issue