fix(AppBar): Use maxLayoutHeight instead of constraints.maxHeight

Also revert padding changes
This commit is contained in:
Ahmad Ansori Palembani 2025-01-17 10:16:57 +07:00
parent d2ddf7dfb0
commit ece849b008
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6

View file

@ -475,11 +475,12 @@ private class TopAppBarMeasurePolicy(
y = y =
when (titleVerticalArrangement) { when (titleVerticalArrangement) {
Arrangement.Bottom -> { Arrangement.Bottom -> {
val paddingFromBottom = (constraints.maxHeight - (navigationIconPlaceable.height - titleBaseline)) / 2 val padding = (maxLayoutHeight - navigationIconPlaceable.height) / 2
val paddingFromBottom = padding - (navigationIconPlaceable.height - titleBaseline)
val heightWithPadding = paddingFromBottom + navigationIconPlaceable.height val heightWithPadding = paddingFromBottom + navigationIconPlaceable.height
val adjustedBottomPadding = val adjustedBottomPadding =
if (heightWithPadding > constraints.maxHeight) { if (heightWithPadding > maxLayoutHeight) {
paddingFromBottom - (heightWithPadding - constraints.maxHeight) paddingFromBottom - (heightWithPadding - maxLayoutHeight)
} else { } else {
paddingFromBottom paddingFromBottom
} }
@ -523,12 +524,11 @@ private class TopAppBarMeasurePolicy(
Arrangement.Bottom -> { Arrangement.Bottom -> {
// Calculate the actual padding from the bottom of the title, taking // Calculate the actual padding from the bottom of the title, taking
// into account its baseline. // into account its baseline.
val adjustedTitleHeight = titlePlaceable.height - titleBaseline
val paddingFromBottom = if (titleBottomPadding == 0) { val paddingFromBottom = if (titleBottomPadding == 0) {
(constraints.maxHeight - adjustedTitleHeight) / 2 (maxLayoutHeight - titlePlaceable.height) / 2
} else { } else {
titleBottomPadding - adjustedTitleHeight titleBottomPadding
} } - (titlePlaceable.height - titleBaseline)
// Adjust the bottom padding to a smaller number if there is no room // Adjust the bottom padding to a smaller number if there is no room
// to fit the title. // to fit the title.
@ -555,12 +555,13 @@ private class TopAppBarMeasurePolicy(
y = y =
when (titleVerticalArrangement) { when (titleVerticalArrangement) {
Arrangement.Bottom -> { Arrangement.Bottom -> {
val paddingFromBottom = (constraints.maxHeight - (actionIconsPlaceable.height - titleBaseline)) / 2 val padding = (maxLayoutHeight - actionIconsPlaceable.height) / 2
val paddingFromBottom = padding - (actionIconsPlaceable.height - titleBaseline)
val heightWithPadding = paddingFromBottom + actionIconsPlaceable.height val heightWithPadding = paddingFromBottom + actionIconsPlaceable.height
val adjustedBottomPadding = val adjustedBottomPadding =
if (heightWithPadding > constraints.maxHeight) { if (heightWithPadding > maxLayoutHeight) {
paddingFromBottom - paddingFromBottom -
(heightWithPadding - constraints.maxHeight) (heightWithPadding - maxLayoutHeight)
} else { } else {
paddingFromBottom paddingFromBottom
} }