todo: dialogs are routes, deterministic fixtures, dead grip fixed
- Commit
42eb3438afaac146a1920125ae86b04701a152b0- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-02 00:16 UTC (4 days ago)
- Parents
fb6fc75
DialogAsRoute (14): the list edit/delete, todo delete/move, bulk move/date, import-confirm and digest-time dialogs are now Route dialog destinations with DialogPage() entries in Navigation.kt, rendering stateless content moved/created under ui/dialogs/ (ListPicker, ListSectionPicker, ListEdit, date/time pickers, DeleteTodo, DeleteList, ImportConfirm). Screens push them through new action-contract callbacks (TodoActions, TodoListActions, BulkActions, digest/import openers); entries act through TodoViewModel (import preview is held there, bulk entries dispatch the bulk-result key so TodoListPage bumps TodoListUiState.bulkClearSignal and the list drops its selection). The due/reminder/start pickers nested in the editor bottom sheets and the quick-add multi-line paste confirm stay local with verbatim DIALOG LOCAL EXCEPTION reasons: the sheets/composer are not routes yet and their second-step/composer text has no route/result shape. RouteScreenshotCoverage (2): MetadataPreviews captures are renamed to the route keys (1-todo-list, 2-todo-detail, plus todo-list variants) and gain phone captures for every new dialog route with fixed literals. FixtureDeterminism (27): the eight test files that seed due/reminder times relative to code that reads the real wall clock carry per-file FIXTURE RELATIVE-TIME EXCEPTION reasons. NoDeadClick (1): the reorder grip is a plain Box container; reorderDragHandle owns the gesture instead of an IconButton with an empty click. Test contracts adapted to route requests (bulk/detail tests assert the open callbacks and carried ids; dialog content is still rendered directly in TodoComposeDialogsTest). exceptions.tsv regenerated: no diff, the structure tool does not inventory dialog/fixture markers. Verified: ./gradlew :todo:lint :todo:lintVitalRelease :todo:testDevUnitTest :todo:compileReleaseKotlin all green (424 tests, 0 failures).
Diff
todo/AGENTS.md
diff --git a/todo/AGENTS.md b/todo/AGENTS.mdindex 88825a540a..3f9d9eb27e 100644--- a/todo/AGENTS.md+++ b/todo/AGENTS.md@@ -6,6 +6,7 @@ _Install: ./install todo (dev by default)._ - Gradle: :todo / dir: todo/ - Package roots present: ui, data, domain, platform, sync, notifications, widget, service, intents - Entry files: MainActivity.kt, Route.kt, Navigation.kt, TodoApplication.kt+- Dialog routes: `Route` dialog destinations (list edit/delete, todo delete/move, bulk move/date, import confirm, digest time) are `DialogPage()` entries in Navigation.kt rendering stateless content from `ui/dialogs/`; sheet-nested pickers and the quick-add paste confirm remain local (see DIALOG LOCAL EXCEPTION markers in those files) - Deps: :library:room, :library:widgets, :library:wearlink - Metadata: metadata_data/todo.md (present) - Rust: no / screenshotTest: yes@@ -32,6 +33,8 @@ _Install: ./install todo (dev by default)._ - TodoQuery.kt, TodoView.kt, QuickAddParser.kt + QuickAddWords.kt, Recurrence.kt, Completion.kt, DueDates.kt, DueBuckets.kt, Positions.kt, Reminders.kt, format/ ### platform/ - TodoViewModel.kt, TodoEditor.kt, TodoListUiContract.kt, TodoEditorUiContract.kt, TodoBackground.kt, IntentRouter.kt, TodoDataTransfer.kt, AppBackupAgent.kt+### ui/dialogs/+- ListPickerDialog.kt, ListSectionPickerDialog.kt, ListEditDialog.kt, TodoDatePickerDialog.kt, TodoTimePickerDialog.kt, DeleteTodoDialog.kt, DeleteListDialog.kt, ImportConfirmDialog.kt (stateless dialog content for the dialog routes) ### sync/ - RelayTodoProvider.kt, RelayEnvelopes.kt, CalendarMirror.kt, WearTodoSync.kt (phone side of the wear companion; wire protocol `com.vayunmathur.library.wearlink.todo.WearTodoProtocol` in `:library:wearlink`, shared with `:todo-wear`) ### notifications/ widget/ service/ intents/
todo/src/main/java/com/vayunmathur/todo/Navigation.kt
diff --git a/todo/src/main/java/com/vayunmathur/todo/Navigation.kt b/todo/src/main/java/com/vayunmathur/todo/Navigation.ktindex 4b403ec623..407634d349 100644--- a/todo/src/main/java/com/vayunmathur/todo/Navigation.kt+++ b/todo/src/main/java/com/vayunmathur/todo/Navigation.kt@@ -2,20 +2,37 @@ package com.vayunmathur.todo import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue+import androidx.compose.runtime.rememberCoroutineScope+import androidx.compose.ui.platform.LocalResources import androidx.lifecycle.compose.collectAsStateWithLifecycle+import com.vayunmathur.library.ui.rememberMessenger+import com.vayunmathur.library.util.DetailPage+import com.vayunmathur.library.util.DialogPage import com.vayunmathur.library.util.ListDetailPage import com.vayunmathur.library.util.ListPage+import com.vayunmathur.library.util.LocalNavResultRegistry import com.vayunmathur.library.util.MainNavigation import com.vayunmathur.library.util.MorphPage-import com.vayunmathur.library.util.DetailPage import com.vayunmathur.library.util.rememberNavBackStack+import com.vayunmathur.todo.domain.TodoView import com.vayunmathur.todo.platform.TodoViewModel+import com.vayunmathur.todo.ui.BULK_RESULT_KEY import com.vayunmathur.todo.ui.IntentEffect import com.vayunmathur.todo.ui.SettingsPage import com.vayunmathur.todo.ui.TodoDetailPage import com.vayunmathur.todo.ui.TodoListPage import com.vayunmathur.todo.ui.TodoShell+import com.vayunmathur.todo.ui.dialogs.DeleteListDialog+import com.vayunmathur.todo.ui.dialogs.DeleteTodoDialog+import com.vayunmathur.todo.ui.dialogs.ImportConfirmDialog+import com.vayunmathur.todo.ui.dialogs.ListEditDialog+import com.vayunmathur.todo.ui.dialogs.ListPickerDialog+import com.vayunmathur.todo.ui.dialogs.ListSectionPickerDialog+import com.vayunmathur.todo.ui.dialogs.TodoDatePickerDialog+import com.vayunmathur.todo.ui.dialogs.TodoTimePickerDialog import com.vayunmathur.todo.ui.rememberTodoShellState+import kotlinx.coroutines.launch+import kotlinx.datetime.LocalTime @Composable fun Navigation(todoViewModel: TodoViewModel) {@@ -44,6 +61,144 @@ fun Navigation(todoViewModel: TodoViewModel) { entry<Route.Settings>(metadata = DetailPage()) { SettingsPage(backStack, todoViewModel) }+ entry<Route.ListEditDialog>(metadata = DialogPage()) { route ->+ val lists by todoViewModel.lists.collectAsStateWithLifecycle()+ val list = lists.firstOrNull { it.syncId == route.listSyncId }+ ListEditDialog(+ list = list,+ onSave = { saved ->+ todoViewModel.saveList(saved)+ if (route.listSyncId == null) {+ todoViewModel.clearSearchQuery()+ backStack.reset(Route.TodoList(TodoView.InList(saved.syncId).key))+ } else {+ backStack.pop()+ }+ },+ onDelete = list?.let { existing ->+ { backStack.add(Route.DeleteListDialog(existing.syncId)) }+ },+ onDismiss = { backStack.pop() },+ )+ }+ entry<Route.DeleteListDialog>(metadata = DialogPage()) { route ->+ val lists by todoViewModel.lists.collectAsStateWithLifecycle()+ val list = lists.firstOrNull { it.syncId == route.listSyncId }+ DeleteListDialog(+ listName = list?.name.orEmpty(),+ onConfirm = {+ list?.let { todoViewModel.deleteList(it) }+ // Pop the delete dialog and any list-edit dialog under it.+ backStack.pop()+ if (backStack.last() is Route.ListEditDialog) backStack.pop()+ val current = backStack.backStack.filterIsInstance<Route.TodoList>().lastOrNull()+ if (current?.viewKey == TodoView.InList(route.listSyncId).key) {+ backStack.reset(Route.TodoList(TodoView.Inbox.key))+ }+ },+ onDismiss = { backStack.pop() },+ )+ }+ entry<Route.DeleteTodoDialog>(metadata = DialogPage()) { route ->+ val todos by todoViewModel.todos.collectAsStateWithLifecycle()+ DeleteTodoDialog(+ onConfirm = {+ todos.firstOrNull { it.id == route.todoId }?.let {+ todoViewModel.delete(listOf(it))+ }+ backStack.pop()+ if (backStack.last() is Route.TodoDetail) backStack.pop()+ },+ onDismiss = { backStack.pop() },+ )+ }+ entry<Route.MoveTodoDialog>(metadata = DialogPage()) { route ->+ val todos by todoViewModel.todos.collectAsStateWithLifecycle()+ val lists by todoViewModel.lists.collectAsStateWithLifecycle()+ val todo = todos.firstOrNull { it.id == route.todoId }+ ListSectionPickerDialog(+ lists = lists,+ currentList = todo?.listSyncId,+ currentSection = todo?.section,+ onPick = { listSyncId, section ->+ todo?.let {+ todoViewModel.upsertAll(+ listOf(it.copy(listSyncId = listSyncId, section = section)),+ )+ }+ backStack.pop()+ },+ onDismiss = { backStack.pop() },+ )+ }+ entry<Route.BulkMoveDialog>(metadata = DialogPage()) { route ->+ val todos by todoViewModel.todos.collectAsStateWithLifecycle()+ val lists by todoViewModel.lists.collectAsStateWithLifecycle()+ val registry = LocalNavResultRegistry.current+ val scope = rememberCoroutineScope()+ ListPickerDialog(+ lists = lists,+ current = "",+ onPick = { listSyncId ->+ val selected = todos.filter { it.id in route.todoIds }+ todoViewModel.move(selected, listSyncId)+ scope.launch { registry.dispatchResult(BULK_RESULT_KEY, true) }+ backStack.pop()+ },+ onDismiss = { backStack.pop() },+ )+ }+ entry<Route.BulkDateDialog>(metadata = DialogPage()) { route ->+ val todos by todoViewModel.todos.collectAsStateWithLifecycle()+ val registry = LocalNavResultRegistry.current+ val scope = rememberCoroutineScope()+ TodoDatePickerDialog(+ initial = null,+ onConfirm = { dueAt ->+ val selected = todos.filter { it.id in route.todoIds }+ todoViewModel.reschedule(selected, dueAt)+ scope.launch { registry.dispatchResult(BULK_RESULT_KEY, true) }+ backStack.pop()+ },+ onDismiss = { backStack.pop() },+ )+ }+ entry<Route.ImportConfirmDialog>(metadata = DialogPage()) {+ val tasks by todoViewModel.importPreview.collectAsStateWithLifecycle()+ val messenger = rememberMessenger()+ val resources = LocalResources.current+ ImportConfirmDialog(+ tasks = tasks,+ onConfirm = {+ todoViewModel.import(tasks) { n ->+ messenger.show(+ resources.getQuantityString(R.plurals.imported, n, n),+ )+ }+ todoViewModel.clearImportPreview()+ backStack.pop()+ },+ onDismiss = {+ todoViewModel.clearImportPreview()+ backStack.pop()+ },+ )+ }+ entry<Route.DigestTimeDialog>(metadata = DialogPage()) { route ->+ TodoTimePickerDialog(+ initial = LocalTime(+ (route.minutes / 60).toInt(),+ (route.minutes % 60).toInt(),+ ),+ onConfirm = { time ->+ todoViewModel.updateSettings {+ setDigestMinutes(time.hour.toLong() * 60 + time.minute)+ }+ backStack.pop()+ },+ onDismiss = { backStack.pop() },+ )+ } } } }
todo/src/main/java/com/vayunmathur/todo/Route.kt
diff --git a/todo/src/main/java/com/vayunmathur/todo/Route.kt b/todo/src/main/java/com/vayunmathur/todo/Route.ktindex 0b27e83d0c..fced822251 100644--- a/todo/src/main/java/com/vayunmathur/todo/Route.kt+++ b/todo/src/main/java/com/vayunmathur/todo/Route.kt@@ -17,4 +17,36 @@ sealed interface Route : NavKey { /** The app settings screen. */ @Serializable data object Settings : Route++ /** Create ([listSyncId] null) or edit a list dialog. */+ @Serializable+ data class ListEditDialog(val listSyncId: String? = null) : Route++ /** Delete confirmation dialog for the list with [listSyncId]. */+ @Serializable+ data class DeleteListDialog(val listSyncId: String) : Route++ /** Delete confirmation dialog for the task with [todoId]. */+ @Serializable+ data class DeleteTodoDialog(val todoId: Long) : Route++ /** Move dialog (list + section) for the task with [todoId]. */+ @Serializable+ data class MoveTodoDialog(val todoId: Long) : Route++ /** Move dialog for the bulk-selected tasks with [todoIds]. */+ @Serializable+ data class BulkMoveDialog(val todoIds: List<Long>) : Route++ /** Date picker dialog rescheduling the bulk-selected tasks with [todoIds]. */+ @Serializable+ data class BulkDateDialog(val todoIds: List<Long>) : Route++ /** Import confirmation dialog; the parsed tasks are held by the ViewModel. */+ @Serializable+ data object ImportConfirmDialog : Route++ /** Time picker dialog for the daily digest time, starting at [minutes] after midnight. */+ @Serializable+ data class DigestTimeDialog(val minutes: Long) : Route }
todo/src/main/java/com/vayunmathur/todo/platform/TodoEditorUiContract.kt
diff --git a/todo/src/main/java/com/vayunmathur/todo/platform/TodoEditorUiContract.kt b/todo/src/main/java/com/vayunmathur/todo/platform/TodoEditorUiContract.ktindex 30a48900c1..de496b9963 100644--- a/todo/src/main/java/com/vayunmathur/todo/platform/TodoEditorUiContract.kt+++ b/todo/src/main/java/com/vayunmathur/todo/platform/TodoEditorUiContract.kt@@ -32,6 +32,12 @@ interface TodoActions { fun duplicate() {} fun deleteTodo() {} + /** Pushes the delete-confirmation dialog route for this task. */+ fun openDeleteConfirm() {}++ /** Pushes the move-to-list dialog route for this task. */+ fun openMoveToList() {}+ /** Shared no-op TodoActions instance for previews. */ companion object { val Noop: TodoActions = object : TodoActions {}
todo/src/main/java/com/vayunmathur/todo/platform/TodoListUiContract.kt
diff --git a/todo/src/main/java/com/vayunmathur/todo/platform/TodoListUiContract.kt b/todo/src/main/java/com/vayunmathur/todo/platform/TodoListUiContract.ktindex 8d298eb794..129aa02153 100644--- a/todo/src/main/java/com/vayunmathur/todo/platform/TodoListUiContract.kt+++ b/todo/src/main/java/com/vayunmathur/todo/platform/TodoListUiContract.kt@@ -23,6 +23,8 @@ data class TodoListUiState( val showAddButton: Boolean = true, /** Epoch ms the relative due labels are computed against. */ val now: Long = System.currentTimeMillis(),+ /** Incremented by the binding page when a bulk dialog route applies, so the screen drops its selection. */+ val bulkClearSignal: Int = 0, /** False until the todos DAO emits at least once, so an empty list can show a spinner. */ val hasLoaded: Boolean = true, )@@ -52,6 +54,12 @@ interface TodoListActions { fun reschedule(todos: List<Todo>, dueAt: Long?) {} fun setPriority(todos: List<Todo>, priority: Int) {} + /** Pushes the bulk move-to-list dialog route for the selected task [ids]. */+ fun openBulkMove(ids: List<Long>) {}++ /** Pushes the bulk date-picker dialog route for the selected task [ids]. */+ fun openBulkDate(ids: List<Long>) {}+ /** Shared no-op TodoListActions instance for previews. */ companion object { val Noop: TodoListActions = object : TodoListActions {}
todo/src/main/java/com/vayunmathur/todo/platform/TodoViewModel.kt
diff --git a/todo/src/main/java/com/vayunmathur/todo/platform/TodoViewModel.kt b/todo/src/main/java/com/vayunmathur/todo/platform/TodoViewModel.ktindex 43aff14133..9cd1ed5e0c 100644--- a/todo/src/main/java/com/vayunmathur/todo/platform/TodoViewModel.kt+++ b/todo/src/main/java/com/vayunmathur/todo/platform/TodoViewModel.kt@@ -168,6 +168,18 @@ class TodoViewModel( } } + /** Tasks parsed from an import file, awaiting confirmation in the import dialog route. */+ private val _importPreview = MutableStateFlow<List<ImportedTask>>(emptyList())+ val importPreview: StateFlow<List<ImportedTask>> = _importPreview.asStateFlow()++ fun setImportPreview(tasks: List<ImportedTask>) {+ _importPreview.value = tasks+ }++ fun clearImportPreview() {+ _importPreview.value = emptyList()+ }+ fun updateSettings(block: suspend TodoSettings.() -> Unit) { viewModelScope.launch(io) { settings.block() } }
todo/src/main/java/com/vayunmathur/todo/ui/BulkActionBar.kt
diff --git a/todo/src/main/java/com/vayunmathur/todo/ui/BulkActionBar.kt b/todo/src/main/java/com/vayunmathur/todo/ui/BulkActionBar.ktindex 8278f4a612..b232f05f68 100644--- a/todo/src/main/java/com/vayunmathur/todo/ui/BulkActionBar.kt+++ b/todo/src/main/java/com/vayunmathur/todo/ui/BulkActionBar.kt@@ -32,6 +32,12 @@ interface BulkActions { fun move(listSyncId: String?) fun reschedule(dueAt: Long?) fun setPriority(priority: Int)++ /** Pushes the move-to-list dialog route; its entry applies the pick. */+ fun openMovePicker() {}++ /** Pushes the date-picker dialog route; its entry applies the pick. */+ fun openDatePicker() {} } /** Top bar shown while tasks are selected. */@@ -39,8 +45,6 @@ interface BulkActions { @Composable fun BulkActionBar(count: Int, lists: List<TodoList>, actions: BulkActions) { var menu by remember { mutableStateOf(false) }- var pickList by remember { mutableStateOf(false) }- var pickDate by remember { mutableStateOf(false) } TopAppBar( title = { Text(pluralStringResource(R.plurals.selected_count, count, count)) },@@ -57,12 +61,12 @@ fun BulkActionBar(count: Int, lists: List<TodoList>, actions: BulkActions) { }) } item(R.string.select_all, actions::selectAll)- item(R.string.move_to) { pickList = true }+ item(R.string.move_to) { actions.openMovePicker() } HorizontalDivider() DueShortcuts.entries.forEach { shortcut -> item(shortcut.label) { actions.reschedule(shortcut.dueAt()) } }- item(R.string.pick_date) { pickDate = true }+ item(R.string.pick_date) { actions.openDatePicker() } HorizontalDivider() for (p in 1..Todo.PRIORITY_MAX) { DropdownMenuItem(text = { Text(stringResource(R.string.priority_n, p)) }, onClick = {@@ -75,18 +79,6 @@ fun BulkActionBar(count: Int, lists: List<TodoList>, actions: BulkActions) { }, ) - if (pickList) {- ListPickerDialog(lists, current = "", onPick = {- actions.move(it)- pickList = false- }, onDismiss = { pickList = false })- }- if (pickDate) {- TodoDatePickerDialog(initial = null, onConfirm = {- actions.reschedule(it)- pickDate = false- }, onDismiss = { pickDate = false })- } } private val DueShortcuts.label: Int
todo/src/main/java/com/vayunmathur/todo/ui/DataSettingsSection.kt
diff --git a/todo/src/main/java/com/vayunmathur/todo/ui/DataSettingsSection.kt b/todo/src/main/java/com/vayunmathur/todo/ui/DataSettingsSection.ktindex de9a8d8c80..2e8278650b 100644--- a/todo/src/main/java/com/vayunmathur/todo/ui/DataSettingsSection.kt+++ b/todo/src/main/java/com/vayunmathur/todo/ui/DataSettingsSection.kt@@ -6,34 +6,26 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue-import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope-import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalResources-import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp-import com.vayunmathur.library.ui.AlertDialog import com.vayunmathur.library.ui.SettingsRow import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.TextButton import com.vayunmathur.library.ui.rememberMessenger import com.vayunmathur.todo.R import com.vayunmathur.todo.domain.format.ExportFormat-import com.vayunmathur.todo.domain.format.ImportedTask import com.vayunmathur.todo.platform.TodoViewModel import kotlinx.coroutines.launch-import com.vayunmathur.library.ui.R as UiR /** Backup/restore plus import (todo.txt, CSV, iCalendar — detected) and export in each format. */ @Composable-fun DataSettingsSection(viewModel: TodoViewModel) {+fun DataSettingsSection(viewModel: TodoViewModel, onOpenImportConfirm: () -> Unit = {}) { val messenger = rememberMessenger() val resources = LocalResources.current val scope = rememberCoroutineScope()- var preview by remember { mutableStateOf<List<ImportedTask>?>(null) } val exported = stringResource(R.string.export_done) val nothing = stringResource(R.string.import_nothing) @@ -46,7 +38,12 @@ fun DataSettingsSection(viewModel: TodoViewModel) { uri ?: return@rememberLauncherForActivityResult scope.launch { val tasks = viewModel.readImport(uri)- if (tasks.isEmpty()) messenger.show(nothing) else preview = tasks+ if (tasks.isEmpty()) {+ messenger.show(nothing)+ } else {+ viewModel.setImportPreview(tasks)+ onOpenImportConfirm()+ } } } @@ -63,20 +60,7 @@ fun DataSettingsSection(viewModel: TodoViewModel) { ) } - preview?.let { tasks ->- AlertDialog(- onDismissRequest = { preview = null },- title = { Text(pluralStringResource(R.plurals.import_confirm, tasks.size, tasks.size)) },- text = { Text(tasks.take(PREVIEW).joinToString("\n") { "• " + it.title } + if (tasks.size > PREVIEW) "\n…" else "") },- confirmButton = {- TextButton(onClick = {- viewModel.import(tasks) { n -> messenger.show(resources.getQuantityString(R.plurals.imported, n, n)) }- preview = null- }) { Text(stringResource(R.string.import_action)) }- },- dismissButton = { TextButton(onClick = { preview = null }) { Text(stringResource(UiR.string.cancel)) } },- )- }+ } private fun exportLabel(format: ExportFormat) = when (format) {@@ -84,5 +68,3 @@ private fun exportLabel(format: ExportFormat) = when (format) { ExportFormat.CSV -> R.string.export_csv ExportFormat.ICALENDAR -> R.string.export_ics }--private const val PREVIEW = 8
todo/src/main/java/com/vayunmathur/todo/ui/DueDateSheet.kt
diff --git a/todo/src/main/java/com/vayunmathur/todo/ui/DueDateSheet.kt b/todo/src/main/java/com/vayunmathur/todo/ui/DueDateSheet.ktindex d8486a6c2a..163761ebbf 100644--- a/todo/src/main/java/com/vayunmathur/todo/ui/DueDateSheet.kt+++ b/todo/src/main/java/com/vayunmathur/todo/ui/DueDateSheet.kt@@ -1,4 +1,5 @@ package com.vayunmathur.todo.ui+// DIALOG LOCAL EXCEPTION: date/time pickers are the second step of the due-date bottom sheet; the sheet host is not a route yet, so the date awaiting a time has no route/result shape import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement@@ -23,6 +24,8 @@ import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.ModalBottomSheet import com.vayunmathur.library.ui.Text import com.vayunmathur.todo.R+import com.vayunmathur.todo.ui.dialogs.TodoDatePickerDialog+import com.vayunmathur.todo.ui.dialogs.TodoTimePickerDialog import com.vayunmathur.todo.domain.DueDates import com.vayunmathur.todo.domain.DueShortcuts import kotlinx.datetime.LocalDate
todo/src/main/java/com/vayunmathur/todo/ui/EditorSheetHost.kt
diff --git a/todo/src/main/java/com/vayunmathur/todo/ui/EditorSheetHost.kt b/todo/src/main/java/com/vayunmathur/todo/ui/EditorSheetHost.ktindex e1b4c15ba4..d5072670ad 100644--- a/todo/src/main/java/com/vayunmathur/todo/ui/EditorSheetHost.kt+++ b/todo/src/main/java/com/vayunmathur/todo/ui/EditorSheetHost.kt@@ -1,4 +1,5 @@ package com.vayunmathur.todo.ui+// DIALOG LOCAL EXCEPTION: the start-date picker is nested inside the editor sheet host, which is not a route yet; its clear-versus-pick choice is sheet-local second-step state import androidx.compose.foundation.clickable import androidx.compose.runtime.Composable@@ -13,6 +14,8 @@ import com.vayunmathur.library.ui.ListItem import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.TextButton import com.vayunmathur.todo.R+import com.vayunmathur.todo.ui.dialogs.ListSectionPickerDialog+import com.vayunmathur.todo.ui.dialogs.TodoDatePickerDialog import com.vayunmathur.todo.data.Todo import com.vayunmathur.todo.domain.DueDates import com.vayunmathur.todo.domain.Recurrence
todo/src/main/java/com/vayunmathur/todo/ui/QuickAddBar.kt
diff --git a/todo/src/main/java/com/vayunmathur/todo/ui/QuickAddBar.kt b/todo/src/main/java/com/vayunmathur/todo/ui/QuickAddBar.ktindex 93a1bf4bce..bb4dc88ef0 100644--- a/todo/src/main/java/com/vayunmathur/todo/ui/QuickAddBar.kt+++ b/todo/src/main/java/com/vayunmathur/todo/ui/QuickAddBar.kt@@ -1,4 +1,5 @@ package com.vayunmathur.todo.ui+// DIALOG LOCAL EXCEPTION: the multi-line paste confirmation returns the joined text to the local quick-add composer (add-as-one) as well as creating tasks through it; composer text is local field state with no route/result shape import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column
todo/src/main/java/com/vayunmathur/todo/ui/ReminderSettingsSection.kt
diff --git a/todo/src/main/java/com/vayunmathur/todo/ui/ReminderSettingsSection.kt b/todo/src/main/java/com/vayunmathur/todo/ui/ReminderSettingsSection.ktindex 3e23e69ab6..11104f5cc4 100644--- a/todo/src/main/java/com/vayunmathur/todo/ui/ReminderSettingsSection.kt+++ b/todo/src/main/java/com/vayunmathur/todo/ui/ReminderSettingsSection.kt@@ -1,10 +1,6 @@ package com.vayunmathur.todo.ui import androidx.compose.runtime.Composable-import androidx.compose.runtime.getValue-import androidx.compose.runtime.mutableStateOf-import androidx.compose.runtime.remember-import androidx.compose.runtime.setValue import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import com.vayunmathur.library.ui.DateString@@ -24,10 +20,10 @@ fun ReminderSettingsSection( digestMinutes: Long, onDigestEnabled: (Boolean) -> Unit, onDigestMinutes: (Long) -> Unit,+ onOpenDigestTimePicker: () -> Unit = {}, ) { val context = LocalContext.current val requestPermission = rememberNotificationPermissionRequest()- var pickTime by remember { mutableStateOf(false) } val time = LocalTime((digestMinutes / MINUTES_PER_HOUR).toInt(), (digestMinutes % MINUTES_PER_HOUR).toInt()) SettingsSection(title = stringResource(R.string.settings_reminders)) { SettingsSwitchRow(@@ -43,7 +39,7 @@ fun ReminderSettingsSection( title = stringResource(R.string.settings_digest_time), supportingText = DateString.time(time, rememberIs24Hour()), enabled = digestEnabled,- onClick = { pickTime = true },+ onClick = onOpenDigestTimePicker, ) if (!SpecialAccess.hasExactAlarms(context)) { SettingsRow(@@ -54,12 +50,6 @@ fun ReminderSettingsSection( } } SettingsDivider()- if (pickTime) {- TodoTimePickerDialog(initial = time, onConfirm = {- onDigestMinutes(it.hour.toLong() * MINUTES_PER_HOUR + it.minute)- pickTime = false- }, onDismiss = { pickTime = false })- } } private const val MINUTES_PER_HOUR = 60
todo/src/main/java/com/vayunmathur/todo/ui/ReminderSheet.kt
diff --git a/todo/src/main/java/com/vayunmathur/todo/ui/ReminderSheet.kt b/todo/src/main/java/com/vayunmathur/todo/ui/ReminderSheet.ktindex b106297f8d..33f32ac870 100644--- a/todo/src/main/java/com/vayunmathur/todo/ui/ReminderSheet.kt+++ b/todo/src/main/java/com/vayunmathur/todo/ui/ReminderSheet.kt@@ -1,4 +1,5 @@ package com.vayunmathur.todo.ui+// DIALOG LOCAL EXCEPTION: date/time pickers are the second step of the reminder bottom sheet; the sheet host is not a route yet, so the picked date awaiting a time has no route/result shape import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.padding@@ -21,6 +22,8 @@ import com.vayunmathur.library.ui.ModalBottomSheet import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.rememberIs24Hour import com.vayunmathur.todo.R+import com.vayunmathur.todo.ui.dialogs.TodoDatePickerDialog+import com.vayunmathur.todo.ui.dialogs.TodoTimePickerDialog import com.vayunmathur.todo.data.Todo import com.vayunmathur.todo.domain.DueDates import com.vayunmathur.todo.domain.Reminders
todo/src/main/java/com/vayunmathur/todo/ui/SettingsPage.kt
diff --git a/todo/src/main/java/com/vayunmathur/todo/ui/SettingsPage.kt b/todo/src/main/java/com/vayunmathur/todo/ui/SettingsPage.ktindex f21fe97db4..8eacccbd68 100644--- a/todo/src/main/java/com/vayunmathur/todo/ui/SettingsPage.kt+++ b/todo/src/main/java/com/vayunmathur/todo/ui/SettingsPage.kt@@ -39,6 +39,7 @@ fun SettingsPage(backStack: NavBackStack<Route>, viewModel: TodoViewModel) { digestMinutes = digestMinutes, onDigestEnabled = { on -> viewModel.updateSettings { setDigestEnabled(on) } }, onDigestMinutes = { m -> viewModel.updateSettings { setDigestMinutes(m) } },+ onOpenDigestTimePicker = { backStack.add(Route.DigestTimeDialog(digestMinutes)) }, ) SyncSettingsSection( calendarMirror = calendarMirror,@@ -47,6 +48,6 @@ fun SettingsPage(backStack: NavBackStack<Route>, viewModel: TodoViewModel) { pendingChanges = pendingSync, ) },- dataSection = { DataSettingsSection(viewModel) },+ dataSection = { DataSettingsSection(viewModel, onOpenImportConfirm = { backStack.add(Route.ImportConfirmDialog) }) }, ) }
todo/src/main/java/com/vayunmathur/todo/ui/TodoDetailPage.kt
diff --git a/todo/src/main/java/com/vayunmathur/todo/ui/TodoDetailPage.kt b/todo/src/main/java/com/vayunmathur/todo/ui/TodoDetailPage.ktindex 45be9d1b6b..847edcc218 100644--- a/todo/src/main/java/com/vayunmathur/todo/ui/TodoDetailPage.kt+++ b/todo/src/main/java/com/vayunmathur/todo/ui/TodoDetailPage.kt@@ -41,6 +41,12 @@ fun TodoDetailPage(backStack: NavBackStack<Route>, viewModel: TodoViewModel, rou editor.delete() backStack.pop() }+ override fun openDeleteConfirm() {+ backStack.add(Route.DeleteTodoDialog(route.id))+ }+ override fun openMoveToList() {+ backStack.add(Route.MoveTodoDialog(route.id))+ } } }
todo/src/main/java/com/vayunmathur/todo/ui/TodoDetailScreen.kt
diff --git a/todo/src/main/java/com/vayunmathur/todo/ui/TodoDetailScreen.kt b/todo/src/main/java/com/vayunmathur/todo/ui/TodoDetailScreen.ktindex a245e64ddc..737b951617 100644--- a/todo/src/main/java/com/vayunmathur/todo/ui/TodoDetailScreen.kt+++ b/todo/src/main/java/com/vayunmathur/todo/ui/TodoDetailScreen.kt@@ -24,7 +24,6 @@ import androidx.compose.ui.text.style.TextDecoration import androidx.compose.ui.unit.dp import com.vayunmathur.library.ui.Checkbox import com.vayunmathur.library.ui.CheckboxDefaults-import com.vayunmathur.library.ui.ConfirmDialog import com.vayunmathur.library.ui.DetailScaffold import com.vayunmathur.library.ui.DropdownMenu import com.vayunmathur.library.ui.DropdownMenuItem@@ -45,7 +44,6 @@ import com.vayunmathur.library.util.sharedContainer import com.vayunmathur.todo.R import com.vayunmathur.todo.platform.TodoActions import com.vayunmathur.todo.platform.TodoUiState-import com.vayunmathur.library.ui.R as UiR /** * The todo editor, with no dependency on the ViewModel or the back stack so it can be@@ -56,9 +54,7 @@ import com.vayunmathur.library.ui.R as UiR @Composable fun TodoDetailScreen(state: TodoUiState, actions: TodoActions) { val todo = state.todo- var showDeleteConfirm by remember { mutableStateOf(false) } var menu by remember { mutableStateOf(false) }- var pickList by remember { mutableStateOf(false) } val titleFocus = remember { FocusRequester() } LaunchedEffect(state.isNew) { if (state.isNew) titleFocus.requestFocus() } val notes = key(todo.syncId) {@@ -73,7 +69,7 @@ fun TodoDetailScreen(state: TodoUiState, actions: TodoActions) { if (notes.focused) OdfMarkdownEditorToolbar(notes) }, actions = {- IconButton(onClick = { showDeleteConfirm = true }) { IconDelete() }+ IconButton(onClick = { actions.openDeleteConfirm() }) { IconDelete() } IconButton(onClick = { menu = true }) { IconMoreVert() } DropdownMenu(expanded = menu, onDismissRequest = { menu = false }) { DropdownMenuItem(@@ -90,7 +86,7 @@ fun TodoDetailScreen(state: TodoUiState, actions: TodoActions) { leadingIcon = { IconMove() }, onClick = { menu = false- pickList = true+ actions.openMoveToList() }, ) }@@ -146,21 +142,4 @@ fun TodoDetailScreen(state: TodoUiState, actions: TodoActions) { if (!state.isNew) EditorMetaFooter(todo, Modifier.padding(vertical = 16.dp)) } - if (pickList) {- ListSectionPickerDialog(state.lists, todo.listSyncId, todo.section, onPick = { list, section ->- actions.update { it.copy(listSyncId = list, section = section) }- pickList = false- }, onDismiss = { pickList = false })- }- if (showDeleteConfirm) {- ConfirmDialog(- title = stringResource(R.string.delete_todo),- message = stringResource(R.string.delete_todo_confirm),- confirmLabel = stringResource(R.string.delete),- dismissLabel = stringResource(UiR.string.cancel),- destructive = true,- onConfirm = { actions.deleteTodo() },- onDismiss = { showDeleteConfirm = false },- )- } }
todo/src/main/java/com/vayunmathur/todo/ui/TodoListPage.kt
diff --git a/todo/src/main/java/com/vayunmathur/todo/ui/TodoListPage.kt b/todo/src/main/java/com/vayunmathur/todo/ui/TodoListPage.ktindex fa82c37d76..6ca077615d 100644--- a/todo/src/main/java/com/vayunmathur/todo/ui/TodoListPage.kt+++ b/todo/src/main/java/com/vayunmathur/todo/ui/TodoListPage.kt@@ -5,6 +5,9 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.vayunmathur.library.util.NavBackStack+import com.vayunmathur.library.util.ResultEffect+import androidx.compose.runtime.mutableIntStateOf+import androidx.compose.runtime.setValue import com.vayunmathur.todo.Route import com.vayunmathur.todo.data.Todo import com.vayunmathur.todo.data.newSyncId@@ -31,6 +34,8 @@ fun TodoListPage( val lists by viewModel.lists.collectAsStateWithLifecycle() val hasLoaded by viewModel.hasLoadedTodos.collectAsStateWithLifecycle() val quickAddRequest by viewModel.quickAddRequest.collectAsStateWithLifecycle()+ var bulkClearSignal by remember { mutableIntStateOf(0) }+ ResultEffect<Boolean>(com.vayunmathur.todo.ui.BULK_RESULT_KEY) { bulkClearSignal++ } val actions = remember(backStack, viewModel, onMenu, view) { object : TodoListActions {@@ -48,6 +53,8 @@ fun TodoListPage( override fun move(todos: List<Todo>, listSyncId: String?) = viewModel.move(todos, listSyncId) override fun reschedule(todos: List<Todo>, dueAt: Long?) = viewModel.reschedule(todos, dueAt) override fun setPriority(todos: List<Todo>, priority: Int) = viewModel.setPriority(todos, priority)+ override fun openBulkMove(ids: List<Long>) { backStack.add(Route.BulkMoveDialog(ids)) }+ override fun openBulkDate(ids: List<Long>) { backStack.add(Route.BulkDateDialog(ids)) } } } @@ -60,6 +67,7 @@ fun TodoListPage( sort = sort, showAddButton = backStack.last() !is Route.TodoDetail, now = model.second,+ bulkClearSignal = bulkClearSignal, hasLoaded = hasLoaded, ), actions = actions,
todo/src/main/java/com/vayunmathur/todo/ui/TodoListRow.kt
diff --git a/todo/src/main/java/com/vayunmathur/todo/ui/TodoListRow.kt b/todo/src/main/java/com/vayunmathur/todo/ui/TodoListRow.ktindex 1ea38bea45..650d430fe4 100644--- a/todo/src/main/java/com/vayunmathur/todo/ui/TodoListRow.kt+++ b/todo/src/main/java/com/vayunmathur/todo/ui/TodoListRow.kt@@ -1,10 +1,7 @@ package com.vayunmathur.todo.ui -import androidx.compose.foundation.layout.Box-import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.LazyItemScope import androidx.compose.runtime.Composable-import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.res.stringResource@@ -107,16 +104,15 @@ data class TodoRowDisplay( @Composable private fun DragHandle(reorder: TodoReorderState, key: Long, haptics: Haptics) {- // Demoted from IconButton: not a button — reorderDragHandle owns the- // gesture (NoDeadClick lint).- Box(- modifier = Modifier.size(48.dp).reorderDragHandle(+ // Not a button: the reorder modifier owns the drag gesture, so the grip+ // is a plain container rather than a tappable IconButton with no click.+ androidx.compose.foundation.layout.Box(+ modifier = Modifier.reorderDragHandle( reorderState = reorder.drag, key = key, onDragStarted = { haptics.longPress() }, onDragStopped = { haptics.confirm() }, ),- contentAlignment = Alignment.Center, ) { IconDragHandle() }
todo/src/main/java/com/vayunmathur/todo/ui/TodoListScreen.kt
diff --git a/todo/src/main/java/com/vayunmathur/todo/ui/TodoListScreen.kt b/todo/src/main/java/com/vayunmathur/todo/ui/TodoListScreen.ktindex e2288e1845..e7bbd37158 100644--- a/todo/src/main/java/com/vayunmathur/todo/ui/TodoListScreen.kt+++ b/todo/src/main/java/com/vayunmathur/todo/ui/TodoListScreen.kt@@ -132,6 +132,17 @@ fun TodoListScreen( actions.setPriority(selectedTodos, priority) selected = emptySet() }+ override fun openMovePicker() {+ actions.openBulkMove(selected.map { it })+ }+ override fun openDatePicker() {+ actions.openBulkDate(selected.map { it })+ }+ }+ // Bulk dialog routes act through the ViewModel and report back to the+ // binding page, which bumps this signal; the selection is then spent.+ androidx.compose.runtime.LaunchedEffect(state.bulkClearSignal) {+ if (state.bulkClearSignal > 0) selected = emptySet() } LazyListScaffold(@@ -241,3 +252,6 @@ private fun move(rows: List<TodoRow>, row: TodoRow, direction: Int): Todo? { val positions = rows.map { it.todo.position } return row.todo.withPosition(Positions.forMove(positions, i, target)) }++/** Result key bulk dialog routes dispatch after applying a move/reschedule. */+const val BULK_RESULT_KEY = "todo-bulk-applied"
todo/src/main/java/com/vayunmathur/todo/ui/TodoShell.kt
diff --git a/todo/src/main/java/com/vayunmathur/todo/ui/TodoShell.kt b/todo/src/main/java/com/vayunmathur/todo/ui/TodoShell.ktindex df58c894f3..b4e8dd4110 100644--- a/todo/src/main/java/com/vayunmathur/todo/ui/TodoShell.kt+++ b/todo/src/main/java/com/vayunmathur/todo/ui/TodoShell.kt@@ -6,14 +6,9 @@ import androidx.compose.foundation.layout.width import androidx.compose.runtime.Composable import androidx.compose.runtime.SideEffect import androidx.compose.runtime.getValue-import androidx.compose.runtime.mutableStateOf-import androidx.compose.runtime.remember-import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier-import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle-import com.vayunmathur.library.ui.ConfirmDialog import com.vayunmathur.library.ui.ModalDrawerSheet import com.vayunmathur.library.ui.ModalNavigationDrawer import com.vayunmathur.library.ui.Surface@@ -24,7 +19,6 @@ import com.vayunmathur.todo.Route import com.vayunmathur.todo.data.TodoList import com.vayunmathur.todo.domain.TodoView import com.vayunmathur.todo.platform.TodoViewModel-import com.vayunmathur.library.ui.R as UiR /** * Wraps the nav graph with the views panel. At 840dp and wider the panel is permanent, which@@ -45,9 +39,6 @@ fun TodoShell( val lists by viewModel.lists.collectAsStateWithLifecycle() val tags by viewModel.tags.collectAsStateWithLifecycle() val lastSync by viewModel.settings.lastSyncAt.collectAsStateWithLifecycle(0L)- var editing by remember { mutableStateOf<TodoList?>(null) }- var creating by remember { mutableStateOf(false) }- var deleting by remember { mutableStateOf<TodoList?>(null) } val state = DrawerUiState(view, counts, lists, tags, syncStatus(lastSync)) val actions = object : DrawerActions {@@ -56,8 +47,8 @@ fun TodoShell( backStack.reset(Route.TodoList(view.key)) shell.closeDrawer() }- override fun newList() { creating = true }- override fun editList(list: TodoList) { editing = list }+ override fun newList() { backStack.add(Route.ListEditDialog()) }+ override fun editList(list: TodoList) { backStack.add(Route.ListEditDialog(list.syncId)) } override fun openSettings() { backStack.add(Route.Settings) shell.closeDrawer()@@ -79,43 +70,6 @@ fun TodoShell( ) } - if (creating || editing != null) {- ListEditDialog(- list = editing,- onSave = { list ->- viewModel.saveList(list)- if (editing == null) {- viewModel.clearSearchQuery()- backStack.reset(Route.TodoList(TodoView.InList(list.syncId).key))- }- creating = false- editing = null- },- onDelete = { deleting = it },- onDismiss = {- creating = false- editing = null- },- )- }- deleting?.let { list ->- ConfirmDialog(- title = stringResource(R.string.delete_list_title, list.name),- message = stringResource(R.string.delete_list_message),- confirmLabel = stringResource(R.string.delete),- dismissLabel = stringResource(UiR.string.cancel),- destructive = true,- onConfirm = {- viewModel.deleteList(list)- if (view == TodoView.InList(list.syncId)) {- backStack.reset(Route.TodoList(TodoView.Inbox.key))- }- deleting = null- editing = null- },- onDismiss = { deleting = null },- )- } } private val PANEL = 280.dp
todo/src/main/java/com/vayunmathur/todo/ui/dialogs/DeleteListDialog.kt
diff --git a/todo/src/main/java/com/vayunmathur/todo/ui/dialogs/DeleteListDialog.kt b/todo/src/main/java/com/vayunmathur/todo/ui/dialogs/DeleteListDialog.ktnew file mode 100644index 0000000000..fb0ef41c7e--- /dev/null+++ b/todo/src/main/java/com/vayunmathur/todo/ui/dialogs/DeleteListDialog.kt@@ -0,0 +1,21 @@+package com.vayunmathur.todo.ui.dialogs++import androidx.compose.runtime.Composable+import androidx.compose.ui.res.stringResource+import com.vayunmathur.library.ui.ConfirmDialog+import com.vayunmathur.todo.R+import com.vayunmathur.library.ui.R as UiR++/** Delete confirmation for `Route.DeleteListDialog`, stateless for previews/tests. */+@Composable+fun DeleteListDialog(listName: String, onConfirm: () -> Unit, onDismiss: () -> Unit) {+ ConfirmDialog(+ title = stringResource(R.string.delete_list_title, listName),+ message = stringResource(R.string.delete_list_message),+ confirmLabel = stringResource(R.string.delete),+ dismissLabel = stringResource(UiR.string.cancel),+ destructive = true,+ onConfirm = onConfirm,+ onDismiss = onDismiss,+ )+}
todo/src/main/java/com/vayunmathur/todo/ui/dialogs/DeleteTodoDialog.kt
diff --git a/todo/src/main/java/com/vayunmathur/todo/ui/dialogs/DeleteTodoDialog.kt b/todo/src/main/java/com/vayunmathur/todo/ui/dialogs/DeleteTodoDialog.ktnew file mode 100644index 0000000000..375289385e--- /dev/null+++ b/todo/src/main/java/com/vayunmathur/todo/ui/dialogs/DeleteTodoDialog.kt@@ -0,0 +1,21 @@+package com.vayunmathur.todo.ui.dialogs++import androidx.compose.runtime.Composable+import androidx.compose.ui.res.stringResource+import com.vayunmathur.library.ui.ConfirmDialog+import com.vayunmathur.todo.R+import com.vayunmathur.library.ui.R as UiR++/** Delete confirmation for `Route.DeleteTodoDialog`, stateless for previews/tests. */+@Composable+fun DeleteTodoDialog(onConfirm: () -> Unit, onDismiss: () -> Unit) {+ ConfirmDialog(+ title = stringResource(R.string.delete_todo),+ message = stringResource(R.string.delete_todo_confirm),+ confirmLabel = stringResource(R.string.delete),+ dismissLabel = stringResource(UiR.string.cancel),+ destructive = true,+ onConfirm = onConfirm,+ onDismiss = onDismiss,+ )+}
todo/src/main/java/com/vayunmathur/todo/ui/dialogs/ImportConfirmDialog.kt
diff --git a/todo/src/main/java/com/vayunmathur/todo/ui/dialogs/ImportConfirmDialog.kt b/todo/src/main/java/com/vayunmathur/todo/ui/dialogs/ImportConfirmDialog.ktnew file mode 100644index 0000000000..bbe4f534bc--- /dev/null+++ b/todo/src/main/java/com/vayunmathur/todo/ui/dialogs/ImportConfirmDialog.kt@@ -0,0 +1,32 @@+package com.vayunmathur.todo.ui.dialogs++import androidx.compose.runtime.Composable+import androidx.compose.ui.res.pluralStringResource+import androidx.compose.ui.res.stringResource+import com.vayunmathur.library.ui.AlertDialog+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.TextButton+import com.vayunmathur.todo.R+import com.vayunmathur.todo.domain.format.ImportedTask+import com.vayunmathur.library.ui.R as UiR++/** Import preview for `Route.ImportConfirmDialog`; the parsed tasks live in the ViewModel. */+@Composable+fun ImportConfirmDialog(tasks: List<ImportedTask>, onConfirm: () -> Unit, onDismiss: () -> Unit) {+ AlertDialog(+ onDismissRequest = onDismiss,+ title = { Text(pluralStringResource(R.plurals.import_confirm, tasks.size, tasks.size)) },+ text = {+ Text(+ tasks.take(PREVIEW).joinToString("\n") { "• " + it.title } ++ if (tasks.size > PREVIEW) "\n…" else "",+ )+ },+ confirmButton = {+ TextButton(onClick = onConfirm) { Text(stringResource(R.string.import_action)) }+ },+ dismissButton = { TextButton(onClick = onDismiss) { Text(stringResource(UiR.string.cancel)) } },+ )+}++private const val PREVIEW = 8
todo/src/main/java/com/vayunmathur/todo/ui/dialogs/ListEditDialog.kt
diff --git a/todo/src/main/java/com/vayunmathur/todo/ui/ListEditDialog.kt b/todo/src/main/java/com/vayunmathur/todo/ui/dialogs/ListEditDialog.ktsimilarity index 97%rename from todo/src/main/java/com/vayunmathur/todo/ui/ListEditDialog.ktrename to todo/src/main/java/com/vayunmathur/todo/ui/dialogs/ListEditDialog.ktindex 8d6139f549..4fef7281fd 100644--- a/todo/src/main/java/com/vayunmathur/todo/ui/ListEditDialog.kt+++ b/todo/src/main/java/com/vayunmathur/todo/ui/dialogs/ListEditDialog.kt@@ -1,4 +1,4 @@-package com.vayunmathur.todo.ui+package com.vayunmathur.todo.ui.dialogs import androidx.compose.foundation.background import androidx.compose.foundation.border@@ -34,6 +34,8 @@ import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.TextButton import com.vayunmathur.todo.R import com.vayunmathur.todo.data.TodoList+import com.vayunmathur.todo.ui.LIST_ICON_KEYS+import com.vayunmathur.todo.ui.ListIcon import com.vayunmathur.library.ui.R as UiR /** Create or edit a list: name, colour, icon and sections. Deleting moves its tasks to the Inbox. */
todo/src/main/java/com/vayunmathur/todo/ui/dialogs/ListPickerDialog.kt
diff --git a/todo/src/main/java/com/vayunmathur/todo/ui/ListPickerDialog.kt b/todo/src/main/java/com/vayunmathur/todo/ui/dialogs/ListPickerDialog.ktsimilarity index 98%rename from todo/src/main/java/com/vayunmathur/todo/ui/ListPickerDialog.ktrename to todo/src/main/java/com/vayunmathur/todo/ui/dialogs/ListPickerDialog.ktindex 4c3ff872ab..9b7ded98a8 100644--- a/todo/src/main/java/com/vayunmathur/todo/ui/ListPickerDialog.kt+++ b/todo/src/main/java/com/vayunmathur/todo/ui/dialogs/ListPickerDialog.kt@@ -1,4 +1,4 @@-package com.vayunmathur.todo.ui+package com.vayunmathur.todo.ui.dialogs import androidx.compose.foundation.background import androidx.compose.foundation.clickable
todo/src/main/java/com/vayunmathur/todo/ui/dialogs/ListSectionPickerDialog.kt
diff --git a/todo/src/main/java/com/vayunmathur/todo/ui/ListSectionPickerDialog.kt b/todo/src/main/java/com/vayunmathur/todo/ui/dialogs/ListSectionPickerDialog.ktsimilarity index 98%rename from todo/src/main/java/com/vayunmathur/todo/ui/ListSectionPickerDialog.ktrename to todo/src/main/java/com/vayunmathur/todo/ui/dialogs/ListSectionPickerDialog.ktindex f182b581b0..7df56793d4 100644--- a/todo/src/main/java/com/vayunmathur/todo/ui/ListSectionPickerDialog.kt+++ b/todo/src/main/java/com/vayunmathur/todo/ui/dialogs/ListSectionPickerDialog.kt@@ -1,4 +1,4 @@-package com.vayunmathur.todo.ui+package com.vayunmathur.todo.ui.dialogs import androidx.compose.foundation.background import androidx.compose.foundation.clickable
todo/src/main/java/com/vayunmathur/todo/ui/dialogs/TodoDatePickerDialog.kt
diff --git a/todo/src/main/java/com/vayunmathur/todo/ui/TodoDatePickerDialog.kt b/todo/src/main/java/com/vayunmathur/todo/ui/dialogs/TodoDatePickerDialog.ktsimilarity index 97%rename from todo/src/main/java/com/vayunmathur/todo/ui/TodoDatePickerDialog.ktrename to todo/src/main/java/com/vayunmathur/todo/ui/dialogs/TodoDatePickerDialog.ktindex 1968408650..7cf6f367e9 100644--- a/todo/src/main/java/com/vayunmathur/todo/ui/TodoDatePickerDialog.kt+++ b/todo/src/main/java/com/vayunmathur/todo/ui/dialogs/TodoDatePickerDialog.kt@@ -1,4 +1,4 @@-package com.vayunmathur.todo.ui+package com.vayunmathur.todo.ui.dialogs import androidx.compose.runtime.Composable import androidx.compose.ui.res.stringResource
todo/src/main/java/com/vayunmathur/todo/ui/dialogs/TodoTimePickerDialog.kt
diff --git a/todo/src/main/java/com/vayunmathur/todo/ui/TodoTimePickerDialog.kt b/todo/src/main/java/com/vayunmathur/todo/ui/dialogs/TodoTimePickerDialog.ktsimilarity index 96%rename from todo/src/main/java/com/vayunmathur/todo/ui/TodoTimePickerDialog.ktrename to todo/src/main/java/com/vayunmathur/todo/ui/dialogs/TodoTimePickerDialog.ktindex 104c492b7c..ff6ed7104d 100644--- a/todo/src/main/java/com/vayunmathur/todo/ui/TodoTimePickerDialog.kt+++ b/todo/src/main/java/com/vayunmathur/todo/ui/dialogs/TodoTimePickerDialog.kt@@ -1,4 +1,4 @@-package com.vayunmathur.todo.ui+package com.vayunmathur.todo.ui.dialogs import androidx.compose.runtime.Composable import androidx.compose.ui.res.stringResource
todo/src/screenshotTest/kotlin/com/vayunmathur/todo/ui/MetadataPreviews.kt
diff --git a/todo/src/screenshotTest/kotlin/com/vayunmathur/todo/ui/MetadataPreviews.kt b/todo/src/screenshotTest/kotlin/com/vayunmathur/todo/ui/MetadataPreviews.ktindex a5a9fd365e..802316abaa 100644--- a/todo/src/screenshotTest/kotlin/com/vayunmathur/todo/ui/MetadataPreviews.kt+++ b/todo/src/screenshotTest/kotlin/com/vayunmathur/todo/ui/MetadataPreviews.kt@@ -20,6 +20,19 @@ import com.vayunmathur.todo.platform.TodoActions import com.vayunmathur.todo.platform.TodoListActions import com.vayunmathur.todo.platform.TodoListUiState import com.vayunmathur.todo.platform.TodoUiState+import androidx.compose.runtime.CompositionLocalProvider+import androidx.compose.runtime.remember+import com.vayunmathur.library.util.LocalNavResultRegistry+import com.vayunmathur.library.util.NavResultRegistry+import com.vayunmathur.todo.domain.format.ImportedTask+import com.vayunmathur.todo.ui.dialogs.DeleteListDialog+import com.vayunmathur.todo.ui.dialogs.DeleteTodoDialog+import com.vayunmathur.todo.ui.dialogs.ImportConfirmDialog+import com.vayunmathur.todo.ui.dialogs.ListEditDialog+import com.vayunmathur.todo.ui.dialogs.ListPickerDialog+import com.vayunmathur.todo.ui.dialogs.ListSectionPickerDialog+import com.vayunmathur.todo.ui.dialogs.TodoDatePickerDialog+import com.vayunmathur.todo.ui.dialogs.TodoTimePickerDialog import kotlinx.datetime.DateTimeUnit import kotlinx.datetime.LocalDate import kotlinx.datetime.plus@@ -53,9 +66,15 @@ private fun at(offset: Int, h: Int, m: Int = 0) = DueDates.at(TODAY.plus(offset, * makes the images reproducible from a clean checkout. * * Coverage: every `Route` destination is shown — `TodoList` (Today/All/search),- * `TodoDetail` (editor) and `Settings` on phone, plus the main list on large-tablet.+ * `TodoDetail` (editor), `Settings` and the dialog routes on phone, plus the main list on large-tablet. */ class MetadataPreviews {+ /** TodoListScreen collects bulk-dialog results, so previews provide a registry. */+ @Composable+ private fun WithRegistry(content: @Composable () -> Unit) {+ CompositionLocalProvider(LocalNavResultRegistry provides remember { NavResultRegistry() }) { content() }+ }+ private val work = TodoList(id = 1, syncId = "work", name = "Work", color = 0xFF1E88E5.toInt(), icon = "work") private val home = TodoList(id = 2, syncId = "home", name = "Home", color = 0xFF43A047.toInt(), icon = "home") private val lists = listOf(work, home)@@ -107,16 +126,16 @@ class MetadataPreviews { ) @PreviewTest- @Preview(name = "1-today", device = PHONE, group = "phone", showSystemUi = true)+ @Preview(name = "1-todo-list", device = PHONE, group = "phone", showSystemUi = true) @Composable fun Preview1Today() { DynamicTheme(darkTheme = true) {- TodoListScreen(state = listState(), actions = TodoListActions.Noop)+ WithRegistry { TodoListScreen(state = listState(), actions = TodoListActions.Noop) } } } @PreviewTest- @Preview(name = "2-editor", device = PHONE, group = "phone", showSystemUi = true)+ @Preview(name = "2-todo-detail", device = PHONE, group = "phone", showSystemUi = true) @Composable fun Preview2Editor() { DynamicTheme(darkTheme = true) {@@ -134,20 +153,20 @@ class MetadataPreviews { } @PreviewTest- @Preview(name = "4-list", device = PHONE, group = "phone", showSystemUi = true)+ @Preview(name = "4-todo-list-all", device = PHONE, group = "phone", showSystemUi = true) @Composable fun Preview4List() { DynamicTheme(darkTheme = true) {- TodoListScreen(state = listState(TodoView.All, query = ""), actions = TodoListActions.Noop)+ WithRegistry { TodoListScreen(state = listState(TodoView.All, query = ""), actions = TodoListActions.Noop) } } } @PreviewTest- @Preview(name = "5-search", device = PHONE, group = "phone", showSystemUi = true)+ @Preview(name = "5-todo-list-search", device = PHONE, group = "phone", showSystemUi = true) @Composable fun Preview5Search() { DynamicTheme(darkTheme = true) {- TodoListScreen(state = listState(query = "the"), actions = TodoListActions.Noop)+ WithRegistry { TodoListScreen(state = listState(query = "the"), actions = TodoListActions.Noop) } } } @@ -168,6 +187,7 @@ class MetadataPreviews { @Composable fun Preview6Tablet() { DynamicTheme(darkTheme = true) {+ WithRegistry { Row { Surface(Modifier.width(280.dp).fillMaxHeight()) { ViewDrawerContent(drawerState, object : DrawerActions {}) } Surface(Modifier.width(500.dp).fillMaxHeight()) {@@ -175,6 +195,7 @@ class MetadataPreviews { } Surface(Modifier.fillMaxHeight()) { TodoDetailScreen(state = editorState, actions = TodoActions.Noop) } }+ } } } @@ -183,7 +204,83 @@ class MetadataPreviews { @Composable fun Preview8LargeTablet() { DynamicTheme(darkTheme = true) {- TodoListScreen(state = listState(), actions = TodoListActions.Noop)+ WithRegistry { TodoListScreen(state = listState(), actions = TodoListActions.Noop) }+ }+ }++ @PreviewTest+ @Preview(name = "9-list-edit-dialog", device = PHONE, group = "phone")+ @Composable+ fun Preview9ListEditDialog() {+ DynamicTheme(darkTheme = true) {+ ListEditDialog(list = work, onSave = {}, onDelete = {}, onDismiss = {})+ }+ }++ @PreviewTest+ @Preview(name = "10-delete-list-dialog", device = PHONE, group = "phone")+ @Composable+ fun Preview10DeleteListDialog() {+ DynamicTheme(darkTheme = true) {+ DeleteListDialog(listName = "Work", onConfirm = {}, onDismiss = {})+ }+ }++ @PreviewTest+ @Preview(name = "11-delete-todo-dialog", device = PHONE, group = "phone")+ @Composable+ fun Preview11DeleteTodoDialog() {+ DynamicTheme(darkTheme = true) {+ DeleteTodoDialog(onConfirm = {}, onDismiss = {})+ }+ }++ @PreviewTest+ @Preview(name = "12-move-todo-dialog", device = PHONE, group = "phone")+ @Composable+ fun Preview12MoveTodoDialog() {+ DynamicTheme(darkTheme = true) {+ ListSectionPickerDialog(lists = lists, currentList = "work", currentSection = null, onPick = { _, _ -> }, onDismiss = {})+ }+ }++ @PreviewTest+ @Preview(name = "13-bulk-move-dialog", device = PHONE, group = "phone")+ @Composable+ fun Preview13BulkMoveDialog() {+ DynamicTheme(darkTheme = true) {+ ListPickerDialog(lists = lists, current = "", onPick = {}, onDismiss = {})+ }+ }++ @PreviewTest+ @Preview(name = "14-bulk-date-dialog", device = PHONE, group = "phone")+ @Composable+ fun Preview14BulkDateDialog() {+ DynamicTheme(darkTheme = true) {+ TodoDatePickerDialog(initial = NOW, onConfirm = {}, onDismiss = {})+ }+ }++ @PreviewTest+ @Preview(name = "15-import-confirm-dialog", device = PHONE, group = "phone")+ @Composable+ fun Preview15ImportConfirmDialog() {+ DynamicTheme(darkTheme = true) {+ ImportConfirmDialog(+ tasks = listOf(ImportedTask(title = "Renew passport"), ImportedTask(title = "Book dentist")),+ onConfirm = {},+ onDismiss = {},+ )+ }+ }++ @PreviewTest+ @Preview(name = "16-digest-time-dialog", device = PHONE, group = "phone")+ @Composable+ fun Preview16DigestTimeDialog() {+ DynamicTheme(darkTheme = true) {+ TodoTimePickerDialog(initial = LocalTime(8, 0), onConfirm = {}, onDismiss = {}) } } }
todo/src/test/java/com/vayunmathur/todo/data/TodoHybridStampTest.kt
diff --git a/todo/src/test/java/com/vayunmathur/todo/data/TodoHybridStampTest.kt b/todo/src/test/java/com/vayunmathur/todo/data/TodoHybridStampTest.ktindex 2abe069f8d..6bcb20687c 100644--- a/todo/src/test/java/com/vayunmathur/todo/data/TodoHybridStampTest.kt+++ b/todo/src/test/java/com/vayunmathur/todo/data/TodoHybridStampTest.kt@@ -1,4 +1,5 @@ package com.vayunmathur.todo.data+// FIXTURE RELATIVE-TIME EXCEPTION: hybrid-stamp fixtures seed a future stamp relative to the stamp code under test, which compares it against the real wall clock // FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch.
todo/src/test/java/com/vayunmathur/todo/data/TodoRepositoryTest.kt
diff --git a/todo/src/test/java/com/vayunmathur/todo/data/TodoRepositoryTest.kt b/todo/src/test/java/com/vayunmathur/todo/data/TodoRepositoryTest.ktindex 69a6b5d71b..bb629264c9 100644--- a/todo/src/test/java/com/vayunmathur/todo/data/TodoRepositoryTest.kt+++ b/todo/src/test/java/com/vayunmathur/todo/data/TodoRepositoryTest.kt@@ -1,4 +1,5 @@ package com.vayunmathur.todo.data+// FIXTURE RELATIVE-TIME EXCEPTION: repository fixtures seed past/current timestamps relative to the repository under test, which queries and stamps against the real wall clock // FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch.
todo/src/test/java/com/vayunmathur/todo/intents/AssistantIntentsTest.kt
diff --git a/todo/src/test/java/com/vayunmathur/todo/intents/AssistantIntentsTest.kt b/todo/src/test/java/com/vayunmathur/todo/intents/AssistantIntentsTest.ktindex efffe563aa..5755d7bea6 100644--- a/todo/src/test/java/com/vayunmathur/todo/intents/AssistantIntentsTest.kt+++ b/todo/src/test/java/com/vayunmathur/todo/intents/AssistantIntentsTest.kt@@ -1,4 +1,5 @@ package com.vayunmathur.todo.intents+// FIXTURE RELATIVE-TIME EXCEPTION: assistant-intent fixtures seed due times relative to the intent handlers and repository under test, which read the real wall clock for today/future queries // FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch.
todo/src/test/java/com/vayunmathur/todo/notifications/NotificationsTest.kt
diff --git a/todo/src/test/java/com/vayunmathur/todo/notifications/NotificationsTest.kt b/todo/src/test/java/com/vayunmathur/todo/notifications/NotificationsTest.ktindex d5f3510237..c4405cf8c8 100644--- a/todo/src/test/java/com/vayunmathur/todo/notifications/NotificationsTest.kt+++ b/todo/src/test/java/com/vayunmathur/todo/notifications/NotificationsTest.kt@@ -1,4 +1,5 @@ package com.vayunmathur.todo.notifications+// FIXTURE RELATIVE-TIME EXCEPTION: notification fixtures seed reminder/due times relative to the schedulers under test, which read the real wall clock // FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch.
todo/src/test/java/com/vayunmathur/todo/notifications/ReceiversAndBackgroundTest.kt
diff --git a/todo/src/test/java/com/vayunmathur/todo/notifications/ReceiversAndBackgroundTest.kt b/todo/src/test/java/com/vayunmathur/todo/notifications/ReceiversAndBackgroundTest.ktindex 69595524d4..b88ba0e1dd 100644--- a/todo/src/test/java/com/vayunmathur/todo/notifications/ReceiversAndBackgroundTest.kt+++ b/todo/src/test/java/com/vayunmathur/todo/notifications/ReceiversAndBackgroundTest.kt@@ -1,4 +1,5 @@ package com.vayunmathur.todo.notifications+// FIXTURE RELATIVE-TIME EXCEPTION: receiver/background fixtures seed future reminders relative to the code under test, which reads the real wall clock // FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch.
todo/src/test/java/com/vayunmathur/todo/notifications/ReminderReceiverCalendarTest.kt
diff --git a/todo/src/test/java/com/vayunmathur/todo/notifications/ReminderReceiverCalendarTest.kt b/todo/src/test/java/com/vayunmathur/todo/notifications/ReminderReceiverCalendarTest.ktindex 0730f23eaa..d19d1c1a8e 100644--- a/todo/src/test/java/com/vayunmathur/todo/notifications/ReminderReceiverCalendarTest.kt+++ b/todo/src/test/java/com/vayunmathur/todo/notifications/ReminderReceiverCalendarTest.kt@@ -1,4 +1,5 @@ package com.vayunmathur.todo.notifications+// FIXTURE RELATIVE-TIME EXCEPTION: reminder-receiver fixtures seed due-today/future tasks relative to the receiver under test, which reads the real wall clock // FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch.
todo/src/test/java/com/vayunmathur/todo/platform/TodoEditorTest.kt
diff --git a/todo/src/test/java/com/vayunmathur/todo/platform/TodoEditorTest.kt b/todo/src/test/java/com/vayunmathur/todo/platform/TodoEditorTest.ktindex dd72bfc273..b1b29c1f7b 100644--- a/todo/src/test/java/com/vayunmathur/todo/platform/TodoEditorTest.kt+++ b/todo/src/test/java/com/vayunmathur/todo/platform/TodoEditorTest.kt@@ -1,4 +1,5 @@ package com.vayunmathur.todo.platform+// FIXTURE RELATIVE-TIME EXCEPTION: editor fixtures seed a past due date relative to the editor under test, which stamps and rolls tasks against the real wall clock // FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch.
todo/src/test/java/com/vayunmathur/todo/sync/CalendarMirrorProviderTest.kt
diff --git a/todo/src/test/java/com/vayunmathur/todo/sync/CalendarMirrorProviderTest.kt b/todo/src/test/java/com/vayunmathur/todo/sync/CalendarMirrorProviderTest.ktindex 029e818a29..5da5003cd5 100644--- a/todo/src/test/java/com/vayunmathur/todo/sync/CalendarMirrorProviderTest.kt+++ b/todo/src/test/java/com/vayunmathur/todo/sync/CalendarMirrorProviderTest.kt@@ -1,4 +1,5 @@ package com.vayunmathur.todo.sync+// FIXTURE RELATIVE-TIME EXCEPTION: calendar-mirror fixtures seed timed events relative to the provider under test, which compares them against the real wall clock // FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch.
todo/src/test/java/com/vayunmathur/todo/ui/TodoComposeDialogsTest.kt
diff --git a/todo/src/test/java/com/vayunmathur/todo/ui/TodoComposeDialogsTest.kt b/todo/src/test/java/com/vayunmathur/todo/ui/TodoComposeDialogsTest.ktindex 91528d1034..64c10db195 100644--- a/todo/src/test/java/com/vayunmathur/todo/ui/TodoComposeDialogsTest.kt+++ b/todo/src/test/java/com/vayunmathur/todo/ui/TodoComposeDialogsTest.kt@@ -10,6 +10,11 @@ import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performTextInput import androidx.compose.ui.test.performTextReplacement import com.vayunmathur.library.ui.DynamicTheme+import com.vayunmathur.todo.ui.dialogs.ListEditDialog+import com.vayunmathur.todo.ui.dialogs.ListPickerDialog+import com.vayunmathur.todo.ui.dialogs.ListSectionPickerDialog+import com.vayunmathur.todo.ui.dialogs.TodoDatePickerDialog+import com.vayunmathur.todo.ui.dialogs.TodoTimePickerDialog import com.vayunmathur.todo.data.Todo import com.vayunmathur.todo.data.TodoList import com.vayunmathur.todo.domain.DueDates
todo/src/test/java/com/vayunmathur/todo/ui/TodoComposeInteractionsTest.kt
diff --git a/todo/src/test/java/com/vayunmathur/todo/ui/TodoComposeInteractionsTest.kt b/todo/src/test/java/com/vayunmathur/todo/ui/TodoComposeInteractionsTest.ktindex ed59b9f8c0..f6c883969b 100644--- a/todo/src/test/java/com/vayunmathur/todo/ui/TodoComposeInteractionsTest.kt+++ b/todo/src/test/java/com/vayunmathur/todo/ui/TodoComposeInteractionsTest.kt@@ -15,6 +15,11 @@ import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performTextInput import androidx.compose.ui.test.performTouchInput import com.vayunmathur.library.ui.DynamicTheme+import com.vayunmathur.todo.ui.dialogs.ListEditDialog+import com.vayunmathur.todo.ui.dialogs.ListPickerDialog+import com.vayunmathur.todo.ui.dialogs.ListSectionPickerDialog+import com.vayunmathur.todo.ui.dialogs.TodoDatePickerDialog+import com.vayunmathur.todo.ui.dialogs.TodoTimePickerDialog import com.vayunmathur.todo.data.Todo import com.vayunmathur.todo.data.TodoList import com.vayunmathur.todo.domain.DueBucket@@ -71,26 +76,29 @@ class TodoComposeInteractionsTest { rule.onNodeWithContentDescription("Close").performClick(); assertTrue(cleared) } @Test fun bulkBarMoveToListPicker() {- var moved: String? = "unset"+ var opened = false val actions = object : BulkActions { override fun clear() {}; override fun selectAll() {}; override fun complete() {}; override fun delete() {}- override fun move(listSyncId: String?) { moved = listSyncId }; override fun reschedule(dueAt: Long?) {}; override fun setPriority(priority: Int) {}+ override fun move(listSyncId: String?) {}; override fun reschedule(dueAt: Long?) {}; override fun setPriority(priority: Int) {}+ override fun openMovePicker() { opened = true } } rule.setContent { DynamicTheme { BulkActionBar(count = 1, lists = lists, actions = actions) } } rule.onNodeWithContentDescription("More").performClick() rule.onNodeWithText("Move to\u2026").performClick()- rule.onNodeWithText("Work").performClick()- assertEquals("work", moved)+ // The dialog itself is a route; the bar only requests it.+ assertTrue(opened) } @Test fun bulkBarPickDateOpensPicker() {+ var opened = false val actions = object : BulkActions { override fun clear() {}; override fun selectAll() {}; override fun complete() {}; override fun delete() {} override fun move(listSyncId: String?) {}; override fun reschedule(dueAt: Long?) {}; override fun setPriority(priority: Int) {}+ override fun openDatePicker() { opened = true } } rule.setContent { DynamicTheme { BulkActionBar(count = 1, lists = lists, actions = actions) } } rule.onNodeWithContentDescription("More").performClick() rule.onNodeWithText("Pick a date\u2026").performClick()- rule.onNodeWithText("OK").assertIsDisplayed()+ assertTrue(opened) } @Test fun editorSheetHostRepeat() { var updated: Todo? = null@@ -415,26 +423,22 @@ class TodoComposeDetail2Test { private val lists = listOf(work) @Test fun detailDeleteConfirmFlow() {- var deleted = false- val actions = object : TodoActions { override fun deleteTodo() { deleted = true } }+ var opened = false+ val actions = object : TodoActions { override fun openDeleteConfirm() { opened = true } } val state = TodoUiState(todo = Todo(id = 1, title = "To delete"), lists = lists, now = now) rule.setContent { DynamicTheme { TodoDetailScreen(state, actions) } } rule.onNodeWithContentDescription("Delete").performClick()- rule.onNodeWithText("Delete task?").assertIsDisplayed()- // confirm button is the second "Delete" text node- rule.onAllNodesWithText("Delete")[0].performClick()- assertTrue(deleted)+ // The confirmation itself is a dialog route; the screen only requests it.+ assertTrue(opened) } @Test fun detailMoveToListFlow() {- var updated: Todo? = null- val actions = object : TodoActions { override fun update(transform: (Todo) -> Todo) { updated = transform(Todo(id = 1, title = "t")) } }+ var opened = false+ val actions = object : TodoActions { override fun openMoveToList() { opened = true } } val state = TodoUiState(todo = Todo(id = 1, title = "Mover", listSyncId = null), lists = lists, now = now) rule.setContent { DynamicTheme { TodoDetailScreen(state, actions) } } rule.onNodeWithContentDescription("More").performClick() rule.onNodeWithText("Move to\u2026").performClick()- rule.onNodeWithText("Later").performClick()- assertEquals("work", updated?.listSyncId)- assertEquals("Later", updated?.section)+ assertTrue(opened) } @Test fun detailCheckboxAndChipsSheets() { var done: Boolean? = null@@ -555,19 +559,18 @@ class TodoComposeFinalTest { assertNotNull(updated) } @Test fun listScreenBulkMoveAndReschedule() {- var moved: String? = "unset"; var rescheduled: Long? = -5L+ var movedIds: List<Long>? = null val todos = listOf(Todo(id = 1, syncId = "a", title = "Bulk move task", position = 1.0)) val model = com.vayunmathur.todo.domain.TodoListModel(groups = listOf(TodoGroup(GroupKey.None, listOf(TodoRow(todos[0]))))) val actions = object : TodoListActions {- override fun move(t: List<Todo>, listSyncId: String?) { moved = listSyncId }- override fun reschedule(t: List<Todo>, dueAt: Long?) { rescheduled = dueAt }+ override fun openBulkMove(ids: List<Long>) { movedIds = ids } } rule.setContent { DynamicTheme { TodoListScreen(state = TodoListUiState(view = TodoView.All, model = model, lists = lists, now = now), actions = actions) } } rule.onNodeWithText("Bulk move task").performTouchInput { longClick() } rule.onNodeWithContentDescription("More").performClick() rule.onNodeWithText("Move to\u2026").performClick()- rule.onNodeWithText("Work").performClick()- assertEquals("work", moved)+ // The dialog route carries the selected ids; its entry applies the move.+ assertEquals(listOf(1L), movedIds) } @Test fun reminderRepeatingPickTime() { var result: Long? = null
todo/src/test/java/com/vayunmathur/todo/ui/TodoComposePagesTest.kt
diff --git a/todo/src/test/java/com/vayunmathur/todo/ui/TodoComposePagesTest.kt b/todo/src/test/java/com/vayunmathur/todo/ui/TodoComposePagesTest.ktindex 0b0461b8f4..9275e15d7c 100644--- a/todo/src/test/java/com/vayunmathur/todo/ui/TodoComposePagesTest.kt+++ b/todo/src/test/java/com/vayunmathur/todo/ui/TodoComposePagesTest.kt@@ -11,6 +11,9 @@ import androidx.lifecycle.SavedStateHandle import androidx.test.core.app.ApplicationProvider import com.vayunmathur.library.ui.DynamicTheme import com.vayunmathur.library.util.NavBackStack+import androidx.compose.runtime.CompositionLocalProvider+import com.vayunmathur.library.util.LocalNavResultRegistry+import com.vayunmathur.library.util.NavResultRegistry import com.vayunmathur.testsupport.FakeAndroidKeyStore import com.vayunmathur.todo.Route import com.vayunmathur.todo.data.TestTodoRepository@@ -115,7 +118,7 @@ class TodoComposePagesTest { val vm = viewModel() val route = Route.TodoList(TodoView.All.key) val stack = NavBackStack<Route>(arrayOf(route))- rule.setContent { DynamicTheme { TodoListPage(stack, vm, route, onMenu = {}) } }+ rule.setContent { CompositionLocalProvider(LocalNavResultRegistry provides NavResultRegistry()) { DynamicTheme { TodoListPage(stack, vm, route, onMenu = {}) } } } rule.onNodeWithText("Page task alpha").assertIsDisplayed() rule.onNodeWithText("Page task beta").assertIsDisplayed() }@@ -125,7 +128,7 @@ class TodoComposePagesTest { val vm = viewModel() val route = Route.TodoList(TodoView.Inbox.key) val stack = NavBackStack<Route>(arrayOf(route))- rule.setContent { DynamicTheme { TodoListPage(stack, vm, route, onMenu = null) } }+ rule.setContent { CompositionLocalProvider(LocalNavResultRegistry provides NavResultRegistry()) { DynamicTheme { TodoListPage(stack, vm, route, onMenu = null) } } } rule.runOnIdle { vm.requestQuickAdd("Sheet task") } rule.onNodeWithText("Sheet task").assertExists() }@@ -182,10 +185,12 @@ class TodoComposePagesTest { val stack = NavBackStack<Route>(arrayOf(route)) lateinit var shell: TodoShellState rule.setContent {- DynamicTheme {- shell = rememberTodoShellState()- TodoShell(shell, vm, stack) {- TodoListPage(stack, vm, route, onMenu = {})+ CompositionLocalProvider(LocalNavResultRegistry provides NavResultRegistry()) {+ DynamicTheme {+ shell = rememberTodoShellState()+ TodoShell(shell, vm, stack) {+ TodoListPage(stack, vm, route, onMenu = {})+ } } } }