Skip to content

Instantly share code, notes, and snippets.

@Levi-Moreira
Last active February 12, 2024 08:09
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/febc1bd3fe19ba1071a1c0fa7922d2f8 to your computer and use it in GitHub Desktop.
Save Levi-Moreira/febc1bd3fe19ba1071a1c0fa7922d2f8 to your computer and use it in GitHub Desktop.
val appBarOffset by remember { mutableIntStateOf(0) }
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
val connection = remember {
object : NestedScrollConnection {
override fun onPreScroll(
available: Offset,
source: NestedScrollSource
): Offset {
return super.onPreScroll(available, source)
}
}
}
Box(Modifier.nestedScroll(connection)) {
LazyColumn(contentPadding = PaddingValues(top = AppBarHeight)) {
items(Contents) {
ListItem(item = it)
}
}
TopAppBar(
modifier = Modifier.offset { IntOffset(0, 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