Review fixes: previews on grouped rows, long-press on every browse header, one clear KDoc (#59, #140)

This commit is contained in:
makiolaj committed 2026-11-27 15:28:00 +01:00
1 parent 03e050a14a
commit 4338e9e843
2 files changed
+37 -25

No files matched your search

@@ -87,6 +87,7 @@ import de.jeanlucmakiola.agendula.ui.views.vector
import de.jeanlucmakiola.floret.components.ActionButton
import de.jeanlucmakiola.floret.components.GroupedListInset
import de.jeanlucmakiola.floret.components.GroupedRow
import de.jeanlucmakiola.floret.components.GroupedSurface
import de.jeanlucmakiola.floret.components.IconInfoCard
import de.jeanlucmakiola.floret.components.Position
import de.jeanlucmakiola.floret.components.ReorderableColumn
@@ -624,28 +625,30 @@ private fun TaskCard(
onViewAll: (() -> Unit)?,
completedTime: Boolean = false,
) {
Surface(
shape = RoundedCornerShape(22.dp),
color = MaterialTheme.colorScheme.surfaceContainer,
modifier = Modifier.fillMaxWidth().padding(horizontal = GroupedListInset),
) {
Column {
tasks.forEach { task ->
UpcomingRow(
task = task,
onClick = { onOpenTask(task) },
onToggle = onToggle?.let { toggle -> { toggle(task) } },
completedTime = completedTime,
)
val count = tasks.size + if (onViewAll != null) 1 else 0
Column {
tasks.forEachIndexed { index, task ->
GroupedSurface(
position = positionOf(index, count),
modifier = Modifier.padding(horizontal = GroupedListInset),
onClick = { onOpenTask(task) },
) {
UpcomingRowContent(task, onToggle?.let { toggle -> { toggle(task) } }, completedTime)
}
if (onViewAll != null) ViewAllRow(onViewAll)
}
if (onViewAll != null) {
GroupedSurface(
position = positionOf(count - 1, count),
modifier = Modifier.padding(horizontal = GroupedListInset),
onClick = onViewAll,
) { ViewAllRow() }
}
}
}
@Composable
private fun ViewAllRow(onViewAll: () -> Unit) {
Surface(onClick = onViewAll, color = Color.Transparent, modifier = Modifier.fillMaxWidth()) {
private fun ViewAllRow() {
run {
Row(
modifier = Modifier.fillMaxWidth().heightIn(min = 48.dp).padding(horizontal = 16.dp),
verticalAlignment = Alignment.CenterVertically,
@@ -673,11 +676,19 @@ private fun ViewAllRow(onViewAll: () -> Unit) {
* line says when it was completed.
*/
@Composable
internal fun UpcomingRow(task: Task, onClick: () -> Unit, onToggle: (() -> Unit)? = null, completedTime: Boolean = false) {
internal fun UpcomingRow(task: Task, onClick: () -> Unit) {
Surface(onClick = onClick, color = Color.Transparent, modifier = Modifier.fillMaxWidth()) {
UpcomingRowContent(task, onToggle = null, completedTime = false)
}
}
/** [UpcomingRow]'s content, for a container that takes the tap itself. */
@Composable
private fun UpcomingRowContent(task: Task, onToggle: (() -> Unit)?, completedTime: Boolean) {
val dark = isSystemInDarkTheme()
val muted = MaterialTheme.colorScheme.onSurfaceVariant
val metaStyle = MaterialTheme.typography.bodySmall
Surface(onClick = onClick, color = Color.Transparent, modifier = Modifier.fillMaxWidth()) {
run {
Row(
modifier = Modifier
.fillMaxWidth()
@@ -1064,7 +1075,7 @@ internal fun LazyListScope.browseBlock(
ListsHeader(state.marksIgnoredScope(block), reordering = false, onToggleReorderLists, actions.newList, rowModifier)
}
shown.forEach { group ->
item(key = "$key-acct-${group.accountName}") { AccountHeader(group.accountName) }
item(key = "$key-acct-${group.accountName}") { Box(rowModifier) { AccountHeader(group.accountName) } }
itemsIndexed(group.lists, key = { _, o -> "$key-list-${o.list.id}" }) { index, overview ->
GroupedRow(
title = overview.list.name,
@@ -1080,7 +1091,9 @@ internal fun LazyListScope.browseBlock(
BlockType.TAGS -> {
val tags = sections.tags
if (tags.isEmpty()) return
item(key = "$key-header") { SectionHeader(stringResource(R.string.tags_header), marked = state.marksIgnoredScope(block)) }
item(key = "$key-header") {
Box(rowModifier) { SectionHeader(stringResource(R.string.tags_header), marked = state.marksIgnoredScope(block)) }
}
itemsIndexed(tags, key = { _, t -> "$key-tag-${t.tag}" }) { index, overview ->
GroupedRow(
title = overview.tag,
@@ -1098,7 +1111,7 @@ internal fun LazyListScope.browseBlock(
item(key = key) { Column(rowModifier) { BlockBody(block, state, actions, editing = false) } }
return
}
item(key = "$key-header") { FiltersHeader(state.marksIgnoredScope(block), actions.newFilter) }
item(key = "$key-header") { Box(rowModifier) { FiltersHeader(state.marksIgnoredScope(block), actions.newFilter) } }
itemsIndexed(filters, key = { _, f -> "$key-filter-${f.filter.id}" }) { index, overview ->
GroupedRow(
title = overview.filter.name,
@@ -512,11 +512,10 @@ class TaskListViewModel @Inject constructor(
}
/**
* Deletes every completed task in [listId]. A completed occurrence goes on its
* own, a series that is closed as a whole goes whole, and a parent that still
* has open subtasks stays — deleting it would take them along.
* Deletes the completed tasks this screen shows that [clearableCompleted] lets
* go. A completed occurrence goes on its own, a series that is closed as a
* whole goes whole, and a parent that still has open subtasks stays.
*/
/** Deletes the completed tasks this screen shows that [clearableCompleted] lets go. */
fun clearCompleted() {
val done = (state.value as? TaskListUiState.Content)?.clearableCompleted().orEmpty()
appScope.launch {