summaryrefslogtreecommitdiff
path: root/ui/compose/src/main
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2024-05-28 15:03:31 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2024-05-28 15:03:31 +0530
commitc33d1100b775aa7396a076580bda11b4159cb30d (patch)
tree9ad051d12982c7222e512f114c30a080a1ff571c /ui/compose/src/main
parent62398099649e379a2c44e242fc9f8deb3f96d9c1 (diff)
fix(compose): adjust APSAppBar API and add previews
Diffstat (limited to 'ui/compose/src/main')
-rw-r--r--ui/compose/src/main/kotlin/app/passwordstore/ui/APSAppBar.kt24
1 files changed, 22 insertions, 2 deletions
diff --git a/ui/compose/src/main/kotlin/app/passwordstore/ui/APSAppBar.kt b/ui/compose/src/main/kotlin/app/passwordstore/ui/APSAppBar.kt
index 94b646b7..1a65a2f7 100644
--- a/ui/compose/src/main/kotlin/app/passwordstore/ui/APSAppBar.kt
+++ b/ui/compose/src/main/kotlin/app/passwordstore/ui/APSAppBar.kt
@@ -1,8 +1,11 @@
package app.passwordstore.ui
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
+import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
@@ -11,7 +14,11 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.painter.Painter
+import androidx.compose.ui.graphics.vector.rememberVectorPainter
import androidx.compose.ui.unit.dp
+import app.passwordstore.ui.compose.preview.DevicePreviews
+import app.passwordstore.ui.compose.preview.ThemePreviews
+import app.passwordstore.ui.compose.theme.APSTheme
@Composable
@OptIn(ExperimentalMaterial3Api::class)
@@ -19,14 +26,14 @@ public fun APSAppBar(
title: String,
backgroundColor: Color,
navigationIcon: Painter?,
- onNavigationIconClick: (() -> Unit)?,
modifier: Modifier = Modifier,
+ onNavigationIconClick: (() -> Unit) = {},
) {
TopAppBar(
title = { Text(text = title) },
navigationIcon = {
if (navigationIcon != null) {
- IconButton(onClick = { onNavigationIconClick?.invoke() }) {
+ IconButton(onClick = { onNavigationIconClick.invoke() }) {
Icon(
painter = navigationIcon,
contentDescription = null,
@@ -38,3 +45,16 @@ public fun APSAppBar(
modifier = modifier.shadow(8.dp),
)
}
+
+@ThemePreviews
+@DevicePreviews
+@Composable
+private fun APSAppBarPreview() {
+ APSTheme {
+ APSAppBar(
+ title = "Preview",
+ backgroundColor = MaterialTheme.colorScheme.surface,
+ navigationIcon = rememberVectorPainter(Icons.AutoMirrored.Filled.ArrowBack),
+ )
+ }
+}