astronomy: cover ObjectDetail and HistoryDatePicker screenshots
- Commit
70b99f4c311230916d805c4ded4229e246566e3f- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-02 06:14 UTC (4 days ago)
- Parents
e128cac
RouteScreenshotCoverage flagged Route.ObjectDetail and
Route.HistoryDatePicker: every leaf route needs a capture in
src/screenshotTest, and both were missing, so fresh
:astronomy:lintVitalRelease failed with two errors.
ObjectDetailPage bound the ViewModel directly, so its UI could
not be rendered from a preview. Extract the stateless
ObjectDetailScreen (one public composable per file, so it gets
its own file) taking the resolved DetailInfo, the
RiseTransitSet, a trajectory flag and an explicit TimeZone;
ObjectDetailPage keeps its signature and delegates, passing the
system zone exactly as before. DetailInfo becomes module-visible
so the screenshot source set can build a fixture from it.
Add Preview5ObjectDetail ("5-object-detail") and
Preview6HistoryDatePicker ("6-history-date-picker"), both in
the existing phone form-factor bucket. Fixtures are fixed only:
Jupiter reuses SampleSky's coordinates and fixed Julian
rise/transit/set dates in America/Los_Angeles, and the date
picker is pinned to LocalDate(2026, 2, 14) with a throwaway
NavResultRegistry, mirroring the FindFamily history-picker
preview. No wall-clock reads. Regenerated listing photos
phone/4.png and phone/5.png via :astronomy:metadata (six images,
existing three byte-unchanged), and listed ObjectDetailScreen.kt
in astronomy/AGENTS.md key files.
Verified: fresh :astronomy:lint and :astronomy:lintVitalRelease
green; ktlint main+screenshotTest source sets green;
:astronomy:metadata renders both new previews.
:astronomy:testDevUnitTest: 63/64 pass; the one failure,
SettingsScreenInteractionsTest sliders-announce (expected 2
progress nodes, got 3), is in SettingsScreen code and its test,
both untouched by this change and failing identically on the
isolated rerun.Diff
astronomy/AGENTS.md
diff --git a/astronomy/AGENTS.md b/astronomy/AGENTS.mdindex 56a7aea28e..f209e30554 100644--- a/astronomy/AGENTS.md+++ b/astronomy/AGENTS.md@@ -49,6 +49,7 @@ _Install: ./install astronomy (dev by default)._ - com/vayunmathur/astronomy/ui/SkyGrid.kt - com/vayunmathur/astronomy/ui/SkyArt.kt - com/vayunmathur/astronomy/ui/ObjectDetailPage.kt+- com/vayunmathur/astronomy/ui/ObjectDetailScreen.kt - com/vayunmathur/astronomy/ui/SearchPage.kt - com/vayunmathur/astronomy/ui/SettingsPage.kt - com/vayunmathur/astronomy/ui/components/CameraBackground.kt
astronomy/src/main/java/com/vayunmathur/astronomy/ui/ObjectDetailPage.kt
diff --git a/astronomy/src/main/java/com/vayunmathur/astronomy/ui/ObjectDetailPage.kt b/astronomy/src/main/java/com/vayunmathur/astronomy/ui/ObjectDetailPage.ktindex 49da89233a..1490bb51b4 100644--- a/astronomy/src/main/java/com/vayunmathur/astronomy/ui/ObjectDetailPage.kt+++ b/astronomy/src/main/java/com/vayunmathur/astronomy/ui/ObjectDetailPage.kt@@ -1,37 +1,17 @@ package com.vayunmathur.astronomy.ui -import androidx.compose.foundation.layout.Arrangement-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.rememberScrollState-import androidx.compose.foundation.verticalScroll import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.remember-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.domain.engine.TimeEngine import com.vayunmathur.astronomy.domain.engine.toDeg import com.vayunmathur.astronomy.platform.AstronomyViewModel-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.Text-import com.vayunmathur.library.ui.TopAppBarOverlay import com.vayunmathur.library.util.NavBackStack+import kotlinx.datetime.TimeZone import kotlinx.datetime.toLocalDateTime import kotlin.time.ExperimentalTime-import com.vayunmathur.library.ui.R as UiR @OptIn(ExperimentalTime::class) @Composable@@ -46,73 +26,17 @@ fun ObjectDetailPage( val detail = remember(objectId, visibleSky) { resolveDetail(objectId, visibleSky, viewModel) } - // 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),- ) {- 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)-- 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 { jdToLocal(it) } ?: "—"))- Text(stringResource(R.string.transit_1, rs.transitJd?.let { jdToLocal(it) } ?: "—"))- Text(stringResource(R.string.set_1, rs.setJd?.let { jdToLocal(it) } ?: "—"))- }- }- }-- // 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 (trajectory.isNotEmpty()) {- Text(- stringResource(R.string.trajectory_24h_15m_steps_yellow_line_on),- style = MaterialTheme.typography.labelSmall,- )- }- }-- TopAppBarOverlay(- modifier = Modifier.align(Alignment.TopCenter),- onNavigateBack = { backStack.pop() },- )- }+ ObjectDetailScreen(+ backStack = backStack,+ detail = detail,+ objectId = objectId,+ riseSet = riseSet,+ hasTrajectory = trajectory.isNotEmpty(),+ timeZone = TimeZone.currentSystemDefault(),+ ) } -private data class DetailInfo(+data class DetailInfo( val title: String, val subtitle: String, val raDeg: Double,@@ -235,9 +159,6 @@ private fun projectCatalogStar( .VisibleStar(star, aa, raDec) } -@OptIn(ExperimentalTime::class)-private fun jdToLocal(jd: Double): String = formatJdInZone(jd, kotlinx.datetime.TimeZone.currentSystemDefault())- /** * Formats a Julian date as a wall-clock date/time in [timeZone] * ("2025-06-21 05:30"). Rise/set instants are computed in UTC; showing
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.ktnew file mode 100644index 0000000000..874feb7298--- /dev/null+++ b/astronomy/src/main/java/com/vayunmathur/astronomy/ui/ObjectDetailScreen.kt@@ -0,0 +1,128 @@+package com.vayunmathur.astronomy.ui++import androidx.compose.foundation.layout.Arrangement+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.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.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.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+ * 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.+ */+@OptIn(ExperimentalTime::class)+@Composable+fun ObjectDetailScreen(+ backStack: NavBackStack<Route>,+ detail: DetailInfo?,+ objectId: String,+ riseSet: RiseSetCalculator.RiseTransitSet?,+ 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),+ ) {+ 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)++ 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) } ?: "—",+ ),+ )+ Text(+ stringResource(+ R.string.set_1,+ rs.setJd?.let { formatJdInZone(it, timeZone) } ?: "—",+ ),+ )+ }+ }+ }++ // 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,+ )+ }+ }++ TopAppBarOverlay(+ modifier = Modifier.align(Alignment.TopCenter),+ onNavigateBack = { backStack.pop() },+ )+ }+}++private fun Double.format(d: Int): String = "%.${d}f".format(this)
astronomy/src/screenshotTest/kotlin/com/vayunmathur/astronomy/ui/MetadataPreviews.kt
diff --git a/astronomy/src/screenshotTest/kotlin/com/vayunmathur/astronomy/ui/MetadataPreviews.kt b/astronomy/src/screenshotTest/kotlin/com/vayunmathur/astronomy/ui/MetadataPreviews.ktindex ba43603957..bc31b96c69 100644--- a/astronomy/src/screenshotTest/kotlin/com/vayunmathur/astronomy/ui/MetadataPreviews.kt+++ b/astronomy/src/screenshotTest/kotlin/com/vayunmathur/astronomy/ui/MetadataPreviews.kt@@ -10,6 +10,7 @@ import com.vayunmathur.astronomy.data.model.DeepSkyObject import com.vayunmathur.astronomy.data.model.Star import com.vayunmathur.astronomy.domain.engine.AltAz import com.vayunmathur.astronomy.domain.engine.RaDec+import com.vayunmathur.astronomy.domain.engine.RiseSetCalculator import com.vayunmathur.astronomy.platform.ConstellationLine import com.vayunmathur.astronomy.platform.ConstellationMode import com.vayunmathur.astronomy.platform.ObserverLocation@@ -26,9 +27,11 @@ import com.vayunmathur.astronomy.platform.VisibleSky import com.vayunmathur.astronomy.platform.VisibleStar import com.vayunmathur.astronomy.platform.VisibleSun import com.vayunmathur.library.ui.DynamicTheme+import com.vayunmathur.library.ui.dialog.DatePickerDialog import com.vayunmathur.library.util.LocalNavResultRegistry import com.vayunmathur.library.util.NavResultRegistry import com.vayunmathur.library.util.rememberNavBackStack+import kotlinx.datetime.LocalDate import kotlinx.datetime.TimeZone import kotlin.time.Instant @@ -126,6 +129,67 @@ class MetadataPreviews { ) } }++ @PreviewTest+ @Preview(name = "5-object-detail", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview5ObjectDetail() {+ DynamicTheme(darkTheme = true) {+ ObjectDetailScreen(+ backStack =+ rememberNavBackStack<Route>(+ Route.SkyMap,+ Route.ObjectDetail("PLANET_JUPITER"),+ ),+ // Jupiter from SampleSky: RA/Dec and alt/az are the same fixed+ // coordinates the sky-map capture uses (rad values converted to+ // degrees the way resolveDetail presents them), rise/transit/set+ // are fixed Julian dates on that same night.+ detail =+ DetailInfo(+ title = "Jupiter",+ subtitle = "Planet",+ raDeg = 73.50,+ decDeg = 21.50,+ altAz = 68.8 to 224.4,+ mag = -2.31,+ raDec = 1.28282 to 0.37525,+ extra = "Dist 4.523 AU",+ ),+ objectId = "PLANET_JUPITER",+ riseSet =+ RiseSetCalculator.RiseTransitSet(+ riseJd = 2461085.20,+ transitJd = 2461085.52,+ setJd = 2461085.84,+ ),+ hasTrajectory = true,+ timeZone = TimeZone.of("America/Los_Angeles"),+ )+ }+ }++ @PreviewTest+ @Preview(name = "6-history-date-picker", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview6HistoryDatePicker() {+ DynamicTheme(darkTheme = true) {+ // DatePickerDialog dispatches its result through LocalNavResultRegistry,+ // which only MainNavigation provides; hand it a throwaway one like the+ // sky-map preview does — no preview confirms a date.+ CompositionLocalProvider(LocalNavResultRegistry provides remember { NavResultRegistry() }) {+ DatePickerDialog(+ backStack =+ rememberNavBackStack<Route>(+ Route.SkyMap,+ Route.HistoryDatePicker(LocalDate(2026, 2, 14)),+ ),+ resultKey = "AstroHistoryDatePicker",+ initialDate = LocalDate(2026, 2, 14),+ )+ }+ }+ } } // ---- Sample data -----------------------------------------------------------------
metadata_data/photos/astronomy/phone/4.png
diff --git a/metadata_data/photos/astronomy/phone/4.png b/metadata_data/photos/astronomy/phone/4.pngnew file mode 100644index 0000000000..4218bfb33fBinary files /dev/null and b/metadata_data/photos/astronomy/phone/4.png differ
metadata_data/photos/astronomy/phone/5.png
diff --git a/metadata_data/photos/astronomy/phone/5.png b/metadata_data/photos/astronomy/phone/5.pngnew file mode 100644index 0000000000..6f9e372fcbBinary files /dev/null and b/metadata_data/photos/astronomy/phone/5.png differ