From ece849b00821cc333ccbe150a0c364df93e7fcc7 Mon Sep 17 00:00:00 2001 From: Ahmad Ansori Palembani Date: Fri, 17 Jan 2025 10:16:57 +0700 Subject: [PATCH] fix(AppBar): Use maxLayoutHeight instead of constraints.maxHeight Also revert padding changes --- .../java/yokai/presentation/core/AppBar.kt | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/presentation/core/src/main/java/yokai/presentation/core/AppBar.kt b/presentation/core/src/main/java/yokai/presentation/core/AppBar.kt index 575512310a..6715a6e07b 100644 --- a/presentation/core/src/main/java/yokai/presentation/core/AppBar.kt +++ b/presentation/core/src/main/java/yokai/presentation/core/AppBar.kt @@ -475,11 +475,12 @@ private class TopAppBarMeasurePolicy( y = when (titleVerticalArrangement) { 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 adjustedBottomPadding = - if (heightWithPadding > constraints.maxHeight) { - paddingFromBottom - (heightWithPadding - constraints.maxHeight) + if (heightWithPadding > maxLayoutHeight) { + paddingFromBottom - (heightWithPadding - maxLayoutHeight) } else { paddingFromBottom } @@ -523,12 +524,11 @@ private class TopAppBarMeasurePolicy( Arrangement.Bottom -> { // Calculate the actual padding from the bottom of the title, taking // into account its baseline. - val adjustedTitleHeight = titlePlaceable.height - titleBaseline val paddingFromBottom = if (titleBottomPadding == 0) { - (constraints.maxHeight - adjustedTitleHeight) / 2 + (maxLayoutHeight - titlePlaceable.height) / 2 } else { - titleBottomPadding - adjustedTitleHeight - } + titleBottomPadding + } - (titlePlaceable.height - titleBaseline) // Adjust the bottom padding to a smaller number if there is no room // to fit the title. @@ -555,12 +555,13 @@ private class TopAppBarMeasurePolicy( y = when (titleVerticalArrangement) { 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 adjustedBottomPadding = - if (heightWithPadding > constraints.maxHeight) { + if (heightWithPadding > maxLayoutHeight) { paddingFromBottom - - (heightWithPadding - constraints.maxHeight) + (heightWithPadding - maxLayoutHeight) } else { paddingFromBottom }