diff --git a/app/src/main/java/fr/uparis/diamantkennel/memorisationapplication/HomeScreen.kt b/app/src/main/java/fr/uparis/diamantkennel/memorisationapplication/HomeScreen.kt index f94a00c..7638cfe 100644 --- a/app/src/main/java/fr/uparis/diamantkennel/memorisationapplication/HomeScreen.kt +++ b/app/src/main/java/fr/uparis/diamantkennel/memorisationapplication/HomeScreen.kt @@ -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, - 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") } }) +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 = confirm) { Text(text = "Ok") } }) @Composable -fun DeletionDBDialog(dismiss: () -> 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") } }) +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 = confirm) { Text(text = "Ok") } }) @Composable fun ShowList( diff --git a/app/src/main/java/fr/uparis/diamantkennel/memorisationapplication/data/MemoDao.kt b/app/src/main/java/fr/uparis/diamantkennel/memorisationapplication/data/MemoDao.kt index d88514b..0a074b3 100644 --- a/app/src/main/java/fr/uparis/diamantkennel/memorisationapplication/data/MemoDao.kt +++ b/app/src/main/java/fr/uparis/diamantkennel/memorisationapplication/data/MemoDao.kt @@ -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> diff --git a/app/src/main/java/fr/uparis/diamantkennel/memorisationapplication/ui/HomeViewModel.kt b/app/src/main/java/fr/uparis/diamantkennel/memorisationapplication/ui/HomeViewModel.kt index 8f6486f..4229d2a 100644 --- a/app/src/main/java/fr/uparis/diamantkennel/memorisationapplication/ui/HomeViewModel.kt +++ b/app/src/main/java/fr/uparis/diamantkennel/memorisationapplication/ui/HomeViewModel.kt @@ -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 }