From 90f1623749379f0edb15f6bd5bcbe2c589adb196 Mon Sep 17 00:00:00 2001 From: cemal Date: Fri, 8 Dec 2023 13:42:54 +0100 Subject: [PATCH] Improvments in design --- src/main/kotlin/main/Compare.kt | 2 +- src/main/kotlin/main/Form.kt | 21 +++++- src/main/kotlin/main/Glossary.kt | 13 +++- src/main/kotlin/main/Home.kt | 125 +++++++++++++++++++------------ src/main/kotlin/main/Verify.kt | 17 +++-- 5 files changed, 117 insertions(+), 61 deletions(-) diff --git a/src/main/kotlin/main/Compare.kt b/src/main/kotlin/main/Compare.kt index d68a303..260de71 100644 --- a/src/main/kotlin/main/Compare.kt +++ b/src/main/kotlin/main/Compare.kt @@ -27,7 +27,7 @@ fun compareResults( horizontalAlignment = Alignment.CenterHorizontally ) { Text( - text = "Le code contient ${compareWords(glossaryWords, codeWords)}% des mots du glossaire\"", + text = "Le code contient ${compareWords(glossaryWords, codeWords)}% des mots du glossaire", style = MaterialTheme.typography.h3 ) } diff --git a/src/main/kotlin/main/Form.kt b/src/main/kotlin/main/Form.kt index 1b297bf..0d1e37b 100644 --- a/src/main/kotlin/main/Form.kt +++ b/src/main/kotlin/main/Form.kt @@ -3,6 +3,7 @@ package main import androidx.compose.foundation.layout.* import androidx.compose.material.* import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.ArrowBack import androidx.compose.material.icons.filled.Check import androidx.compose.material.icons.filled.Close import androidx.compose.runtime.Composable @@ -149,8 +150,8 @@ fun formPage(onCancelClick: () -> Unit) { contentColor = Color.White ) ) { - Icon(imageVector = Icons.Default.Close, contentDescription = null) - Text("Annuler") + Icon(imageVector = Icons.Default.ArrowBack, contentDescription = null) + Text("Retour") } Button( onClick = { @@ -199,7 +200,13 @@ fun formPage(onCancelClick: () -> Unit) { Snackbar( modifier = Modifier.padding(16.dp), action = { - Button(onClick = { requiredFieldsSnackbarVisibleState.value = false }) { + Button( + onClick = { requiredFieldsSnackbarVisibleState.value = false }, + colors = ButtonDefaults.buttonColors( + backgroundColor = customRedColor, + contentColor = Color.White + ) + ) { Text("OK") } } @@ -211,7 +218,13 @@ fun formPage(onCancelClick: () -> Unit) { Snackbar( modifier = Modifier.padding(16.dp), action = { - Button(onClick = { alreadyExistSnackbarVisibleState.value = false }) { + Button( + onClick = { alreadyExistSnackbarVisibleState.value = false }, + colors = ButtonDefaults.buttonColors( + backgroundColor = customRedColor, + contentColor = Color.White + ) + ) { Text("OK") } } diff --git a/src/main/kotlin/main/Glossary.kt b/src/main/kotlin/main/Glossary.kt index 0b02c8d..c695faa 100644 --- a/src/main/kotlin/main/Glossary.kt +++ b/src/main/kotlin/main/Glossary.kt @@ -1,9 +1,6 @@ package main -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.* import androidx.compose.material.Button import androidx.compose.material.ButtonDefaults import androidx.compose.material.MaterialTheme @@ -51,6 +48,8 @@ fun glossaryPage( Button( onClick = onAddWordClick, + modifier = Modifier + .width(300.dp), colors = ButtonDefaults.buttonColors( backgroundColor = customRedColor, contentColor = Color.White @@ -61,6 +60,8 @@ fun glossaryPage( Button( onClick = onImportClick, + modifier = Modifier + .width(300.dp), colors = ButtonDefaults.buttonColors( backgroundColor = customRedColor, contentColor = Color.White @@ -71,6 +72,8 @@ fun glossaryPage( Button( onClick = onExportClick, + modifier = Modifier + .width(300.dp), colors = ButtonDefaults.buttonColors( backgroundColor = customRedColor, contentColor = Color.White @@ -81,6 +84,8 @@ fun glossaryPage( Button( onClick = onSeeGlossaryClick, + modifier = Modifier + .width(300.dp), colors = ButtonDefaults.buttonColors( backgroundColor = customRedColor, contentColor = Color.White diff --git a/src/main/kotlin/main/Home.kt b/src/main/kotlin/main/Home.kt index c65baf1..fe971c5 100644 --- a/src/main/kotlin/main/Home.kt +++ b/src/main/kotlin/main/Home.kt @@ -1,10 +1,7 @@ package main import androidx.compose.foundation.layout.* -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text +import androidx.compose.material.* import androidx.compose.runtime.* import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -12,18 +9,17 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp var mostUsedWordList = mutableMapOf() - @Composable fun homePage( onGlossaryClick: () -> Unit, onCodeToVerifyClick: () -> Unit ) { + val noFileSnackbarVisibleState = remember { mutableStateOf(false) } Column( modifier = Modifier.fillMaxSize(), verticalArrangement = Arrangement.Center, horizontalAlignment = Alignment.CenterHorizontally - ) { Text("Quali'Nomme", style = MaterialTheme.typography.h3) @@ -31,50 +27,87 @@ fun homePage( Spacer(modifier = Modifier.height(16.dp)) - Row( - horizontalArrangement = Arrangement.spacedBy(16.dp) - ) { - Button( - onClick = onGlossaryClick, - colors = ButtonDefaults.buttonColors( - backgroundColor = customRedColor, - contentColor = Color.White - ) + Column { // Wrap the Row in a Column + Row( + horizontalArrangement = Arrangement.spacedBy(16.dp) ) { - Text("Glossaire") + Button( + onClick = onGlossaryClick, + modifier = Modifier + .width(200.dp), + colors = ButtonDefaults.buttonColors( + backgroundColor = customRedColor, + contentColor = Color.White + ) + ) { + Text("Glossaire") + } + + Button( + onClick = onCodeToVerifyClick, + modifier = Modifier + .width(200.dp), + colors = ButtonDefaults.buttonColors( + backgroundColor = customRedColor, + contentColor = Color.White + ) + ) { + Text("Code à Vérifier") + } + + Button( + onClick = { + //if file not uploaded show snackbar + if (mostUsedWordList.isEmpty()) { + noFileSnackbarVisibleState.value = true + println("Veuillez d'abord importer un fichier") + return@Button + } else { + isCompareClicked = true + } + + }, + modifier = Modifier + .width(200.dp), + colors = ButtonDefaults.buttonColors( + backgroundColor = customRedColor, + contentColor = Color.White + ), + //disable if file not uploaded + enabled = mostUsedWordList.isNotEmpty() + ) { + Text("Comparer") + } } - Button( - onClick = onCodeToVerifyClick, - colors = ButtonDefaults.buttonColors( - backgroundColor = customRedColor, - contentColor = Color.White - ) + } + + if (noFileSnackbarVisibleState.value) { + Snackbar( + modifier = Modifier.padding(16.dp), + action = { + Button( + onClick = { noFileSnackbarVisibleState.value = false }, + colors = ButtonDefaults.buttonColors( + backgroundColor = customRedColor, + contentColor = Color.White + ) + ) { + Text("OK") + } + } ) { - Text("Code à Vérifier") - } - - Button( - onClick = { - isCompareClicked = true - - }, - colors = ButtonDefaults.buttonColors( - backgroundColor = customRedColor, - contentColor = Color.White - ) - ) { - Text("Comparer") - } - - if (isCompareClicked) { - println(mostUsedWordList.keys.toList()) - compareResults( - glossaryWords = loadDatasFromFile(), - codeWords = mostUsedWordList.keys.toList(), - onBackClick = { isCompareClicked = false } - ) + Text("Veuillez d'abord importer un fichier") } } + + if (isCompareClicked) { + println(mostUsedWordList.keys.toList()) + compareResults( + glossaryWords = loadDatasFromFile(), + codeWords = mostUsedWordList.keys.toList(), + onBackClick = { isCompareClicked = false } + ) + } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/main/Verify.kt b/src/main/kotlin/main/Verify.kt index a22e404..f96eaef 100644 --- a/src/main/kotlin/main/Verify.kt +++ b/src/main/kotlin/main/Verify.kt @@ -1,9 +1,6 @@ package main -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.* import androidx.compose.material.Button import androidx.compose.material.ButtonDefaults import androidx.compose.material.MaterialTheme @@ -41,26 +38,34 @@ fun choixLangagePage( ) { Button( onClick = onPythonClick, + modifier = Modifier + .width(125.dp), colors = ButtonDefaults.buttonColors( backgroundColor = customRedColor, contentColor = Color.White - ) + ), + enabled = false ) { Text("Python") } Button( onClick = onJavaClick, + modifier = Modifier + .width(125.dp), colors = ButtonDefaults.buttonColors( backgroundColor = customRedColor, contentColor = Color.White - ) + ), + enabled = false ) { Text("Java") } Button( onClick = onJavaScriptClick, + modifier = Modifier + .width(125.dp), colors = ButtonDefaults.buttonColors( backgroundColor = customRedColor, contentColor = Color.White