Improvments in design

main
Cemal Odabasioglu 2023-12-08 13:42:54 +01:00
parent 21fc7ce28d
commit 90f1623749
5 changed files with 117 additions and 61 deletions

View File

@ -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
)
}

View File

@ -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")
}
}

View File

@ -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

View File

@ -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<String, Int>()
@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")
Text("Veuillez d'abord importer un fichier")
}
}
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 }
)
}
if (isCompareClicked) {
println(mostUsedWordList.keys.toList())
compareResults(
glossaryWords = loadDatasFromFile(),
codeWords = mostUsedWordList.keys.toList(),
onBackClick = { isCompareClicked = false }
)
}
}
}

View File

@ -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