fmt
This commit is contained in:
parent
a98e9d34e3
commit
9ed25aaab4
3 changed files with 25 additions and 17 deletions
|
@ -107,7 +107,7 @@ fun HomeScreen(padding: PaddingValues, model: HomeViewModel = viewModel()) {
|
||||||
onClick = { Toast.makeText(context, "Start", Toast.LENGTH_SHORT).show() }) {
|
onClick = { Toast.makeText(context, "Start", Toast.LENGTH_SHORT).show() }) {
|
||||||
Text(text = context.getString(R.string.main_button_start), fontSize = 30.sp)
|
Text(text = context.getString(R.string.main_button_start), fontSize = 30.sp)
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.padding(top = 50.dp))
|
Spacer(modifier = Modifier.padding(top = 50.dp))
|
||||||
|
|
||||||
DeleteRow(context, model)
|
DeleteRow(context, model)
|
||||||
|
@ -119,8 +119,10 @@ private fun DeleteRow(
|
||||||
context: Context,
|
context: Context,
|
||||||
model: HomeViewModel
|
model: HomeViewModel
|
||||||
) {
|
) {
|
||||||
Row(modifier = Modifier.fillMaxWidth(),
|
Row(
|
||||||
horizontalArrangement = Arrangement.Center,/*, horizontalArrangement = Arrangement.SpaceEvenly*/) {
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.Center,/*, horizontalArrangement = Arrangement.SpaceEvenly*/
|
||||||
|
) {
|
||||||
Button(onClick = {
|
Button(onClick = {
|
||||||
(model::doAction)(ActionHome.DELETION_DB)
|
(model::doAction)(ActionHome.DELETION_DB)
|
||||||
}, colors = ButtonDefaults.buttonColors(containerColor = colorResource(id = R.color.red))) {
|
}, colors = ButtonDefaults.buttonColors(containerColor = colorResource(id = R.color.red))) {
|
||||||
|
@ -169,13 +171,13 @@ private fun ActionRow(
|
||||||
@Composable
|
@Composable
|
||||||
fun CreationDialog(
|
fun CreationDialog(
|
||||||
dismiss: () -> Unit,
|
dismiss: () -> Unit,
|
||||||
model : HomeViewModel = viewModel()
|
model: HomeViewModel = viewModel()
|
||||||
) {
|
) {
|
||||||
val sujet by model.sujet
|
val sujet by model.sujet
|
||||||
|
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
onDismissRequest = dismiss,
|
onDismissRequest = dismiss,
|
||||||
title = { Text(text ="Créer un sujet") },
|
title = { Text(text = "Créer un sujet") },
|
||||||
text = {
|
text = {
|
||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
sujet,
|
sujet,
|
||||||
|
@ -205,7 +207,7 @@ fun ImportDialog(
|
||||||
model: HomeViewModel
|
model: HomeViewModel
|
||||||
) {
|
) {
|
||||||
val radioOptions = listOf("Locale", "Internet")
|
val radioOptions = listOf("Locale", "Internet")
|
||||||
val (selectedOption, onOptionSelected) = remember {mutableStateOf(radioOptions[0])}
|
val (selectedOption, onOptionSelected) = remember { mutableStateOf(radioOptions[0]) }
|
||||||
|
|
||||||
var lien by remember { mutableStateOf("") }
|
var lien by remember { mutableStateOf("") }
|
||||||
|
|
||||||
|
@ -241,8 +243,8 @@ fun ImportDialog(
|
||||||
|
|
||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
value = lien,
|
value = lien,
|
||||||
onValueChange = {newTextValue -> lien = newTextValue},
|
onValueChange = { newTextValue -> lien = newTextValue },
|
||||||
label = {Text(text = "Lien") }
|
label = { Text(text = "Lien") }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -265,25 +267,25 @@ fun ImportDialog(
|
||||||
@Composable
|
@Composable
|
||||||
fun ErrorDialog(errMsg: String, dismiss: () -> Unit) =
|
fun ErrorDialog(errMsg: String, dismiss: () -> Unit) =
|
||||||
AlertDialog(onDismissRequest = dismiss,
|
AlertDialog(onDismissRequest = dismiss,
|
||||||
title = { Text(text = "Erreur")},
|
title = { Text(text = "Erreur") },
|
||||||
text = { Text(text = errMsg) },
|
text = { Text(text = errMsg) },
|
||||||
confirmButton = {Button(onClick = dismiss) { Text(text = "Ok") }}
|
confirmButton = { Button(onClick = dismiss) { Text(text = "Ok") } }
|
||||||
)
|
)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun DeletionDialog(dismiss: () -> Unit) =
|
fun DeletionDialog(dismiss: () -> Unit) =
|
||||||
AlertDialog(onDismissRequest = dismiss,
|
AlertDialog(onDismissRequest = dismiss,
|
||||||
title = { Text(text = "Supprimer un jeu de question")},
|
title = { Text(text = "Supprimer un jeu de question") },
|
||||||
text = { Text(text = "Voulez-vous supprimer ce jeu de question ?") },
|
text = { Text(text = "Voulez-vous supprimer ce jeu de question ?") },
|
||||||
confirmButton = {Button(onClick = dismiss) { Text(text = "Ok") }}
|
confirmButton = { Button(onClick = dismiss) { Text(text = "Ok") } }
|
||||||
)
|
)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun DeletionDBDialog(dismiss: () -> Unit) =
|
fun DeletionDBDialog(dismiss: () -> Unit) =
|
||||||
AlertDialog(onDismissRequest = dismiss,
|
AlertDialog(onDismissRequest = dismiss,
|
||||||
title = { Text(text = "Supprimer la base de données")},
|
title = { Text(text = "Supprimer la base de données") },
|
||||||
text = { Text(text = "Voulez-vous 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 = dismiss) { Text(text = "Ok") } }
|
||||||
)
|
)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
@ -321,10 +323,10 @@ fun ListItem(
|
||||||
Modifier.fillMaxSize(),
|
Modifier.fillMaxSize(),
|
||||||
colors = CardDefaults.cardColors(containerColor)
|
colors = CardDefaults.cardColors(containerColor)
|
||||||
) {
|
) {
|
||||||
Row (
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
horizontalArrangement = Arrangement.SpaceEvenly
|
horizontalArrangement = Arrangement.SpaceEvenly
|
||||||
){
|
) {
|
||||||
Text(set.toString(), modifier = Modifier.padding(2.dp))
|
Text(set.toString(), modifier = Modifier.padding(2.dp))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
package fr.uparis.diamantkennel.memorisationapplication.ui
|
package fr.uparis.diamantkennel.memorisationapplication.ui
|
||||||
|
|
||||||
enum class ErrorsAjout { BAD_ENTRY, DUPLICATE}
|
enum class ErrorsAjout { BAD_ENTRY, DUPLICATE }
|
||||||
|
|
|
@ -68,19 +68,23 @@ class HomeViewModel(application: Application) : AndroidViewModel(application) {
|
||||||
ActionHome.CREATION -> {
|
ActionHome.CREATION -> {
|
||||||
creation.value = true
|
creation.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionHome.IMPORTATION -> {
|
ActionHome.IMPORTATION -> {
|
||||||
importation.value = true
|
importation.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionHome.MODIFIER -> {
|
ActionHome.MODIFIER -> {
|
||||||
if (selected.value != null) {
|
if (selected.value != null) {
|
||||||
modification.value = true
|
modification.value = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionHome.DELETION_SELECT -> {
|
ActionHome.DELETION_SELECT -> {
|
||||||
if (selected.value != null) {
|
if (selected.value != null) {
|
||||||
deletionSelect.value = true
|
deletionSelect.value = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionHome.DELETION_DB -> {
|
ActionHome.DELETION_DB -> {
|
||||||
deletionDB.value = true
|
deletionDB.value = true
|
||||||
}
|
}
|
||||||
|
@ -114,9 +118,11 @@ class HomeViewModel(application: Application) : AndroidViewModel(application) {
|
||||||
fun dismissCreation() {
|
fun dismissCreation() {
|
||||||
creation.value = false
|
creation.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
fun dismissModification() {
|
fun dismissModification() {
|
||||||
modification.value = false
|
modification.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
fun dismissImportation() {
|
fun dismissImportation() {
|
||||||
importation.value = false
|
importation.value = false
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue