Skip to content

Commit

Permalink
Fix wrong order of measurement, fixes onebone#19
Browse files Browse the repository at this point in the history
  • Loading branch information
onebone committed Nov 16, 2021
1 parent 20e801f commit eabeae9
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions lib/src/main/java/me/onebone/toolbar/CollapsingToolbarScaffold.kt
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,6 @@ fun CollapsingToolbarScaffold(
minHeight = 0
)

val bodyConstraints = constraints.copy(
minWidth = 0,
minHeight = 0,
maxHeight =
if(scrollStrategy == ScrollStrategy.ExitUntilCollapsed)
max(0, constraints.maxHeight - toolbarState.minHeight)
else
constraints.maxHeight
)

val toolbarPlaceables = subcompose(CollapsingToolbarScaffoldContent.Toolbar) {
CollapsingToolbar(
modifier = toolbarModifier,
Expand All @@ -115,6 +105,18 @@ fun CollapsingToolbarScaffold(
}
}.map { it.measure(toolbarConstraints) }

val bodyConstraints = constraints.copy(
minWidth = 0,
minHeight = 0,
maxHeight = when(scrollStrategy) {
ScrollStrategy.ExitUntilCollapsed ->
(constraints.maxHeight - toolbarState.minHeight).coerceAtLeast(0)

ScrollStrategy.EnterAlways, ScrollStrategy.EnterAlwaysCollapsed ->
constraints.maxHeight
}
)

val bodyPlaceables = subcompose(CollapsingToolbarScaffoldContent.Body) {
body()
}.map { it.measure(bodyConstraints) }
Expand Down

0 comments on commit eabeae9

Please sign in to comment.