Change views for compare
parent
08e8577a5c
commit
a72708d76c
|
@ -26,6 +26,7 @@ fun glossaryList(
|
|||
) {
|
||||
|
||||
var isCompareClicked by remember { mutableStateOf(false) }
|
||||
var selectedGlossary by remember { mutableStateOf<Glossary?>(null) }
|
||||
val noFileSnackbarVisibleState = remember { mutableStateOf(false) }
|
||||
|
||||
Column(
|
||||
|
@ -62,7 +63,13 @@ fun glossaryList(
|
|||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
buttonComponent(glossary.name, { onGlossarySelected(glossary) }, width = 200)
|
||||
buttonComponent(
|
||||
glossary.name,
|
||||
{
|
||||
onGlossarySelected(glossary)
|
||||
currentPage.value = "compareTable"
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -96,4 +103,10 @@ fun glossaryList(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
when {
|
||||
isCompareClicked && selectedGlossary == null -> {
|
||||
currentPage.value = "compareGlossary"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -62,7 +62,13 @@ fun projectList(
|
|||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
buttonComponent(project.name, { onProjectSelected(project) }, width = 200)
|
||||
buttonComponent(
|
||||
project.name,
|
||||
{
|
||||
onProjectSelected(project)
|
||||
currentPage.value = "compareGlossary"
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package main
|
||||
|
||||
import androidx.compose.foundation.*
|
||||
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.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.material.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
|
@ -25,9 +23,9 @@ enum class Language {
|
|||
fun homePage(
|
||||
languageManager: LanguageManager,
|
||||
onProjectClick: () -> Unit,
|
||||
onCodeToVerifyClick: () -> Unit
|
||||
onCodeToVerifyClick: () -> Unit,
|
||||
onCompareClick: () -> Unit,
|
||||
) {
|
||||
val appState = AppState
|
||||
val noFileSnackbarVisibleState = remember { mutableStateOf(false) }
|
||||
var isCompareClicked by remember { mutableStateOf(false) }
|
||||
var selectedGlossary by remember { mutableStateOf<Glossary?>(null) }
|
||||
|
@ -83,7 +81,7 @@ fun homePage(
|
|||
noFileSnackbarVisibleState.value = true
|
||||
return@Button
|
||||
} else {
|
||||
isCompareClicked = true
|
||||
onCompareClick()
|
||||
}
|
||||
},
|
||||
modifier = Modifier.width(200.dp),
|
||||
|
@ -124,69 +122,12 @@ fun homePage(
|
|||
noFileSnackbarVisibleState.value = true
|
||||
return@dropdownButtonComponent
|
||||
} else {
|
||||
isCompareClicked = true
|
||||
currentPage.value = "compareProject"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var selectedProject by remember { mutableStateOf<Project?>(null) }
|
||||
|
||||
|
||||
when {
|
||||
isCompareClicked && selectedProject == null && selectedGlossary == null -> {
|
||||
projectList(
|
||||
projects = loadProjects(),
|
||||
onProjectSelected = { project ->
|
||||
selectedProject = project
|
||||
appState.selectedProject = selectedProject
|
||||
},
|
||||
onBackClick = {
|
||||
isCompareClicked = false
|
||||
selectedGlossary = null
|
||||
selectedProject = null
|
||||
},
|
||||
onProjectClick = { currentPage.value = "projects" },
|
||||
languageManager = languageManager,
|
||||
onCodeToVerifyClick = { currentPage.value = "choixLangage" }
|
||||
)
|
||||
}
|
||||
|
||||
isCompareClicked && selectedGlossary == null -> {
|
||||
glossaryList(
|
||||
glossaries = loadGlossaries(appState.selectedProject!!),
|
||||
onGlossarySelected = { glossary ->
|
||||
selectedGlossary = glossary
|
||||
},
|
||||
onBackClick = {
|
||||
isCompareClicked = false
|
||||
selectedGlossary = null
|
||||
selectedProject = null
|
||||
},
|
||||
onProjectClick = { currentPage.value = "projects" },
|
||||
languageManager = languageManager,
|
||||
onCodeToVerifyClick = { currentPage.value = "choixLangage" }
|
||||
)
|
||||
}
|
||||
|
||||
isCompareClicked -> {
|
||||
selectedGlossary?.let {
|
||||
compareResults(
|
||||
languageManager = languageManager,
|
||||
glossaryWords = loadDatasFromFile(it.jsonFilePath),
|
||||
codeWords = mostUsedWordList.keys.toList(),
|
||||
onBackClick = {
|
||||
isCompareClicked = false
|
||||
selectedGlossary = null
|
||||
selectedProject = null
|
||||
},
|
||||
onProjectClick = { currentPage.value = "projects" },
|
||||
onCodeToVerifyClick = { currentPage.value = "choixLangage" },
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HelpButton {
|
||||
showHelpPage = true
|
||||
|
|
|
@ -5,12 +5,12 @@ import androidx.compose.foundation.layout.padding
|
|||
import androidx.compose.material.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.ExperimentalComposeUiApi
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.*
|
||||
import main.AppState.selectedGlossary
|
||||
import java.awt.FileDialog
|
||||
import java.awt.Frame
|
||||
import java.io.File
|
||||
|
@ -29,7 +29,7 @@ object AppState {
|
|||
var selectedGlossary: Glossary? = null
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterialApi::class, ExperimentalComposeUiApi::class)
|
||||
@OptIn(ExperimentalMaterialApi::class)
|
||||
@Composable
|
||||
@Preview
|
||||
fun app() {
|
||||
|
@ -53,6 +53,7 @@ fun app() {
|
|||
languageManager,
|
||||
onProjectClick = { currentPage.value = "projects" },
|
||||
onCodeToVerifyClick = { currentPage.value = "choixLangage" },
|
||||
onCompareClick = { currentPage.value = "compareProject" },
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -83,6 +84,52 @@ fun app() {
|
|||
)
|
||||
}
|
||||
|
||||
"compareProject" -> {
|
||||
var selectedProject by remember { mutableStateOf<Project?>(null) }
|
||||
projectList(
|
||||
projects = loadProjects(),
|
||||
onProjectSelected = { project ->
|
||||
selectedProject = project
|
||||
appState.selectedProject = selectedProject
|
||||
},
|
||||
onBackClick = {
|
||||
currentPage.value = "accueil"
|
||||
},
|
||||
onProjectClick = { currentPage.value = "projects" },
|
||||
languageManager = languageManager,
|
||||
onCodeToVerifyClick = { currentPage.value = "choixLangage" }
|
||||
)
|
||||
}
|
||||
|
||||
"compareGlossary" -> {
|
||||
var selectedGlossary by remember { mutableStateOf<Glossary?>(null) }
|
||||
glossaryList(
|
||||
glossaries = loadGlossaries(appState.selectedProject!!),
|
||||
onGlossarySelected = { glossary ->
|
||||
selectedGlossary = glossary
|
||||
},
|
||||
onBackClick = {
|
||||
currentPage.value = "compareProject"
|
||||
},
|
||||
onProjectClick = { currentPage.value = "projects" },
|
||||
languageManager = languageManager,
|
||||
onCodeToVerifyClick = { currentPage.value = "choixLangage" }
|
||||
)
|
||||
}
|
||||
|
||||
"compareTable" -> {
|
||||
compareResults(
|
||||
languageManager = languageManager,
|
||||
glossaryWords = selectedGlossary?.jsonFilePath?.let { loadDatasFromFile(it) } ?: emptyList(),
|
||||
codeWords = mostUsedWordList.keys.toList(),
|
||||
onBackClick = {
|
||||
currentPage.value = "compareGlossary"
|
||||
},
|
||||
onProjectClick = { currentPage.value = "projects" },
|
||||
onCodeToVerifyClick = { currentPage.value = "choixLangage" },
|
||||
)
|
||||
}
|
||||
|
||||
"nouveauProjet" ->{
|
||||
newProject(
|
||||
languageManager,
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
package main
|
||||
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.Button
|
||||
import androidx.compose.material.ButtonDefaults
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.material.*
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.ArrowBack
|
||||
import androidx.compose.runtime.*
|
||||
|
@ -131,7 +128,7 @@ fun choixLangagePage(
|
|||
noFileSnackbarVisibleState.value = true
|
||||
return@dropdownButtonComponent
|
||||
} else {
|
||||
isCompareClicked = true
|
||||
currentPage.value = "compareProject"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue