Added glossary choose before comparing and bugfix
parent
3a514674a8
commit
7ecf4cd68d
|
@ -3,6 +3,8 @@ package main
|
|||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
|
@ -26,105 +28,155 @@ fun homePage(
|
|||
val noFileSnackbarVisibleState = remember { mutableStateOf(false) }
|
||||
var isCompareClicked by remember { mutableStateOf(false) }
|
||||
|
||||
// Utilisez un Box pour placer le drapeau en haut à droite
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(16.dp),
|
||||
contentAlignment = Alignment.TopEnd
|
||||
) {
|
||||
// Utilisez les images des drapeaux
|
||||
Image(
|
||||
painter = painterResource(if (languageManager.currentLanguage == Language.FRENCH) "FR.png" else "EN.png"),
|
||||
contentDescription = "Language Flag",
|
||||
modifier = Modifier.size(48.dp)
|
||||
.clickable { languageManager.changeLanguage() }
|
||||
)
|
||||
}
|
||||
var selectedGlossary by remember { mutableStateOf<Glossary?>(null) }
|
||||
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
verticalArrangement = Arrangement.Center,
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Text("Quali'Nomme", style = MaterialTheme.typography.h3)
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
Column {
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.spacedBy(16.dp)
|
||||
) {
|
||||
Button(
|
||||
onClick = onGlossaryClick,
|
||||
modifier = Modifier.width(200.dp),
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
backgroundColor = customRedColor,
|
||||
contentColor = Color.White
|
||||
)
|
||||
) {
|
||||
Text(languageManager.getGlossaryText())
|
||||
}
|
||||
|
||||
Button(
|
||||
onClick = onCodeToVerifyClick,
|
||||
modifier = Modifier.width(200.dp),
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
backgroundColor = customRedColor,
|
||||
contentColor = Color.White
|
||||
)
|
||||
) {
|
||||
Text(languageManager.getCodeToVerifyText())
|
||||
}
|
||||
|
||||
Button(
|
||||
onClick = {
|
||||
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
|
||||
),
|
||||
enabled = mostUsedWordList.isNotEmpty()
|
||||
) {
|
||||
Text(languageManager.getCompareText())
|
||||
}
|
||||
}
|
||||
if (!isCompareClicked && selectedGlossary == null) {
|
||||
// Utilisez un Box pour placer le drapeau en haut à droite
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(16.dp),
|
||||
contentAlignment = Alignment.TopEnd
|
||||
) {
|
||||
// Utilisez les images des drapeaux
|
||||
Image(
|
||||
painter = painterResource(if (languageManager.currentLanguage == Language.FRENCH) "FR.png" else "EN.png"),
|
||||
contentDescription = "Language Flag",
|
||||
modifier = Modifier.size(48.dp)
|
||||
.clickable { languageManager.changeLanguage() }
|
||||
)
|
||||
}
|
||||
|
||||
if (noFileSnackbarVisibleState.value) {
|
||||
Snackbar(
|
||||
modifier = Modifier.padding(16.dp),
|
||||
action = {
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
verticalArrangement = Arrangement.Center,
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Text("Quali'Nomme", style = MaterialTheme.typography.h3)
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
Column {
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.spacedBy(16.dp)
|
||||
) {
|
||||
Button(
|
||||
onClick = { noFileSnackbarVisibleState.value = false },
|
||||
onClick = onGlossaryClick,
|
||||
modifier = Modifier.width(200.dp),
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
backgroundColor = customRedColor,
|
||||
contentColor = Color.White
|
||||
)
|
||||
) {
|
||||
Text("OK")
|
||||
Text(languageManager.getGlossaryText())
|
||||
}
|
||||
|
||||
Button(
|
||||
onClick = onCodeToVerifyClick,
|
||||
modifier = Modifier.width(200.dp),
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
backgroundColor = customRedColor,
|
||||
contentColor = Color.White
|
||||
)
|
||||
) {
|
||||
Text(languageManager.getCodeToVerifyText())
|
||||
}
|
||||
|
||||
Button(
|
||||
onClick = {
|
||||
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
|
||||
),
|
||||
enabled = mostUsedWordList.isNotEmpty()
|
||||
) {
|
||||
Text(languageManager.getCompareText())
|
||||
}
|
||||
}
|
||||
) {
|
||||
Text("Veuillez d'abord importer un fichier")
|
||||
}
|
||||
|
||||
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("Veuillez d'abord importer un fichier")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isCompareClicked) {
|
||||
println(mostUsedWordList.keys.toList())
|
||||
if (isCompareClicked && selectedGlossary == null) {
|
||||
GlossaryList(glossaries = loadGlossaries()) { glossary ->
|
||||
selectedGlossary = glossary
|
||||
}
|
||||
} else if (isCompareClicked) {
|
||||
selectedGlossary?.let {
|
||||
compareResults(
|
||||
glossaryWords = loadDatasFromFile("glossaire.json"),
|
||||
glossaryWords = loadDatasFromFile(it.jsonFilePath),
|
||||
codeWords = mostUsedWordList.keys.toList(),
|
||||
onBackClick = { isCompareClicked = false }
|
||||
onBackClick = { isCompareClicked = false; selectedGlossary = null }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun GlossaryList(glossaries: List<Glossary>, onGlossarySelected: (Glossary) -> Unit) {
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
verticalArrangement = Arrangement.Center,
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Text("Sélectionnez un glossaire", style = MaterialTheme.typography.h5)
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
LazyColumn(
|
||||
modifier = Modifier.padding(10.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(10.dp)
|
||||
) {
|
||||
items(glossaries) { glossary ->
|
||||
Row(
|
||||
modifier = Modifier.width(200.dp).fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Button(
|
||||
onClick = {
|
||||
onGlossarySelected(glossary)
|
||||
},
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
backgroundColor = customRedColor,
|
||||
contentColor = Color.White
|
||||
)
|
||||
) {
|
||||
Text(glossary.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Spacer(modifier = Modifier.height(6.dp))
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.*
|
|||
|
||||
|
||||
val customRedColor = Color(0xFFB70D1B)
|
||||
val currentPage = mutableStateOf("accueil")
|
||||
|
||||
@OptIn(ExperimentalMaterialApi::class)
|
||||
@Composable
|
||||
|
@ -28,7 +29,6 @@ val customRedColor = Color(0xFFB70D1B)
|
|||
fun app() {
|
||||
val languageManager = remember { LanguageManager() }
|
||||
MaterialTheme {
|
||||
val currentPage = remember { mutableStateOf("accueil") }
|
||||
|
||||
var glossaryDetail: List<Word> by remember { mutableStateOf(emptyList()) }
|
||||
var isJavaScriptFileSelected by remember { mutableStateOf(false) }
|
||||
|
@ -52,7 +52,7 @@ fun app() {
|
|||
homePage(
|
||||
languageManager,
|
||||
onGlossaryClick = { currentPage.value = "glossaires" },
|
||||
onCodeToVerifyClick = { currentPage.value = "choixLangage" }
|
||||
onCodeToVerifyClick = { currentPage.value = "choixLangage" },
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -372,6 +372,7 @@ fun app() {
|
|||
Text("Ce glossaire existe déjà.")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue