diff --git a/app/src/main/java/de/jeanlucmakiola/agendula/ui/lists/ListsScreen.kt b/app/src/main/java/de/jeanlucmakiola/agendula/ui/lists/ListsScreen.kt index cab8856..8707d47 100644 --- a/app/src/main/java/de/jeanlucmakiola/agendula/ui/lists/ListsScreen.kt +++ b/app/src/main/java/de/jeanlucmakiola/agendula/ui/lists/ListsScreen.kt @@ -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 -> "" }