feat: Double tap on Search pulls up the keyboard and fix for gesture back navbar highlight#1598
feat: Double tap on Search pulls up the keyboard and fix for gesture back navbar highlight#1598puksh wants to merge 4 commits intomaxrave-dev:devfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a double-tap gesture on the Search button to bring up the keyboard and fixes an issue where the navbar highlight didn't update correctly when navigating back from Library/Search screens.
Key Changes:
- Implemented double-tap detection on Search navigation items to trigger keyboard focus
- Added LaunchedEffect to update navbar highlight based on current destination
- Introduced a search focus trigger mechanism via SharedViewModel state flow
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| SharedViewModel.kt | Added searchFocusTrigger state flow and triggerSearchFocus() function to coordinate keyboard focus requests |
| SearchScreen.kt | Added LaunchedEffect to observe searchFocusTrigger and request focus when triggered |
| AppBottomNavigationBar.kt | Implemented double-tap detection, added LaunchedEffect to sync selectedIndex with navigation state, and added viewModel parameter |
| App.kt | Passed viewModel to navigation components to enable search focus triggering |
| LiquidGlassAppBottomNavigationBar.android.kt | Replaced FloatingActionButton with Box using combinedClickable for double-tap support and added LaunchedEffect for highlight sync |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| selected = selectedIndex == screen.ordinal, | ||
| onClick = { | ||
| if (selectedIndex == screen.ordinal) { | ||
| val currentTime = System.currentTimeMillis() |
There was a problem hiding this comment.
Using System.currentTimeMillis() for double-click detection can be unreliable if the system clock changes. Consider using a monotonic time source that is guaranteed to always move forward, such as a platform-specific monotonic clock or Compose's withFrameNanos if available in common code.
| selected = selectedIndex == index, | ||
| onClick = { | ||
| if (selectedIndex == screen.ordinal) { | ||
| val currentTime = System.currentTimeMillis() |
There was a problem hiding this comment.
Using System.currentTimeMillis() for double-click detection can be unreliable if the system clock changes. Consider using a monotonic time source that is guaranteed to always move forward, such as a platform-specific monotonic clock or Compose's withFrameNanos if available in common code.
...dMain/kotlin/com/maxrave/simpmusic/ui/component/LiquidGlassAppBottomNavigationBar.android.kt
Outdated
Show resolved
Hide resolved
| import androidx.compose.foundation.ExperimentalFoundationApi | ||
| import androidx.compose.foundation.Image | ||
| import androidx.compose.foundation.background | ||
| import androidx.compose.foundation.combinedClickable |
There was a problem hiding this comment.
The ExperimentalFoundationApi annotation and combinedClickable import are added but never used in this file. The double-click detection is implemented manually instead. Either remove these unused imports or consider using combinedClickable for more reliable double-click handling.
Summary
Added a quick gesture for keyboard pull up - double tap on the Search button. It is commonly found in nearly every other app. Also fixed a small bug with the button highlight when gesturing Back. Fixes #1250
Changes
Double tap on Search brings up the keyboard
Previously: Double tapping on the Search button on Navbar didn't do anything
After: Double tap brings up the keyboard
Fixed Navbar icon highlight not correcting itself when triggering a Back gesture/button tap
Previously: Going back from Library/Search still ahs Library/Search highlighted
After: Going back from Library/Search highlights the Home button
Testing