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,32 +176,39 @@ 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)
) { ) {
items(glossaries) { glossary -> if (glossaries.isEmpty()) {
Row( item {
modifier = Modifier.width(200.dp).fillMaxWidth(), Text("Aucun glossaire disponible")
horizontalArrangement = Arrangement.SpaceBetween }
) { } else {
Button( items(glossaries) { glossary ->
onClick = { Row(
onGlossarySelected(glossary) modifier = Modifier.width(200.dp).fillMaxWidth(),
}, horizontalArrangement = Arrangement.SpaceBetween
modifier = Modifier
.width(150.dp)
.padding(10.dp, 0.dp, 0.dp, 0.dp),
colors = ButtonDefaults.buttonColors(
backgroundColor = customRedColor,
contentColor = Color.White
)
) { ) {
Text(glossary.name) Button(
onClick = {
onGlossarySelected(glossary)
},
modifier = Modifier
.width(150.dp)
.padding(10.dp, 0.dp, 0.dp, 0.dp),
colors = ButtonDefaults.buttonColors(
backgroundColor = customRedColor,
contentColor = Color.White
)
) {
Text(glossary.name)
}
} }
} }
} }
@ -240,32 +247,43 @@ 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)
) { ) {
items(projects) { project: Project -> if (projects.isEmpty()) {
Row( item {
modifier = Modifier.width(200.dp).fillMaxWidth(), Text("Aucun projet disponible")
horizontalArrangement = Arrangement.SpaceBetween }
) { } else {
Button( items(projects) { project: Project ->
onClick = { Row(
onProjectSelected(project) modifier = Modifier.width(200.dp).fillMaxWidth(),
}, horizontalArrangement = Arrangement.SpaceBetween
modifier = Modifier
.width(150.dp)
.padding(10.dp, 0.dp, 0.dp, 0.dp),
colors = ButtonDefaults.buttonColors(
backgroundColor = customRedColor,
contentColor = Color.White
)
) { ) {
Text(project.name) Button(
onClick = {
onProjectSelected(project)
},
modifier = Modifier
.width(150.dp)
.padding(10.dp, 0.dp, 0.dp, 0.dp),
colors = ButtonDefaults.buttonColors(
backgroundColor = customRedColor,
contentColor = Color.White
)
) {
Text(project.name)
}
} }
} }
} }

View File

@ -81,46 +81,55 @@ 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()
LazyColumn( glossaries = loadGlossaries(appState.selectedProject!!)
state = scrollState, if (glossaries.isEmpty()) {
modifier = Modifier.padding(10.dp), Text("Aucun glossaire n'a été créé pour ce projet")
verticalArrangement = Arrangement.spacedBy(10.dp) } else {
) { LazyColumn(
glossaries = loadGlossaries(appState.selectedProject!!) state = scrollState,
println(glossaries) modifier = Modifier.padding(10.dp),
items(glossaries) { glossary -> verticalArrangement = Arrangement.spacedBy(10.dp)
Row( ) {
modifier = Modifier.width(200.dp).fillMaxWidth(), println(glossaries)
horizontalArrangement = Arrangement.SpaceBetween items(glossaries) { glossary ->
) { Row(
Button( modifier = Modifier.width(200.dp).fillMaxWidth(),
onClick = { horizontalArrangement = Arrangement.SpaceBetween
selectedGlossary = glossary
currentPage.value = "glossaireOptions"
},
modifier = Modifier
.width(150.dp),
colors = ButtonDefaults.buttonColors(
backgroundColor = customRedColor,
contentColor = Color.White
)
) { ) {
Text(glossary.name) Button(
} onClick = {
selectedGlossary = glossary
IconButton( currentPage.value = "glossaireOptions"
onClick = { },
// Handle delete glossary action modifier = Modifier
glossaries = glossaries.filterNot { it == glossary } .width(150.dp),
val file = File(glossaryPath + (appState.selectedProject?.name ) + "/" + glossary.jsonFilePath) colors = ButtonDefaults.buttonColors(
file.delete() backgroundColor = customRedColor,
contentColor = Color.White
)
) {
Text(glossary.name)
}
IconButton(
onClick = {
// Handle delete glossary action
glossaries = glossaries.filterNot { it == glossary }
val file =
File(glossaryPath + (appState.selectedProject?.name) + "/" + glossary.jsonFilePath)
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,41 +39,51 @@ 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)
) { ) {
items(projects, key = { project -> project.name }) { project -> if (projects.isEmpty()) {
Row( item {
modifier = Modifier.width(200.dp).fillMaxWidth(), Text("Aucun projet n'a été créé")
horizontalArrangement = Arrangement.SpaceBetween }
) { } else {
Button( items(projects, key = { project -> project.name }) { project ->
onClick = { Row(
appState.selectedProject = project modifier = Modifier.width(200.dp).fillMaxWidth(),
currentPage.value = "glossaires" horizontalArrangement = Arrangement.SpaceBetween
},
modifier = Modifier
.width(150.dp),
colors = ButtonDefaults.buttonColors(
backgroundColor = customRedColor,
contentColor = Color.White
)
) { ) {
Text(project.name) Button(
} onClick = {
appState.selectedProject = project
currentPage.value = "glossaires"
IconButton( },
onClick = { modifier = Modifier
// Handle delete project action .width(150.dp),
projects = projects.filterNot { it.name == project.name } colors = ButtonDefaults.buttonColors(
println(projects) backgroundColor = customRedColor,
val directory = File("src/main/resources/projects/${project.name}/") contentColor = Color.White
directory.deleteRecursively() )
currentPage.value = "projects" ) {
Text(project.name)
}
IconButton(
onClick = {
// Handle delete project action
projects = projects.filterNot { it.name == project.name }
println(projects)
val directory = File("src/main/resources/projects/${project.name}/")
directory.deleteRecursively()
currentPage.value = "projects"
}
) {
Icon(imageVector = Icons.Default.Delete, contentDescription = "Delete Project")
} }
) {
Icon(imageVector = Icons.Default.Delete, contentDescription = "Delete Project")
} }
} }
} }