Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search in Android Nearby Transit #584

Merged
merged 7 commits into from
Dec 17, 2024
Merged

Conversation

JackVCurtis
Copy link
Contributor

@JackVCurtis JackVCurtis commented Dec 12, 2024

Summary

Ticket: 🤖 | Search | Search bar in nearby transit

What is this PR for?

This adds the search bar overlay to Android and allows search by stop with navigation to stop details. UI is left for the next ticket. I've skipped testing this PR in order to unblock other work, but will be adding tests before marking the ticket complete.

iOS

  • If you added any user-facing strings on iOS, are they included in Localizable.xcstrings?
    • Add temporary machine translations, marked "Needs Review"
      android
  • All user-facing strings added to strings resource

Testing

What testing have you done?

@JackVCurtis JackVCurtis force-pushed the jvc-android-search-in-nearby branch from e3fcf9b to 1b2998d Compare December 16, 2024 16:53
@JackVCurtis JackVCurtis changed the title demonstration of weird onQueryChange hook Search in Android Nearby Transit Dec 16, 2024
@JackVCurtis JackVCurtis marked this pull request as ready for review December 16, 2024 17:15
@JackVCurtis JackVCurtis requested a review from a team as a code owner December 16, 2024 17:15
@JackVCurtis JackVCurtis force-pushed the jvc-android-search-in-nearby branch from cd1a4a1 to 6620c12 Compare December 16, 2024 18:54
Copy link
Collaborator

@KaylaBrady KaylaBrady left a comment

Choose a reason for hiding this comment

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

This is a good start! A few comments about structure / functionality.

The main piece from this PR that is blocking other work is the existence of the SearchBarOverlay view. I'm OK with merging this as-is since there is a plan to add tests, and so long as these comments are addressed.

var searchInputState by rememberSaveable { mutableStateOf("") }
val searchResults = getSearchResults(searchInputState)

fun handleSearch(stopId: String) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion(non-blocking): handleSearch seems like a misnomer here; this seems to be something along the lines of handleTapResult?

query: String,
searchResultRepository: ISearchResultRepository = koinInject()
): SearchResults? {
val viewModel = remember(query) { SearchResultsViewModel(searchResultRepository, query) }
Copy link
Collaborator

Choose a reason for hiding this comment

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

question: Why recreate the VM on each query, vs. persist the VM & update the data it uses via a launchedEffect? I found the latter approach helpful in #588, and I think it will help with a missing piece of search functionality:

When I search for a stop, tap that stop, then click the X button to go back to nearby transit, I should see the search bar with my previous query & search results like I do on iOS.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The difference in iOS behavior is unrelated, that was me manually clearing the state. I've switched to a persistent VM for consistency with your approach elsewhere, though.

if (
searchResults?.stops != null && searchResults.stops.isNotEmpty()
) {
handleSearch(searchResults.stops[0].id)
Copy link
Collaborator

Choose a reason for hiding this comment

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

question: selecting the first result by default is unexpected to me - is that an android-specific pattern?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the behavior when you hit the equivalent of the "Enter" button. What do you think we should do instead?

Copy link
Collaborator

Choose a reason for hiding this comment

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

on the iOS-side, hitting the "done" button on search does nothing (or maybe re-runs the search in the background? but the effect is the same - you still see a list of search results to choose from, rather than automatically being taken to the first result)

@JackVCurtis JackVCurtis force-pushed the jvc-android-search-in-nearby branch 2 times, most recently from 8a40dcb to f4a4147 Compare December 17, 2024 16:13
@JackVCurtis JackVCurtis force-pushed the jvc-android-search-in-nearby branch from 560d19b to 762436f Compare December 17, 2024 18:31
@JackVCurtis
Copy link
Contributor Author

Untouched iOS tests are failing due to network issues on XCode Cloud - merging anyway.

@JackVCurtis JackVCurtis merged commit 2fb7f43 into main Dec 17, 2024
5 of 7 checks passed
@JackVCurtis JackVCurtis deleted the jvc-android-search-in-nearby branch December 17, 2024 19:00
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