From 630446c2e20d975ca6c58cba77dfb826d8300737 Mon Sep 17 00:00:00 2001 From: MohitMaliFtechiz Date: Wed, 2 Apr 2025 15:22:58 +0530 Subject: [PATCH] Fixed: Extra top margin in `KiwixAppBar` when opening `KiwixSearchView`. * The issue occurred because our application already has `Edge-To-Edge` mode enabled, but Compose's `TopAppBar` automatically adds a top margin when insets change. This resulted in double padding in the toolbar. * To fix this, we now apply only the side insets to the toolbar, as the top insets are already handled. --- .../kiwixmobile/core/ui/components/KiwixAppBar.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/ui/components/KiwixAppBar.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/ui/components/KiwixAppBar.kt index 6e7044eae..684131ceb 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/ui/components/KiwixAppBar.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/ui/components/KiwixAppBar.kt @@ -22,8 +22,12 @@ import androidx.annotation.StringRes import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.WindowInsets +import androidx.compose.foundation.layout.WindowInsetsSides import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.only import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.statusBars import androidx.compose.foundation.lazy.LazyListState import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon @@ -78,7 +82,11 @@ fun KiwixAppBar( colors = TopAppBarDefaults.topAppBarColors( containerColor = Black, scrolledContainerColor = Black - ) + ), + // Edge-to-Edge mode is already enabled in our application, + // so we don't need to apply additional top insets. + // This prevents unwanted extra margin at the top. + windowInsets = WindowInsets.statusBars.only(WindowInsetsSides.Horizontal) ) } }