krz/moonrise

Night-sky companion for iPhone, Apple Watch and Vision Pro: what's up tonight, the Moon, planets, launches and missions, and a Library of the solar system. SwiftUI app with a Cloudflare Workers backend. astronomy cloudflare-workers ios night-sky space swiftui visionos watchos

Commit 31a9a6beb6

31a9a6beb64e6b820b47920f3e52a8d9b128654c

parent: 28610facd5

Unsigned

cmc <hello@cleberg.net> · 2026-10-22 05:11 UTC

Screenshots for 5.8; labels that no longer overlap (!142)

- `App/UITests/ScreenshotTests.swift`: Denver, night mode off; Sky, Tonight, System map, 3D, Sun, launches, Library, Jupiter. Skipped unless `SCREENSHOT_DIR` is set:
  `TEST_RUNNER_SCREENSHOT_DIR=… xcodebuild test -configuration Release -only-testing:MoonriseUITests/ScreenshotTests`
- `App/AppStore/screenshots/iphone-6.3`, `iphone-6.9`, `header-21x9.png`, `header-16x9.png` redone. iPad and Watch sets unchanged.
- Fixes the captures showed:
  - `OrreryView`: labels placed after marks, planets first, overlapping ones skipped (Juno, Psyche, JUICE, Europa Clipper and Parker sat on each other).
  - `SolarSystem3D`: label collision by estimated text width (long comet designations overlapped).
  - `SunScreen`: region numbers above, else below, else omitted near the crowded limb.
  - `SystemScreen` intro no longer says "the five spacecraft".
- Status bar time could not be overridden (`simctl status_bar --time` rejects every format on this runtime), so it shows the capture time.

Layout: unified · split

App/AppStore/header-16x9.png

Binary file not shown.

App/AppStore/header-21x9.png

Binary file not shown.

App/AppStore/screenshots/iphone-6.3/01-sky.png

Binary file not shown.

App/AppStore/screenshots/iphone-6.3/02-tonight.png

Binary file not shown.

App/AppStore/screenshots/iphone-6.3/03-system.png

Binary file not shown.

App/AppStore/screenshots/iphone-6.3/04-3d.png

Binary file not shown.

App/AppStore/screenshots/iphone-6.3/05-sun.png

Binary file not shown.

App/AppStore/screenshots/iphone-6.3/06-launches.png

Binary file not shown.

App/AppStore/screenshots/iphone-6.3/07-library.png

Binary file not shown.

App/AppStore/screenshots/iphone-6.3/08-jupiter.png

Binary file not shown.

App/AppStore/screenshots/iphone-6.9/01-sky.png

Binary file not shown.

App/AppStore/screenshots/iphone-6.9/02-tonight.png

Binary file not shown.

App/AppStore/screenshots/iphone-6.9/03-system.png

Binary file not shown.

App/AppStore/screenshots/iphone-6.9/04-3d.png

Binary file not shown.

App/AppStore/screenshots/iphone-6.9/05-sun.png

Binary file not shown.

App/AppStore/screenshots/iphone-6.9/06-launches.png

Binary file not shown.

App/AppStore/screenshots/iphone-6.9/07-library.png

Binary file not shown.

App/AppStore/screenshots/iphone-6.9/08-jupiter.png

Binary file not shown.

