final language

main
ByrmGkcn 2024-01-15 18:33:25 +01:00
parent 39de56a91b
commit 04f263dbb3
14 changed files with 241 additions and 58 deletions

View File

@ -41,6 +41,7 @@ dependencies {
testImplementation("junit:junit:4.13.1") testImplementation("junit:junit:4.13.1")
implementation("org.apache.poi:poi:5.0.0") implementation("org.apache.poi:poi:5.0.0")
implementation("org.apache.poi:poi-ooxml:5.0.0") implementation("org.apache.poi:poi-ooxml:5.0.0")
implementation("pl.droidsonroids.gif:android-gif-drawable:1.2.23")
testImplementation("org.junit.jupiter:junit-jupiter:5.8.1") testImplementation("org.junit.jupiter:junit-jupiter:5.8.1")
testImplementation("org.junit.jupiter:junit-jupiter:5.8.1") testImplementation("org.junit.jupiter:junit-jupiter:5.8.1")
} }

View File

@ -19,6 +19,7 @@ import org.apache.poi.ss.usermodel.HorizontalAlignment
@Composable @Composable
fun compareResults( fun compareResults(
languageManager: LanguageManager,
glossaryWords: List<Word>, glossaryWords: List<Word>,
codeWords: List<String>, codeWords: List<String>,
onBackClick: () -> Unit, onBackClick: () -> Unit,
@ -64,17 +65,18 @@ fun compareResults(
contentColor = Color.White contentColor = Color.White
) )
) { ) {
Text("Retour") Text(languageManager.getBackText())
} }
} }
dropdownButtonComponent( dropdownButtonComponent(
items = listOf("Glossaire", "Code à vérifier", "Comparer") languageManager = languageManager,
items = listOf(languageManager.getGlossaryText(), languageManager.getCodeToVerifyText(), languageManager.getCompareText())
) { selectedOption -> ) { selectedOption ->
// Handle the selected option // Handle the selected option
when (selectedOption) { when (selectedOption) {
"Glossaire" -> onProjectClick() languageManager.getGlossaryText() -> onProjectClick()
"Code à vérifier" -> onCodeToVerifyClick() languageManager.getCodeToVerifyText() -> onCodeToVerifyClick()
"Comparer" -> { languageManager.getCompareText() -> {
if (mostUsedWordList.isEmpty()) { if (mostUsedWordList.isEmpty()) {
noFileSnackbarVisibleState.value = true noFileSnackbarVisibleState.value = true
return@dropdownButtonComponent return@dropdownButtonComponent

View File

@ -21,6 +21,7 @@ import main.component.dropdownButtonComponent
@OptIn(ExperimentalMaterialApi::class) @OptIn(ExperimentalMaterialApi::class)
@Composable @Composable
fun glossaryDetailedPage( fun glossaryDetailedPage(
languageManager: LanguageManager,
glossary: List<Word>, glossary: List<Word>,
glossaryName: String, glossaryName: String,
onBackClick: () -> Unit, onBackClick: () -> Unit,
@ -130,13 +131,14 @@ fun glossaryDetailedPage(
} }
} }
dropdownButtonComponent( dropdownButtonComponent(
items = listOf("Glossaire", "Code à vérifier", "Comparer") languageManager = languageManager,
items = listOf(languageManager.getGlossaryText(), languageManager.getCodeToVerifyText(), languageManager.getCompareText())
) { selectedOption -> ) { selectedOption ->
// Handle the selected option // Handle the selected option
when (selectedOption) { when (selectedOption) {
"Glossaire" -> onProjectClick() languageManager.getGlossaryText() -> onProjectClick()
"Code à vérifier" -> onCodeToVerifyClick() languageManager.getCodeToVerifyText() -> onCodeToVerifyClick()
"Comparer" -> { languageManager.getCompareText() -> {
if (mostUsedWordList.isEmpty()) { if (mostUsedWordList.isEmpty()) {
noFileSnackbarVisibleState.value = true noFileSnackbarVisibleState.value = true
return@dropdownButtonComponent return@dropdownButtonComponent

View File

@ -38,6 +38,7 @@ val frame = Frame()
@Composable @Composable
fun glossariesPage( fun glossariesPage(
languageManager: LanguageManager,
currentPage: MutableState<String>, currentPage: MutableState<String>,
onProjectClick: () -> Unit, onProjectClick: () -> Unit,
onCodeToVerifyClick: () -> Unit onCodeToVerifyClick: () -> Unit
@ -52,7 +53,7 @@ fun glossariesPage(
verticalArrangement = Arrangement.Center, verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally horizontalAlignment = Alignment.CenterHorizontally
) { ) {
Text("Sélectionnez un glossaire", style = MaterialTheme.typography.h5) Text(languageManager.getSelectGlossaryText(), style = MaterialTheme.typography.h5)
Spacer(modifier = Modifier.height(16.dp)) Spacer(modifier = Modifier.height(16.dp))
@ -60,12 +61,13 @@ fun glossariesPage(
modifier = Modifier modifier = Modifier
.height(300.dp) .height(300.dp)
.width(250.dp) .width(250.dp)
.padding(10.dp) .padding(10.dp),
contentAlignment = Alignment.Center
) { ) {
val scrollState = rememberLazyListState() val scrollState = rememberLazyListState()
glossaries = loadGlossaries(appState.selectedProject!!) glossaries = loadGlossaries(appState.selectedProject!!)
if (glossaries.isEmpty()) { if (glossaries.isEmpty()) {
Text("Aucun glossaire n'a été créé pour ce projet") Text(languageManager.getNoGlossaryText())
} else { } else {
LazyColumn( LazyColumn(
state = scrollState, state = scrollState,
@ -119,7 +121,7 @@ fun glossariesPage(
Spacer(modifier = Modifier.height(16.dp)) Spacer(modifier = Modifier.height(16.dp))
// mettre un texte "ou" // mettre un texte "ou"
Text("ou", style = MaterialTheme.typography.h5) Text(languageManager.getOuText(), style = MaterialTheme.typography.h5)
Spacer(modifier = Modifier.height(16.dp)) Spacer(modifier = Modifier.height(16.dp))
@ -134,7 +136,7 @@ fun glossariesPage(
contentColor = Color.White contentColor = Color.White
) )
) { ) {
Text("Créer un nouveau glossaire") Text(languageManager.getNewGlossaryText())
} }
Spacer(modifier = Modifier.height(6.dp)) Spacer(modifier = Modifier.height(6.dp))
@ -150,17 +152,18 @@ fun glossariesPage(
contentColor = Color.White contentColor = Color.White
) )
) { ) {
Text("Retour") Text(languageManager.getBackText())
} }
} }
dropdownButtonComponent( dropdownButtonComponent(
items = listOf("Glossaire", "Code à vérifier", "Comparer") languageManager = languageManager,
items = listOf(languageManager.getGlossaryText(), languageManager.getCodeToVerifyText(), languageManager.getCompareText())
) { selectedOption -> ) { selectedOption ->
// Handle the selected option // Handle the selected option
when (selectedOption) { when (selectedOption) {
"Glossaire" -> onProjectClick() languageManager.getGlossaryText() -> onProjectClick()
"Code à vérifier" -> onCodeToVerifyClick() languageManager.getCodeToVerifyText() -> onCodeToVerifyClick()
"Comparer" -> { languageManager.getCompareText() -> {
if (mostUsedWordList.isEmpty()) { if (mostUsedWordList.isEmpty()) {
noFileSnackbarVisibleState.value = true noFileSnackbarVisibleState.value = true
return@dropdownButtonComponent return@dropdownButtonComponent
@ -175,6 +178,7 @@ fun glossariesPage(
@OptIn(ExperimentalStdlibApi::class, ExperimentalComposeUiApi::class) @OptIn(ExperimentalStdlibApi::class, ExperimentalComposeUiApi::class)
@Composable @Composable
fun newGlossary( fun newGlossary(
languageManager: LanguageManager,
currentPage: MutableState<String>, currentPage: MutableState<String>,
) { ) {
val isEmptySnackbarVisibleState = remember { mutableStateOf(false) } val isEmptySnackbarVisibleState = remember { mutableStateOf(false) }

View File

@ -1,10 +1,12 @@
package main package main
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.*
import androidx.compose.material.* import androidx.compose.material.*
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import main.component.buttonComponent import main.component.buttonComponent
@ -22,14 +24,27 @@ fun HelpPage(onBackClick: () -> Unit) {
Spacer(modifier = Modifier.height(16.dp)) Spacer(modifier = Modifier.height(16.dp))
Text("Contenu de l'aide...") // Charger et afficher le premier GIF
Image(
painter = painterResource("1.gif"),
contentDescription = "GIF 1",
modifier = Modifier.size(150.dp)
)
Spacer(modifier = Modifier.height(16.dp))
// Charger et afficher le deuxième GIF
Image(
painter = painterResource("2.gif"),
contentDescription = "GIF 2",
modifier = Modifier.size(150.dp)
)
Spacer(modifier = Modifier.height(16.dp)) Spacer(modifier = Modifier.height(16.dp))
buttonComponent("OK", onBackClick) buttonComponent("OK", onBackClick)
} }
} }
@Composable @Composable
fun HelpButton(onHelpClick: () -> Unit) { fun HelpButton(onHelpClick: () -> Unit) {
Box( Box(

View File

@ -112,13 +112,14 @@ fun homePage(
// Example usage with text options // Example usage with text options
dropdownButtonComponent( dropdownButtonComponent(
items = listOf("Glossaire", "Code à vérifier", "Comparer") languageManager = languageManager,
items = listOf(languageManager.getGlossaryText(), languageManager.getCodeToVerifyText(), languageManager.getCompareText())
) { selectedOption -> ) { selectedOption ->
// Handle the selected option // Handle the selected option
when (selectedOption) { when (selectedOption) {
"Glossaire" -> onProjectClick() languageManager.getGlossaryText() -> onProjectClick()
"Code à vérifier" -> onCodeToVerifyClick() languageManager.getCodeToVerifyText() -> onCodeToVerifyClick()
"Comparer" -> { languageManager.getCompareText() -> {
if (mostUsedWordList.isEmpty()) { if (mostUsedWordList.isEmpty()) {
noFileSnackbarVisibleState.value = true noFileSnackbarVisibleState.value = true
return@dropdownButtonComponent return@dropdownButtonComponent
@ -146,6 +147,7 @@ fun homePage(
selectedProject = null selectedProject = null
}, },
onProjectClick = { currentPage.value = "projects" }, onProjectClick = { currentPage.value = "projects" },
languageManager = languageManager,
onCodeToVerifyClick = { currentPage.value = "choixLangage" } onCodeToVerifyClick = { currentPage.value = "choixLangage" }
) )
} }
@ -162,6 +164,7 @@ fun homePage(
selectedProject = null selectedProject = null
}, },
onProjectClick = { currentPage.value = "projects" }, onProjectClick = { currentPage.value = "projects" },
languageManager = languageManager,
onCodeToVerifyClick = { currentPage.value = "choixLangage" } onCodeToVerifyClick = { currentPage.value = "choixLangage" }
) )
} }
@ -169,6 +172,7 @@ fun homePage(
isCompareClicked -> { isCompareClicked -> {
selectedGlossary?.let { selectedGlossary?.let {
compareResults( compareResults(
languageManager = languageManager,
glossaryWords = loadDatasFromFile(it.jsonFilePath), glossaryWords = loadDatasFromFile(it.jsonFilePath),
codeWords = mostUsedWordList.keys.toList(), codeWords = mostUsedWordList.keys.toList(),
onBackClick = { onBackClick = {
@ -193,6 +197,7 @@ fun homePage(
@Composable @Composable
fun glossaryList( fun glossaryList(
languageManager: LanguageManager,
glossaries: List<Glossary>, glossaries: List<Glossary>,
onGlossarySelected: (Glossary) -> Unit, onGlossarySelected: (Glossary) -> Unit,
onBackClick: () -> Unit, onBackClick: () -> Unit,
@ -254,6 +259,7 @@ fun glossaryList(
} }
dropdownButtonComponent( dropdownButtonComponent(
languageManager,
items = listOf("Glossaire", "Code à vérifier", "Comparer") items = listOf("Glossaire", "Code à vérifier", "Comparer")
) { selectedOption -> ) { selectedOption ->
// Handle the selected option // Handle the selected option
@ -274,6 +280,7 @@ fun glossaryList(
@Composable @Composable
fun projectList( fun projectList(
languageManager: LanguageManager,
projects: List<Project>, projects: List<Project>,
onProjectSelected: (Project) -> Unit, onProjectSelected: (Project) -> Unit,
onBackClick: () -> Unit, onBackClick: () -> Unit,
@ -334,6 +341,7 @@ fun projectList(
buttonComponent("Retour", onBackClick) buttonComponent("Retour", onBackClick)
} }
dropdownButtonComponent( dropdownButtonComponent(
languageManager,
items = listOf("Glossaire", "Code à vérifier", "Comparer") items = listOf("Glossaire", "Code à vérifier", "Comparer")
) { selectedOption -> ) { selectedOption ->
// Handle the selected option // Handle the selected option

View File

@ -81,4 +81,139 @@ class LanguageManager {
Language.ENGLISH -> "Back" Language.ENGLISH -> "Back"
} }
} }
fun getSelectProjectText(): String {
return when (currentLanguage) {
Language.FRENCH -> "Sélectionnez un projet"
Language.ENGLISH -> "Select a project"
}
}
fun getNoProjectText(): String {
return when (currentLanguage) {
Language.FRENCH -> "Aucun projet n'a été créé"
Language.ENGLISH -> "There is no project"
}
}
fun getNewProjectText(): String {
return when (currentLanguage) {
Language.FRENCH -> "Créer un nouveau projet"
Language.ENGLISH -> "Create a new project"
}
}
fun getBackText(): String {
return when (currentLanguage) {
Language.FRENCH -> "Retour"
Language.ENGLISH -> "Back"
}
}
fun getMenuText(): String {
return "Menu"
}
fun getNameProjectText(): String {
return when (currentLanguage) {
Language.FRENCH -> "Nom du projet"
Language.ENGLISH -> "Project name"
}
}
fun getEnterProjectNameText(): Any {
return when (currentLanguage) {
Language.FRENCH -> "Veuillez saisir un nom pour le projet"
Language.ENGLISH -> "Please enter a name for the project"
}
}
fun getNoSpaceInProjectNameText(): Any {
return when (currentLanguage) {
Language.FRENCH -> "Le nom du projet ne doit pas contenir d'espace"
Language.ENGLISH -> "The project name cannot contain spaces"
}
}
fun getGlossaryAlreadyExistsText(): Any {
return when (currentLanguage) {
Language.FRENCH -> "Le nom du projet existe déjà"
Language.ENGLISH -> "The project name already exists"
}
}
fun getInvalidCharacterText(): Any {
return when (currentLanguage) {
Language.FRENCH -> "Le nom du projet ne doit pas contenir les caractères suivants : / \\ : * ? \" < > |"
Language.ENGLISH -> "The project name cannot contain the following characters: / \\ : * ? \" < > |"
}
}
fun getCreateProjectText(): Any {
return when (currentLanguage) {
Language.FRENCH -> "Créer"
Language.ENGLISH -> "Create"
}
}
fun getNameGlossaryText(): String {
return when (currentLanguage) {
Language.FRENCH -> "Nom du glossaire"
Language.ENGLISH -> "Glossary name"
}
}
fun getNoGlossaryText(): String {
return when (currentLanguage) {
Language.FRENCH -> "Aucun glossaire n'a été créé"
Language.ENGLISH -> "There is no glossary"
}
}
fun getSelectGlossaryText(): String {
return when (currentLanguage) {
Language.FRENCH -> "Sélectionnez un glossaire"
Language.ENGLISH -> "Select a glossary"
}
}
fun getCreateGlossaryText(): String {
return when (currentLanguage) {
Language.FRENCH -> "Créer un nouveau glossaire"
Language.ENGLISH -> "Create a new glossary"
}
}
fun getAcceuil(): String {
return when (currentLanguage) {
Language.FRENCH -> "Accueil"
Language.ENGLISH -> "Home"
}
}
fun getNewGlossaryText(): String {
return when (currentLanguage) {
Language.FRENCH -> "Créer un nouveau glossaire"
Language.ENGLISH -> "Create a new glossary"
}
}
fun getOuText(): String {
return when (currentLanguage) {
Language.FRENCH -> "ou"
Language.ENGLISH -> "or"
}
}
} }

View File

@ -58,6 +58,7 @@ fun app() {
"glossaires" -> { "glossaires" -> {
glossariesPage( glossariesPage(
languageManager,
currentPage = currentPage, currentPage = currentPage,
onProjectClick = { currentPage.value = "projets" }, onProjectClick = { currentPage.value = "projets" },
onCodeToVerifyClick = { currentPage.value = "choixLangage" }, onCodeToVerifyClick = { currentPage.value = "choixLangage" },
@ -68,20 +69,23 @@ fun app() {
// Nouvelle page pour créer un nouveau glossaire // Nouvelle page pour créer un nouveau glossaire
"nouveauGlossaire" -> { "nouveauGlossaire" -> {
newGlossary( newGlossary(
languageManager,
currentPage = currentPage, currentPage = currentPage,
) )
} }
"projects" -> { "projects" -> {
projectsPage( projectsPage(
currentPage = currentPage,
onProjectClick = { currentPage.value = "projects" }, onProjectClick = { currentPage.value = "projects" },
onCodeToVerifyClick = { currentPage.value = "choixLangage" }, onCodeToVerifyClick = { currentPage.value = "choixLangage" },
languageManager = languageManager,
currentPage = currentPage,
) )
} }
"nouveauProjet" ->{ "nouveauProjet" ->{
newProject( newProject(
languageManager,
currentPage = currentPage currentPage = currentPage
) )
} }
@ -114,6 +118,7 @@ fun app() {
} }
}, },
onProjectClick = { currentPage.value = "projects" }, onProjectClick = { currentPage.value = "projects" },
languageManager = languageManager,
onCodeToVerifyClick = { currentPage.value = "choixLangage" }, onCodeToVerifyClick = { currentPage.value = "choixLangage" },
) )
} }
@ -152,6 +157,7 @@ fun app() {
} }
"occurrence" -> { "occurrence" -> {
parsedWordsTable( parsedWordsTable(
languageManager,
mostUsedWordList, mostUsedWordList,
onBackClick = { currentPage.value = "choixLangage" }, onBackClick = { currentPage.value = "choixLangage" },
onProjectClick = { currentPage.value = "projects" }, onProjectClick = { currentPage.value = "projects" },

View File

@ -29,6 +29,7 @@ fun loadProjects(): List<Project> {
@Composable @Composable
fun projectsPage( fun projectsPage(
languageManager: LanguageManager,
currentPage: MutableState<String>, currentPage: MutableState<String>,
onProjectClick: () -> Unit, onProjectClick: () -> Unit,
onCodeToVerifyClick: () -> Unit onCodeToVerifyClick: () -> Unit
@ -45,6 +46,7 @@ fun projectsPage(
) { ) {
Text("Sélectionnez un projet", style = MaterialTheme.typography.h5) Text("Sélectionnez un projet", style = MaterialTheme.typography.h5)
Text(languageManager.getSelectProjectText(), style = MaterialTheme.typography.h5)
Spacer(modifier = Modifier.height(16.dp)) Spacer(modifier = Modifier.height(16.dp))
@ -52,12 +54,13 @@ fun projectsPage(
modifier = Modifier modifier = Modifier
.height(300.dp) .height(300.dp)
.width(250.dp) .width(250.dp)
.padding(10.dp) .padding(10.dp),
contentAlignment = Alignment.Center
) { ) {
val scrollState = rememberLazyListState() val scrollState = rememberLazyListState()
projects = loadProjects() projects = loadProjects()
if (projects.isEmpty()) { if (projects.isEmpty()) {
Text("Aucun proje n'a été créé") Text(languageManager.getNoProjectText())
} else { } else {
LazyColumn( LazyColumn(
state = scrollState, state = scrollState,
@ -122,7 +125,7 @@ fun projectsPage(
contentColor = Color.White contentColor = Color.White
) )
) { ) {
Text("Créer un nouveau projet") Text(languageManager.getNewProjectText())
} }
Spacer(modifier = Modifier.height(6.dp)) Spacer(modifier = Modifier.height(6.dp))
@ -138,17 +141,18 @@ fun projectsPage(
contentColor = Color.White contentColor = Color.White
) )
) { ) {
Text("Retour") Text(languageManager.getBackText())
} }
} }
dropdownButtonComponent( dropdownButtonComponent(
items = listOf("Glossaire", "Code à vérifier", "Comparer") languageManager = languageManager,
items = listOf(languageManager.getGlossaryText(), languageManager.getCodeToVerifyText(), languageManager.getCompareText())
) { selectedOption -> ) { selectedOption ->
// Handle the selected option // Handle the selected option
when (selectedOption) { when (selectedOption) {
"Glossaire" -> onProjectClick() languageManager.getGlossaryText() -> onProjectClick()
"Code à vérifier" -> onCodeToVerifyClick() languageManager.getCodeToVerifyText() -> onCodeToVerifyClick()
"Comparer" -> { languageManager.getCompareText() -> {
if (mostUsedWordList.isEmpty()) { if (mostUsedWordList.isEmpty()) {
noFileSnackbarVisibleState.value = true noFileSnackbarVisibleState.value = true
return@dropdownButtonComponent return@dropdownButtonComponent
@ -163,6 +167,7 @@ fun projectsPage(
@OptIn(ExperimentalComposeUiApi::class) @OptIn(ExperimentalComposeUiApi::class)
@Composable @Composable
fun newProject( fun newProject(
languageManager: LanguageManager,
currentPage: MutableState<String> currentPage: MutableState<String>
){ ){
var projectName by remember { mutableStateOf("") } var projectName by remember { mutableStateOf("") }
@ -177,7 +182,7 @@ fun newProject(
verticalArrangement = Arrangement.Center, verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally horizontalAlignment = Alignment.CenterHorizontally
){ ){
Text("Nom du projet", style = MaterialTheme.typography.h5) Text(languageManager.getNameProjectText(), style = MaterialTheme.typography.h5)
Spacer(modifier = Modifier.height(16.dp)) Spacer(modifier = Modifier.height(16.dp))
val projectsList = loadProjects() val projectsList = loadProjects()
@ -186,7 +191,7 @@ fun newProject(
value = projectName, value = projectName,
singleLine = true, singleLine = true,
onValueChange = { projectName = it }, onValueChange = { projectName = it },
label = { Text("Nom du projet") }, label = { Text(languageManager.getNameProjectText()) },
colors = TextFieldDefaults.textFieldColors( colors = TextFieldDefaults.textFieldColors(
focusedIndicatorColor = customRedColor, focusedIndicatorColor = customRedColor,
unfocusedIndicatorColor = Color.Gray, unfocusedIndicatorColor = Color.Gray,
@ -198,16 +203,16 @@ fun newProject(
.onKeyEvent { event -> .onKeyEvent { event ->
if (event.key == Key.Enter && event.type == KeyEventType.KeyDown) { if (event.key == Key.Enter && event.type == KeyEventType.KeyDown) {
if (projectName.isEmpty()) { if (projectName.isEmpty()) {
println("Veuillez saisir un nom pour le nouveau projet") println(languageManager.getEnterProjectNameText())
isEmptySnackbarVisibleState.value = true isEmptySnackbarVisibleState.value = true
} else if (projectName.contains(" ")) { } else if (projectName.contains(" ")) {
println("Le nom du projet ne doit pas contenir d'espace") println(languageManager.getNoSpaceInProjectNameText())
containsSpaceSnackbarVisibleState.value = true containsSpaceSnackbarVisibleState.value = true
} else if (projectsList.any { it.name == projectName }) { } else if (projectsList.any { it.name == projectName }) {
println("Le nom du projet existe déjà") println(languageManager.getGlossaryAlreadyExistsText())
glossaryAlreadyExistsSnackbarVisibleState.value = true glossaryAlreadyExistsSnackbarVisibleState.value = true
} else if (!isValidFileName(projectName)) { } else if (!isValidFileName(projectName)) {
println("Le nom du projet contient des caractères non autorisés") println(languageManager.getInvalidCharacterText())
invalidCharacterSnackbarVisibleState.value = true invalidCharacterSnackbarVisibleState.value = true
} else { } else {
val directory = File("src/main/resources/projects/$projectName/") val directory = File("src/main/resources/projects/$projectName/")
@ -227,16 +232,16 @@ fun newProject(
Button( Button(
onClick = { onClick = {
if (projectName.isEmpty()) { if (projectName.isEmpty()) {
println("Veuillez saisir un nom pour le nouveau projet") println(languageManager.getEnterProjectNameText())
isEmptySnackbarVisibleState.value = true isEmptySnackbarVisibleState.value = true
} else if (projectName.contains(" ")) { } else if (projectName.contains(" ")) {
println("Le nom du projet ne doit pas contenir d'espace") println(languageManager.getNoSpaceInProjectNameText())
containsSpaceSnackbarVisibleState.value = true containsSpaceSnackbarVisibleState.value = true
} else if (projectsList.any { it.name == projectName }) { } else if (projectsList.any { it.name == projectName }) {
println("Le nom du projet existe déjà") println(languageManager.getGlossaryAlreadyExistsText())
glossaryAlreadyExistsSnackbarVisibleState.value = true glossaryAlreadyExistsSnackbarVisibleState.value = true
} else if (!isValidFileName(projectName)) { } else if (!isValidFileName(projectName)) {
println("Le nom du projet contient des caractères non autorisés") println(languageManager.getInvalidCharacterText())
invalidCharacterSnackbarVisibleState.value = true invalidCharacterSnackbarVisibleState.value = true
} else { } else {
val directory = File("src/main/resources/projects/$projectName/") val directory = File("src/main/resources/projects/$projectName/")
@ -252,7 +257,7 @@ fun newProject(
contentColor = Color.White contentColor = Color.White
) )
) { ) {
Text("Créer") Text(languageManager.getCreateProjectText().toString())
} }
Spacer(modifier = Modifier.height(6.dp)) Spacer(modifier = Modifier.height(6.dp))
@ -268,7 +273,7 @@ fun newProject(
contentColor = Color.White contentColor = Color.White
) )
) { ) {
Text("Retour") Text(languageManager.getBackText())
} }
if (isEmptySnackbarVisibleState.value) { if (isEmptySnackbarVisibleState.value) {
@ -286,7 +291,7 @@ fun newProject(
} }
} }
) { ) {
Text("Veuillez entrer un nom de projet.") Text(languageManager.getEnterProjectNameText().toString())
} }
} }
if (containsSpaceSnackbarVisibleState.value) { if (containsSpaceSnackbarVisibleState.value) {
@ -304,7 +309,7 @@ fun newProject(
} }
} }
) { ) {
Text("Veuillez ne pas mettre d'espace dans le nom du projet.") Text(languageManager.getNoSpaceInProjectNameText().toString())
} }
} }
if (glossaryAlreadyExistsSnackbarVisibleState.value) { if (glossaryAlreadyExistsSnackbarVisibleState.value) {
@ -322,7 +327,7 @@ fun newProject(
} }
} }
) { ) {
Text("Ce projet existe déjà.") Text(languageManager.getGlossaryAlreadyExistsText().toString())
} }
} }
if (invalidCharacterSnackbarVisibleState.value) { if (invalidCharacterSnackbarVisibleState.value) {
@ -340,7 +345,7 @@ fun newProject(
} }
} }
) { ) {
Text("Le nom du projet contient des caractères non autorisés (caractères spéciaux).") Text(languageManager.getInvalidCharacterText().toString())
} }
} }
} }

View File

@ -120,13 +120,14 @@ fun choixLangagePage(
} }
} }
dropdownButtonComponent( dropdownButtonComponent(
items = listOf("Glossaire", "Code à vérifier", "Comparer") languageManager = languageManager,
items = listOf(languageManager.getGlossaryText(), languageManager.getCodeToVerifyText(), languageManager.getCompareText())
) { selectedOption -> ) { selectedOption ->
// Handle the selected option // Handle the selected option
when (selectedOption) { when (selectedOption) {
"Glossaire" -> onProjectClick() languageManager.getGlossaryText() -> onProjectClick()
"Code à vérifier" -> onCodeToVerifyClick() languageManager.getCodeToVerifyText() -> onCodeToVerifyClick()
"Comparer" -> { languageManager.getCompareText() -> {
if (mostUsedWordList.isEmpty()) { if (mostUsedWordList.isEmpty()) {
noFileSnackbarVisibleState.value = true noFileSnackbarVisibleState.value = true
return@dropdownButtonComponent return@dropdownButtonComponent

View File

@ -8,10 +8,12 @@ import androidx.compose.runtime.*
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import main.LanguageManager
import main.customRedColor import main.customRedColor
@Composable @Composable
fun dropdownButtonComponent( fun dropdownButtonComponent(
languageManager: LanguageManager,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
items: List<String>, items: List<String>,
onItemSelected: (String) -> Unit onItemSelected: (String) -> Unit

View File

@ -18,6 +18,7 @@ import main.component.dropdownButtonComponent
@Composable @Composable
fun parsedWordsTable( fun parsedWordsTable(
languageManager: LanguageManager,
parsedWords: Map<String, Int>, parsedWords: Map<String, Int>,
onBackClick: () -> Unit, onBackClick: () -> Unit,
onProjectClick: () -> Unit, onProjectClick: () -> Unit,
@ -64,13 +65,14 @@ fun parsedWordsTable(
} }
} }
dropdownButtonComponent( dropdownButtonComponent(
items = listOf("Glossaire", "Code à vérifier", "Comparer") languageManager = languageManager,
items = listOf(languageManager.getGlossaryText(), languageManager.getCodeToVerifyText(), languageManager.getCompareText())
) { selectedOption -> ) { selectedOption ->
// Handle the selected option // Handle the selected option
when (selectedOption) { when (selectedOption) {
"Glossaire" -> onProjectClick() languageManager.getGlossaryText() -> onProjectClick()
"Code à vérifier" -> onCodeToVerifyClick() languageManager.getCodeToVerifyText() -> onCodeToVerifyClick()
"Comparer" -> { languageManager.getCompareText() -> {
if (mostUsedWordList.isEmpty()) { if (mostUsedWordList.isEmpty()) {
noFileSnackbarVisibleState.value = true noFileSnackbarVisibleState.value = true
return@dropdownButtonComponent return@dropdownButtonComponent

BIN
src/main/resources/1.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 MiB

BIN
src/main/resources/2.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 MiB