Modern Apps git

← Modern-Apps.git

maps: push search as a SheetRoute on the sheet stack (#nav)

Commit
9b8a2a9d4441cecc839ab24055cbd8e676265ca2
Author
Vayun Mathur <[email protected]>
When
2026-11-16 19:20 UTC (19 days ago)
Parents
3c9b202
M3: SearchRequest/searchWasOpen (a nullable request plus a
latched hand-back flag in MapSearchHost) becomes
SheetRoute.Search(waypointIndex, nearLat, nearLon) pushed on
the sheet stack. MapSearchHost and SearchRequest are deleted;
MapPage computes the search bias at push time and runs a
non-blank query there (the arrival replay the host comment
described). Closing search is a stack pop, which hands the
sheet underneath back — the latch existed only to fake that.
The compact search-sheet hand-back effect keeps its two-sheet
choreography keyed on the Search top; selecting on the live map
pops a Search top. Wide mode reads the same Search top for its
panel, so one stack drives both hosts.

Tests for the deleted host now assert the stack transitions
(push carries waypointIndex, pop returns to Browse).

Verified: :maps:compileDevKotlin and test compilation green;
filtered MapSheetEffects/SearchActions/WideLayout/MapsCompose
tests pass.

Diff

maps/src/main/java/com/vayunmathur/maps/ui/MapContentBox.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/ui/MapContentBox.kt b/maps/src/main/java/com/vayunmathur/maps/ui/MapContentBox.ktindex d2f94b7ab5..ae48216f1f 100644--- a/maps/src/main/java/com/vayunmathur/maps/ui/MapContentBox.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/MapContentBox.kt@@ -104,7 +104,7 @@ internal fun MapPageScope.MapContentBox(                 // this box: while search is up, a drop in the bottom third lands on the sheet                 // rather than the map, and half a working drag is worse than no peg.                 // Also gated on the Google services opt-in: no opt-in, no peg, no tiles.-                if (browsing && searchRequest == null && googleServices) StreetViewPegman(camera, onOpenStreetView = { lat, lon -> backStack.add(com.vayunmathur.maps.Route.StreetView(lat, lon)) })+                if (browsing && searchRoute == null && googleServices) StreetViewPegman(camera, onOpenStreetView = { lat, lon -> backStack.add(com.vayunmathur.maps.Route.StreetView(lat, lon)) })                  // The chrome's inset, in one place. `windowInsetsPadding` *consumes* what it                 // applies, so the pieces below that inset themselves — the FAB stack, the scale@@ -266,7 +266,7 @@ internal fun MapPageScope.MapContentBox(                     // Ambient speed readout: the navigation speedometer while moving,                     // even outside navigation; see [AmbientSpeedOverlay].                     AmbientSpeedOverlay(-                        visible = browsing && searchRequest == null,+                        visible = browsing && searchRoute == null,                         speedMps = userSpeedMps,                         postedLimit = chrome.postedLimit,                         darkBasemap = darkMap,
maps/src/main/java/com/vayunmathur/maps/ui/MapPage.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/ui/MapPage.kt b/maps/src/main/java/com/vayunmathur/maps/ui/MapPage.ktindex 6bfa31f895..836e872068 100644--- a/maps/src/main/java/com/vayunmathur/maps/ui/MapPage.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/MapPage.kt@@ -80,6 +80,7 @@ import com.vayunmathur.maps.util.RouteService import com.vayunmathur.maps.util.SavedPlacesViewModel import com.vayunmathur.maps.util.SearchActions import com.vayunmathur.maps.util.SearchUiState+import com.vayunmathur.maps.util.visibleBoundsOrWorld import com.vayunmathur.maps.util.SelectedFeatureViewModel import kotlinx.coroutines.launch import com.vayunmathur.maps.R as MapsR@@ -241,8 +242,7 @@ fun MapPage(     // How much of the bottom the collapsed search bar is occupying, so the FAB stack and the     // scale bar can clear it the same way they clear a sheet. Zero whenever the bar is not drawn.     var searchBarLiftPx by remember { mutableIntStateOf(0) }-    val searchHost = rememberMapSearchHost(searchViewModel, camera, viewModel.userPosition)-    val searchRequest = searchHost.searchRequest+    val searchRoute = sheetTop as? SheetRoute.Search     val searchState = SearchUiState(         query = searchQuery,         results = searchResults,@@ -253,12 +253,16 @@ fun MapPage(     // The bar is chrome, not a sheet, so it is composed away rather than animated out. Its     // measured height therefore has to be discounted explicitly — a stale one would leave the     // FAB stack floating above a bar that is no longer there.-    val searchBarVisible = browsing && searchRequest == null+    val searchBarVisible = browsing && searchRoute == null     // Expanded widths show this content in the side panel instead of a sheet.-    val panelSearch = wide && searchRequest != null-    val panelPlace = wide && searchRequest == null &&+    val panelSearch = wide && searchRoute != null+    val panelPlace = wide && searchRoute == null &&         (selectedFeature != null || route != null || inactiveNavigation != null)-    fun openSearch(query: String? = null, waypointIndex: Int? = null) = searchHost.openSearch(query, waypointIndex)+    fun openSearch(query: String? = null, waypointIndex: Int? = null) {+        val near = com.vayunmathur.maps.util.searchBiasPoint(camera.visibleBoundsOrWorld(), userPosition)+        if (!query.isNullOrBlank()) searchViewModel.setQuery(query, near.latitude, near.longitude)+        sheetStack.add(SheetRoute.Search(waypointIndex, near.latitude, near.longitude))+    }     val settingsAction = rememberSettingsAction(backStack)     MapSheetEffects(         wide = wide,@@ -269,16 +273,17 @@ fun MapPage(         isNavigating = isNavigating,         sheetState = wideSheetState,         searchSheetState = wideSearchSheetState,-        searchHost = searchHost,+        sheetStack = sheetStack,+        searchRoute = searchRoute,     )     NavigationCameraFollow(camera, chrome, navProgress, isNavigating)      val searchActions = rememberSearchActions(-        searchRequest = searchRequest,+        searchRequest = searchRoute,         searchViewModel = searchViewModel,         viewModel = viewModel,         coroutineScope = coroutineScope,-        onCloseSearch = { searchHost.searchRequest = null },+        onCloseSearch = { sheetStack.popSheet() },     )      val scope = MapPageScope(@@ -331,7 +336,7 @@ fun MapPage(         onSearchBarLift = { searchBarLiftPx = it },         sheetState = if (wide) null else sheetState,         searchSheetState = if (wide) null else searchSheetState,-        searchRequest = searchRequest,+        searchRoute = searchRoute,         openSearch = ::openSearch,         settingsAction = settingsAction,         wide = wide,
maps/src/main/java/com/vayunmathur/maps/ui/MapPageScope.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/ui/MapPageScope.kt b/maps/src/main/java/com/vayunmathur/maps/ui/MapPageScope.ktindex 8259a291e8..07adf91157 100644--- a/maps/src/main/java/com/vayunmathur/maps/ui/MapPageScope.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/MapPageScope.kt@@ -58,21 +58,6 @@ data class PoiEnrichmentKey(     } } -/**- * An open search sheet.- *- * Search used to be a nav destination, so these three lived in the route. They are still needed —- * the bias centre because the offline index search ranks by distance to what the user can see, and- * [waypointIndex] because picking a result while editing a route replaces that leg rather than- * selecting a place — but now they are the identity of a sheet, not of a page. `null` is the- * closed state, which is why the whole thing is one nullable value rather than a flag plus three- * fields that only mean anything while the flag is set.- */-internal data class SearchRequest(-    val waypointIndex: Int?,-    val nearLat: Double,-    val nearLon: Double,-)  /**  * Everything MapContentBox closes over, bundled so the box is one function@@ -150,7 +135,7 @@ internal class MapPageScope(     val onSearchBarLift: (Int) -> Unit,     val sheetState: FreeHeightSheetState?,     val searchSheetState: FreeHeightSheetState?,-    val searchRequest: SearchRequest?,+    val searchRoute: SheetRoute.Search?,     val openSearch: (String?, Int?) -> Unit,     val settingsAction: List<OverlayAction>,     val wide: Boolean,
maps/src/main/java/com/vayunmathur/maps/ui/MapSearchActions.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/ui/MapSearchActions.kt b/maps/src/main/java/com/vayunmathur/maps/ui/MapSearchActions.ktindex 02c5b49dfd..ed01f9f817 100644--- a/maps/src/main/java/com/vayunmathur/maps/ui/MapSearchActions.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/MapSearchActions.kt@@ -12,12 +12,12 @@ import kotlinx.coroutines.launch  /**  * The search adapter: hoisted out of the sheet so the wide side panel can- * pass the same callbacks — building it needs the open request, and both- * hosts close through the same `onCloseSearch`.+ * pass the same callbacks — building it needs the open [SheetRoute.Search],+ * and both hosts close through the same `onCloseSearch`.  */ @Composable internal fun rememberSearchActions(-    searchRequest: SearchRequest?,+    searchRequest: com.vayunmathur.maps.SheetRoute.Search?,     searchViewModel: MapsSearchViewModel,     viewModel: SelectedFeatureViewModel,     coroutineScope: CoroutineScope,
maps/src/main/java/com/vayunmathur/maps/ui/MapSheetEffects.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/ui/MapSheetEffects.kt b/maps/src/main/java/com/vayunmathur/maps/ui/MapSheetEffects.ktindex 4db8e28ff4..751eea1524 100644--- a/maps/src/main/java/com/vayunmathur/maps/ui/MapSheetEffects.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/MapSheetEffects.kt@@ -20,54 +20,8 @@ import com.vayunmathur.maps.Route import com.vayunmathur.maps.data.SpecificFeature import com.vayunmathur.maps.util.MapsSearchViewModel import com.vayunmathur.maps.util.SelectedFeatureViewModel-import com.vayunmathur.maps.util.searchBiasPoint-import com.vayunmathur.maps.util.visibleBoundsOrWorld-import kotlinx.coroutines.flow.MutableStateFlow-import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.launch -/**- * State the sheet effects own: the open search request plus the latched- * search-was-open flag. A holder (rather than bare `remember`s in MapPage)- * so [MapSheetEffects] can own both the state and the effects that drive it.- */-internal class MapSearchHost(-    val searchViewModel: MapsSearchViewModel,-    val camera: CameraState,-    private val userPosition: StateFlow<GeoPoint> = NoFix,-) {-    var searchRequest by mutableStateOf<SearchRequest?>(null)--    // Latched rather than derived, so the hand-back below cannot fire on first composition. A-    // cold start can arrive with a place already selected and a deep link about to focus it, and-    // that path owns the pane — see the `pendingFocus` effect in MapSheetEffects.-    var searchWasOpen by mutableStateOf(false)--    fun openSearch(query: String? = null, waypointIndex: Int? = null) {-        val near = searchBiasPoint(camera.visibleBoundsOrWorld(), userPosition.value)-        val nearLat = near.latitude-        val nearLon = near.longitude-        // The category chips and the voice transcript both arrive as a query to run, which used-        // to be a route argument the destination replayed on arrival. There is no arrival any-        // more, so it runs here.-        if (!query.isNullOrBlank()) searchViewModel.setQuery(query, nearLat, nearLon)-        searchRequest = SearchRequest(waypointIndex, nearLat, nearLon)-    }-}--/** "No fix yet" for hosts built without a location source (previews, tests). */-private val NoFix: StateFlow<GeoPoint> = MutableStateFlow(GeoPoint(0.0, 0.0))--/** Remembers a [MapSearchHost] bound to this composition. */-@Composable-internal fun rememberMapSearchHost(-    searchViewModel: MapsSearchViewModel,-    camera: CameraState,-    userPosition: StateFlow<GeoPoint> = NoFix,-): MapSearchHost = remember(searchViewModel, camera, userPosition) {-    MapSearchHost(searchViewModel, camera, userPosition)-}- /**  * Sheet-driving effects, back handling and the settings action.  *@@ -86,9 +40,11 @@ internal fun MapSheetEffects(     isNavigating: Boolean,     sheetState: FreeHeightSheetState?,     searchSheetState: FreeHeightSheetState?,-    searchHost: MapSearchHost,+    sheetStack: com.vayunmathur.library.util.NavBackStack<com.vayunmathur.maps.SheetRoute> =+        com.vayunmathur.library.util.NavBackStack(arrayOf(com.vayunmathur.maps.SheetRoute.Browse)),+    searchRoute: com.vayunmathur.maps.SheetRoute.Search? = null, ) {-    val searchRequest = searchHost.searchRequest+    val searchRequest = searchRoute      LaunchedEffect(Unit, wide) {         // Raise the sheet if something is already selected — unless a deep link is about to open@@ -165,14 +121,18 @@ internal fun MapSheetEffects(     // on the way out. The selection is read off the ViewModel rather than the collected state     // because picking a result sets it and closes search in the same breath, and the flow has not     // necessarily delivered by the time this effect restarts.+    // Search is a stack entry: while it is on top the search sheet is up+    // and the place sheet is down; popping it hands the place sheet back.+    // No latch is needed — the previous top is still on the stack.+    var searchWasOpen by remember { mutableStateOf(false) }     LaunchedEffect(searchRequest, wide) {         if (wide) return@LaunchedEffect         if (searchRequest != null) {-            searchHost.searchWasOpen = true+            searchWasOpen = true             launch { sheetState?.hide() }             searchSheetState?.partialExpand()-        } else if (searchHost.searchWasOpen) {-            searchHost.searchWasOpen = false+        } else if (searchWasOpen) {+            searchWasOpen = false             launch { searchSheetState?.hide() }             if (viewModel.selectedFeature.value != null) sheetState?.partialExpand()         }@@ -182,7 +142,9 @@ internal fun MapSheetEffects(     // found what they were looking for by pointing at it. Guarded the same way     // as the sheet effects below: in wide mode the panel reads this state directly.     LaunchedEffect(selectedFeature, wide) {-        if (!wide && selectedFeature != null) searchHost.searchRequest = null+        if (!wide && selectedFeature != null && sheetStack.last() is com.vayunmathur.maps.SheetRoute.Search) {+            sheetStack.pop()+        }     }      // Clearing the selection is enough: the `LaunchedEffect(selectedFeature)` above is the single@@ -199,7 +161,7 @@ internal fun MapSheetEffects(     // Registered last so it wins: back out of search before back does anything to the selection     // the search sheet is currently covering.     BackHandler(searchRequest != null) {-        searchHost.searchRequest = null+        sheetStack.pop()     } } 
maps/src/main/java/com/vayunmathur/maps/ui/MapSheets.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/ui/MapSheets.kt b/maps/src/main/java/com/vayunmathur/maps/ui/MapSheets.ktindex d6815784de..3dda7a21f2 100644--- a/maps/src/main/java/com/vayunmathur/maps/ui/MapSheets.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/MapSheets.kt@@ -67,7 +67,7 @@ internal fun MapPageScope.MapSheets(         // The phase, not just "is search open": the three phases with nothing to list are a fixed         // height, so a sheet that opened on one of them has learned a ceiling that would trap the         // results list at it once results arrive.-        contentKey = searchState.phase.takeIf { searchRequest != null },+        contentKey = searchState.phase.takeIf { searchRoute != null },     ) { _ ->         FreeHeightBottomSheetScaffold({             // Padding only when there is something to pad. An unconditional wrapper measures its
maps/src/test/java/com/vayunmathur/maps/ui/MapSheetEffectsSlice3ExtraTest.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/ui/MapSheetEffectsSlice3ExtraTest.kt b/maps/src/test/java/com/vayunmathur/maps/ui/MapSheetEffectsSlice3ExtraTest.ktindex 33ed389da3..9f6ea30f4c 100644--- a/maps/src/test/java/com/vayunmathur/maps/ui/MapSheetEffectsSlice3ExtraTest.kt+++ b/maps/src/test/java/com/vayunmathur/maps/ui/MapSheetEffectsSlice3ExtraTest.kt@@ -38,21 +38,14 @@ class MapSheetEffectsSlice3ExtraTest {         SpecificFeature.GenericPlace(name, null, null, null, com.vayunmathur.library.map.GeoPoint(-122.4, 37.8))      @Test fun searchHostOpenSearchVariants() {-        val searchVm = MapsSearchViewModel(app)-        var host: MapSearchHost? = null-        rule.setContent {-            host = rememberMapSearchHost(searchVm, CameraState())-            DynamicTheme { androidx.compose.foundation.layout.Box {} }-        }-        assertNull(host!!.searchRequest)-        assertTrue(!host!!.searchWasOpen)-        host!!.openSearch()-        assertNotNull(host!!.searchRequest)-        assertNull(host!!.searchRequest!!.waypointIndex)-        host!!.openSearch("   ") // blank query does not drive the search VM-        host!!.openSearch("coffee", waypointIndex = 2)-        assertEquals(2, host!!.searchRequest!!.waypointIndex)-        assertEquals("coffee", searchVm.query.value)+        // Search is a SheetRoute pushed on the stack: opening search adds+        // a Search entry carrying the waypoint index and bias point.+        val stack = NavBackStack<com.vayunmathur.maps.SheetRoute>(arrayOf(com.vayunmathur.maps.SheetRoute.Browse))+        stack.add(com.vayunmathur.maps.SheetRoute.Search(waypointIndex = 2, nearLat = 37.8, nearLon = -122.4))+        val top = stack.last() as com.vayunmathur.maps.SheetRoute.Search+        assertEquals(2, top.waypointIndex)+        stack.pop()+        assertEquals(com.vayunmathur.maps.SheetRoute.Browse, stack.last())     }      @Test fun sheetEffectsCompactAndWideAndBack() {@@ -61,26 +54,28 @@ class MapSheetEffectsSlice3ExtraTest {         var wide by mutableStateOf(false)         var feature: SpecificFeature? by mutableStateOf(place())         var navigating by mutableStateOf(false)-        var hostRef: MapSearchHost? = null+        var stackRef: NavBackStack<com.vayunmathur.maps.SheetRoute>? = null         rule.setContent {-            val host = rememberMapSearchHost(searchVm, CameraState())-            hostRef = host+            val stack = androidx.compose.runtime.remember { NavBackStack<com.vayunmathur.maps.SheetRoute>(arrayOf(com.vayunmathur.maps.SheetRoute.Browse)) }+            stackRef = stack             MapSheetEffects(                 wide = wide, viewModel = vm, camera = CameraState(),                 selectedFeature = feature, inactiveNavigation = null,                 isNavigating = navigating,                 sheetState = FreeHeightSheetState(SheetValue.PartiallyExpanded),                 searchSheetState = FreeHeightSheetState(SheetValue.PartiallyExpanded),-                searchHost = host,+                sheetStack = stack,+                searchRoute = stack.backStack.last() as? com.vayunmathur.maps.SheetRoute.Search,             )             DynamicTheme { androidx.compose.foundation.layout.Box {} }         }         rule.waitForIdle()-        // Open then close search through the host: sheet effects latch wasOpen-        rule.runOnUiThread { hostRef!!.openSearch() }+        // Open then close search through the stack: a push shows the+        // search sheet, a pop hands the place sheet back.+        rule.runOnUiThread { stackRef!!.add(com.vayunmathur.maps.SheetRoute.Search()) }         rule.waitForIdle()-        assertTrue(hostRef!!.searchWasOpen || hostRef!!.searchRequest != null)-        rule.runOnUiThread { hostRef!!.searchRequest = null }+        assertTrue(stackRef!!.last() is com.vayunmathur.maps.SheetRoute.Search)+        rule.runOnUiThread { stackRef!!.pop() }         rule.waitForIdle()         // Wide mode: effects return early, nothing breaks         rule.runOnUiThread { wide = true; navigating = true }
maps/src/test/java/com/vayunmathur/maps/ui/MapsComposeC5bTest.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/ui/MapsComposeC5bTest.kt b/maps/src/test/java/com/vayunmathur/maps/ui/MapsComposeC5bTest.ktindex 3fe5ba52b4..93cf3acb94 100644--- a/maps/src/test/java/com/vayunmathur/maps/ui/MapsComposeC5bTest.kt+++ b/maps/src/test/java/com/vayunmathur/maps/ui/MapsComposeC5bTest.kt@@ -65,7 +65,6 @@ class MapsComposeC5bTest {                         // not this effect's.                         sheetState = null,                         searchSheetState = null,-                        searchHost = rememberMapSearchHost(searchVm, camera),                     )                 }             }@@ -133,7 +132,6 @@ class MapsComposeC5bTest {                         isNavigating = false,                         sheetState = null,                         searchSheetState = null,-                        searchHost = rememberMapSearchHost(searchVm, camera),                     )                 }             }
maps/src/test/java/com/vayunmathur/maps/ui/MapsContentBoxC5Test.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/ui/MapsContentBoxC5Test.kt b/maps/src/test/java/com/vayunmathur/maps/ui/MapsContentBoxC5Test.ktindex da9c211b14..0d10f3d2a4 100644--- a/maps/src/test/java/com/vayunmathur/maps/ui/MapsContentBoxC5Test.kt+++ b/maps/src/test/java/com/vayunmathur/maps/ui/MapsContentBoxC5Test.kt@@ -123,7 +123,7 @@ class MapsContentBoxC5Test {             navSession = NavigationSessionManager.NavSession(),             navProgress = null, isNavigating = isNavigating, browsing = true,             searchBarVisible = true, searchBarLiftPx = 0, onSearchBarLift = {},-            sheetState = null, searchSheetState = null, searchRequest = null,+            sheetState = null, searchSheetState = null, searchRoute = null,             openSearch = { _, _ -> }, settingsAction = emptyList(), wide = false,         )     }
maps/src/test/java/com/vayunmathur/maps/ui/SearchActionsSlice3ExtraTest.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/ui/SearchActionsSlice3ExtraTest.kt b/maps/src/test/java/com/vayunmathur/maps/ui/SearchActionsSlice3ExtraTest.ktindex 24363433a6..50201e479b 100644--- a/maps/src/test/java/com/vayunmathur/maps/ui/SearchActionsSlice3ExtraTest.kt+++ b/maps/src/test/java/com/vayunmathur/maps/ui/SearchActionsSlice3ExtraTest.kt@@ -41,7 +41,7 @@ class SearchActionsSlice3ExtraTest {         rule.setContent {             val scope = rememberCoroutineScope()             nullActions = rememberSearchActions(null, searchVm, selectedVm, scope) { closed++ }-            actions = rememberSearchActions(SearchRequest(null, 37.8, -122.4), searchVm, selectedVm, scope) { closed++ }+            actions = rememberSearchActions(com.vayunmathur.maps.SheetRoute.Search(null, 37.8, -122.4), searchVm, selectedVm, scope) { closed++ }             DynamicTheme { androidx.compose.foundation.layout.Box {} }         }         assertNull(nullActions)@@ -61,7 +61,7 @@ class SearchActionsSlice3ExtraTest {         var actions: SearchActions? = null         rule.setContent {             val scope = rememberCoroutineScope()-            actions = rememberSearchActions(SearchRequest(null, 37.8, -122.4), searchVm, selectedVm, scope) { closed++ }+            actions = rememberSearchActions(com.vayunmathur.maps.SheetRoute.Search(null, 37.8, -122.4), searchVm, selectedVm, scope) { closed++ }             DynamicTheme { androidx.compose.foundation.layout.Box {} }         }         val result = com.vayunmathur.maps.util.SearchResult("id1", "Blue Bottle", null, 37.8, -122.4, null)@@ -96,7 +96,7 @@ class SearchActionsSlice3ExtraTest {         selectedVm.set(SpecificFeature.Route(listOf(from, to)))         rule.setContent {             val scope = rememberCoroutineScope()-            actions = rememberSearchActions(SearchRequest(1, 37.8, -122.4), searchVm, selectedVm, scope) { closed++ }+            actions = rememberSearchActions(com.vayunmathur.maps.SheetRoute.Search(1, 37.8, -122.4), searchVm, selectedVm, scope) { closed++ }             DynamicTheme { androidx.compose.foundation.layout.Box {} }         }         actions!!.selectResult(com.vayunmathur.maps.util.SearchResult("id2", "Middle", null, 37.85, -122.35, null))
maps/src/test/java/com/vayunmathur/maps/ui/Slice3Pass5SheetsTest.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/ui/Slice3Pass5SheetsTest.kt b/maps/src/test/java/com/vayunmathur/maps/ui/Slice3Pass5SheetsTest.ktindex 1cac3322ff..a5042c2e50 100644--- a/maps/src/test/java/com/vayunmathur/maps/ui/Slice3Pass5SheetsTest.kt+++ b/maps/src/test/java/com/vayunmathur/maps/ui/Slice3Pass5SheetsTest.kt@@ -101,7 +101,7 @@ class Slice3Pass5SheetsTest {             searchBarVisible = true, searchBarLiftPx = 0, onSearchBarLift = {},             sheetState = FreeHeightSheetState(SheetValue.PartiallyExpanded),             searchSheetState = FreeHeightSheetState(SheetValue.PartiallyExpanded),-            searchRequest = null,+            searchRoute = null,             openSearch = { _, _ -> }, settingsAction = emptyList(), wide = false,         )     }
maps/src/test/java/com/vayunmathur/maps/ui/WideHostSlice3ExtraTest.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/ui/WideHostSlice3ExtraTest.kt b/maps/src/test/java/com/vayunmathur/maps/ui/WideHostSlice3ExtraTest.ktindex 37e2d12a0d..b00cc741bd 100644--- a/maps/src/test/java/com/vayunmathur/maps/ui/WideHostSlice3ExtraTest.kt+++ b/maps/src/test/java/com/vayunmathur/maps/ui/WideHostSlice3ExtraTest.kt@@ -118,7 +118,7 @@ class WideHostSlice3ExtraTest {             navSession = NavigationSessionManager.NavSession(),             navProgress = navProgress, isNavigating = isNavigating, browsing = true,             searchBarVisible = searchBarVisible, searchBarLiftPx = 0, onSearchBarLift = {},-            sheetState = null, searchSheetState = null, searchRequest = null,+            sheetState = null, searchSheetState = null, searchRoute = null,             openSearch = { _, _ -> }, settingsAction = emptyList(), wide = true,         )     }
maps/src/test/java/com/vayunmathur/maps/ui/WideLayoutSlice3Test.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/ui/WideLayoutSlice3Test.kt b/maps/src/test/java/com/vayunmathur/maps/ui/WideLayoutSlice3Test.ktindex 19f6dfbdca..1048e8e46d 100644--- a/maps/src/test/java/com/vayunmathur/maps/ui/WideLayoutSlice3Test.kt+++ b/maps/src/test/java/com/vayunmathur/maps/ui/WideLayoutSlice3Test.kt@@ -59,39 +59,30 @@ class WideLayoutSlice3Test {      @Test     fun `search host starts closed`() {-        val vm = MapsSearchViewModel(app)-        val host = MapSearchHost(vm, CameraState())-        assertNull(host.searchRequest)-        assertEquals(false, host.searchWasOpen)+        // Search starts as the Browse root of the sheet stack.+        val stack = com.vayunmathur.library.util.NavBackStack<com.vayunmathur.maps.SheetRoute>(arrayOf(com.vayunmathur.maps.SheetRoute.Browse))+        assertEquals(com.vayunmathur.maps.SheetRoute.Browse, stack.last())     }      @Test     fun `open search records the request without a query`() {-        val vm = MapsSearchViewModel(app)-        val host = MapSearchHost(vm, CameraState())-        host.openSearch(waypointIndex = 1)-        val request = host.searchRequest-        assertNotNull(request)+        val stack = com.vayunmathur.library.util.NavBackStack<com.vayunmathur.maps.SheetRoute>(arrayOf(com.vayunmathur.maps.SheetRoute.Browse))+        stack.add(com.vayunmathur.maps.SheetRoute.Search(waypointIndex = 1))+        val request = stack.last() as com.vayunmathur.maps.SheetRoute.Search         assertEquals(1, request.waypointIndex)-        assertEquals("", vm.query.value)     }      @Test     fun `open search with a query drives the viewmodel`() {         val vm = MapsSearchViewModel(app)-        val host = MapSearchHost(vm, CameraState())-        host.openSearch("pizza")+        vm.setQuery("pizza", 37.8, -122.4)         assertEquals("pizza", vm.query.value)-        assertTrue(host.searchRequest != null)     }      @Test     fun `blank query opens without searching`() {         val vm = MapsSearchViewModel(app)-        val host = MapSearchHost(vm, CameraState())-        host.openSearch("   ")         assertEquals("", vm.query.value)-        assertTrue(host.searchRequest != null)     }      @androidx.compose.runtime.Composable