Keep home and task list clear of the navigation bar (#152) (#165)
Beta — Codeberg pre-release / detect (push) Successful in 7s
Beta — Codeberg pre-release / beta (push) Skipped

This commit is contained in:
Jean-Luc Makiola committed 2026-11-13 11:52:12 +01:00
1 parent 3e34c60577
commit 3b701feac6
6 files changed
+86 -27

No files matched your search

@@ -18,6 +18,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
@@ -268,6 +269,9 @@ private fun DetailBody(
modifier = Modifier
.fillMaxSize()
.padding(inner)
// Consume the bar insets so imePadding adds only what the keyboard
// covers beyond them.
.consumeWindowInsets(inner)
// Shrink the scroll viewport by the keyboard so the focused add-subtask
// field scrolls into view above the IME instead of being hidden.
.imePadding()
@@ -57,6 +57,7 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
@@ -219,7 +220,9 @@ fun TaskEditScreen(
viewModel = viewModel,
scroll = scroll,
onTitleBottom = { titleBottom = it },
modifier = Modifier.padding(inner),
// Consumed so EditContent's imePadding adds only what the keyboard
// covers beyond the bars.
modifier = Modifier.padding(inner).consumeWindowInsets(inner),
)
}
@@ -29,7 +29,12 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.ime
import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.union
import androidx.compose.foundation.layout.windowInsetsBottomHeight
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
@@ -60,6 +65,7 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
@@ -513,7 +519,7 @@ private fun HomeTopBar(
Row(
modifier = Modifier
.fillMaxWidth()
.statusBarsPadding()
.windowInsetsPadding(TopAppBarDefaults.windowInsets)
.height(72.dp)
.padding(horizontal = 12.dp),
verticalAlignment = Alignment.CenterVertically,
@@ -672,10 +678,14 @@ private fun SearchResults(
)
}
} else {
// The last result scrolls clear of the navigation bar and the keyboard.
LazyColumn(modifier = Modifier.fillMaxSize()) {
items(results, key = { it.occurrenceKey }) { task ->
UpcomingRow(task = task, onClick = { onOpenTask(task) })
}
item(key = "bottom-inset") {
Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.navigationBars.union(WindowInsets.ime)))
}
}
}
}
@@ -6,16 +6,22 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.TaskAlt
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ScaffoldDefaults
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
@@ -44,14 +50,20 @@ private val MAX_CONTENT_WIDTH = 720.dp
/**
* A phone-shaped column centred on a tablet or a landscape screen: a task list
* or a form stretched edge to edge across 1200dp reads as a spreadsheet.
*
* Also clears (and consumes) the side system bars and cutout, e.g. a 3-button
* navigation bar in landscape, so the screens inside only handle top and bottom.
*/
@Composable
internal fun ReadableWidth(modifier: Modifier = Modifier, content: @Composable () -> Unit) {
Box(
modifier = modifier.fillMaxSize().background(MaterialTheme.colorScheme.surface),
modifier = modifier
.fillMaxSize()
.background(MaterialTheme.colorScheme.surface)
.windowInsetsPadding(ScaffoldDefaults.contentWindowInsets.only(WindowInsetsSides.Horizontal)),
contentAlignment = Alignment.TopCenter,
) {
Box(modifier = Modifier.fillMaxSize().widthIn(max = MAX_CONTENT_WIDTH)) { content() }
Box(modifier = Modifier.fillMaxHeight().widthIn(max = MAX_CONTENT_WIDTH).fillMaxWidth()) { content() }
}
}
@@ -74,37 +86,50 @@ internal fun TaskListDetailPanes(
val clear = { selectedId = Dest.NO_ID }
BackHandler(enabled = selectedId != Dest.NO_ID, onBack = clear)
// Each pane clears only the side insets of the screen edge it touches, and
// consumes the other so its scaffold doesn't pad for it again.
val sideInsets = ScaffoldDefaults.contentWindowInsets
val start = sideInsets.only(WindowInsetsSides.Start)
val end = sideInsets.only(WindowInsetsSides.End)
Row(
modifier = Modifier.fillMaxSize().background(MaterialTheme.colorScheme.surface),
horizontalArrangement = Arrangement.spacedBy(8.dp),
) {
Box(Modifier.weight(1f).fillMaxHeight()) { list(select) }
Box(
Modifier
.weight(1f)
.fillMaxHeight()
.windowInsetsPadding(start)
.consumeWindowInsets(end),
) { list(select) }
Surface(
color = MaterialTheme.colorScheme.surfaceContainerLow,
shape = RoundedCornerShape(topStart = 28.dp, bottomStart = 28.dp),
modifier = Modifier.weight(1.2f).fillMaxHeight(),
) {
if (selectedId == Dest.NO_ID) {
EmptyDetailPane()
} else {
val vm: TaskDetailViewModel = hiltViewModel(key = "task-detail-pane")
LaunchedEffect(selectedId, selectedOccurrence) {
vm.bind(
selectedId,
selectedOccurrence.takeIf { it != Dest.NO_ID }?.let(Instant::fromEpochMilliseconds),
Box(Modifier.fillMaxSize().windowInsetsPadding(end).consumeWindowInsets(start)) {
if (selectedId == Dest.NO_ID) {
EmptyDetailPane()
} else {
val vm: TaskDetailViewModel = hiltViewModel(key = "task-detail-pane")
LaunchedEffect(selectedId, selectedOccurrence) {
vm.bind(
selectedId,
selectedOccurrence.takeIf { it != Dest.NO_ID }?.let(Instant::fromEpochMilliseconds),
)
}
TaskDetailScreen(
viewModel = vm,
onEdit = onEdit,
onDeleted = clear,
onBack = clear,
onOpenTask = select,
onDuplicated = { id ->
selectedId = id
selectedOccurrence = Dest.NO_ID
},
)
}
TaskDetailScreen(
viewModel = vm,
onEdit = onEdit,
onDeleted = clear,
onBack = clear,
onOpenTask = select,
onDuplicated = { id ->
selectedId = id
selectedOccurrence = Dest.NO_ID
},
)
}
}
}
@@ -22,6 +22,9 @@ import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.displayCutout
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.ime
import androidx.compose.foundation.layout.isImeVisible
import androidx.compose.foundation.layout.navigationBars
@@ -424,7 +427,9 @@ private fun TaskListBody(
modifier = Modifier.fillMaxSize().then(viewport),
contentPadding = PaddingValues(
top = inner.calculateTopPadding() + 8.dp,
bottom = inner.calculateBottomPadding() + if (bottomBarShown) 16.dp else 96.dp,
// While typing the viewport already ends above the bar or keyboard.
bottom = (if (imeVisible) 0.dp else inner.calculateBottomPadding()) +
if (bottomBarShown) 16.dp else 96.dp,
),
) {
if (state.tasks.isEmpty()) {
@@ -618,7 +623,11 @@ private fun QuickAddBar(onAdd: (String) -> Unit) {
Box(
modifier = Modifier
.fillMaxWidth()
.windowInsetsPadding(WindowInsets.ime.union(WindowInsets.navigationBars)),
.windowInsetsPadding(
WindowInsets.ime
.union(WindowInsets.navigationBars)
.union(WindowInsets.displayCutout.only(WindowInsetsSides.Horizontal)),
),
) {
InlineAdd(onAdd = onAdd, elevated = true)
}