Added confirm popup for Ajout mot

main
Cemal Odabasioglu 2023-12-07 14:31:14 +01:00
parent e47b726467
commit 9f91b58052
2 changed files with 63 additions and 19 deletions

View File

@ -38,6 +38,8 @@ dependencies {
implementation("junit:junit:4.13.1")
testImplementation("junit:junit:4.13.1")
}
compose.desktop {

View File

@ -1,32 +1,33 @@
package main
import androidx.compose.desktop.ui.tooling.preview.Preview
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Check
import androidx.compose.material.icons.filled.Close
import java.awt.FileDialog
import java.awt.Frame
import androidx.compose.material.Button
import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.*
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import java.awt.FileDialog
import java.awt.Frame
import java.io.File
import java.io.FileWriter
import java.io.IOException
import kotlinx.serialization.encodeToString
val customRedColor = Color(0xFFB70D1B)
@Composable
fun homePage(
onGlossaireClick: () -> Unit,
@ -274,6 +275,8 @@ fun verifierChampsRequis(mot: Map<String, String>): Boolean {
}
@Composable
fun choixLangagePage(
onRetourClick: () -> Unit,
@ -419,9 +422,55 @@ fun glossairePage(
}
@OptIn(ExperimentalMaterialApi::class)
@Composable
fun formulairePage(onAnnulerClick: () -> Unit) {
val nom = remember { mutableStateOf("") }
val description = remember { mutableStateOf("") }
val contextePrincipal = remember { mutableStateOf("") }
val contexte2 = remember { mutableStateOf("") }
val lieA = remember { mutableStateOf("") }
val synonyme = remember { mutableStateOf("") }
val antonyme = remember { mutableStateOf("") }
val openDialog = remember { mutableStateOf(false) }
if (openDialog.value) {
AlertDialog(
onDismissRequest = {
openDialog.value = false
},
title = {
Text(text = "Confirmation d'ajout de mot")
},
text = {
Text("Le mot a bien été ajouté au glossaire.")
},
confirmButton = {
Button(
onClick = {
openDialog.value = false
nom.value = ""
description.value = ""
contextePrincipal.value = ""
contexte2.value = ""
lieA.value = ""
synonyme.value = ""
antonyme.value = ""
},
colors = ButtonDefaults.buttonColors(
backgroundColor = customRedColor,
contentColor = Color.White
)
) {
Text("Fermer")
}
}
)
}
MaterialTheme {
Column(
modifier = Modifier.padding(16.dp),
@ -430,7 +479,6 @@ fun formulairePage(onAnnulerClick: () -> Unit) {
) {
Text(text = "Nouveau contexte métier", style = MaterialTheme.typography.h5)
val nom = remember { mutableStateOf("") }
TextField(
value = nom.value,
onValueChange = { nom.value = it },
@ -441,7 +489,6 @@ fun formulairePage(onAnnulerClick: () -> Unit) {
)
)
val description = remember { mutableStateOf("") }
TextField(
value = description.value,
onValueChange = { description.value = it },
@ -452,7 +499,6 @@ fun formulairePage(onAnnulerClick: () -> Unit) {
)
)
val contextePrincipal = remember { mutableStateOf("") }
TextField(
value = contextePrincipal.value,
onValueChange = { contextePrincipal.value = it },
@ -463,7 +509,6 @@ fun formulairePage(onAnnulerClick: () -> Unit) {
)
)
val contexte2 = remember { mutableStateOf("") }
TextField(
value = contexte2.value,
onValueChange = { contexte2.value = it },
@ -474,7 +519,6 @@ fun formulairePage(onAnnulerClick: () -> Unit) {
)
)
val lieA = remember { mutableStateOf("") }
TextField(
value = lieA.value,
onValueChange = { lieA.value = it },
@ -485,7 +529,6 @@ fun formulairePage(onAnnulerClick: () -> Unit) {
)
)
val synonyme = remember { mutableStateOf("") }
TextField(
value = synonyme.value,
onValueChange = { synonyme.value = it },
@ -496,7 +539,6 @@ fun formulairePage(onAnnulerClick: () -> Unit) {
)
)
val antonyme = remember { mutableStateOf("") }
TextField(
value = antonyme.value,
onValueChange = { antonyme.value = it },
@ -536,7 +578,7 @@ fun formulairePage(onAnnulerClick: () -> Unit) {
)
ajouterMotAuGlossaire(nouveauMot)
openDialog.value = true
},
colors = ButtonDefaults.buttonColors(