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 horizontalAlignment = Alignment.CenterHorizontally
) { ) {
Text( 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 style = MaterialTheme.typography.h3
) )
} }

View File

@ -3,6 +3,7 @@ package main
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.*
import androidx.compose.material.* import androidx.compose.material.*
import androidx.compose.material.icons.Icons 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.Check
import androidx.compose.material.icons.filled.Close import androidx.compose.material.icons.filled.Close
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@ -149,8 +150,8 @@ fun formPage(onCancelClick: () -> Unit) {
contentColor = Color.White contentColor = Color.White
) )
) { ) {
Icon(imageVector = Icons.Default.Close, contentDescription = null) Icon(imageVector = Icons.Default.ArrowBack, contentDescription = null)
Text("Annuler") Text("Retour")
} }
Button( Button(
onClick = { onClick = {
@ -199,7 +200,13 @@ fun formPage(onCancelClick: () -> Unit) {
Snackbar( Snackbar(
modifier = Modifier.padding(16.dp), modifier = Modifier.padding(16.dp),
action = { action = {
Button(onClick = { requiredFieldsSnackbarVisibleState.value = false }) { Button(
onClick = { requiredFieldsSnackbarVisibleState.value = false },
colors = ButtonDefaults.buttonColors(
backgroundColor = customRedColor,
contentColor = Color.White
)
) {
Text("OK") Text("OK")
} }
} }
@ -211,7 +218,13 @@ fun formPage(onCancelClick: () -> Unit) {
Snackbar( Snackbar(
modifier = Modifier.padding(16.dp), modifier = Modifier.padding(16.dp),
action = { action = {
Button(onClick = { alreadyExistSnackbarVisibleState.value = false }) { Button(
onClick = { alreadyExistSnackbarVisibleState.value = false },
colors = ButtonDefaults.buttonColors(
backgroundColor = customRedColor,
contentColor = Color.White
)
) {
Text("OK") Text("OK")
} }
} }

View File

@ -1,9 +1,6 @@
package main package main
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Button import androidx.compose.material.Button
import androidx.compose.material.ButtonDefaults import androidx.compose.material.ButtonDefaults
import androidx.compose.material.MaterialTheme import androidx.compose.material.MaterialTheme
@ -51,6 +48,8 @@ fun glossaryPage(
Button( Button(
onClick = onAddWordClick, onClick = onAddWordClick,
modifier = Modifier
.width(300.dp),
colors = ButtonDefaults.buttonColors( colors = ButtonDefaults.buttonColors(
backgroundColor = customRedColor, backgroundColor = customRedColor,
contentColor = Color.White contentColor = Color.White
@ -61,6 +60,8 @@ fun glossaryPage(
Button( Button(
onClick = onImportClick, onClick = onImportClick,
modifier = Modifier
.width(300.dp),
colors = ButtonDefaults.buttonColors( colors = ButtonDefaults.buttonColors(
backgroundColor = customRedColor, backgroundColor = customRedColor,
contentColor = Color.White contentColor = Color.White
@ -71,6 +72,8 @@ fun glossaryPage(
Button( Button(
onClick = onExportClick, onClick = onExportClick,
modifier = Modifier
.width(300.dp),
colors = ButtonDefaults.buttonColors( colors = ButtonDefaults.buttonColors(
backgroundColor = customRedColor, backgroundColor = customRedColor,
contentColor = Color.White contentColor = Color.White
@ -81,6 +84,8 @@ fun glossaryPage(
Button( Button(
onClick = onSeeGlossaryClick, onClick = onSeeGlossaryClick,
modifier = Modifier
.width(300.dp),
colors = ButtonDefaults.buttonColors( colors = ButtonDefaults.buttonColors(
backgroundColor = customRedColor, backgroundColor = customRedColor,
contentColor = Color.White contentColor = Color.White

View File

@ -1,10 +1,7 @@
package main package main
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.*
import androidx.compose.material.Button import androidx.compose.material.*
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.* import androidx.compose.runtime.*
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
@ -12,18 +9,17 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
var mostUsedWordList = mutableMapOf<String, Int>() var mostUsedWordList = mutableMapOf<String, Int>()
@Composable @Composable
fun homePage( fun homePage(
onGlossaryClick: () -> Unit, onGlossaryClick: () -> Unit,
onCodeToVerifyClick: () -> Unit onCodeToVerifyClick: () -> Unit
) { ) {
val noFileSnackbarVisibleState = remember { mutableStateOf(false) }
Column( Column(
modifier = Modifier.fillMaxSize(), modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center, verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally horizontalAlignment = Alignment.CenterHorizontally
) { ) {
Text("Quali'Nomme", style = MaterialTheme.typography.h3) Text("Quali'Nomme", style = MaterialTheme.typography.h3)
@ -31,50 +27,87 @@ fun homePage(
Spacer(modifier = Modifier.height(16.dp)) Spacer(modifier = Modifier.height(16.dp))
Row( Column { // Wrap the Row in a Column
horizontalArrangement = Arrangement.spacedBy(16.dp) Row(
) { horizontalArrangement = Arrangement.spacedBy(16.dp)
Button(
onClick = onGlossaryClick,
colors = ButtonDefaults.buttonColors(
backgroundColor = customRedColor,
contentColor = Color.White
)
) { ) {
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( if (noFileSnackbarVisibleState.value) {
backgroundColor = customRedColor, Snackbar(
contentColor = Color.White 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 package main
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Button import androidx.compose.material.Button
import androidx.compose.material.ButtonDefaults import androidx.compose.material.ButtonDefaults
import androidx.compose.material.MaterialTheme import androidx.compose.material.MaterialTheme
@ -41,26 +38,34 @@ fun choixLangagePage(
) { ) {
Button( Button(
onClick = onPythonClick, onClick = onPythonClick,
modifier = Modifier
.width(125.dp),
colors = ButtonDefaults.buttonColors( colors = ButtonDefaults.buttonColors(
backgroundColor = customRedColor, backgroundColor = customRedColor,
contentColor = Color.White contentColor = Color.White
) ),
enabled = false
) { ) {
Text("Python") Text("Python")
} }
Button( Button(
onClick = onJavaClick, onClick = onJavaClick,
modifier = Modifier
.width(125.dp),
colors = ButtonDefaults.buttonColors( colors = ButtonDefaults.buttonColors(
backgroundColor = customRedColor, backgroundColor = customRedColor,
contentColor = Color.White contentColor = Color.White
) ),
enabled = false
) { ) {
Text("Java") Text("Java")
} }
Button( Button(
onClick = onJavaScriptClick, onClick = onJavaScriptClick,
modifier = Modifier
.width(125.dp),
colors = ButtonDefaults.buttonColors( colors = ButtonDefaults.buttonColors(
backgroundColor = customRedColor, backgroundColor = customRedColor,
contentColor = Color.White contentColor = Color.White