diff --git a/android/app/src/main/java/fr/iut/sciencequest/ViewModels/KahootViewModel.kt b/android/app/src/main/java/fr/iut/sciencequest/ViewModels/KahootViewModel.kt index d7d92cd..5a1cc93 100644 --- a/android/app/src/main/java/fr/iut/sciencequest/ViewModels/KahootViewModel.kt +++ b/android/app/src/main/java/fr/iut/sciencequest/ViewModels/KahootViewModel.kt @@ -14,22 +14,30 @@ class KahootViewModel: ViewModel() { private val handler = Handler(Looper.getMainLooper()) fun lancerPartie() { - var nbPoints: Int - var tpsReponse = 10_000 handler.postDelayed( { Log.d("KahootViewModel","J'actualise les questions") - nbPoints = if(uiState.value.reponseChoisie) { - 10_000 - tpsReponse - } else { - 0 - } uiState.value = KahootUIState(StubQuestionWithReponses2, duréePartie = uiState.value.duréePartie, - nbPoints = uiState.value.nbPoints + nbPoints, + nbPoints = uiState.value.nbPoints, reponseChoisie = false) }, uiState.value.duréePartie * 1000 ) } + + // NOTE : tpsReponse en ms + fun ajouterPoints(tpsReponse: Int) { + + val nbPoints = if(uiState.value.reponseChoisie) { + 10_000 - tpsReponse + } else { + 0 + } + uiState.value = KahootUIState(uiState.value.question, + duréePartie = uiState.value.duréePartie, + nbPoints = uiState.value.nbPoints + nbPoints, + reponseChoisie = false) + Log.d("KahootViewModel","Le joueur à ${uiState.value.reponseChoisie}") + } } \ No newline at end of file diff --git a/android/app/src/main/java/fr/iut/sciencequest/navigation/NavHost.kt b/android/app/src/main/java/fr/iut/sciencequest/navigation/NavHost.kt index 4968078..95743d3 100644 --- a/android/app/src/main/java/fr/iut/sciencequest/navigation/NavHost.kt +++ b/android/app/src/main/java/fr/iut/sciencequest/navigation/NavHost.kt @@ -19,7 +19,7 @@ import fr.iut.sciencequest.view.scientifiques.scientifiqueListeScreen @Composable -fun NavHost(context: Context) { +fun NavHost() { val navController = rememberNavController() NavHost( modifier = Modifier.fillMaxSize(), @@ -72,8 +72,7 @@ fun NavHost(context: Context) { }, goToHome = { navController.navigate("home") - }, - context = context + } ) }