From ee19f84f916705b0250645a26f90361393e331de Mon Sep 17 00:00:00 2001 From: OneWay Date: Mon, 21 Sep 2026 14:39:12 +0800 Subject: [PATCH] fix(ui): align article title with the first search result in two panes In landscape the detail pane rendered the title inside a fixed 56.dp bar and centered the text in it, so the headword sat about 14 dp lower than the first search result next to it. Add a compact variant of the title bar without the fixed height; the title line now shares the top offset of the first list row. --- .../example/research/ui/article/ArticleScreen.kt | 14 ++++++++++---- .../example/research/ui/main/AdaptiveMainScreen.kt | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/example/research/ui/article/ArticleScreen.kt b/app/src/main/java/com/example/research/ui/article/ArticleScreen.kt index 14c4f23..c799827 100644 --- a/app/src/main/java/com/example/research/ui/article/ArticleScreen.kt +++ b/app/src/main/java/com/example/research/ui/article/ArticleScreen.kt @@ -211,7 +211,8 @@ fun ArticleTitleBar( articleState: ArticleState?, showBackButton: Boolean, onNavigateBack: () -> Unit, - modifier: Modifier = Modifier + modifier: Modifier = Modifier, + compact: Boolean = false, ) { val title = when (articleState) { is ArticleState.Loading -> articleState.title @@ -230,9 +231,14 @@ fun ArticleTitleBar( modifier = Modifier .fillMaxWidth() .windowInsetsPadding(AppWindowInsets.topAndHorizontalSafeDrawing) - .padding( - top = Spacing.listItemVertical, - bottom = Spacing.listItemVertical + .then( + if (compact) { + Modifier.padding(vertical = Spacing.listItemVertical) + } else { + Modifier + .padding(top = Spacing.topBarPadding, bottom = Spacing.topBarPadding) + .height(Spacing.topBarHeight) + } ), verticalAlignment = Alignment.CenterVertically ) { diff --git a/app/src/main/java/com/example/research/ui/main/AdaptiveMainScreen.kt b/app/src/main/java/com/example/research/ui/main/AdaptiveMainScreen.kt index 0b450ec..0408705 100644 --- a/app/src/main/java/com/example/research/ui/main/AdaptiveMainScreen.kt +++ b/app/src/main/java/com/example/research/ui/main/AdaptiveMainScreen.kt @@ -99,6 +99,7 @@ fun AdaptiveMainScreen( articleState = articleState, showBackButton = isShowingDetail && articleState != null, onNavigateBack = onNavigateBackFromArticle, + compact = true, modifier = Modifier.windowInsetsPadding( WindowInsets.safeDrawing.only(WindowInsetsSides.Top) )