Added aucun projet/glossaire

main
Cemal Odabasioglu 2023-12-21 09:38:05 +01:00
parent 4794c8f3b1
commit 708cbd9522
3 changed files with 138 additions and 100 deletions

View File

@ -176,14 +176,20 @@ fun glossaryList(glossaries: List<Glossary>, onGlossarySelected: (Glossary) -> U
Box( Box(
modifier = Modifier modifier = Modifier
.height(500.dp) .height(500.dp)
.width(250.dp)
.padding(10.dp) .padding(10.dp)
) { ) {
val scrollState = rememberLazyListState() val scrollState = rememberLazyListState()
LazyColumn( LazyColumn(
state = scrollState, state = scrollState,
modifier = Modifier.padding(10.dp).border(1.dp, Color.Black), modifier = Modifier.padding(10.dp).width(250.dp).border(1.dp, Color.Black),
verticalArrangement = Arrangement.spacedBy(10.dp) verticalArrangement = Arrangement.spacedBy(10.dp)
) { ) {
if (glossaries.isEmpty()) {
item {
Text("Aucun glossaire disponible")
}
} else {
items(glossaries) { glossary -> items(glossaries) { glossary ->
Row( Row(
modifier = Modifier.width(200.dp).fillMaxWidth(), modifier = Modifier.width(200.dp).fillMaxWidth(),
@ -206,6 +212,7 @@ fun glossaryList(glossaries: List<Glossary>, onGlossarySelected: (Glossary) -> U
} }
} }
} }
}
VerticalScrollbar( VerticalScrollbar(
modifier = Modifier.align(Alignment.CenterEnd).fillMaxHeight(), modifier = Modifier.align(Alignment.CenterEnd).fillMaxHeight(),
adapter = rememberScrollbarAdapter(scrollState) adapter = rememberScrollbarAdapter(scrollState)
@ -240,14 +247,24 @@ fun projectList(projects: List<Project>, onProjectSelected: (Project) -> Unit, o
Box( Box(
modifier = Modifier modifier = Modifier
.height(500.dp) .height(500.dp)
.width(350.dp)
.padding(10.dp) .padding(10.dp)
) { ) {
val scrollState = rememberLazyListState() val scrollState = rememberLazyListState()
LazyColumn( LazyColumn(
state = scrollState, state = scrollState,
modifier = Modifier.padding(10.dp).border(1.dp, Color.Black), modifier = Modifier
.padding(10.dp)
.width(250.dp)
.height(300.dp)
.border(1.dp, Color.Black),
verticalArrangement = Arrangement.spacedBy(10.dp) verticalArrangement = Arrangement.spacedBy(10.dp)
) { ) {
if (projects.isEmpty()) {
item {
Text("Aucun projet disponible")
}
} else {
items(projects) { project: Project -> items(projects) { project: Project ->
Row( Row(
modifier = Modifier.width(200.dp).fillMaxWidth(), modifier = Modifier.width(200.dp).fillMaxWidth(),
@ -270,6 +287,7 @@ fun projectList(projects: List<Project>, onProjectSelected: (Project) -> Unit, o
} }
} }
} }
}
VerticalScrollbar( VerticalScrollbar(
modifier = Modifier.align(Alignment.CenterEnd).fillMaxHeight(), modifier = Modifier.align(Alignment.CenterEnd).fillMaxHeight(),
adapter = rememberScrollbarAdapter(scrollState) adapter = rememberScrollbarAdapter(scrollState)

View File

@ -81,16 +81,20 @@ fun app() {
Box( Box(
modifier = Modifier modifier = Modifier
.height(300.dp) .height(300.dp)
.width(250.dp)
.padding(10.dp) .padding(10.dp)
.border(1.dp, Color.Black) .border(1.dp, Color.Black)
) { ) {
val scrollState = rememberLazyListState() val scrollState = rememberLazyListState()
glossaries = loadGlossaries(appState.selectedProject!!)
if (glossaries.isEmpty()) {
Text("Aucun glossaire n'a été créé pour ce projet")
} else {
LazyColumn( LazyColumn(
state = scrollState, state = scrollState,
modifier = Modifier.padding(10.dp), modifier = Modifier.padding(10.dp),
verticalArrangement = Arrangement.spacedBy(10.dp) verticalArrangement = Arrangement.spacedBy(10.dp)
) { ) {
glossaries = loadGlossaries(appState.selectedProject!!)
println(glossaries) println(glossaries)
items(glossaries) { glossary -> items(glossaries) { glossary ->
Row( Row(
@ -116,11 +120,16 @@ fun app() {
onClick = { onClick = {
// Handle delete glossary action // Handle delete glossary action
glossaries = glossaries.filterNot { it == glossary } glossaries = glossaries.filterNot { it == glossary }
val file = File(glossaryPath + (appState.selectedProject?.name ) + "/" + glossary.jsonFilePath) val file =
File(glossaryPath + (appState.selectedProject?.name) + "/" + glossary.jsonFilePath)
file.delete() file.delete()
} }
) { ) {
Icon(imageVector = Icons.Default.Delete, contentDescription = "Delete Glossary") Icon(
imageVector = Icons.Default.Delete,
contentDescription = "Delete Glossary"
)
}
} }
} }
} }

View File

@ -1,5 +1,6 @@
package main package main
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.items
@ -38,9 +39,18 @@ fun projectsPage(
Spacer(modifier = Modifier.height(16.dp)) Spacer(modifier = Modifier.height(16.dp))
LazyColumn( LazyColumn(
modifier = Modifier.padding(10.dp), modifier = Modifier
.padding(10.dp)
.width(200.dp)
.height(300.dp)
.border(1.dp, Color.Black),
verticalArrangement = Arrangement.spacedBy(10.dp) verticalArrangement = Arrangement.spacedBy(10.dp)
) { ) {
if (projects.isEmpty()) {
item {
Text("Aucun projet n'a été créé")
}
} else {
items(projects, key = { project -> project.name }) { project -> items(projects, key = { project -> project.name }) { project ->
Row( Row(
modifier = Modifier.width(200.dp).fillMaxWidth(), modifier = Modifier.width(200.dp).fillMaxWidth(),
@ -77,6 +87,7 @@ fun projectsPage(
} }
} }
} }
}
Spacer(modifier = Modifier.height(16.dp)) Spacer(modifier = Modifier.height(16.dp))