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,11 +27,14 @@ fun homePage(
Spacer(modifier = Modifier.height(16.dp)) Spacer(modifier = Modifier.height(16.dp))
Column { // Wrap the Row in a Column
Row( Row(
horizontalArrangement = Arrangement.spacedBy(16.dp) horizontalArrangement = Arrangement.spacedBy(16.dp)
) { ) {
Button( Button(
onClick = onGlossaryClick, onClick = onGlossaryClick,
modifier = Modifier
.width(200.dp),
colors = ButtonDefaults.buttonColors( colors = ButtonDefaults.buttonColors(
backgroundColor = customRedColor, backgroundColor = customRedColor,
contentColor = Color.White contentColor = Color.White
@ -46,6 +45,8 @@ fun homePage(
Button( Button(
onClick = onCodeToVerifyClick, onClick = onCodeToVerifyClick,
modifier = Modifier
.width(200.dp),
colors = ButtonDefaults.buttonColors( colors = ButtonDefaults.buttonColors(
backgroundColor = customRedColor, backgroundColor = customRedColor,
contentColor = Color.White contentColor = Color.White
@ -56,15 +57,48 @@ fun homePage(
Button( Button(
onClick = { 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 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")
}
}
}
if (noFileSnackbarVisibleState.value) {
Snackbar(
modifier = Modifier.padding(16.dp),
action = {
Button(
onClick = { noFileSnackbarVisibleState.value = false },
colors = ButtonDefaults.buttonColors( colors = ButtonDefaults.buttonColors(
backgroundColor = customRedColor, backgroundColor = customRedColor,
contentColor = Color.White contentColor = Color.White
) )
) { ) {
Text("Comparer") Text("OK")
}
}
) {
Text("Veuillez d'abord importer un fichier")
}
} }
if (isCompareClicked) { if (isCompareClicked) {
@ -76,5 +110,4 @@ fun homePage(
) )
} }
} }
}
} }

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