add languages
parent
3956aad6c1
commit
dc97d22b03
|
@ -39,6 +39,7 @@ dependencies {
|
|||
testImplementation("junit:junit:4.13.1")
|
||||
implementation("org.apache.poi:poi:5.0.0")
|
||||
implementation("org.apache.poi:poi-ooxml:5.0.0")
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.io.IOException
|
|||
|
||||
@Composable
|
||||
fun glossaryPage(
|
||||
languageManager: LanguageManager,
|
||||
onAddWordClick: () -> Unit,
|
||||
onImportClick: () -> Unit,
|
||||
onExportClick: () -> Unit,
|
||||
|
@ -34,7 +35,7 @@ fun glossaryPage(
|
|||
verticalArrangement = Arrangement.Top, // Align content at the top
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Text(text = "Glossaire", style = MaterialTheme.typography.h3)
|
||||
Text(text = languageManager.getGlossaryTitle(), style = MaterialTheme.typography.h3)
|
||||
}
|
||||
|
||||
Column(
|
||||
|
@ -55,7 +56,7 @@ fun glossaryPage(
|
|||
contentColor = Color.White
|
||||
)
|
||||
) {
|
||||
Text("Ajouter un mot")
|
||||
Text(languageManager.getAddWordText())
|
||||
}
|
||||
|
||||
Button(
|
||||
|
@ -67,7 +68,7 @@ fun glossaryPage(
|
|||
contentColor = Color.White
|
||||
)
|
||||
) {
|
||||
Text("Importer un fichier CSV ou XLSX")
|
||||
Text(languageManager.getImportText())
|
||||
}
|
||||
|
||||
Button(
|
||||
|
@ -79,7 +80,7 @@ fun glossaryPage(
|
|||
contentColor = Color.White
|
||||
)
|
||||
) {
|
||||
Text("Exporter un fichier CSV")
|
||||
Text(languageManager.getExportText())
|
||||
}
|
||||
|
||||
Button(
|
||||
|
@ -91,7 +92,7 @@ fun glossaryPage(
|
|||
contentColor = Color.White
|
||||
)
|
||||
) {
|
||||
Text("Voir le glossaire")
|
||||
Text(languageManager.getSeeGlossaryText())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,7 +108,7 @@ fun glossaryPage(
|
|||
contentColor = Color.White
|
||||
)
|
||||
) {
|
||||
Text("Retour")
|
||||
Text(languageManager.getBackButtonText())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,47 @@
|
|||
package main
|
||||
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.material.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import java.util.*
|
||||
|
||||
var mostUsedWordList = mutableMapOf<String, Int>()
|
||||
|
||||
enum class Language {
|
||||
FRENCH, ENGLISH
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun homePage(
|
||||
languageManager: LanguageManager,
|
||||
onGlossaryClick: () -> Unit,
|
||||
onCodeToVerifyClick: () -> Unit
|
||||
) {
|
||||
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() }
|
||||
)
|
||||
}
|
||||
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
|
@ -23,41 +50,36 @@ fun homePage(
|
|||
) {
|
||||
Text("Quali'Nomme", style = MaterialTheme.typography.h3)
|
||||
|
||||
var isCompareClicked by remember { mutableStateOf(false) }
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
Column { // Wrap the Row in a Column
|
||||
Column {
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.spacedBy(16.dp)
|
||||
) {
|
||||
Button(
|
||||
onClick = onGlossaryClick,
|
||||
modifier = Modifier
|
||||
.width(200.dp),
|
||||
modifier = Modifier.width(200.dp),
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
backgroundColor = customRedColor,
|
||||
contentColor = Color.White
|
||||
)
|
||||
) {
|
||||
Text("Glossaire")
|
||||
Text(languageManager.getGlossaryText())
|
||||
}
|
||||
|
||||
Button(
|
||||
onClick = onCodeToVerifyClick,
|
||||
modifier = Modifier
|
||||
.width(200.dp),
|
||||
modifier = Modifier.width(200.dp),
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
backgroundColor = customRedColor,
|
||||
contentColor = Color.White
|
||||
)
|
||||
) {
|
||||
Text("Code à Vérifier")
|
||||
Text(languageManager.getCodeToVerifyText())
|
||||
}
|
||||
|
||||
Button(
|
||||
onClick = {
|
||||
//if file not uploaded show snackbar
|
||||
if (mostUsedWordList.isEmpty()) {
|
||||
noFileSnackbarVisibleState.value = true
|
||||
println("Veuillez d'abord importer un fichier")
|
||||
|
@ -65,21 +87,17 @@ fun homePage(
|
|||
} else {
|
||||
isCompareClicked = true
|
||||
}
|
||||
|
||||
},
|
||||
modifier = Modifier
|
||||
.width(200.dp),
|
||||
modifier = Modifier.width(200.dp),
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
backgroundColor = customRedColor,
|
||||
contentColor = Color.White
|
||||
),
|
||||
//disable if file not uploaded
|
||||
enabled = mostUsedWordList.isNotEmpty()
|
||||
) {
|
||||
Text("Comparer")
|
||||
Text(languageManager.getCompareText())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (noFileSnackbarVisibleState.value) {
|
||||
|
@ -111,3 +129,28 @@ fun homePage(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun getGlossaryButtonText(language: Language): String {
|
||||
return when (language) {
|
||||
Language.FRENCH -> "Glossaire"
|
||||
Language.ENGLISH -> "Glossary"
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun getCodeToVerifyButtonText(language: Language): String {
|
||||
return when (language) {
|
||||
Language.FRENCH -> "Code à Vérifier"
|
||||
Language.ENGLISH -> "Code to Verify"
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun getCompareButtonText(language: Language): String {
|
||||
return when (language) {
|
||||
Language.FRENCH -> "Comparer"
|
||||
Language.ENGLISH -> "Compare"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
package main
|
||||
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
|
||||
class LanguageManager {
|
||||
var currentLanguage by mutableStateOf(Language.FRENCH)
|
||||
private set
|
||||
|
||||
fun changeLanguage() {
|
||||
currentLanguage = if (currentLanguage == Language.FRENCH) Language.ENGLISH else Language.FRENCH
|
||||
}
|
||||
|
||||
fun getGlossaryText(): String {
|
||||
return when (currentLanguage) {
|
||||
Language.FRENCH -> "Glossaire"
|
||||
Language.ENGLISH -> "Glossary"
|
||||
}
|
||||
}
|
||||
|
||||
fun getCodeToVerifyText(): String {
|
||||
return when (currentLanguage) {
|
||||
Language.FRENCH -> "Code à Vérifier"
|
||||
Language.ENGLISH -> "Code to Verify"
|
||||
}
|
||||
}
|
||||
|
||||
fun getCompareText(): String {
|
||||
return when (currentLanguage) {
|
||||
Language.FRENCH -> "Comparer"
|
||||
Language.ENGLISH -> "Compare"
|
||||
}
|
||||
}
|
||||
|
||||
fun getAddWordText(): String {
|
||||
return when (currentLanguage) {
|
||||
Language.FRENCH -> "Ajouter un mot"
|
||||
Language.ENGLISH -> "Add a word"
|
||||
}
|
||||
}
|
||||
|
||||
fun getImportText(): String {
|
||||
return when (currentLanguage) {
|
||||
Language.FRENCH -> "Importer un fichier"
|
||||
Language.ENGLISH -> "Import a file"
|
||||
}
|
||||
}
|
||||
|
||||
fun getExportText(): String {
|
||||
return when (currentLanguage) {
|
||||
Language.FRENCH -> "Exporter un fichier"
|
||||
Language.ENGLISH -> "Export a file"
|
||||
}
|
||||
}
|
||||
|
||||
fun getSeeGlossaryText(): String {
|
||||
return when (currentLanguage) {
|
||||
Language.FRENCH -> "Voir le glossaire"
|
||||
Language.ENGLISH -> "See glossary"
|
||||
}
|
||||
}
|
||||
|
||||
fun getGlossaryTitle(): String {
|
||||
return when (currentLanguage) {
|
||||
Language.FRENCH -> "Glossaire"
|
||||
Language.ENGLISH -> "Glossary"
|
||||
}
|
||||
}
|
||||
|
||||
fun getLanguageChoiceTitle(): String {
|
||||
return when (currentLanguage) {
|
||||
Language.FRENCH -> "Choix du langage"
|
||||
Language.ENGLISH -> "Language choice"
|
||||
}
|
||||
}
|
||||
|
||||
fun getBackButtonText(): String {
|
||||
return when (currentLanguage) {
|
||||
Language.FRENCH -> "Retour"
|
||||
Language.ENGLISH -> "Back"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,6 +17,7 @@ val customRedColor = Color(0xFFB70D1B)
|
|||
@Composable
|
||||
@Preview
|
||||
fun app() {
|
||||
val languageManager = LanguageManager()
|
||||
MaterialTheme {
|
||||
val currentPage = remember { mutableStateOf("accueil") }
|
||||
|
||||
|
@ -26,6 +27,7 @@ fun app() {
|
|||
when (currentPage.value) {
|
||||
"accueil" -> {
|
||||
homePage(
|
||||
languageManager,
|
||||
onGlossaryClick = { currentPage.value = "glossaire" },
|
||||
onCodeToVerifyClick = { currentPage.value = "choixLangage" }
|
||||
)
|
||||
|
@ -33,6 +35,7 @@ fun app() {
|
|||
|
||||
"glossaire" -> {
|
||||
glossaryPage(
|
||||
languageManager,
|
||||
onAddWordClick = { currentPage.value = "formulaire" },
|
||||
onImportClick = {
|
||||
selectFile(setOf("csv", "xlsx")) { filePath ->
|
||||
|
@ -77,6 +80,7 @@ fun app() {
|
|||
val javaExtensions = setOf("java")
|
||||
val jsExtensions = setOf("js", "html")
|
||||
choixLangagePage(
|
||||
languageManager,
|
||||
onBackClick = { currentPage.value = "accueil" },
|
||||
onPythonClick = {
|
||||
selectFile(pythonExtensions) { filePath ->
|
||||
|
|
|
@ -13,6 +13,7 @@ import androidx.compose.ui.unit.dp
|
|||
|
||||
@Composable
|
||||
fun choixLangagePage(
|
||||
languageManager: LanguageManager,
|
||||
onBackClick: () -> Unit,
|
||||
onPythonClick: () -> Unit,
|
||||
onJavaClick: () -> Unit,
|
||||
|
@ -24,7 +25,7 @@ fun choixLangagePage(
|
|||
verticalArrangement = Arrangement.Top, // Align content at the top
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Text(text = "Choix du langage", style = MaterialTheme.typography.h3)
|
||||
Text(text = languageManager.getLanguageChoiceTitle(), style = MaterialTheme.typography.h3)
|
||||
}
|
||||
|
||||
Column(
|
||||
|
@ -87,7 +88,7 @@ fun choixLangagePage(
|
|||
contentColor = Color.White
|
||||
)
|
||||
) {
|
||||
Text("Retour")
|
||||
Text(languageManager.getBackButtonText())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 239 B |
Loading…
Reference in New Issue