From b983f1fad861fe207d662b23203b0183910d2fe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolf=20Montwe=CC=81?= Date: Tue, 28 Mar 2023 11:22:36 +0200 Subject: [PATCH] Add TopAppBar template --- .../designsystem/organism/TopAppBar.kt | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 core/ui/compose/designsystem/src/main/kotlin/app/k9mail/core/ui/compose/designsystem/organism/TopAppBar.kt diff --git a/core/ui/compose/designsystem/src/main/kotlin/app/k9mail/core/ui/compose/designsystem/organism/TopAppBar.kt b/core/ui/compose/designsystem/src/main/kotlin/app/k9mail/core/ui/compose/designsystem/organism/TopAppBar.kt new file mode 100644 index 000000000..edef44446 --- /dev/null +++ b/core/ui/compose/designsystem/src/main/kotlin/app/k9mail/core/ui/compose/designsystem/organism/TopAppBar.kt @@ -0,0 +1,55 @@ +package app.k9mail.core.ui.compose.designsystem.organism + +import androidx.compose.foundation.layout.RowScope +import androidx.compose.material.Icon +import androidx.compose.material.IconButton +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import app.k9mail.core.ui.compose.theme.Icons +import app.k9mail.core.ui.compose.theme.MainTheme +import app.k9mail.core.ui.compose.theme.PreviewWithThemes +import androidx.compose.material.TopAppBar as MaterialTopAppBar + +@Composable +fun TopAppBar( + title: String, + modifier: Modifier = Modifier, + navigationIcon: @Composable (() -> Unit)? = null, + actions: @Composable RowScope.() -> Unit = {}, +) { + MaterialTopAppBar( + title = { Text(text = title) }, + modifier = modifier, + navigationIcon = navigationIcon, + actions = actions, + backgroundColor = MainTheme.colors.toolbar, + ) +} + +@Preview +@Composable +internal fun TopAppBarPreview() { + PreviewWithThemes { + TopAppBar( + title = "Title", + navigationIcon = { + IconButton(onClick = {}) { + Icon( + imageVector = Icons.Outlined.menu, + contentDescription = null, + ) + } + }, + actions = { + IconButton(onClick = {}) { + Icon( + imageVector = Icons.Outlined.menu, + contentDescription = null, + ) + } + }, + ) + } +}