Last active
July 15, 2022 20:07
-
-
Save AlShevelev/b2b0bc26eea96e7ce9e0a70781e4240e to your computer and use it in GitHub Desktop.
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
@Composable | |
internal fun Root() { | |
val toolbarHeightPx = remember { mutableStateOf(0f) } | |
val topPanelOffset = remember { mutableStateOf(0f) } | |
Scaffold( | |
topBar = { | |
TopBarFixed( | |
maxOffset = toolbarHeightPx.value, | |
currentOffset = topPanelOffset.value | |
) | |
} | |
) { | |
CoordinatedScroll( | |
collapsingAreaHeightPx = toolbarHeightPx | |
) { offset, nestedScroll -> | |
topPanelOffset.value = offset | |
Box( | |
Modifier | |
.fillMaxSize() | |
.nestedScroll(nestedScroll) | |
) { | |
TopBarCollapsing( | |
currentOffset = offset, | |
maxOffset = toolbarHeightPx.value, | |
modifier = Modifier | |
.zIndex(1f) | |
.fillMaxWidth(), | |
onHeightCalculated = { | |
toolbarHeightPx.value = it | |
} | |
) | |
val contentPadding = with(LocalDensity.current) { | |
toolbarHeightPx.value.toInt().toDp() | |
} | |
ScrollableContent( | |
contentTopPadding = contentPadding, | |
modifier = Modifier | |
.fillMaxSize() | |
.background(Color.Yellow) | |
) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment