weather: no dead drawer toggle beside permanent panel (#945)
- Commit
702784cb51680bc0a105bfd78bf4ecf15e346bdd- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-04 18:40 UTC (1 day ago)
- Parents
7bf40b6
In landscape the weather home was condensed to about a third of the screen from the left. Root cause of the reported squeeze: the released Home/WeatherMap routes carried list-pane metadata, so the shared ListDetailSceneStrategy put the whole forecast in its ~1/3-width list pane beside an empty detail pane, and inside that pane the home screen - keyed off the activity window class rather than its available width - split again into an uncapped 35% locations panel plus forecast. That combination is already gone in this tree (full-screen route entries, and HomeScreen laying out from its BoxWithConstraints width with a bounded 280-360dp panel and a two-column forecast on medium/expanded widths), but nothing tested it at the level where it broke: the screen composed through the real navigation host at a real landscape window size. Remaining defect in the wide layout, fixed here: the expanded (permanent-panel) branch reused the modal-drawer controls. The forecast search bars hamburger button and clickable surface toggled a drawer state that no drawer composable consumes in that branch, so tapping it did nothing visible while arming the back handler keyed off the same state - a later back press was swallowed by a drawer that was never on screen. MainSearchBar now takes drawerToggleEnabled (threaded through ForecastColumn and ForecastScaffold); HomeScreens expanded branch passes false, so the bar renders as a plain location label there - no hamburger, no click. Compact and medium (landscape phone) keep the drawer toggle exactly as before. weather/AGENTS.md records the expanded behaviour. Regression tests (ComposeScreensTest, Robolectric window qualifiers so the window itself is landscape-sized): - homeScreenLandscapePhoneUsesFullWidth: 800x360dp home fills the width, cards split into two columns across it. - homeScreenExpandedSplitsPanelAndForecast: 1100x700dp shows the bounded locations panel with the forecast beside it. - navigationHostLandscapeDoesNotSqueezeHome: the same through MainNavigation, guarding the route-metadata contract whose breach caused the reported squeeze. - mainSearchBarWithoutDrawerToggleStillShowsLocation: the toggle-less bar still renders the active location. Assertions use merged/structural nodes; raw Text semantics bounds are not layout truth under Robolectric. Verified fresh (gradle --rerun-tasks, 384 tasks executed): ./gradlew :weather:lint :weather:lintVitalRelease :weather:testDevUnitTest - lint 0 errors (46 pre-existing warnings, none in touched files), 260 unit tests, 0 failures. No unrelated failures to attribute. Local commit only; the GitHub issue is left open for the owner.
Diff
weather/AGENTS.md
diff --git a/weather/AGENTS.md b/weather/AGENTS.mdindex 273e14ab53..7990136e15 100644--- a/weather/AGENTS.md+++ b/weather/AGENTS.md@@ -64,7 +64,7 @@ receivers are a phone-only surface and early-return on a watch. - com/vayunmathur/weather/data/WeatherRefreshWorker.kt - com/vayunmathur/weather/data/SavedLocation.kt ### domain/ + domain/map/ — pure formatting + map metadata (no Android)-- com/vayunmathur/weather/domain/HomeLayout.kt — pure home width breakpoints (600/840dp): compact = modal drawer + single column, medium = full-width two-column forecast, expanded = bounded 280–360dp locations panel + two-column forecast; the home screen sizes itself from its available width, not the activity window+- com/vayunmathur/weather/domain/HomeLayout.kt — pure home width breakpoints (600/840dp): compact = modal drawer + single column, medium = full-width two-column forecast, expanded = bounded 280–360dp locations panel + two-column forecast; the home screen sizes itself from its available width, not the activity window; in expanded the panel is permanent, so the forecast's search bar renders without a drawer toggle - com/vayunmathur/weather/domain/WmoCode.kt - com/vayunmathur/weather/domain/UnitFormat.kt - com/vayunmathur/weather/domain/DateTimeFormat.kt
weather/src/main/java/com/vayunmathur/weather/ui/ForecastColumn.kt
diff --git a/weather/src/main/java/com/vayunmathur/weather/ui/ForecastColumn.kt b/weather/src/main/java/com/vayunmathur/weather/ui/ForecastColumn.ktindex 16aa7e9f3b..5f72bd731c 100644--- a/weather/src/main/java/com/vayunmathur/weather/ui/ForecastColumn.kt+++ b/weather/src/main/java/com/vayunmathur/weather/ui/ForecastColumn.kt@@ -59,6 +59,8 @@ internal fun ForecastColumn( onOpenMap: (WeatherMetric, String?) -> Unit, /** Medium/expanded widths: show the cards in two columns instead of one stretched column. */ wide: Boolean = false,+ /** False in the expanded layout, whose locations panel is permanent (no drawer to toggle). */+ drawerToggleEnabled: Boolean = true, ) { var graphMetric by remember { mutableStateOf<WeatherMetric?>(null) } @@ -73,6 +75,7 @@ internal fun ForecastColumn( paddingValues = paddingValues, drawerState = drawerState, activeLocation = state.location,+ drawerToggleEnabled = drawerToggleEnabled, ) if (forecast == null) {
weather/src/main/java/com/vayunmathur/weather/ui/HomePage.kt
diff --git a/weather/src/main/java/com/vayunmathur/weather/ui/HomePage.kt b/weather/src/main/java/com/vayunmathur/weather/ui/HomePage.ktindex 26e8a724e7..d4bad3dd1d 100644--- a/weather/src/main/java/com/vayunmathur/weather/ui/HomePage.kt+++ b/weather/src/main/java/com/vayunmathur/weather/ui/HomePage.kt@@ -198,6 +198,8 @@ internal fun ForecastScaffold( modifier: Modifier = Modifier, /** Two card columns instead of one stretched column (medium/expanded widths). */ wide: Boolean = false,+ /** False in the expanded layout, whose locations panel is permanent (no drawer to toggle). */+ drawerToggleEnabled: Boolean = true, ) { AppScaffold( topBar = {},@@ -214,6 +216,7 @@ internal fun ForecastScaffold( nowEpochSec = nowEpochSec, onOpenMap = onOpenMap, wide = wide,+ drawerToggleEnabled = drawerToggleEnabled, ) } }
weather/src/main/java/com/vayunmathur/weather/ui/HomeScreen.kt
diff --git a/weather/src/main/java/com/vayunmathur/weather/ui/HomeScreen.kt b/weather/src/main/java/com/vayunmathur/weather/ui/HomeScreen.ktindex 7bb6251552..0d74dd1a00 100644--- a/weather/src/main/java/com/vayunmathur/weather/ui/HomeScreen.kt+++ b/weather/src/main/java/com/vayunmathur/weather/ui/HomeScreen.kt@@ -134,6 +134,9 @@ fun HomeScreen( nowEpochSec = nowEpochSec, onOpenMap = onOpenMap, wide = wide,+ // The panel beside this forecast is permanent, so+ // there is no drawer for the search bar to toggle.+ drawerToggleEnabled = false, modifier = Modifier.weight(1f).fillMaxHeight(), ) }
weather/src/main/java/com/vayunmathur/weather/ui/components/MainSearchBar.kt
diff --git a/weather/src/main/java/com/vayunmathur/weather/ui/components/MainSearchBar.kt b/weather/src/main/java/com/vayunmathur/weather/ui/components/MainSearchBar.ktindex f24f2125ab..67dc46383d 100644--- a/weather/src/main/java/com/vayunmathur/weather/ui/components/MainSearchBar.kt+++ b/weather/src/main/java/com/vayunmathur/weather/ui/components/MainSearchBar.kt@@ -39,6 +39,15 @@ fun MainSearchBar( paddingValues: PaddingValues, drawerState: DrawerState, activeLocation: SavedLocation?,+ /**+ * False where there is no modal drawer to toggle — the expanded+ * layout, where the locations list is already a permanent panel beside+ * the forecast. The bar then renders as a plain location label: no+ * hamburger button, and the surface is not clickable, so it cannot arm+ * a drawer state (and the back handler keyed off it) that nothing+ * on screen can satisfy.+ */+ drawerToggleEnabled: Boolean = true, ) { val scope = rememberCoroutineScope() val toggleDrawer = {@@ -67,7 +76,7 @@ fun MainSearchBar( end = 16.dp, ) .fillMaxWidth()- .clickable { toggleDrawer() },+ .then(if (drawerToggleEnabled) Modifier.clickable { toggleDrawer() } else Modifier), ) { Row( modifier = Modifier@@ -76,10 +85,12 @@ fun MainSearchBar( .padding(horizontal = 4.dp), verticalAlignment = Alignment.CenterVertically, ) {- IconButton(onClick = { toggleDrawer() }) {- IconMenu(tint = MaterialTheme.colorScheme.onSurfaceVariant)+ if (drawerToggleEnabled) {+ IconButton(onClick = { toggleDrawer() }) {+ IconMenu(tint = MaterialTheme.colorScheme.onSurfaceVariant)+ }+ Spacer(Modifier.width(4.dp)) }- Spacer(Modifier.width(4.dp)) Column(modifier = Modifier.weight(1f)) { Text( text = locationText,
weather/src/test/java/com/vayunmathur/weather/ui/ComposeScreensTest.kt
diff --git a/weather/src/test/java/com/vayunmathur/weather/ui/ComposeScreensTest.kt b/weather/src/test/java/com/vayunmathur/weather/ui/ComposeScreensTest.ktindex b45cf4646c..5d2f2cb077 100644--- a/weather/src/test/java/com/vayunmathur/weather/ui/ComposeScreensTest.kt+++ b/weather/src/test/java/com/vayunmathur/weather/ui/ComposeScreensTest.kt@@ -175,6 +175,118 @@ class ComposeScreensTest { rule.onNodeWithText("Berlin", substring = true).assertIsDisplayed() } + @org.robolectric.annotation.Config(qualifiers = "w800dp-h360dp-land")+ @Test fun homeScreenLandscapePhoneUsesFullWidth() {+ // Regression for #945: a landscape phone (800x360dp, medium width)+ // must lay the forecast out across the whole available width, not+ // condensed into a ~1/3 column on the left.+ rule.setContent {+ HomeScreen(+ state = LocationUiState(location = loc(), forecast = forecast()),+ units = DisplayUnits(),+ actions = WeatherActions.Noop,+ precipitationNowcast = null,+ nowEpochSec = 1760000000L,+ )+ }+ val bar = rule.onNodeWithText("Berlin, Germany").fetchSemanticsNode().boundsInRoot+ assertTrue(bar.width > 500f, "search bar width ${bar.width} in 800dp landscape")+ assertTrue(bar.left < 100f, "search bar left ${bar.left}")+ // The wide body must split into two columns across the full width:+ // Summary in the left column, metric blocks in the right column.+ val summary = rule.onNodeWithText("Summary").fetchSemanticsNode().boundsInRoot+ val humidity = rule.onNodeWithText("Humidity").fetchSemanticsNode().boundsInRoot+ assertTrue(summary.left < 200f, "summary in left column, $summary humidity $humidity bar $bar")+ assertTrue(humidity.left > 350f, "blocks column starts right, humidity $humidity summary $summary")+ }++ @org.robolectric.annotation.Config(qualifiers = "w1100dp-h700dp-land")+ @Test fun navigationHostLandscapeDoesNotSqueezeHome() {+ // #945 at the host level: through MainNavigation (which installs a+ // list-detail scene strategy), the home forecast must still fill+ // the window - panel beside it on expanded widths, never a ~1/3+ // list pane beside an empty detail pane.+ rule.setContent {+ val stack = com.vayunmathur.library.util.rememberNavBackStack<Route>(Route.Home())+ com.vayunmathur.library.util.MainNavigation(stack) {+ entry<Route.Home> {+ HomeScreen(+ state = LocationUiState(location = loc(), forecast = forecast()),+ units = DisplayUnits(),+ actions = WeatherActions.Noop,+ precipitationNowcast = null,+ nowEpochSec = 1760000000L,+ drawerContent = {+ LocationsScreen(+ state = LocationsUiState(+ rows = listOf(LocationRow(loc(), "No data yet", 2, true)),+ activeLocationId = 1L,+ ),+ actions = WeatherActions.Noop,+ )+ },+ )+ }+ }+ }+ // The panel's location row is a merged (clickable) node, so its+ // bounds are the row's real layout bounds: a bounded panel on the+ // left, not a squeezed sliver and not the whole window.+ val panelRow = rule.onNodeWithText("Berlin").fetchSemanticsNode().boundsInRoot+ assertTrue(panelRow.left < 100f, "panel row at left, $panelRow")+ assertTrue(panelRow.width in 200f..400f, "panel row width ${panelRow.width}")+ // The forecast's metric blocks sit beside the panel, in the+ // forecast's right column - proof the forecast holds the rest of+ // the window rather than a ~1/3 list pane.+ val humidity = rule.onNodeWithText("Humidity").fetchSemanticsNode().boundsInRoot+ assertTrue(humidity.left > panelRow.right + 50f, "forecast beside panel, humidity $humidity panel $panelRow")+ }++ @org.robolectric.annotation.Config(qualifiers = "w1100dp-h700dp-land")+ @Test fun homeScreenExpandedSplitsPanelAndForecast() {+ // Expanded (tablet/desktop): bounded locations panel on the left,+ // forecast keeps the majority of the width beside it.+ rule.setContent {+ HomeScreen(+ state = LocationUiState(location = loc(), forecast = forecast()),+ units = DisplayUnits(),+ actions = WeatherActions.Noop,+ precipitationNowcast = null,+ nowEpochSec = 1760000000L,+ drawerContent = {+ LocationsScreen(+ state = LocationsUiState(+ rows = listOf(LocationRow(loc(), "No data yet", 2, true)),+ activeLocationId = 1L,+ ),+ actions = WeatherActions.Noop,+ )+ },+ )+ }+ rule.onNodeWithText("Locations").assertIsDisplayed()+ val panelRow = rule.onNodeWithText("Berlin").fetchSemanticsNode().boundsInRoot+ assertTrue(panelRow.left < 100f, "panel row at left, $panelRow")+ assertTrue(panelRow.width in 200f..400f, "panel row width ${panelRow.width}")+ val humidity = rule.onNodeWithText("Humidity").fetchSemanticsNode().boundsInRoot+ assertTrue(humidity.left > panelRow.right + 50f, "forecast beside panel, humidity $humidity panel $panelRow")+ }++ @org.robolectric.annotation.Config(qualifiers = "w800dp-h360dp-land")+ @Test fun mainSearchBarWithoutDrawerToggleStillShowsLocation() {+ // Expanded layout: the bar is a plain location label (no drawer+ // toggle), but the location itself must still render.+ rule.setContent {+ MainSearchBar(+ paddingValues = PaddingValues(0.dp),+ drawerState = rememberDrawerState(DrawerValue.Closed),+ activeLocation = loc(),+ drawerToggleEnabled = false,+ )+ }+ rule.onNodeWithText("Berlin, Germany").assertIsDisplayed()+ }+ @Test fun locationsScreenSelectAndSearch() { var selected: SavedLocation? = null var searched = false