Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit c33d110

Browse files
committed
fix(compose): adjust APSAppBar API and add previews
1 parent 6239809 commit c33d110

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

ui/compose/src/main/kotlin/app/passwordstore/ui/APSAppBar.kt

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package app.passwordstore.ui
22

3+
import androidx.compose.material.icons.Icons
4+
import androidx.compose.material.icons.automirrored.filled.ArrowBack
35
import androidx.compose.material3.ExperimentalMaterial3Api
46
import androidx.compose.material3.Icon
57
import androidx.compose.material3.IconButton
8+
import androidx.compose.material3.MaterialTheme
69
import androidx.compose.material3.Text
710
import androidx.compose.material3.TopAppBar
811
import androidx.compose.material3.TopAppBarDefaults
@@ -11,22 +14,26 @@ import androidx.compose.ui.Modifier
1114
import androidx.compose.ui.draw.shadow
1215
import androidx.compose.ui.graphics.Color
1316
import androidx.compose.ui.graphics.painter.Painter
17+
import androidx.compose.ui.graphics.vector.rememberVectorPainter
1418
import androidx.compose.ui.unit.dp
19+
import app.passwordstore.ui.compose.preview.DevicePreviews
20+
import app.passwordstore.ui.compose.preview.ThemePreviews
21+
import app.passwordstore.ui.compose.theme.APSTheme
1522

1623
@Composable
1724
@OptIn(ExperimentalMaterial3Api::class)
1825
public fun APSAppBar(
1926
title: String,
2027
backgroundColor: Color,
2128
navigationIcon: Painter?,
22-
onNavigationIconClick: (() -> Unit)?,
2329
modifier: Modifier = Modifier,
30+
onNavigationIconClick: (() -> Unit) = {},
2431
) {
2532
TopAppBar(
2633
title = { Text(text = title) },
2734
navigationIcon = {
2835
if (navigationIcon != null) {
29-
IconButton(onClick = { onNavigationIconClick?.invoke() }) {
36+
IconButton(onClick = { onNavigationIconClick.invoke() }) {
3037
Icon(
3138
painter = navigationIcon,
3239
contentDescription = null,
@@ -38,3 +45,16 @@ public fun APSAppBar(
3845
modifier = modifier.shadow(8.dp),
3946
)
4047
}
48+
49+
@ThemePreviews
50+
@DevicePreviews
51+
@Composable
52+
private fun APSAppBarPreview() {
53+
APSTheme {
54+
APSAppBar(
55+
title = "Preview",
56+
backgroundColor = MaterialTheme.colorScheme.surface,
57+
navigationIcon = rememberVectorPainter(Icons.AutoMirrored.Filled.ArrowBack),
58+
)
59+
}
60+
}

0 commit comments

Comments
 (0)