fix: dismissing deletion dialog wasn't cancelling the deletion, also remove useless decorator in dao

This commit is contained in:
Mylloon 2024-01-03 22:53:05 +01:00
parent cf161ed12c
commit b5922d7280
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
3 changed files with 20 additions and 10 deletions

View file

@ -94,12 +94,14 @@ fun HomeScreen(
if (deletionRequest) {
DeletionDialog(
model::dismissDeleteOne,
model::deleteSelected
)
}
if (deletionDBRequest) {
DeletionDBDialog(
model::dismissDeleteAll,
model::deleteAll
)
}
@ -271,16 +273,18 @@ fun ErrorDialog(errMsg: String, dismiss: () -> Unit) = AlertDialog(onDismissRequ
confirmButton = { Button(onClick = dismiss) { Text(text = "Ok") } })
@Composable
fun DeletionDialog(dismiss: () -> Unit) = AlertDialog(onDismissRequest = dismiss,
fun DeletionDialog(dismiss: () -> Unit, confirm: () -> Unit) =
AlertDialog(onDismissRequest = dismiss,
title = { Text(text = "Supprimer un jeu de question") },
text = { Text(text = "Voulez-vous supprimer ce jeu de question ?") },
confirmButton = { Button(onClick = dismiss) { Text(text = "Ok") } })
confirmButton = { Button(onClick = confirm) { Text(text = "Ok") } })
@Composable
fun DeletionDBDialog(dismiss: () -> Unit) = AlertDialog(onDismissRequest = dismiss,
fun DeletionDBDialog(dismiss: () -> Unit, confirm: () -> Unit) =
AlertDialog(onDismissRequest = dismiss,
title = { Text(text = "Supprimer la base de données") },
text = { Text(text = "Voulez-vous supprimer la base de données ?") },
confirmButton = { Button(onClick = dismiss) { Text(text = "Ok") } })
confirmButton = { Button(onClick = confirm) { Text(text = "Ok") } })
@Composable
fun ShowList(

View file

@ -4,7 +4,6 @@ import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Transaction
import kotlinx.coroutines.flow.Flow
@Dao
@ -15,7 +14,6 @@ interface MemoDao {
@Insert
suspend fun insertQuestion(question: Question)
@Transaction
@Query("SELECT * FROM SetQuestions")
fun loadAllSets(): Flow<List<SetOfQuestions>>

View file

@ -125,6 +125,14 @@ class HomeViewModel(application: Application) : AndroidViewModel(application) {
creation.value = false
}
fun dismissDeleteOne() {
deletionSelect.value = false
}
fun dismissDeleteAll() {
deletionDB.value = false
}
fun dismissModification() {
modification.value = false
}