diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/Insets.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/Insets.kt new file mode 100644 index 0000000..fd7802d --- /dev/null +++ b/android/app/src/main/java/com/siriusdevops/onionwire/ui/Insets.kt @@ -0,0 +1,45 @@ +package com.siriusdevops.onionwire.ui + +import androidx.compose.foundation.layout.WindowInsets +import androidx.compose.foundation.layout.WindowInsetsSides +import androidx.compose.foundation.layout.ime +import androidx.compose.foundation.layout.only +import androidx.compose.foundation.layout.systemBars +import androidx.compose.foundation.layout.union +import androidx.compose.foundation.layout.windowInsetsPadding +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier + +/** + * The bottom + horizontal window insets one screen's content root must apply + * itself. + * + * `MainActivity` calls `enableEdgeToEdge()`, which means + * `setDecorFitsSystemWindows(window, false)`. On API 30+ that stops the + * framework from resizing the window for the soft keyboard: the manifest's + * `android:windowSoftInputMode="adjustResize"` has nothing left to resize, and + * the IME arrives as a *window inset* instead. `Scaffold`'s + * `contentWindowInsets` only covers `systemBars`, so anything anchored to the + * bottom of the window — the chat composer, a submit button under a text field + * — ends up drawn behind the keyboard, reachable only by dismissing it. + * + * The IME's bottom inset already covers the navigation bar, so the two are + * unioned (per-side `max`), never summed: keyboard height while typing, + * navigation-bar height otherwise, and no double padding in between. + * + * The `Top` side is deliberately excluded — a `Scaffold`'s `pad.top` is the app + * bar's own measured height, and the app bar carries its own status-bar inset + * (`TopAppBarDefaults.windowInsets`). + * + * Pair every use with `Scaffold(contentWindowInsets = WindowInsets(0, 0, 0, 0))` + * so the same inset is not applied twice. + * + * `@Composable` because `WindowInsets.systemBars` / `WindowInsets.ime` are + * composable reads — call it from a composable (every call site is one). + */ +@Composable +fun Modifier.screenContentInsets(): Modifier = + windowInsetsPadding( + WindowInsets.systemBars.union(WindowInsets.ime) + .only(WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom), + ) \ No newline at end of file diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/RosterScreen.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/RosterScreen.kt index 18b8750..ed641dc 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/RosterScreen.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/ui/RosterScreen.kt @@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height @@ -52,6 +53,11 @@ fun RosterScreen( var confirmWipe by remember { mutableStateOf(false) } Scaffold( + // The content root below consumes systemBars ∪ ime itself (see + // `screenContentInsets`); zeroing the Scaffold's own insets keeps the + // navigation bar from being applied twice and lets the wipe-confirm + // strip sit above the keyboard instead of under it. + contentWindowInsets = WindowInsets(0, 0, 0, 0), topBar = { TopAppBar( title = { Text("OnionWire") }, @@ -64,7 +70,7 @@ fun RosterScreen( ) }, ) { pad -> - Column(Modifier.padding(pad).fillMaxSize()) { + Column(Modifier.padding(pad).fillMaxSize().screenContentInsets()) { Card( modifier = Modifier.fillMaxWidth().padding(horizontal = 12.dp), @@ -134,7 +140,11 @@ fun RosterScreen( ) } } else { - LazyColumn(Modifier.fillMaxSize()) { + // weight(1f), not fillMaxSize(): the list must yield height to + // its siblings (the action row and the wipe-confirm strip above + // it) when the IME shrinks the window, instead of claiming all + // of it and pushing them off the bottom. + LazyColumn(Modifier.weight(1f).fillMaxWidth()) { items(friends, key = { it.pubkeyHex }) { f -> FriendRow(f) { onOpenChat(f) } HorizontalDivider() diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletScreen.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletScreen.kt index 0e5d8e8..bc09ec7 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletScreen.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletScreen.kt @@ -9,14 +9,15 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.foundation.lazy.items +import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.foundation.verticalScroll import androidx.compose.material3.Button import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults @@ -82,6 +83,11 @@ fun WalletScreen( LaunchedEffect(Unit) { reload() } Scaffold( + // The content root below consumes systemBars ∪ ime itself (see + // `screenContentInsets`); zeroing the Scaffold's own insets keeps the + // navigation bar from being applied twice, and keeps the IME inset out + // of the Scaffold's inner padding. + contentWindowInsets = WindowInsets(0, 0, 0, 0), topBar = { TopAppBar( title = { Text("Wallet") }, @@ -95,7 +101,13 @@ fun WalletScreen( }, ) { pad -> Column( - Modifier.padding(pad).fillMaxSize(), + Modifier + .padding(pad) + .fillMaxSize() + // systemBars ∪ ime, applied outside the scrolling viewport so + // the inset does not scroll away with the content. + .screenContentInsets() + .verticalScroll(rememberScrollState()), ) { Card( modifier = Modifier @@ -171,19 +183,18 @@ fun WalletScreen( style = MaterialTheme.typography.titleSmall, modifier = Modifier.padding(horizontal = 12.dp, vertical = 4.dp), ) - LazyColumn( + // Plain Column, not a LazyColumn: the root is a scrolling + // container now, so a nested lazy list would either throw on the + // unbounded height or need an arbitrary cap. `walletRecentTransfers` + // is bounded (25 rows), and the page scrolls as one gesture. + Column( modifier = Modifier .fillMaxWidth() - .weight(1f, fill = false) .padding(horizontal = 12.dp), verticalArrangement = Arrangement.spacedBy(4.dp), ) { - items(transfers, key = { it.txid }) { t -> - TransferCard(t) - } + transfers.forEach { t -> TransferCard(t) } } - } else { - Spacer(Modifier.weight(1f)) } val kind = composer