Custom-rules tiles and previews are named by their rules and lead back to the source picker (#59, #172)
This commit is contained in:
1 parent
d6ea0091f8
commit
879ae7e244
1 file changed
+12
-4
@@ -105,6 +105,7 @@ import de.jeanlucmakiola.agendula.ui.tasklist.TaskListViewModel
|
||||
import de.jeanlucmakiola.agendula.ui.tasklist.UndoReceipt
|
||||
import de.jeanlucmakiola.agendula.ui.tasklist.rememberTaskRows
|
||||
import de.jeanlucmakiola.agendula.ui.tasklist.taskRows
|
||||
import de.jeanlucmakiola.agendula.ui.views.scopeSummary
|
||||
import de.jeanlucmakiola.agendula.ui.views.ScopeChipRow
|
||||
import de.jeanlucmakiola.agendula.ui.views.ViewSwitcher
|
||||
import de.jeanlucmakiola.agendula.ui.views.viewName
|
||||
@@ -443,7 +444,7 @@ private fun ListsContent(
|
||||
val open = { filter: TaskFilter -> onOpenFilter(filter, scopeFor(block)) }
|
||||
val sections = state.sectionsFor(block)
|
||||
when (block.type) {
|
||||
BlockType.PREVIEW -> previewSection(block, state, open, onOpenTask)
|
||||
BlockType.PREVIEW -> previewSection(block, state, open, onOpenTask, onChooseSource)
|
||||
BlockType.LISTS -> listsSection(
|
||||
key = "${block.id}",
|
||||
options = block.options as BlockOptions.Lists,
|
||||
@@ -553,7 +554,8 @@ private fun Tile(
|
||||
style = tileStyle(source!!, state),
|
||||
count = count,
|
||||
modifier = modifier,
|
||||
onClick = { filter?.let { onOpenFilter(it, scopeFor(block)) } },
|
||||
// Tapped, custom rules open the source picker, which edits or replaces them.
|
||||
onClick = { if (filter != null) onOpenFilter(filter, scopeFor(block)) else onChooseSource(block.id) },
|
||||
)
|
||||
}
|
||||
else -> null
|
||||
@@ -590,6 +592,7 @@ private fun LazyListScope.previewSection(
|
||||
state: ListsUiState.Content,
|
||||
onOpenFilter: (TaskFilter) -> Unit,
|
||||
onOpenTask: (Task) -> Unit,
|
||||
onChooseSource: (Long) -> Unit,
|
||||
) {
|
||||
// TODO(#59): inline done.
|
||||
val source = block.source ?: return
|
||||
@@ -603,7 +606,12 @@ private fun LazyListScope.previewSection(
|
||||
UpcomingPreview(
|
||||
tasks = tasks,
|
||||
onOpenTask = onOpenTask,
|
||||
onViewAll = if (options.showAll && filter != null) ({ onOpenFilter(filter) }) else null,
|
||||
// Custom rules have no screen to show all of; theirs leads to the source picker instead.
|
||||
onViewAll = when {
|
||||
!options.showAll -> null
|
||||
filter != null -> ({ onOpenFilter(filter) })
|
||||
else -> ({ onChooseSource(block.id) })
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -615,7 +623,7 @@ private fun sourceLabel(source: BlockSource, state: ListsUiState.Content): Strin
|
||||
is BlockSource.List -> state.lists.firstOrNull { it.id == source.listId }?.name.orEmpty()
|
||||
is BlockSource.Tag -> source.tag
|
||||
is BlockSource.Filter -> state.filterNames[source.filterId].orEmpty()
|
||||
is BlockSource.Rules -> stringResource(R.string.view_source_custom_label)
|
||||
is BlockSource.Rules -> scopeSummary(source.rule, state.lists.associate { it.id to it.name })
|
||||
is BlockSource.ListElsewhere -> ""
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user