Tap an itinerary line item to focus the map on that step#1955
Conversation
In the trip planner, tapping a leaf line item in the directions list now recenters the map on that step's location (board/alight stop, walk-leg endpoint, intermediate stop, or turn-by-turn step), zooming to a street-level default. Expandable rows (those with a chevron) keep toggling their sub-steps and never move the map — only leaf rows send-to-map. The tap rides the existing showItinerary directive seam: DirectionRow -> onFocusPoint -> HomeViewModel.focusItineraryPointOnMap -> MapDirective.FocusItineraryPoint -> MapViewModel.focusItineraryPoint -> CameraCommand.MoveToLocation, reusing the flavor-neutral camera command (no new per-flavor code). Each step's GeoPoint is threaded from the domain legs through DirectionsGenerator/Direction into the Compose DirectionItem model. The focused point is centered within the map's content padding so it lands in the visible band, not behind the results sheet or the directions form: - The directions form card reports its bottom edge as the map's top inset (folded into focusBannerTopEdge/setFocusBannerBottomEdge). - The results sheet reports its height as an independent bottom inset; MapRenderState combines the arrivals and directions bottom insets by max (mirroring applyTopPadding), so neither writer assumes the two never coexist. - Google honors the content padding on newCameraPosition automatically; MapLibre folds renderState.padding into the CameraPosition since it ignores persistent map padding on point moves. Verified on device (DirectionRowFocusTest) and clean on both flavors under -PwarningsAsErrors. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe change adds geographic focus points to direction steps, focuses the map when coordinate-bearing itinerary rows are tapped, preserves expansion behavior for parent rows, and measures directions overlays so camera positioning uses combined map padding. ChangesItinerary map focus
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant DirectionRow
participant HomeViewModel
participant MapFeature
participant MapViewModel
participant MapCamera
DirectionRow->>HomeViewModel: emit focused GeoPoint
HomeViewModel->>MapFeature: dispatch FocusItineraryPoint
MapFeature->>MapViewModel: focusItineraryPoint(point)
MapViewModel->>MapCamera: issue MoveToLocation
MapCamera->>MapCamera: apply overlay-aware content padding
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@onebusaway-android/src/main/java/org/onebusaway/android/ui/tripresults/TripResultsScreen.kt`:
- Around line 340-341: Update the expanded state declaration in DirectionRow to
key remember with item, ensuring expanded state resets when the row’s underlying
DirectionItem changes while preserving state for the same item.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b3fda9fe-8f84-48a5-80d8-a40d8ea30334
📒 Files selected for processing (18)
onebusaway-android/src/androidTest/java/org/onebusaway/android/ui/tripresults/DirectionRowFocusTest.ktonebusaway-android/src/google/java/org/onebusaway/android/map/googlemapsv2/compose/GoogleCameraCommands.ktonebusaway-android/src/main/java/org/onebusaway/android/directions/model/Direction.ktonebusaway-android/src/main/java/org/onebusaway/android/directions/util/DirectionsGenerator.ktonebusaway-android/src/main/java/org/onebusaway/android/map/MapHost.ktonebusaway-android/src/main/java/org/onebusaway/android/map/MapViewModel.ktonebusaway-android/src/main/java/org/onebusaway/android/map/render/CameraCommand.ktonebusaway-android/src/main/java/org/onebusaway/android/map/render/MapRenderState.ktonebusaway-android/src/main/java/org/onebusaway/android/ui/home/HomeScreen.ktonebusaway-android/src/main/java/org/onebusaway/android/ui/home/HomeSheetLogic.ktonebusaway-android/src/main/java/org/onebusaway/android/ui/home/HomeViewModel.ktonebusaway-android/src/main/java/org/onebusaway/android/ui/home/directions/DirectionsFeature.ktonebusaway-android/src/main/java/org/onebusaway/android/ui/home/map/MapFeature.ktonebusaway-android/src/main/java/org/onebusaway/android/ui/tripresults/TripResultsRepository.ktonebusaway-android/src/main/java/org/onebusaway/android/ui/tripresults/TripResultsScreen.ktonebusaway-android/src/main/java/org/onebusaway/android/ui/tripresults/TripResultsUiState.ktonebusaway-android/src/maplibre/java/org/onebusaway/android/map/maplibre/compose/MapLibreCameraCommands.ktonebusaway-android/src/maplibre/java/org/onebusaway/android/map/maplibre/compose/MapLibreComposeAdapter.kt
DirectionRows are keyed by index in the LazyColumn, so switching itineraries reuses a slot for a different DirectionItem. A parameterless remember let a stale expanded state leak into the new itinerary's row; key it on the item so it resets on the swap. (PR #1955 review)
What
Adds reactivity to the trip planner's directions list: tapping a leaf line item recenters the map on that step's location and zooms to a street-level default. Expandable rows (with a chevron) keep toggling their sub-steps and never move the map — only leaves send-to-map (in practice the walk-leg / board rows expand; their turn-by-turn steps and intermediate stops focus).
How
TripLeg/TripPlace/TripStep) viaDirectionsGenerator/Directioninto a singleDirectionItem.focusPoint: GeoPoint?(leg endpoint for board/alight/walk rows; each intermediate stop / turn-by-turn step for sub-items).onFocusPointcallback rides the same path as the existing itinerary selection:DirectionRow→TripResultsSheet/DirectionsResultsSheet→HomeViewModel.focusItineraryPointOnMap→MapDirective.FocusItineraryPoint(GeoPoint)→MapViewModel.focusItineraryPoint→CameraCommand.MoveToLocation. Reuses the flavor-neutral camera command, so no per-flavor code.focusBannerTopEdge/setFocusBannerBottomEdge).MapRenderStatecombines the arrivals and directions bottom insets bymax(mirroringapplyTopPadding), so neither writer has to assume the two never coexist.newCameraPositionautomatically; MapLibre foldsrenderState.paddinginto theCameraPosition(it ignores persistent map padding on point moves).Testing
DirectionRowFocusTest(drives rows by node text, not coordinates): a leaf row focuses its point; an expandable row only expands (asserts no focus) and its revealed leaf sub-step focuses its own point; a point-less row is inert. 3/3 passing on a physical Pixel 7 Pro.obaGoogleandobaMaplibrecompile clean under-PwarningsAsErrors=true; JVM unit suite green.Follow-up
While wiring the padding centering, noticed a pre-existing, separate issue: the route zoom-to that fires on a route request returning doesn't respect map padding (it races the route-header inset). Filed as #1954.
🤖 Generated with Claude Code
Summary by CodeRabbit