-
Notifications
You must be signed in to change notification settings - Fork 1
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
refactor(StopDetailsPage): Pull data into VM #661
base: kb-android-trip-details-barebones
Are you sure you want to change the base?
Conversation
androidApp/src/main/java/com/mbta/tid/mbta_app/android/nearbyTransit/NearbyTransitView.kt
Outdated
Show resolved
Hide resolved
val _stopDepartures = MutableStateFlow<StopDetailsDepartures?>(null) | ||
val stopDepartures: StateFlow<StopDetailsDepartures?> = _stopDepartures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Departures aren't stored in the iOS view model, but I think it makes things a bit easier to work with on the android side. The departures need to get passed from NearbyTransit => StopDetails so that they aren't recalculated & temporarily null when a stop filter changes, so may as well pass it on the VM.
*/ | ||
|
||
// https://stackoverflow.com/a/78911122 | ||
fun recordCurrentNavEntry(sheetRoute: SheetRoutes?) { | ||
_currentNavEntry.value = sheetRoute | ||
|
||
_currentNavEntry.update { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL about update for atomically changing the value of state. This was more relevant for updating stopData
, but also was convenient for updating the current nav entry & previous nav entry together.
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class StopData( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in shared code in case we want to unite it with the swift representation. Schedules are a required field in the swift side, but it was easier to make it optional on the android side & let the predictions & schedules load independently with the way we are using coroutines.
Summary
Ticket: 🤖 | stop + trip details | barebones UX
What is this PR for?
This PR moves the data management of the
StopDetailsPage
out of the component and into a newStopDetailsViewModel
. This will be helpful for organization going forward and is key to resolving an issue with #653, where changing a filter within the stop details page (like tapping a route pill) caused the whole page to reload.Heavily referenced StopDetailsViewModel.swift, pulling in the minimum logic necessary to resolve this one particular issue and unblock other work. We can pull more into the view model as we go.
iOS
android
withContext(Dispatchers.Default)
where possibleTesting
What testing have you done?