@@ -23,8 +23,8 @@ import androidx.compose.foundation.layout.fillMaxSize
23
23
import androidx.compose.foundation.layout.padding
24
24
import androidx.compose.foundation.lazy.LazyColumn
25
25
import androidx.compose.material.icons.Icons
26
+ import androidx.compose.material.icons.automirrored.filled.ArrowBack
26
27
import androidx.compose.material.icons.filled.Add
27
- import androidx.compose.material.icons.filled.ArrowBack
28
28
import androidx.compose.material.icons.filled.Check
29
29
import androidx.compose.material.icons.filled.Edit
30
30
import androidx.compose.material.icons.filled.Image
@@ -59,9 +59,10 @@ import androidx.compose.ui.text.style.TextOverflow
59
59
import androidx.compose.ui.tooling.preview.Preview
60
60
import androidx.compose.ui.unit.dp
61
61
62
- @Preview
63
62
@Composable
64
- fun AppBarExamples () {
63
+ fun AppBarExamples (
64
+ navigateBack : () -> Unit
65
+ ) {
65
66
var selection by remember { mutableStateOf(" none" ) }
66
67
67
68
Surface (
@@ -74,12 +75,14 @@ fun AppBarExamples() {
74
75
" topBarCenter" -> CenterAlignedTopAppBarExample ()
75
76
" topBarMedium" -> MediumTopAppBarExample ()
76
77
" topBarLarge" -> LargeTopAppBarExample ()
78
+ " topBarNavigation" -> TopBarNavigationExample { navigateBack() }
77
79
else -> AppBarOptions (
78
80
toBottom = { selection = " bottomBar" },
79
81
toTopBarSmall = { selection = " topBar" },
80
82
toTopBarCenter = { selection = " topBarCenter" },
81
83
toTopBarMedium = { selection = " topBarMedium" },
82
84
toTopBarLarge = { selection = " topBarLarge" },
85
+ toTopBarNavigation = { selection = " topBarNavigation" },
83
86
)
84
87
}
85
88
}
@@ -92,6 +95,7 @@ fun AppBarOptions(
92
95
toTopBarCenter : () -> Unit ,
93
96
toTopBarMedium : () -> Unit ,
94
97
toTopBarLarge : () -> Unit ,
98
+ toTopBarNavigation : () -> Unit ,
95
99
) {
96
100
Column () {
97
101
Button ({ toBottom() }) {
@@ -109,6 +113,9 @@ fun AppBarOptions(
109
113
Button ({ toTopBarLarge() }) {
110
114
Text (" Large top bar" )
111
115
}
116
+ Button ({ toTopBarNavigation() }) {
117
+ Text (" Top bar navigation example" )
118
+ }
112
119
}
113
120
}
114
121
@@ -211,7 +218,7 @@ fun CenterAlignedTopAppBarExample() {
211
218
navigationIcon = {
212
219
IconButton (onClick = { /* do something */ }) {
213
220
Icon (
214
- imageVector = Icons .Filled .ArrowBack ,
221
+ imageVector = Icons .AutoMirrored . Filled .ArrowBack ,
215
222
contentDescription = " Localized description"
216
223
)
217
224
}
@@ -258,7 +265,7 @@ fun MediumTopAppBarExample() {
258
265
navigationIcon = {
259
266
IconButton (onClick = { /* do something */ }) {
260
267
Icon (
261
- imageVector = Icons .Filled .ArrowBack ,
268
+ imageVector = Icons .AutoMirrored . Filled .ArrowBack ,
262
269
contentDescription = " Localized description"
263
270
)
264
271
}
@@ -305,7 +312,7 @@ fun LargeTopAppBarExample() {
305
312
navigationIcon = {
306
313
IconButton (onClick = { /* do something */ }) {
307
314
Icon (
308
- imageVector = Icons .Filled .ArrowBack ,
315
+ imageVector = Icons .AutoMirrored . Filled .ArrowBack ,
309
316
contentDescription = " Localized description"
310
317
)
311
318
}
@@ -327,6 +334,39 @@ fun LargeTopAppBarExample() {
327
334
}
328
335
// [END android_compose_components_largetopappbar]
329
336
337
+ @OptIn(ExperimentalMaterial3Api ::class )
338
+ // [START android_compose_components_navigation]
339
+ @Composable
340
+ fun TopBarNavigationExample (
341
+ navigateBack : () -> Unit ,
342
+ ) {
343
+ Scaffold (
344
+ topBar = {
345
+ CenterAlignedTopAppBar (
346
+ title = {
347
+ Text (
348
+ " Navigation example" ,
349
+ )
350
+ },
351
+ navigationIcon = {
352
+ IconButton (onClick = navigateBack) {
353
+ Icon (
354
+ imageVector = Icons .AutoMirrored .Filled .ArrowBack ,
355
+ contentDescription = " Localized description"
356
+ )
357
+ }
358
+ },
359
+ )
360
+ },
361
+ ) { innerPadding ->
362
+ Text (
363
+ " Click the back button to pop from the back stack." ,
364
+ modifier = Modifier .padding(innerPadding),
365
+ )
366
+ }
367
+ }
368
+ // [END android_compose_components_navigation]
369
+
330
370
@Composable
331
371
fun ScrollContent (innerPadding : PaddingValues ) {
332
372
val range = 1 .. 100
0 commit comments