[FIX] Context recup dans composant

RepositoryAndroid
Renaud BEURET 1 year ago
parent b306915e68
commit 50d4a03973

@ -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) {
uiState.value = KahootUIState(StubQuestionWithReponses2,
duréePartie = uiState.value.duréePartie,
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(StubQuestionWithReponses2,
uiState.value = KahootUIState(uiState.value.question,
duréePartie = uiState.value.duréePartie,
nbPoints = uiState.value.nbPoints + nbPoints,
reponseChoisie = false)
},
uiState.value.duréePartie * 1000
)
Log.d("KahootViewModel","Le joueur à ${uiState.value.reponseChoisie}")
}
}

@ -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
}
)
}

Loading…
Cancel
Save