Skip to content

feat(android): add search to task list screen#312

Merged
dkhalife merged 3 commits into
mainfrom
android/task-list-search
May 4, 2026
Merged

feat(android): add search to task list screen#312
dkhalife merged 3 commits into
mainfrom
android/task-list-search

Conversation

@dkhalife
Copy link
Copy Markdown
Owner

@dkhalife dkhalife commented May 4, 2026

Summary

Adds search functionality to the Android task list screen.

Behavior

  • Search icon (🔍) in the top-right of the app bar; tapping it animates the bar into a search field that takes focus automatically
  • Full-width text field replaces the collapsing title bar during search; an ✕ icon replaces the search icon and cancels search + clears the query
  • Substring match (case-insensitive) on task title; groups with no matching tasks are hidden automatically
  • Navigation persistence: search state lives in the ViewModel so navigating to task details and pressing back restores the filtered view
  • Cold-start reset: state is not persisted to disk — reopening the app shows no active search

Cursor-jump bug prevention

Previous patterns drove TextField from a ViewModel String, which recreated TextFieldValue without cursor info on every keystroke. This implementation keeps TextFieldValue (including cursor/selection) as local remember(isSearchActive) state. Only .text is pushed to the ViewModel. A LaunchedEffect(searchQuery) re-syncs the local value only when textFieldValue.text != searchQuery (navigation restoration), never during normal typing.

Files changed

File Change
TaskListViewModel.kt Add _searchQuery / _isSearchActive StateFlows + setters; inject into combine for reactive filtering
TaskListScreen.kt Search UI: animated top bar swap, BasicTextField, focus management, search-aware empty state
AppNavigation.kt Collect and wire search state/handlers to TaskListScreen
strings.xml Add search hint, no-results strings, icon content descriptions

- Search icon in top bar expands to a full-width text field; X icon
  collapses it and clears the query
- Substring match (case-insensitive) on task title; empty groups are
  hidden automatically
- Search state stored in TaskListViewModel (survives back-navigation
  within the session, resets on cold start)
- Cursor-jump bug prevented by keeping TextFieldValue (cursor included)
  as local remember state; only .text is pushed to the ViewModel.
  LaunchedEffect re-syncs on navigation restoration only when
  textFieldValue.text != searchQuery
- Empty state shows context-aware message when search yields no results

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 4, 2026 02:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an in-memory (non-persisted) search experience to the Android task list screen, with ViewModel-backed query/state for navigation restoration and reactive filtering of grouped tasks.

Changes:

  • Introduces searchQuery / isSearchActive StateFlows in TaskListViewModel and applies case-insensitive substring filtering before grouping.
  • Adds an animated top app bar swap on TaskListScreen to show a focused search field and a search-aware empty/no-results state.
  • Wires search state + handlers through AppNavigation and adds the required string resources.
Show a summary per file
File Description
android/app/src/main/res/values/strings.xml Adds search hint, no-results messaging, and icon content descriptions.
android/app/src/main/java/com/dkhalife/tasks/viewmodel/TaskListViewModel.kt Adds search StateFlows + setters and filters tasks in the grouping combine pipeline.
android/app/src/main/java/com/dkhalife/tasks/ui/screen/TaskListScreen.kt Implements animated search UI in the top app bar, focus management, and search-aware empty state.
android/app/src/main/java/com/dkhalife/tasks/ui/navigation/AppNavigation.kt Collects and passes search state/handlers between ViewModel and TaskListScreen.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 1

Comment thread android/app/src/main/java/com/dkhalife/tasks/ui/screen/TaskListScreen.kt Outdated
dkhalife and others added 2 commits May 3, 2026 19:50
…ssibility

Switch the search input from BasicTextField with a manual hint overlay to
TextField with a placeholder parameter. TextField exposes proper accessibility
semantics (label/hint) to TalkBack automatically, whereas BasicTextField does
not announce what the field is for to screen readers.

Use transparent container + indicator colors to preserve the existing visual
appearance inside the TopAppBar.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Ensure the search TextField remains fully transparent if ever rendered in
disabled state by adding disabledContainerColor = Color.Transparent alongside
the other container/indicator color overrides.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dkhalife dkhalife enabled auto-merge (squash) May 4, 2026 02:54
@dkhalife dkhalife merged commit 76870a1 into main May 4, 2026
6 checks passed
@dkhalife dkhalife deleted the android/task-list-search branch May 4, 2026 02:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants