From 5256ea64a6e31a2ac9b9c630797e2c2342438135 Mon Sep 17 00:00:00 2001 From: Anthony Date: Tue, 2 Apr 2024 00:32:07 +0200 Subject: [PATCH] feat(connector): add list of all projects screen --- .../kotlin/tab/project/CreateProject.kt | 5 +- .../kotlin/tab/project/ListProjects.kt | 68 +++++++++++++++++++ .../kotlin/tab/project/Projects.kt | 2 +- 3 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 connector/composeApp/src/desktopMain/kotlin/tab/project/ListProjects.kt diff --git a/connector/composeApp/src/desktopMain/kotlin/tab/project/CreateProject.kt b/connector/composeApp/src/desktopMain/kotlin/tab/project/CreateProject.kt index 03db1d4..37ed091 100644 --- a/connector/composeApp/src/desktopMain/kotlin/tab/project/CreateProject.kt +++ b/connector/composeApp/src/desktopMain/kotlin/tab/project/CreateProject.kt @@ -60,7 +60,10 @@ class CreateProject : Screen { Button( contentPadding = ButtonDefaults.ButtonWithIconContentPadding, - onClick = { /* TODO Add re-direction to project lists */ } + onClick = { + // TODO save new project and make sure it redirects to list page + navigator.pop() + } ) { Icon(Icons.Outlined.Add, "Create Project", modifier = Modifier.size(18.dp)) Spacer(Modifier.size(ButtonDefaults.IconSpacing)) diff --git a/connector/composeApp/src/desktopMain/kotlin/tab/project/ListProjects.kt b/connector/composeApp/src/desktopMain/kotlin/tab/project/ListProjects.kt new file mode 100644 index 0000000..adf93d3 --- /dev/null +++ b/connector/composeApp/src/desktopMain/kotlin/tab/project/ListProjects.kt @@ -0,0 +1,68 @@ +package tab.project + +import androidx.compose.foundation.VerticalScrollbar +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.rememberLazyListState +import androidx.compose.foundation.rememberScrollbarAdapter +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight +import androidx.compose.material.icons.outlined.Add +import androidx.compose.material3.* +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import cafe.adriel.voyager.core.screen.Screen +import cafe.adriel.voyager.navigator.LocalNavigator +import cafe.adriel.voyager.navigator.currentOrThrow + +class ListProjects : Screen { + @Composable + override fun Content() { + val navigator = LocalNavigator.currentOrThrow + val state = rememberLazyListState(0) + + Scaffold ( + floatingActionButton = { + ExtendedFloatingActionButton( + onClick = { navigator.push(CreateProject()) }, + content = { + Icon(Icons.Outlined.Add, "Create New Project") + Text("New Project") + } + ) + } + ) { + Column( + modifier = Modifier.fillMaxWidth(), + horizontalAlignment = Alignment.CenterHorizontally, + ) { + Box( + modifier = Modifier.fillMaxWidth(0.7F), + ) { + LazyColumn(state = state) { + items(50) { index -> + ListItem( + overlineContent = { Text("Emergency") }, + headlineContent = { Text("Project $index") }, + trailingContent = { Icon(Icons.AutoMirrored.Filled.KeyboardArrowRight, "Open Project") } + ) + HorizontalDivider() + } + } + VerticalScrollbar( + modifier = Modifier + .align(Alignment.CenterEnd) + .fillMaxHeight(), + adapter = rememberScrollbarAdapter( + scrollState = state, + ), + ) + } + } + } + } +} diff --git a/connector/composeApp/src/desktopMain/kotlin/tab/project/Projects.kt b/connector/composeApp/src/desktopMain/kotlin/tab/project/Projects.kt index b3b2308..75d0fe9 100644 --- a/connector/composeApp/src/desktopMain/kotlin/tab/project/Projects.kt +++ b/connector/composeApp/src/desktopMain/kotlin/tab/project/Projects.kt @@ -30,7 +30,7 @@ object Projects : Tab { @Composable override fun Content() { - Navigator(NoProjects) { + Navigator(ListProjects()) { CurrentScreen() } }