From 9deec816e0b970c58fecf07c6a37e2ed9fe132ad Mon Sep 17 00:00:00 2001 From: cemal Date: Fri, 8 Dec 2023 13:59:34 +0100 Subject: [PATCH] AlertDialog when file upload --- src/main/kotlin/main/Main.kt | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/main/Main.kt b/src/main/kotlin/main/Main.kt index 1f4f15e..4dd3cde 100644 --- a/src/main/kotlin/main/Main.kt +++ b/src/main/kotlin/main/Main.kt @@ -1,7 +1,7 @@ package main import androidx.compose.desktop.ui.tooling.preview.Preview -import androidx.compose.material.MaterialTheme +import androidx.compose.material.* import androidx.compose.runtime.* import androidx.compose.ui.Alignment import androidx.compose.ui.graphics.Color @@ -13,6 +13,7 @@ import java.awt.Frame val customRedColor = Color(0xFFB70D1B) +@OptIn(ExperimentalMaterialApi::class) @Composable @Preview fun app() { @@ -20,6 +21,7 @@ fun app() { val currentPage = remember { mutableStateOf("accueil") } var glossaryDetail: List by remember { mutableStateOf(emptyList()) } + var isJavaScriptFileSelected by remember { mutableStateOf(false) } when (currentPage.value) { "accueil" -> { @@ -89,11 +91,40 @@ fun app() { onJavaScriptClick = { selectFile(jsExtensions) { filePath -> mostUsedWordList = parser(filePath) // Change by parser functions + isJavaScriptFileSelected = true } } ) } - // ... Add other pages here ... + } + if (isJavaScriptFileSelected) { + AlertDialog( + onDismissRequest = { + // Handle dialog dismissal if needed + isJavaScriptFileSelected = false + }, + title = { + Text("Le fichier a été importé avec succès") + }, + text = { + Text("Vous pouvez maintenant comparer votre code avec le glossaire") + }, + confirmButton = { + Button( + onClick = { + // Handle the confirm button action + isJavaScriptFileSelected = false + currentPage.value = "accueil" + }, + colors = ButtonDefaults.buttonColors( + backgroundColor = customRedColor, + contentColor = Color.White + ) + ) { + Text("Ok") + } + } + ) } } }