Last active
February 12, 2024 08:09
-
-
Save Levi-Moreira/5ea6a8b24402d8420d9b4e7dc25ad6fc to your computer and use it in GitHub Desktop.
Modifier Initial Code to include Offsetting of AppBar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val appBarOffset by remember { mutableIntStateOf(0) } | |
Surface( | |
modifier = Modifier.fillMaxSize(), | |
color = MaterialTheme.colorScheme.background | |
) { | |
Box { | |
LazyColumn(contentPadding = PaddingValues(top = AppBarHeight)) { | |
items(Contents) { | |
ListItem(item = it) | |
} | |
} | |
TopAppBar( | |
// use the appBarOffset to actually move the top app bar. | |
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