fmt
This commit is contained in:
parent
4f25c2d266
commit
93e490d1cd
5 changed files with 24 additions and 13 deletions
|
@ -150,4 +150,3 @@ fun <T: Any> ShowDialog(
|
|||
dialog()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ fun PlayScreen(
|
|||
navController: NavController,
|
||||
snackbarHostState: SnackbarHostState,
|
||||
idSet: Int,
|
||||
model: PlayViewModel = viewModel()
|
||||
model: PlayViewModel = viewModel(),
|
||||
) {
|
||||
// First update the list of questions
|
||||
model.updateQuestionList(idSet)
|
||||
|
@ -85,7 +85,7 @@ fun Play(
|
|||
question: Question?,
|
||||
reponse: String,
|
||||
correction: AnswerType?,
|
||||
delay: Int
|
||||
delay: Int,
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
|
||||
|
@ -94,7 +94,10 @@ fun Play(
|
|||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
if (question == null) {
|
||||
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.Center
|
||||
) {
|
||||
Text(context.getString(R.string.no_question), fontSize = 30.sp)
|
||||
}
|
||||
} else {
|
||||
|
@ -163,7 +166,7 @@ fun SnackbarAnswer(
|
|||
model: PlayViewModel,
|
||||
snackbarHostState: SnackbarHostState,
|
||||
cpt: Int,
|
||||
correction: AnswerType?
|
||||
correction: AnswerType?,
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
if (correction != null) {
|
||||
|
@ -178,4 +181,4 @@ fun SnackbarAnswer(
|
|||
model.resetAfterSb()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,9 +67,11 @@ class ModifySetViewModel(application: Application) : AndroidViewModel(applicatio
|
|||
fun modifAction() {
|
||||
action.value = ActionModifySet.MODIFICATION
|
||||
}
|
||||
|
||||
fun ajoutAction() {
|
||||
action.value = ActionModifySet.AJOUT
|
||||
}
|
||||
|
||||
fun supprAction() {
|
||||
action.value = ActionModifySet.SUPPRIMER
|
||||
}
|
||||
|
|
|
@ -6,12 +6,12 @@ import androidx.datastore.preferences.core.edit
|
|||
import androidx.datastore.preferences.core.intPreferencesKey
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import fr.uparis.diamantkennel.memorisationapplication.DELAY
|
||||
import fr.uparis.diamantkennel.memorisationapplication.MemoApplication
|
||||
import fr.uparis.diamantkennel.memorisationapplication.STATS_TOTAL_BAD
|
||||
import fr.uparis.diamantkennel.memorisationapplication.STATS_TOTAL_DONE
|
||||
import fr.uparis.diamantkennel.memorisationapplication.STATS_TOTAL_GOOD
|
||||
import fr.uparis.diamantkennel.memorisationapplication.STATS_TOTAL_TRIED
|
||||
import fr.uparis.diamantkennel.memorisationapplication.DELAY
|
||||
import fr.uparis.diamantkennel.memorisationapplication.data.Question
|
||||
import fr.uparis.diamantkennel.memorisationapplication.dataStore
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
@ -28,7 +28,7 @@ class PlayViewModel(application: Application) : AndroidViewModel(application) {
|
|||
private val statsKeyTotalGood = intPreferencesKey(STATS_TOTAL_GOOD)
|
||||
private val statsKeyTotalBad = intPreferencesKey(STATS_TOTAL_BAD)
|
||||
|
||||
private val delayKey= intPreferencesKey(DELAY)
|
||||
private val delayKey = intPreferencesKey(DELAY)
|
||||
val delay = datastore.data.map { it[delayKey] ?: 5000 }
|
||||
|
||||
var currentQuestion = mutableStateOf<Question?>(null)
|
||||
|
@ -47,7 +47,9 @@ class PlayViewModel(application: Application) : AndroidViewModel(application) {
|
|||
dao.loadQuestions(setId).collect { questionList ->
|
||||
questions.value = questionList.shuffled()
|
||||
if (questions.value.isNotEmpty()) {
|
||||
datastore.edit { it[statsKeyTotal] = (it[statsKeyTotal] ?: 0) + 1 }
|
||||
datastore.edit {
|
||||
it[statsKeyTotal] = (it[statsKeyTotal] ?: 0) + 1
|
||||
}
|
||||
}
|
||||
updateQuestion()
|
||||
}
|
||||
|
@ -106,7 +108,8 @@ class PlayViewModel(application: Application) : AndroidViewModel(application) {
|
|||
}
|
||||
|
||||
fun checkAnswer() {
|
||||
val probaReponse = calcSimilarite(currentQuestion.value!!.reponse, proposedAnswer.value)
|
||||
val probaReponse =
|
||||
calcSimilarite(currentQuestion.value!!.reponse, proposedAnswer.value)
|
||||
if (probaReponse >= .70f) {
|
||||
evaluatedAnswer.value = AnswerType.GOOD
|
||||
} else {
|
||||
|
@ -153,4 +156,4 @@ class PlayViewModel(application: Application) : AndroidViewModel(application) {
|
|||
showAnswer.value = true
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,9 +15,9 @@ import androidx.lifecycle.AndroidViewModel
|
|||
import androidx.lifecycle.viewModelScope
|
||||
import androidx.work.PeriodicWorkRequest
|
||||
import androidx.work.WorkManager
|
||||
import fr.uparis.diamantkennel.memorisationapplication.DELAY
|
||||
import fr.uparis.diamantkennel.memorisationapplication.HOUR
|
||||
import fr.uparis.diamantkennel.memorisationapplication.MINUTE
|
||||
import fr.uparis.diamantkennel.memorisationapplication.DELAY
|
||||
import fr.uparis.diamantkennel.memorisationapplication.MemoApplication
|
||||
import fr.uparis.diamantkennel.memorisationapplication.RappelWorker
|
||||
import fr.uparis.diamantkennel.memorisationapplication.STATS_TOTAL_BAD
|
||||
|
@ -51,7 +51,8 @@ class SettingsViewModel(application: Application) : AndroidViewModel(application
|
|||
val statTotalGood = datastore.data.map { it[statsKeyTotalGood] ?: 0 }
|
||||
val statTotalBad = datastore.data.map { it[statsKeyTotalBad] ?: 0 }
|
||||
|
||||
var prefConfigTime = datastore.data.map { TimeConfig(it[notifH] ?: 8, it[notifM] ?: 0) }
|
||||
var prefConfigTime =
|
||||
datastore.data.map { TimeConfig(it[notifH] ?: 8, it[notifM] ?: 0) }
|
||||
|
||||
var deletionDB = mutableStateOf(false)
|
||||
var deletionStat = mutableStateOf(false)
|
||||
|
@ -159,12 +160,15 @@ class SettingsViewModel(application: Application) : AndroidViewModel(application
|
|||
fun dismissDeletionDB() {
|
||||
deletionDB.value = false
|
||||
}
|
||||
|
||||
fun dismissDeletionStat() {
|
||||
deletionStat.value = false
|
||||
}
|
||||
|
||||
fun dismissNotif() {
|
||||
notif.value = false
|
||||
}
|
||||
|
||||
fun dismissDelayRequest() {
|
||||
delayRequest.value = false
|
||||
}
|
||||
|
|
Reference in a new issue