1
1
package app.passwordstore.ui
2
2
3
+ import androidx.compose.material.icons.Icons
4
+ import androidx.compose.material.icons.automirrored.filled.ArrowBack
3
5
import androidx.compose.material3.ExperimentalMaterial3Api
4
6
import androidx.compose.material3.Icon
5
7
import androidx.compose.material3.IconButton
8
+ import androidx.compose.material3.MaterialTheme
6
9
import androidx.compose.material3.Text
7
10
import androidx.compose.material3.TopAppBar
8
11
import androidx.compose.material3.TopAppBarDefaults
@@ -11,22 +14,26 @@ import androidx.compose.ui.Modifier
11
14
import androidx.compose.ui.draw.shadow
12
15
import androidx.compose.ui.graphics.Color
13
16
import androidx.compose.ui.graphics.painter.Painter
17
+ import androidx.compose.ui.graphics.vector.rememberVectorPainter
14
18
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
15
22
16
23
@Composable
17
24
@OptIn(ExperimentalMaterial3Api ::class )
18
25
public fun APSAppBar (
19
26
title : String ,
20
27
backgroundColor : Color ,
21
28
navigationIcon : Painter ? ,
22
- onNavigationIconClick : (() -> Unit )? ,
23
29
modifier : Modifier = Modifier ,
30
+ onNavigationIconClick : (() -> Unit ) = {},
24
31
) {
25
32
TopAppBar (
26
33
title = { Text (text = title) },
27
34
navigationIcon = {
28
35
if (navigationIcon != null ) {
29
- IconButton (onClick = { onNavigationIconClick? .invoke() }) {
36
+ IconButton (onClick = { onNavigationIconClick.invoke() }) {
30
37
Icon (
31
38
painter = navigationIcon,
32
39
contentDescription = null ,
@@ -38,3 +45,16 @@ public fun APSAppBar(
38
45
modifier = modifier.shadow(8 .dp),
39
46
)
40
47
}
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