From 9f91b58052e1aedeeb75fa022026779197c362cc Mon Sep 17 00:00:00 2001 From: cemal Date: Thu, 7 Dec 2023 14:31:14 +0100 Subject: [PATCH] Added confirm popup for Ajout mot --- build.gradle.kts | 2 + src/main/kotlin/main/Main.kt | 80 +++++++++++++++++++++++++++--------- 2 files changed, 63 insertions(+), 19 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 49fdc59..bf4b973 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -38,6 +38,8 @@ dependencies { implementation("junit:junit:4.13.1") testImplementation("junit:junit:4.13.1") + + } compose.desktop { diff --git a/src/main/kotlin/main/Main.kt b/src/main/kotlin/main/Main.kt index 8268642..11b27b8 100644 --- a/src/main/kotlin/main/Main.kt +++ b/src/main/kotlin/main/Main.kt @@ -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): 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(