Split compare view in different files
parent
489c6f87e6
commit
08e8577a5c
|
@ -0,0 +1,99 @@
|
|||
package main
|
||||
|
||||
import androidx.compose.foundation.VerticalScrollbar
|
||||
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.foundation.rememberScrollbarAdapter
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import main.component.buttonComponent
|
||||
import main.component.dropdownButtonComponent
|
||||
|
||||
@Composable
|
||||
fun glossaryList(
|
||||
languageManager: LanguageManager,
|
||||
glossaries: List<Glossary>,
|
||||
onGlossarySelected: (Glossary) -> Unit,
|
||||
onBackClick: () -> Unit,
|
||||
onProjectClick: () -> Unit,
|
||||
onCodeToVerifyClick: () -> Unit
|
||||
) {
|
||||
|
||||
var isCompareClicked by remember { mutableStateOf(false) }
|
||||
val noFileSnackbarVisibleState = remember { mutableStateOf(false) }
|
||||
|
||||
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))
|
||||
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.height(500.dp)
|
||||
.width(250.dp)
|
||||
.padding(10.dp)
|
||||
) {
|
||||
val scrollState = rememberLazyListState()
|
||||
LazyColumn(
|
||||
state = scrollState,
|
||||
modifier = Modifier
|
||||
.padding(10.dp)
|
||||
.width(200.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(10.dp)
|
||||
) {
|
||||
if (glossaries.isEmpty()) {
|
||||
item {
|
||||
Text("Aucun glossaire disponible")
|
||||
}
|
||||
} else {
|
||||
items(glossaries) { glossary ->
|
||||
Row(
|
||||
modifier = Modifier.width(200.dp).fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
buttonComponent(glossary.name, { onGlossarySelected(glossary) }, width = 200)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
VerticalScrollbar(
|
||||
modifier = Modifier.align(Alignment.CenterEnd).fillMaxHeight(),
|
||||
adapter = rememberScrollbarAdapter(scrollState)
|
||||
)
|
||||
Spacer(modifier = Modifier.height(6.dp))
|
||||
}
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
buttonComponent("Retour", onBackClick)
|
||||
}
|
||||
|
||||
dropdownButtonComponent(
|
||||
languageManager,
|
||||
items = listOf("Glossaire", "Code à vérifier", "Comparer")
|
||||
) { selectedOption ->
|
||||
// Handle the selected option
|
||||
when (selectedOption) {
|
||||
"Glossaire" -> onProjectClick()
|
||||
"Code à vérifier" -> onCodeToVerifyClick()
|
||||
"Comparer" -> {
|
||||
if (mostUsedWordList.isEmpty()) {
|
||||
noFileSnackbarVisibleState.value = true
|
||||
return@dropdownButtonComponent
|
||||
} else {
|
||||
isCompareClicked = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
package main
|
||||
|
||||
import androidx.compose.foundation.VerticalScrollbar
|
||||
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.foundation.rememberScrollbarAdapter
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import main.component.buttonComponent
|
||||
import main.component.dropdownButtonComponent
|
||||
|
||||
@Composable
|
||||
fun projectList(
|
||||
languageManager: LanguageManager,
|
||||
projects: List<Project>,
|
||||
onProjectSelected: (Project) -> Unit,
|
||||
onBackClick: () -> Unit,
|
||||
onProjectClick: () -> Unit,
|
||||
onCodeToVerifyClick: () -> Unit
|
||||
) {
|
||||
|
||||
var isCompareClicked by remember { mutableStateOf(false) }
|
||||
val noFileSnackbarVisibleState = remember { mutableStateOf(false) }
|
||||
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
verticalArrangement = Arrangement.Center,
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Text("Sélectionnez un projet", style = MaterialTheme.typography.h5)
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.height(500.dp)
|
||||
.width(250.dp)
|
||||
.padding(10.dp)
|
||||
) {
|
||||
val scrollState = rememberLazyListState()
|
||||
LazyColumn(
|
||||
state = scrollState,
|
||||
modifier = Modifier
|
||||
.padding(10.dp)
|
||||
.width(200.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(10.dp)
|
||||
) {
|
||||
if (projects.isEmpty()) {
|
||||
item {
|
||||
Text("Aucun glossaire disponible")
|
||||
}
|
||||
} else {
|
||||
items(projects) { project ->
|
||||
Row(
|
||||
modifier = Modifier.width(200.dp).fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
buttonComponent(project.name, { onProjectSelected(project) }, width = 200)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
VerticalScrollbar(
|
||||
modifier = Modifier.align(Alignment.CenterEnd).fillMaxHeight(),
|
||||
adapter = rememberScrollbarAdapter(scrollState)
|
||||
)
|
||||
Spacer(modifier = Modifier.height(6.dp))
|
||||
}
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
buttonComponent("Retour", onBackClick)
|
||||
}
|
||||
dropdownButtonComponent(
|
||||
languageManager,
|
||||
items = listOf("Glossaire", "Code à vérifier", "Comparer")
|
||||
) { selectedOption ->
|
||||
// Handle the selected option
|
||||
when (selectedOption) {
|
||||
"Glossaire" -> onProjectClick()
|
||||
"Code à vérifier" -> onCodeToVerifyClick()
|
||||
"Comparer" -> {
|
||||
if (mostUsedWordList.isEmpty()) {
|
||||
noFileSnackbarVisibleState.value = true
|
||||
return@dropdownButtonComponent
|
||||
} else {
|
||||
isCompareClicked = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -193,169 +193,4 @@ fun homePage(
|
|||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun glossaryList(
|
||||
languageManager: LanguageManager,
|
||||
glossaries: List<Glossary>,
|
||||
onGlossarySelected: (Glossary) -> Unit,
|
||||
onBackClick: () -> Unit,
|
||||
onProjectClick: () -> Unit,
|
||||
onCodeToVerifyClick: () -> Unit
|
||||
) {
|
||||
|
||||
var isCompareClicked by remember { mutableStateOf(false) }
|
||||
val noFileSnackbarVisibleState = remember { mutableStateOf(false) }
|
||||
|
||||
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))
|
||||
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.height(500.dp)
|
||||
.width(250.dp)
|
||||
.padding(10.dp)
|
||||
) {
|
||||
val scrollState = rememberLazyListState()
|
||||
LazyColumn(
|
||||
state = scrollState,
|
||||
modifier = Modifier
|
||||
.padding(10.dp)
|
||||
.width(200.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(10.dp)
|
||||
) {
|
||||
if (glossaries.isEmpty()) {
|
||||
item {
|
||||
Text("Aucun glossaire disponible")
|
||||
}
|
||||
} else {
|
||||
items(glossaries) { glossary ->
|
||||
Row(
|
||||
modifier = Modifier.width(200.dp).fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
buttonComponent(glossary.name, { onGlossarySelected(glossary) }, width = 200)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
VerticalScrollbar(
|
||||
modifier = Modifier.align(Alignment.CenterEnd).fillMaxHeight(),
|
||||
adapter = rememberScrollbarAdapter(scrollState)
|
||||
)
|
||||
Spacer(modifier = Modifier.height(6.dp))
|
||||
}
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
buttonComponent("Retour", onBackClick)
|
||||
}
|
||||
|
||||
dropdownButtonComponent(
|
||||
languageManager,
|
||||
items = listOf("Glossaire", "Code à vérifier", "Comparer")
|
||||
) { selectedOption ->
|
||||
// Handle the selected option
|
||||
when (selectedOption) {
|
||||
"Glossaire" -> onProjectClick()
|
||||
"Code à vérifier" -> onCodeToVerifyClick()
|
||||
"Comparer" -> {
|
||||
if (mostUsedWordList.isEmpty()) {
|
||||
noFileSnackbarVisibleState.value = true
|
||||
return@dropdownButtonComponent
|
||||
} else {
|
||||
isCompareClicked = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun projectList(
|
||||
languageManager: LanguageManager,
|
||||
projects: List<Project>,
|
||||
onProjectSelected: (Project) -> Unit,
|
||||
onBackClick: () -> Unit,
|
||||
onProjectClick: () -> Unit,
|
||||
onCodeToVerifyClick: () -> Unit
|
||||
) {
|
||||
|
||||
var isCompareClicked by remember { mutableStateOf(false) }
|
||||
val noFileSnackbarVisibleState = remember { mutableStateOf(false) }
|
||||
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
verticalArrangement = Arrangement.Center,
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Text("Sélectionnez un projet", style = MaterialTheme.typography.h5)
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.height(500.dp)
|
||||
.width(250.dp)
|
||||
.padding(10.dp)
|
||||
) {
|
||||
val scrollState = rememberLazyListState()
|
||||
LazyColumn(
|
||||
state = scrollState,
|
||||
modifier = Modifier
|
||||
.padding(10.dp)
|
||||
.width(200.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(10.dp)
|
||||
) {
|
||||
if (projects.isEmpty()) {
|
||||
item {
|
||||
Text("Aucun glossaire disponible")
|
||||
}
|
||||
} else {
|
||||
items(projects) { project ->
|
||||
Row(
|
||||
modifier = Modifier.width(200.dp).fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
buttonComponent(project.name, { onProjectSelected(project) }, width = 200)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
VerticalScrollbar(
|
||||
modifier = Modifier.align(Alignment.CenterEnd).fillMaxHeight(),
|
||||
adapter = rememberScrollbarAdapter(scrollState)
|
||||
)
|
||||
Spacer(modifier = Modifier.height(6.dp))
|
||||
}
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
buttonComponent("Retour", onBackClick)
|
||||
}
|
||||
dropdownButtonComponent(
|
||||
languageManager,
|
||||
items = listOf("Glossaire", "Code à vérifier", "Comparer")
|
||||
) { selectedOption ->
|
||||
// Handle the selected option
|
||||
when (selectedOption) {
|
||||
"Glossaire" -> onProjectClick()
|
||||
"Code à vérifier" -> onCodeToVerifyClick()
|
||||
"Comparer" -> {
|
||||
if (mostUsedWordList.isEmpty()) {
|
||||
noFileSnackbarVisibleState.value = true
|
||||
return@dropdownButtonComponent
|
||||
} else {
|
||||
isCompareClicked = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue