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,6 +28,9 @@ fun homePage(
|
|||
val noFileSnackbarVisibleState = remember { mutableStateOf(false) }
|
||||
var isCompareClicked by remember { mutableStateOf(false) }
|
||||
|
||||
var selectedGlossary by remember { mutableStateOf<Glossary?>(null) }
|
||||
|
||||
if (!isCompareClicked && selectedGlossary == null) {
|
||||
// Utilisez un Box pour placer le drapeau en haut à droite
|
||||
Box(
|
||||
modifier = Modifier
|
||||
|
@ -117,14 +122,61 @@ fun homePage(
|
|||
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