From c014d6d90c491bf330e4ce60e7a5ee34ce9a1c4c Mon Sep 17 00:00:00 2001 From: Bruno Deanoz Date: Mon, 22 Jun 2026 01:21:32 +0200 Subject: [PATCH] =?UTF-8?q?fix=20keyboard=20handling=20=E2=80=94=20offset?= =?UTF-8?q?=20dock=20instead=20of=20padding?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit adjustResize didn't work with enableEdgeToEdge (input hidden behind keyboard). imePadding inflated the dock (input too high). New approach: read WindowInsets.ime bottom value directly and apply it as negative Y offset on the dock. The dock slides up by exactly the keyboard height — no inflation, no layout changes. windowSoftInputMode=adjustNothing (edge-to-edge default). When keyboard closed: offset = nav bar height (gesture bar). When keyboard open: offset = keyboard height (includes nav bar). --- app/src/main/AndroidManifest.xml | 2 +- app/src/main/java/dev/kaizen/app/chat/ChatScreen.kt | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0011128..52150ae 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -21,7 +21,7 @@ android:name=".MainActivity" android:exported="true" android:label="@string/app_name" - android:windowSoftInputMode="adjustResize" + android:windowSoftInputMode="adjustNothing" android:theme="@style/Theme.Kaizen"> diff --git a/app/src/main/java/dev/kaizen/app/chat/ChatScreen.kt b/app/src/main/java/dev/kaizen/app/chat/ChatScreen.kt index 514f6fc..1daca86 100644 --- a/app/src/main/java/dev/kaizen/app/chat/ChatScreen.kt +++ b/app/src/main/java/dev/kaizen/app/chat/ChatScreen.kt @@ -15,8 +15,11 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.ExperimentalLayoutApi import androidx.compose.foundation.layout.WindowInsets +import androidx.compose.foundation.layout.ime import androidx.compose.foundation.layout.isImeVisible -import androidx.compose.foundation.layout.navigationBarsPadding +import androidx.compose.foundation.layout.navigationBars +import androidx.compose.foundation.layout.offset +import androidx.compose.ui.platform.LocalDensity import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.statusBarsPadding @@ -704,9 +707,13 @@ fun ChatScreen( // 3. Floating Bottom Control Dock @OptIn(ExperimentalLayoutApi::class) val imeVisible = WindowInsets.isImeVisible + val imeBottom = WindowInsets.ime.getBottom(LocalDensity.current) + val navBottom = WindowInsets.navigationBars.getBottom(LocalDensity.current) + val bottomOffset = if (imeVisible) maxOf(imeBottom, navBottom) else navBottom Column( modifier = Modifier .align(Alignment.BottomCenter) + .offset(y = with(LocalDensity.current) { -bottomOffset.toDp() }) .background( if (imeVisible) { Brush.verticalGradient(listOf(scrimColor, scrimColor)) @@ -721,7 +728,6 @@ fun ChatScreen( ) } ) - .navigationBarsPadding() .then(if (isTablet) Modifier.widthIn(max = 720.dp) else Modifier) ) { if (!imeVisible) {