New task on home takes the task list block's presets; a route rule that doesn't read shows All (#59)
This commit is contained in:
1 parent
32ec1f8331
commit
737a355baf
3 files changed
+17
-5
No files matched your search
@@ -104,7 +104,7 @@ import kotlinx.coroutines.delay
|
||||
fun ListsScreen(
|
||||
onOpenFilter: (TaskFilter, Long?) -> Unit,
|
||||
onOpenTask: (Task) -> Unit,
|
||||
onNewTask: (listId: Long?, tag: String?) -> Unit,
|
||||
onNewTask: (listId: Long?, tag: String?, preset: TaskFilter?) -> Unit,
|
||||
onOpenSettings: () -> Unit,
|
||||
onManageViews: () -> Unit,
|
||||
onEditView: (Long) -> Unit,
|
||||
@@ -220,7 +220,7 @@ fun ListsScreen(
|
||||
// The FAB would otherwise float over the search results, or the layout being edited.
|
||||
if (!searchActive && !editing) {
|
||||
ExtendedFloatingActionButton(
|
||||
onClick = if (noLists) ({ newList = true }) else ({ onNewTask(content?.newTaskList, content?.newTaskTag) }),
|
||||
onClick = if (noLists) ({ newList = true }) else ({ onNewTask(content?.newTaskList, content?.newTaskTag, taskFilter) }),
|
||||
icon = { Icon(Icons.Rounded.Add, contentDescription = null) },
|
||||
text = {
|
||||
Text(stringResource(if (noLists) R.string.list_add else R.string.new_task))
|
||||
|
||||
@@ -141,7 +141,18 @@ fun AgendulaNavHost(
|
||||
ListsScreen(
|
||||
onOpenFilter = { filter, scopeViewId -> nav.navigate(Dest.TaskList.build(filter, scopeViewId)) },
|
||||
onOpenTask = { task -> nav.navigate(task.detailRoute()) },
|
||||
onNewTask = { listId, tag -> nav.navigate(Dest.TaskEdit.buildNew(presetListId = listId, tag = tag)) },
|
||||
// The view's scope picks the list and tag; its task list block's source adds its own presets.
|
||||
onNewTask = { listId, tag, preset ->
|
||||
nav.navigate(
|
||||
Dest.TaskEdit.buildNew(
|
||||
presetListId = listId ?: (preset as? TaskFilter.OfList)?.listId,
|
||||
tag = tag ?: (preset as? TaskFilter.Tagged)?.tag,
|
||||
filterId = (preset as? TaskFilter.Saved)?.id,
|
||||
smartList = (preset as? TaskFilter.Smart)?.list,
|
||||
rule = (preset as? TaskFilter.Matching)?.rule,
|
||||
),
|
||||
)
|
||||
},
|
||||
onNewFilter = { nav.navigate(Dest.FilterEdit.build()) },
|
||||
onOpenSettings = { nav.navigate(Dest.SETTINGS) },
|
||||
onManageViews = { nav.navigate(Dest.MANAGE_VIEWS) },
|
||||
|
||||
@@ -102,10 +102,10 @@ object Dest {
|
||||
return if (scopeViewId == null) base else "$base&$ARG_VIEW=$scopeViewId"
|
||||
}
|
||||
|
||||
/** Reconstruct the filter from a destination's arguments. */
|
||||
/** [text], a rule as a route carries it, read back. */
|
||||
fun ruleOf(text: String): Rule = RuleCodec.decode(text, ROUTE_STORE)
|
||||
|
||||
/** Reconstruct the filter from a destination's arguments; a rule that doesn't read shows All. */
|
||||
fun filterOf(
|
||||
smart: String?,
|
||||
listId: Long,
|
||||
@@ -116,7 +116,8 @@ object Dest {
|
||||
title: String? = null,
|
||||
): TaskFilter = when {
|
||||
smart != null -> TaskFilter.Smart(SmartList.valueOf(smart))
|
||||
rule != null -> TaskFilter.Matching(ruleOf(rule), title)
|
||||
rule != null -> runCatching { ruleOf(rule) }.getOrNull()?.let { TaskFilter.Matching(it, title) }
|
||||
?: TaskFilter.Smart(SmartList.ALL)
|
||||
day != null -> TaskFilter.DueOn(java.time.LocalDate.parse(day))
|
||||
tag != null -> TaskFilter.Tagged(tag)
|
||||
filterId != NO_ID -> TaskFilter.Saved(filterId)
|
||||
|
||||
Reference in new issue
Block a user