App/Sources/SolarSystem3D.swift +6 −3
@@ -757,7 +757,7 @@ struct SolarSystem3DView: View {
757 case .moon: 50 757 case .moon: 50
758 } 758 }
759 } 759 }
760 var placed: [CGPoint] = [] 760 var placed: [CGRect] = []
761 let points = screenPoints(size: size) 761 let points = screenPoints(size: size)
762 // Anything whose centre falls on the disc of a nearer body is hidden behind it. 762 // Anything whose centre falls on the disc of a nearer body is hidden behind it.
763 let discs = points.filter { $0.radius > 4 }.map { ($0.point, $0.radius, cam.distance(to: $0.marker.scene)) } 763 let discs = points.filter { $0.radius > 4 }.map { ($0.point, $0.radius, cam.distance(to: $0.marker.scene)) }
@@ -769,8 +769,11 @@ struct SolarSystem3DView: View {
769 .sorted { rank($0.marker) < rank($1.marker) } 769 .sorted { rank($0.marker) < rank($1.marker) }
770 .map { item in 770 .map { item in
771 let at = CGPoint(x: item.point.x, y: item.point.y - max(item.radius, 5) - 9) 771 let at = CGPoint(x: item.point.x, y: item.point.y - max(item.radius, 5) - 9)
772 let clear = item.marker.id == selected || placed.allSatisfy { abs($0.x - at.x) > 48 || abs($0.y - at.y) > 14 } 772 // caption2 runs about 6 pt a character; a little padding keeps neighbours readable.
773 if clear { placed.append(at) } 773 let width = CGFloat(item.marker.name.count) * 6 + 8
774 let box = CGRect(x: at.x - width / 2, y: at.y - 8, width: width, height: 16)
775 let clear = item.marker.id == selected || !placed.contains { $0.intersects(box) }
776 if clear { placed.append(box) }
774 return (item.marker, item.point, item.radius, clear) 777 return (item.marker, item.point, item.radius, clear)
775 } 778 }
776 } 779 }
App/Sources/SunScreen.swift +25 −7
@@ -217,18 +217,36 @@ struct SunScreen: View {
217 private func regionOverlay(at date: Date) -> some View { 217 private func regionOverlay(at date: Date) -> some View {
218 GeometryReader { g in 218 GeometryReader { g in
219 let r = wavelength.diskRadius * g.size.width 219 let r = wavelength.diskRadius * g.size.width
220 ForEach(regions) { region in 220 ForEach(regionLabelPoints(at: date, size: g.size, radius: r), id: \.number) { l in
221 if let p = region.disk(at: date) { 221 Text(String(l.number))
222 Text(String(region.number)) 222 .font(.system(size: 10, weight: .medium)).monospacedDigit()
223 .font(.system(size: 10, weight: .medium)).monospacedDigit() 223 .foregroundStyle(.white).shadow(color: .black, radius: 2)
224 .foregroundStyle(.white).shadow(color: .black, radius: 2) 224 .position(l.point)
225 .position(x: g.size.width / 2 + p.x * r, y: g.size.height / 2 - p.y * r - 10)
226 }
227 } 225 }
228 } 226 }
229 .accessibilityHidden(true) 227 .accessibilityHidden(true)
230 } 228 }
231 229
230 /// A label above each region, else below it; left out where both would overlap a label already placed
231 /// (regions crowd together near the limb).
232 private func regionLabelPoints(at date: Date, size: CGSize, radius r: CGFloat) -> [(number: Int, point: CGPoint)] {
233 var placed: [CGRect] = []
234 var out: [(number: Int, point: CGPoint)] = []
235 for region in regions {
236 guard let p = region.disk(at: date) else { continue }
237 let x = size.width / 2 + p.x * r, y = size.height / 2 - p.y * r
238 for dy: CGFloat in [-10, 10] {
239 let box = CGRect(x: x - 15, y: y + dy - 7, width: 30, height: 14)
240 if !placed.contains(where: { $0.intersects(box) }) {
241 placed.append(box)
242 out.append((region.number, CGPoint(x: x, y: y + dy)))
243 break
244 }
245 }
246 }
247 return out
248 }
249
232 /// Three columns, stacked at accessibility text sizes. 250 /// Three columns, stacked at accessibility text sizes.
233 private func scalesStrip(_ s: NOAAScales) -> some View { 251 private func scalesStrip(_ s: NOAAScales) -> some View {
234 let stacked = typeSize.isAccessibilitySize 252 let stacked = typeSize.isAccessibilitySize
App/Sources/SystemScreen.swift +1 −1
@@ -99,7 +99,7 @@ struct SystemScreen: View {
99 VStack(alignment: .leading, spacing: 0) { 99 VStack(alignment: .leading, spacing: 0) {
100 Text("Solar system").font(.title.weight(.medium)) 100 Text("Solar system").font(.title.weight(.medium))
101 Rectangle().fill(accent).frame(width: 48, height: 5).padding(.top, 8).padding(.bottom, 12) 101 Rectangle().fill(accent).frame(width: 48, height: 5).padding(.top, 8).padding(.bottom, 12)
102 Text("The planets, and the five spacecraft travelling out of the solar system, seen from above. Drag the slider or press play to watch them move between 1958 and 2050.") 102 Text("The planets and spacecraft, seen from above: the five probes leaving the solar system and the missions at work today. Drag the slider or press play to watch them move between 1958 and 2050.")
103 .font(.subheadline).dimmed(0.75).padding(.bottom, 12) 103 .font(.subheadline).dimmed(0.75).padding(.bottom, 12)
104 modePicker.padding(.bottom, 16) 104 modePicker.padding(.bottom, 16)
105 105
App/UITests/ScreenshotTests.swift added +50
@@ -0,0 +1,50 @@
1import XCTest
2
3/// Captures the App Store and website screenshots from Denver, night mode off. Saved as PNGs to the folder in
4/// SCREENSHOT_DIR (pass TEST_RUNNER_SCREENSHOT_DIR to xcodebuild); skipped without it.
5final class ScreenshotTests: XCTestCase {
6 var app: XCUIApplication!
7 var folder: URL!
8
9 override func setUpWithError() throws {
10 guard let dir = ProcessInfo.processInfo.environment["SCREENSHOT_DIR"] else { throw XCTSkip("SCREENSHOT_DIR not set") }
11 folder = URL(fileURLWithPath: dir)
12 try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true)
13 app = XCUIApplication()
14 app.launchArguments += ["-onboarded", "YES", "-locationMode", "city", "-cityName", "Denver",
15 "-cityLatitude", "39.7392", "-cityLongitude", "-104.9903", "-nightMode", "off"]
16 app.launch()
17 }
18
19 private func shoot(_ name: String, wait: UInt32 = 3) throws {
20 sleep(wait)
21 try XCUIScreen.main.screenshot().pngRepresentation.write(to: folder.appending(path: "\(name).png"))
22 }
23
24 private func tab(_ name: String) {
25 app.tabBars.buttons[name].firstMatch.tap()
26 }
27
28 func testScreenshots() throws {
29 try shoot("01-sky", wait: 6)
30 app.buttons.matching(NSPredicate(format: "label BEGINSWITH 'Moon'")).firstMatch.tap()
31 try shoot("02-tonight")
32 app.swipeDown(velocity: .fast)
33 sleep(1)
34 tab("System")
35 app.buttons["Map"].firstMatch.tap()
36 try shoot("03-system", wait: 4)
37 app.buttons["3D"].firstMatch.tap()
38 try shoot("04-3d", wait: 5)
39 tab("Sun")
40 try shoot("05-sun", wait: 8)
41 tab("News & launches")
42 try shoot("06-launches", wait: 5)
43 tab("Library")
44 try shoot("07-library", wait: 3)
45 app.buttons["See all Planets"].firstMatch.tap()
46 sleep(1)
47 app.staticTexts["Jupiter"].firstMatch.tap()
48 try shoot("08-jupiter", wait: 3)
49 }
50}
Packages/MoonriseKit/Sources/SkyRenderer/Orrery.swift +18 −4
@@ -111,6 +111,20 @@ public struct OrreryView: View {
111 } 111 }
112 context.fill(Path(ellipseIn: CGRect(x: c.x - 4, y: c.y - 4, width: 8, height: 8)), with: .color(Color(red: 0.95, green: 0.75, blue: 0.35))) 112 context.fill(Path(ellipseIn: CGRect(x: c.x - 4, y: c.y - 4, width: 8, height: 8)), with: .color(Color(red: 0.95, green: 0.75, blue: 0.35)))
113 113
114 // Labels are placed after the marks, planets first, then spacecraft in file order; one that would
115 // overlap a placed label is left out (the list below the map names every craft).
116 var labels: [(text: GraphicsContext.ResolvedText, at: CGPoint, anchor: UnitPoint)] = []
117 var placed: [CGRect] = []
118 func label(_ text: Text, at point: CGPoint, anchor: UnitPoint) {
119 let t = context.resolve(text)
120 let size = t.measure(in: CGSize(width: 400, height: 100))
121 let rect = CGRect(x: point.x - anchor.x * size.width, y: point.y - anchor.y * size.height, width: size.width, height: size.height).insetBy(dx: -2, dy: -1)
122 guard !placed.contains(where: { $0.intersects(rect) }) else { return }
123 placed.append(rect)
124 labels.append((t, point, anchor))
125 }
126 var craftLabels: [(Text, CGPoint)] = []
127
114 for craft in Spacecraft.all { 128 for craft in Spacecraft.all {
115 let path = craft.path(until: date) 129 let path = craft.path(until: date)
116 guard let last = path.last else { continue } 130 guard let last = path.last else { continue }
@@ -121,9 +135,7 @@ public struct OrreryView: View {
121 context.stroke(line, with: .color(accent.opacity(faint ? 0.2 : 0.7)), lineWidth: faint ? 0.5 : 0.8) 135 context.stroke(line, with: .color(accent.opacity(faint ? 0.2 : 0.7)), lineWidth: faint ? 0.5 : 0.8)
122 let p = s.point(last) 136 let p = s.point(last)
123 context.fill(Path(ellipseIn: CGRect(x: p.x - 2.5, y: p.y - 2.5, width: 5, height: 5)), with: .color(accent.opacity(faint ? 0.3 : 1))) 137 context.fill(Path(ellipseIn: CGRect(x: p.x - 2.5, y: p.y - 2.5, width: 5, height: 5)), with: .color(accent.opacity(faint ? 0.3 : 1)))
124 if !faint { 138 if !faint { craftLabels.append((Text(craft.name).font(.caption2).foregroundStyle(accent), CGPoint(x: p.x + 6, y: p.y))) }
125 context.draw(Text(craft.name).font(.caption2).foregroundStyle(accent), at: CGPoint(x: p.x + 6, y: p.y), anchor: .leading)
126 }
127 } 139 }
128 140
129 for body in [SolarBody.mercury, .venus, .mars, .jupiter, .saturn, .uranus, .neptune] { 141 for body in [SolarBody.mercury, .venus, .mars, .jupiter, .saturn, .uranus, .neptune] {
@@ -132,9 +144,11 @@ public struct OrreryView: View {
132 let r: CGFloat = [.jupiter, .saturn].contains(body) ? 4 : 3 144 let r: CGFloat = [.jupiter, .saturn].contains(body) ? 4 : 3
133 context.fill(Path(ellipseIn: CGRect(x: p.x - r, y: p.y - r, width: 2 * r, height: 2 * r)), with: .color(ink)) 145 context.fill(Path(ellipseIn: CGRect(x: p.x - r, y: p.y - r, width: 2 * r, height: 2 * r)), with: .color(ink))
134 if [.jupiter, .saturn, .uranus, .neptune].contains(body) { 146 if [.jupiter, .saturn, .uranus, .neptune].contains(body) {
135 context.draw(Text(body.rawValue.capitalized).font(.caption2).foregroundStyle(ink.opacity(0.8)), at: CGPoint(x: p.x, y: p.y + 10)) 147 label(Text(body.rawValue.capitalized).font(.caption2).foregroundStyle(ink.opacity(0.8)), at: CGPoint(x: p.x, y: p.y + 10), anchor: .center)
136 } 148 }
137 } 149 }
150 for (text, p) in craftLabels { label(text, at: p, anchor: .leading) }
151 for l in labels { context.draw(l.text, at: l.at, anchor: l.anchor) }
138 if let earth = try? SkyEngine.heliocentricEarth(at: date) { 152 if let earth = try? SkyEngine.heliocentricEarth(at: date) {
139 let p = s.point(SIMD2(earth.x, earth.y)) 153 let p = s.point(SIMD2(earth.x, earth.y))
140 context.fill(Path(ellipseIn: CGRect(x: p.x - 3, y: p.y - 3, width: 6, height: 6)), with: .color(Color(red: 0.35, green: 0.6, blue: 0.95))) 154 context.fill(Path(ellipseIn: CGRect(x: p.x - 3, y: p.y - 3, width: 6, height: 6)), with: .color(Color(red: 0.35, green: 0.6, blue: 0.95)))