Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Levi-Moreira/4e0c695008d2ea2536d0708b63785c2c to your computer and use it in GitHub Desktop.
Save Levi-Moreira/4e0c695008d2ea2536d0708b63785c2c to your computer and use it in GitHub Desktop.
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
val appBarMaxHeightPx = with(LocalDensity.current) { AppBarHeight.roundToPx() }
val connection = remember(appBarMaxHeightPx) {
CollapsingAppBarNestedScrollConnection(appBarMaxHeightPx)
}
Box(Modifier.nestedScroll(connection)) {
LazyColumn(contentPadding = PaddingValues(top = AppBarHeight)) {
items(Contents) {
ListItem(item = it)
}
}
TopAppBar(
modifier = Modifier.offset { IntOffset(0, connection.appBarOffset) },
title = { Text(text = "Jetpack Compose") },
colors = TopAppBarDefaults.topAppBarColors(
containerColor = Purple40,
titleContentColor = Color.White
)
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment