From 23d4fb1fdde587eed8aa04e7ed365d0d3800e880 Mon Sep 17 00:00:00 2001 From: Ahmad Ansori Palembani Date: Thu, 26 Dec 2024 07:56:15 +0700 Subject: [PATCH] fix(AppBar): Actions aren't aligned properly --- .../java/yokai/presentation/core/AppBar.kt | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 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 1d4974948d..0d6cb21141 100644 --- a/presentation/core/src/main/java/yokai/presentation/core/AppBar.kt +++ b/presentation/core/src/main/java/yokai/presentation/core/AppBar.kt @@ -338,7 +338,7 @@ private fun AppBarLayout( layoutHeight - navigationIconPlaceable.height - max(0, adjustedBottomPadding) } else -> (layoutHeight - navigationIconPlaceable.height) / 2 - } + }, ) // Title @@ -405,13 +405,30 @@ private fun AppBarLayout( } // Arrangement.Top else -> 0 - } + }, ) // Action icons actionIconsPlaceable.placeRelative( x = constraints.maxWidth - actionIconsPlaceable.width, - y = (layoutHeight - actionIconsPlaceable.height) / 2 + y = + when (titleVerticalArrangement) { + Arrangement.Bottom -> { + val padding = (constraints.maxHeight - actionIconsPlaceable.height) / 2 + val paddingFromBottom = padding - (actionIconsPlaceable.height - titleBaseline) + val heightWithPadding = paddingFromBottom + actionIconsPlaceable.height + val adjustedBottomPadding = + if (heightWithPadding > constraints.maxHeight) { + paddingFromBottom - + (heightWithPadding - constraints.maxHeight) + } else { + paddingFromBottom + } + + layoutHeight - actionIconsPlaceable.height - max(0, adjustedBottomPadding) + } + else -> (layoutHeight - actionIconsPlaceable.height) / 2 + }, ) } }