diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/App.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/App.kt index 42348a0..55458b0 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/App.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/App.kt @@ -14,7 +14,7 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import kotlinx.coroutines.launch import net.codinux.banking.ui.appskeleton.BottomBar -import net.codinux.banking.ui.appskeleton.SideMenu +import net.codinux.banking.ui.appskeleton.SideMenuContent import net.codinux.banking.ui.composables.StateHandler import net.codinux.banking.ui.composables.transactions.TransactionsList import net.codinux.banking.ui.config.Colors @@ -44,6 +44,8 @@ fun App() { val uiSettings = DI.uiSettings + val drawerState = DI.uiState.drawerState.collectAsState().value + val coroutineScope = rememberCoroutineScope() coroutineScope.launch { @@ -52,44 +54,45 @@ fun App() { MaterialTheme(colors = colors, typography = typography) { - SideMenu { - Scaffold( - bottomBar = { BottomBar() }, - backgroundColor = Colors.Zinc100, - floatingActionButton = { - FloatingActionButton( - shape = CircleShape, - modifier = Modifier.offset(x = 4.dp, y = fabPositionAdjustment), - onClick = { uiState.showAddAccountDialog.value = true } - ) { - Icon(Icons.Filled.Add, contentDescription = "Add a bank account") - } - }, - snackbarHost = { snackbarHostState -> - StateHandler(uiState, snackbarHostState) + Scaffold( + scaffoldState = rememberScaffoldState(drawerState), + bottomBar = { BottomBar() }, + backgroundColor = Colors.Zinc100, + floatingActionButton = { + FloatingActionButton( + shape = CircleShape, + modifier = Modifier.offset(x = 4.dp, y = fabPositionAdjustment), + onClick = { uiState.showAddAccountDialog.value = true } + ) { + Icon(Icons.Filled.Add, contentDescription = "Add a bank account") + } + }, + drawerContent = { SideMenuContent() }, + drawerBackgroundColor = Colors.DrawerContentBackground, + snackbarHost = { snackbarHostState -> + StateHandler(uiState, snackbarHostState) - SnackbarHost( - hostState = snackbarHostState - ) { data -> - Snackbar( - modifier = Modifier.offset(y = fabPositionAdjustment - 4.dp).padding(horizontal = 12.dp), - action = { if (data.actionLabel == null) null else { - TextButton( - onClick = { data.performAction() }, - content = { Text(data.actionLabel!!, color = Colors.CodinuxSecondaryColor) } - ) - } - }, - content = { Text(data.message, color = snackbarTextColor) }, - backgroundColor = Colors.Primary - ) - } - } - ) { scaffoldPadding -> - Column(Modifier.fillMaxSize().padding(scaffoldPadding), horizontalAlignment = Alignment.CenterHorizontally) { - TransactionsList(uiState, uiSettings) + SnackbarHost( + hostState = snackbarHostState + ) { data -> + Snackbar( + modifier = Modifier.offset(y = fabPositionAdjustment - 4.dp).padding(horizontal = 12.dp), + action = { if (data.actionLabel == null) null else { + TextButton( + onClick = { data.performAction() }, + content = { Text(data.actionLabel!!, color = Colors.CodinuxSecondaryColor) } + ) + } + }, + content = { Text(data.message, color = snackbarTextColor) }, + backgroundColor = Colors.Primary + ) } } + ) { scaffoldPadding -> + Column(Modifier.fillMaxSize().padding(scaffoldPadding), horizontalAlignment = Alignment.CenterHorizontally) { + TransactionsList(uiState, uiSettings) + } } } } \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/appskeleton/SideMenu.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/appskeleton/SideMenu.kt deleted file mode 100644 index 491f3ec..0000000 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/appskeleton/SideMenu.kt +++ /dev/null @@ -1,22 +0,0 @@ -package net.codinux.banking.ui.appskeleton - -import androidx.compose.foundation.layout.fillMaxHeight -import androidx.compose.material.ModalDrawer -import androidx.compose.runtime.Composable -import androidx.compose.runtime.collectAsState -import androidx.compose.ui.Modifier -import net.codinux.banking.ui.config.Colors -import net.codinux.banking.ui.config.DI - -@Composable -fun SideMenu(appContent: @Composable () -> Unit) { - val drawerState = DI.uiState.drawerState.collectAsState().value - - ModalDrawer( - modifier = Modifier.fillMaxHeight(), - drawerState = drawerState, - content = appContent, - drawerBackgroundColor = Colors.DrawerContentBackground, - drawerContent = { SideMenuContent() } - ) -} \ No newline at end of file