import androidx.compose.desktop.ui.tooling.preview.Preview import androidx.compose.foundation.hoverable 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.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.drawscope.DrawScope import androidx.compose.ui.unit.dp import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.Button import androidx.compose.material.MaterialTheme import androidx.compose.material.lightColors import androidx.compose.runtime.* import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.input.pointer.pointerMoveFilter import androidx.compose.ui.res.painterResource import androidx.compose.ui.window.* @OptIn(ExperimentalComposeUiApi::class) @Composable fun HomePage( onGlossaireClick: () -> Unit, onCodeAVerifierClick: () -> Unit ) { var isHover by remember { mutableStateOf(false) } Column( modifier = Modifier.fillMaxSize(), verticalArrangement = Arrangement.Center, horizontalAlignment = Alignment.CenterHorizontally ) { Text("Quali'Nomme", style = MaterialTheme.typography.h3) Spacer(modifier = Modifier.height(16.dp)) Row( horizontalArrangement = Arrangement.spacedBy(16.dp) ) { Button( onClick = onGlossaireClick ) { Text("Glossaire") } Button(onClick = onCodeAVerifierClick ) { Text("Code à Vérifier") } Button(onClick = { /* Action de Comparer */ }) { Text("Comparer") } } } } @Composable @Preview fun App() { MaterialTheme { val currentPage = remember { mutableStateOf("accueil") } when (currentPage.value) { "accueil" -> { HomePage( onGlossaireClick = { currentPage.value = "glossaire" }, onCodeAVerifierClick = { currentPage.value = "choixLangage" } ) } "glossaire" -> { glossairePage( onAjouterMotClick = { currentPage.value = "formulaire" }, onImporterClick = { val fileDialog = FileDialog(Frame(), "Select a file", FileDialog.LOAD) fileDialog.file = "Untitled.csv" // Initial file name fileDialog.isMultipleMode = false // To enable selecting only one file fileDialog.setFile("*.csv") fileDialog.isVisible = true val selectedFile = fileDialog.file val selectedDirectory = fileDialog.directory if (selectedFile != null) { val filePath = selectedDirectory + selectedFile println("Opening: $filePath") } else { println("Open command cancelled by user.") } }, onExporterClick = { /* Action d'export */ }, onRetourClick = { currentPage.value = "accueil" } ) } "formulaire" -> { FormulairePage(onAnnulerClick = { currentPage.value = "glossaire" }) } "choixLangage" -> { ChoixLangagePage( onRetourClick = { currentPage.value = "accueil" }, onPythonClick = { val fileDialog = FileDialog(Frame(), "Select a file", FileDialog.LOAD) fileDialog.file = "Untitled.py" // Initial file name fileDialog.isMultipleMode = false // To enable selecting only one file fileDialog.setFile("*.py") fileDialog.isVisible = true val selectedFile = fileDialog.file val selectedDirectory = fileDialog.directory if (selectedFile != null) { val filePath = selectedDirectory + selectedFile println("Opening: $filePath") } else { println("Open command cancelled by user.") } }, onJavaClick = { val fileDialog = FileDialog(Frame(), "Select a file", FileDialog.LOAD) fileDialog.file = "Untitled.java" // Initial file name fileDialog.isMultipleMode = false // To enable selecting only one file fileDialog.setFile("*.java") fileDialog.isVisible = true val selectedFile = fileDialog.file val selectedDirectory = fileDialog.directory if (selectedFile != null) { val filePath = selectedDirectory + selectedFile println("Opening: $filePath") } else { println("Open command cancelled by user.") } }, onJavaScriptClick = { val fileDialog = FileDialog(Frame(), "Select a file", FileDialog.LOAD) fileDialog.file = "Untitled.js" // Initial file name fileDialog.isMultipleMode = false // To enable selecting only one file fileDialog.setFile("*.js") fileDialog.isVisible = true val selectedFile = fileDialog.file val selectedDirectory = fileDialog.directory if (selectedFile != null) { val filePath = selectedDirectory + selectedFile println("Opening: $filePath") } else { println("Open command cancelled by user.") } } ) } // ... Ajoutez d'autres cas pour les pages "glossaire," "code a verifier," et "comparer" } } } @Composable fun ChoixLangagePage( onRetourClick: () -> Unit, onPythonClick: () -> Unit, onJavaClick: () -> Unit, onJavaScriptClick: () -> Unit ) { Column( modifier = Modifier.fillMaxSize(), verticalArrangement = Arrangement.Top, // Align content at the top horizontalAlignment = Alignment.CenterHorizontally ) { Text(text = "Choix du langage", style = MaterialTheme.typography.h3) } Column( modifier = Modifier .fillMaxSize() // Fills the maximum available width .padding(50.dp), // allign the content in the center vertically and horizontally verticalArrangement = Arrangement.Center, horizontalAlignment = Alignment.CenterHorizontally ) { Button(onClick = onPythonClick) { Text("Python") } Button(onClick = onJavaClick) { Text("Java") } Button(onClick = onJavaScriptClick) { Text("JavaScript") } } // Bouton retour positionné tout en bas et centré horizontalement Column( modifier = Modifier.fillMaxSize().padding(20.dp), verticalArrangement = Arrangement.Bottom, horizontalAlignment = Alignment.CenterHorizontally ) { Button(onClick = onRetourClick) { Text("Retour") } } } @Composable fun glossairePage( onAjouterMotClick: () -> Unit, onImporterClick: () -> Unit, onExporterClick: () -> Unit, onRetourClick: () -> Unit ) { Column( modifier = Modifier.fillMaxSize(), verticalArrangement = Arrangement.Top, // Align content at the top horizontalAlignment = Alignment.CenterHorizontally ) { Text(text = "Glossaire", style = MaterialTheme.typography.h3) } Column( modifier = Modifier .fillMaxSize() // Fills the maximum available width .padding(16.dp), verticalArrangement = Arrangement.Center, horizontalAlignment = Alignment.CenterHorizontally ) { Button(onClick = onAjouterMotClick) { Text("Ajouter un mot") } Button(onClick = onImporterClick) { Text("Importer un fichier CSV") } Button(onClick = onExporterClick) { Text("Exporter un fichier CSV") } } // Bouton retour positionné tout en bas et centré horizontalement Column( modifier = Modifier.fillMaxSize().padding(20.dp), verticalArrangement = Arrangement.Bottom, horizontalAlignment = Alignment.CenterHorizontally ) { Button(onClick = onRetourClick) { Text("Retour") } } } @Composable fun FormulairePage(onAnnulerClick: () -> Unit) { MaterialTheme { Column( modifier = Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(8.dp), horizontalAlignment = Alignment.CenterHorizontally ) { Text(text = "Nouveau contexte métier", style = MaterialTheme.typography.h5) val mot = remember { mutableStateOf("") } TextField( value = mot.value, onValueChange = { mot.value = it }, label = { Text("Mot") } ) val description = remember { mutableStateOf("") } TextField( value = description.value, onValueChange = { description.value = it }, label = { Text("Description") } ) val contextePrincipal = remember { mutableStateOf("") } TextField( value = contextePrincipal.value, onValueChange = { contextePrincipal.value = it }, label = { Text("Contexte principal") } ) val contexte2 = remember { mutableStateOf("") } TextField( value = contexte2.value, onValueChange = { contexte2.value = it }, label = { Text("Contexte 2") } ) val lieA = remember { mutableStateOf("") } TextField( value = lieA.value, onValueChange = { lieA.value = it }, label = { Text("Lié à") } ) val synonyme = remember { mutableStateOf("") } TextField( value = synonyme.value, onValueChange = { synonyme.value = it }, label = { Text("Synonyme") } ) val antonyme = remember { mutableStateOf("") } TextField( value = antonyme.value, onValueChange = { antonyme.value = it }, label = { Text("Antonyme") } ) Row( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceEvenly ) { Button(onClick = onAnnulerClick) { Icon(imageVector = Icons.Default.Close, contentDescription = null) Text("Annuler") } Button(onClick = { /* Action de validation */ }) { Icon(imageVector = Icons.Default.Check, contentDescription = null) Text("Valider") } } } } } fun main() = application { val state = rememberWindowState( placement = WindowPlacement.Floating, position = WindowPosition(Alignment.Center), isMinimized = false, width = 800.dp, height = 600.dp ) Window( title = "Quali'Nomme", resizable = true, state = state, icon = painterResource("assets/logo/logo.png"), onCloseRequest = ::exitApplication ) { App() } }