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") implementation("junit:junit:4.13.1")
testImplementation("junit:junit:4.13.1") testImplementation("junit:junit:4.13.1")
} }
compose.desktop { compose.desktop {

View File

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