astronomy: fix object detail dialog and scaffold search
- Commit
f46c006d5fc36179f4a400cad5f66c234c2fd558- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-05 13:44 UTC (22 hours ago)
- Parents
41e54d3
The object-detail route was already a DialogPage() dialog route, but its body was written as a full screen: a fillMaxSize column with statusBarsPadding inside a top-anchored DesktopMaxWidthContainer and a TopAppBarOverlay back button floating over it. Inside the dialog window that made the content top-anchored and full-height instead of centred, left the sky showing through because nothing painted a background, and put the floating back button on top of the title. ObjectDetailScreen is now a centred wrap-height card: a Box centred in the dialog window holding a Surface in surfaceContainerHigh with extraLarge shape, capped at 560dp, with the title limited to two lines with ellipsis so long names wrap/truncate sanely. The TopAppBarOverlay back button is removed; dismissal stays with the dialog host (outside tap / system back) plus the existing Close button. The object-not-found case now also gets the Close button. SearchScreen had the same overlay arrangement plus a standalone OutlinedTextField guarded by a SCAFFOLD SEARCH EXCEPTION. It now uses AppScaffold with search = ScaffoldSearch(query, onQueryChange, placeholder = "Search"), so the field renders as the solid top app bar title slot and the bar navigation icon closes the page via the back stack, matching other scaffold-search pages. Results keep the expanded-window letterboxing. Screenshot coverage: the existing deterministic captures 5-object-detail (Jupiter fixture) and 2-search / 4-search-expanded render the same stateless screens, so they now capture the fixed dialog and scaffold-search layouts with no new fixture needed. Verification: :astronomy:lint and :astronomy:lintVitalRelease pass; :astronomy:ktlintMainSourceSetCheck passes. :astronomy:testDevUnitTest runs 64 tests with 1 failure, SettingsScreenInteractionsTest sliders announce formatted values, which fails identically on clean origin/main 24a1997 and is unrelated to this change.
Diff
astronomy/src/main/java/com/vayunmathur/astronomy/ui/ObjectDetailScreen.kt
diff --git a/astronomy/src/main/java/com/vayunmathur/astronomy/ui/ObjectDetailScreen.kt b/astronomy/src/main/java/com/vayunmathur/astronomy/ui/ObjectDetailScreen.ktindex 874feb7298..8afcaed4ab 100644--- a/astronomy/src/main/java/com/vayunmathur/astronomy/ui/ObjectDetailScreen.kt+++ b/astronomy/src/main/java/com/vayunmathur/astronomy/ui/ObjectDetailScreen.kt@@ -1,38 +1,44 @@ package com.vayunmathur.astronomy.ui import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding-import androidx.compose.foundation.layout.statusBarsPadding+import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource+import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import com.vayunmathur.astronomy.R import com.vayunmathur.astronomy.Route import com.vayunmathur.astronomy.domain.engine.RiseSetCalculator import com.vayunmathur.library.ui.Card-import com.vayunmathur.library.ui.DesktopMaxWidthContainer import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.OutlinedButton+import com.vayunmathur.library.ui.Surface import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.TopAppBarOverlay import com.vayunmathur.library.util.NavBackStack import kotlinx.datetime.TimeZone import kotlin.time.ExperimentalTime import com.vayunmathur.library.ui.R as UiR /**- * The object-detail screen, with no dependency on the ViewModel so it can be rendered+ * The object-detail dialog body, with no dependency on the ViewModel so it can be rendered * from a `@Preview` — see `src/screenshotTest`, which is where the store listing images * come from. [timeZone] is explicit so a preview can pin the rise/transit/set labels to * a fixed zone instead of the host's.+ *+ * Hosted as a `DialogPage()` route (see Navigation.kt): the dialog window centres+ * this content and handles outside-tap / system-back dismissal, so the body is a+ * centred, wrap-height card on a solid surface — never a full-screen column, no+ * status-bar padding, and no back button of its own. */ @OptIn(ExperimentalTime::class) @Composable@@ -44,84 +50,101 @@ fun ObjectDetailScreen( hasTrajectory: Boolean, timeZone: TimeZone, ) {- // Dialog detail: already correct metadata, just letterbox the column on- // expanded windows so it keeps a readable measure on desktop.- DesktopMaxWidthContainer {- Column(- Modifier- .fillMaxSize()- .statusBarsPadding()- .verticalScroll(rememberScrollState())- .padding(16.dp),- verticalArrangement = Arrangement.spacedBy(12.dp),+ Box(+ Modifier+ .fillMaxSize()+ .padding(24.dp),+ contentAlignment = Alignment.Center,+ ) {+ Surface(+ modifier =+ Modifier+ .widthIn(max = 560.dp)+ .fillMaxWidth(),+ shape = MaterialTheme.shapes.extraLarge,+ color = MaterialTheme.colorScheme.surfaceContainerHigh, ) {- if (detail == null) {- Text(stringResource(R.string.object_not_found, objectId))- return@Column- }- Text(detail.title, style = MaterialTheme.typography.headlineSmall)- Text(detail.subtitle, style = MaterialTheme.typography.bodyMedium)+ Column(+ Modifier+ .verticalScroll(rememberScrollState())+ .padding(24.dp),+ verticalArrangement = Arrangement.spacedBy(12.dp),+ ) {+ if (detail == null) {+ Text(stringResource(R.string.object_not_found, objectId))+ } else {+ Text(+ detail.title,+ style = MaterialTheme.typography.headlineSmall,+ maxLines = 2,+ overflow = TextOverflow.Ellipsis,+ )+ Text(detail.subtitle, style = MaterialTheme.typography.bodyMedium) - Card(Modifier.fillMaxWidth()) {- Column(Modifier.padding(12.dp), verticalArrangement = Arrangement.spacedBy(4.dp)) {- Text(stringResource(R.string.ra_dec, detail.raDeg.format(2), detail.decDeg.format(2)))- Text(stringResource(R.string.ra_h_h, (detail.raDeg / 15.0).format(2)))- detail.altAz?.let { Text(stringResource(R.string.alt_az, it.first.format(1), it.second.format(1))) }- detail.mag?.let { Text(stringResource(R.string.mag, it.format(1))) }- detail.extra?.let { Text(it) }- }- }+ Card(Modifier.fillMaxWidth()) {+ Column(Modifier.padding(12.dp), verticalArrangement = Arrangement.spacedBy(4.dp)) {+ Text(stringResource(R.string.ra_dec, detail.raDeg.format(2), detail.decDeg.format(2)))+ Text(stringResource(R.string.ra_h_h, (detail.raDeg / 15.0).format(2)))+ detail.altAz?.let {+ Text(+ stringResource(R.string.alt_az, it.first.format(1), it.second.format(1)),+ )+ }+ detail.mag?.let { Text(stringResource(R.string.mag, it.format(1))) }+ detail.extra?.let { Text(it) }+ }+ } - Card(Modifier.fillMaxWidth()) {- Column(Modifier.padding(12.dp), verticalArrangement = Arrangement.spacedBy(4.dp)) {- Text(stringResource(R.string.rise_transit_set), style = MaterialTheme.typography.titleSmall)- val rs = riseSet- if (rs == null) {- Text(stringResource(R.string.calculating))- } else if (rs.isNeverUp) {- Text(stringResource(R.string.never_rises_at_this_location))- } else if (rs.isCircumpolar) {- Text(stringResource(R.string.circumpolar_never_sets))- } else {- Text(- stringResource(- R.string.rise_1,- rs.riseJd?.let { formatJdInZone(it, timeZone) } ?: "—",- ),- )- Text(- stringResource(- R.string.transit_1,- rs.transitJd?.let { formatJdInZone(it, timeZone) } ?: "—",- ),- )+ Card(Modifier.fillMaxWidth()) {+ Column(Modifier.padding(12.dp), verticalArrangement = Arrangement.spacedBy(4.dp)) {+ Text(stringResource(R.string.rise_transit_set), style = MaterialTheme.typography.titleSmall)+ val rs = riseSet+ if (rs == null) {+ Text(stringResource(R.string.calculating))+ } else if (rs.isNeverUp) {+ Text(stringResource(R.string.never_rises_at_this_location))+ } else if (rs.isCircumpolar) {+ Text(stringResource(R.string.circumpolar_never_sets))+ } else {+ Text(+ stringResource(+ R.string.rise_1,+ rs.riseJd?.let { formatJdInZone(it, timeZone) } ?: "—",+ ),+ )+ Text(+ stringResource(+ R.string.transit_1,+ rs.transitJd?.let { formatJdInZone(it, timeZone) } ?: "—",+ ),+ )+ Text(+ stringResource(+ R.string.set_1,+ rs.setJd?.let { formatJdInZone(it, timeZone) } ?: "—",+ ),+ )+ }+ }+ }++ if (hasTrajectory) { Text(- stringResource(- R.string.set_1,- rs.setJd?.let { formatJdInZone(it, timeZone) } ?: "—",- ),+ stringResource(R.string.trajectory_24h_15m_steps_yellow_line_on),+ style = MaterialTheme.typography.labelSmall, ) } }- } - // No center button per request – detail only, view always follows phone- Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {- OutlinedButton(onClick = { backStack.pop() }) { Text(stringResource(UiR.string.close)) }- }-- if (hasTrajectory) {- Text(- stringResource(R.string.trajectory_24h_15m_steps_yellow_line_on),- style = MaterialTheme.typography.labelSmall,- )+ // No center button per request – detail only, view always follows phone+ Row(+ Modifier.fillMaxWidth(),+ horizontalArrangement = Arrangement.End,+ ) {+ OutlinedButton(onClick = { backStack.pop() }) { Text(stringResource(UiR.string.close)) }+ } } }-- TopAppBarOverlay(- modifier = Modifier.align(Alignment.TopCenter),- onNavigateBack = { backStack.pop() },- ) } }
astronomy/src/main/java/com/vayunmathur/astronomy/ui/SearchScreen.kt
diff --git a/astronomy/src/main/java/com/vayunmathur/astronomy/ui/SearchScreen.kt b/astronomy/src/main/java/com/vayunmathur/astronomy/ui/SearchScreen.ktindex 66b37e6603..c4bcea39c6 100644--- a/astronomy/src/main/java/com/vayunmathur/astronomy/ui/SearchScreen.kt+++ b/astronomy/src/main/java/com/vayunmathur/astronomy/ui/SearchScreen.kt@@ -1,15 +1,9 @@ package com.vayunmathur.astronomy.ui -// SCAFFOLD SEARCH EXCEPTION: full-bleed sky-map screen with TopAppBarOverlay chrome; no scaffold host for the catalog search field import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement-import androidx.compose.foundation.layout.Column-import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize-import androidx.compose.foundation.layout.fillMaxWidth-import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding-import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.runtime.Composable@@ -17,26 +11,30 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue-import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp-import com.vayunmathur.astronomy.R import com.vayunmathur.astronomy.Route import com.vayunmathur.astronomy.platform.SearchActions+import com.vayunmathur.library.ui.AppScaffold import com.vayunmathur.library.ui.DesktopMaxWidthContainer import com.vayunmathur.library.ui.HorizontalDivider import com.vayunmathur.library.ui.IconChevronRight import com.vayunmathur.library.ui.ListItem-import com.vayunmathur.library.ui.OutlinedTextField+import com.vayunmathur.library.ui.ScaffoldSearch import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.TopAppBarOverlay import com.vayunmathur.library.util.NavBackStack+import com.vayunmathur.library.ui.R as UiR /** * The catalog search screen, with no dependency on the ViewModel so it can be rendered * from a `@Preview` — see `src/screenshotTest`, which is where the store listing images * come from.+ *+ * Screen-level search goes through the scaffold: [AppScaffold]'s `search` slot+ * renders the field as the top app bar's title, and the bar's own navigation+ * icon (wired to [backStack]) closes the page — no standalone search bar and+ * no floating overlay bar. */ @Composable fun SearchScreen(@@ -51,26 +49,28 @@ fun SearchScreen( var query by remember { mutableStateOf(initialQuery) } var results by remember { mutableStateOf(actions.search(initialQuery)) } - // Letterbox the single results column on expanded windows; the sky map- // itself stays full-bleed by design.- DesktopMaxWidthContainer {- Column(- Modifier- .fillMaxSize()- .statusBarsPadding()- .padding(top = 56.dp)- .padding(12.dp),- ) {- OutlinedTextField(value = query, onValueChange = {- query = it- results = actions.search(it)- }, label = {- Text(- stringResource(R.string.search_stars_planets_messier),- )- }, modifier = Modifier.fillMaxWidth())- Spacer(Modifier.height(8.dp))- LazyColumn(verticalArrangement = Arrangement.spacedBy(4.dp)) {+ AppScaffold(+ title = stringResource(UiR.string.search),+ backStack = backStack,+ search =+ ScaffoldSearch(+ query = query,+ onQueryChange = {+ query = it+ results = actions.search(it)+ },+ placeholder = stringResource(UiR.string.search),+ ),+ ) { padding ->+ // Letterbox the single results column on expanded windows.+ DesktopMaxWidthContainer {+ LazyColumn(+ Modifier+ .fillMaxSize()+ .padding(padding)+ .padding(horizontal = 12.dp),+ verticalArrangement = Arrangement.spacedBy(4.dp),+ ) { items(results) { r -> ListItem( headlineContent = { Text(r.title) },@@ -91,10 +91,5 @@ fun SearchScreen( } } }-- TopAppBarOverlay(- modifier = Modifier.align(Alignment.TopCenter),- onNavigateBack = { backStack.pop() },- ) } }