commit 07f4c3e161a0f20c22daf4b0afe0d9632a705738
parent 31bbcd351807fae0d7912388e3b213445de7abbd
Author: Jean Schurger <jean@schurger.org>
Date: Sat, 14 Nov 2026 15:16:33 -0500
Home and the other pre-camera screens on plain black, full screen; the home fits without scrolling
On a device the home screen was a translucent card over the live camera
preview. It is now a full screen on opaque black, like the dive computer
page, without the camera's top and bottom bars (its own info button opens
the diagnostics). In landscape it uses the whole safe area in two columns
and picks the largest type sizes that fit (regular, then compact); the
ScrollView only remains as a last resort. The fullest state (housing
detected, four pre-closing warnings, two denied permissions, last dive,
no-fly time, pending dives) fits on an iPhone SE.
The vacuum sequence cards, the opening cards and the "allow camera" card
are on black too: the preview shows only while the camera is usable (leak
test, sealed dive, simulation). The bottom bar (mode, counter, lenses) is
shown with the camera only. The capture session itself is unchanged.
Launch arguments for screenshots: -previewPattern (test pattern instead
of the preview), -demoHomeWorstCase, -demoVacuum.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Diffstat:
4 files changed, 177 insertions(+), 71 deletions(-)
diff --git a/OpenMerou/App/AppModel.swift b/OpenMerou/App/AppModel.swift
@@ -161,6 +161,11 @@ final class AppModel {
startSimulatedDive(profile, skip: UserDefaults.standard.double(forKey: "diveSkip"))
}
if arguments.contains("-computerPage") { showingComputer = true }
+ // "-demoVacuum": simulated housing brought back to the first card of the vacuum sequence.
+ if arguments.contains("-demoVacuum") {
+ housing.startSimulation()
+ housing.simulatedPress(.right, long: true)
+ }
}
/// Simulated housing: plays `profile` on its pressure sensor (a minute at the surface ends the dive).
diff --git a/OpenMerou/UI/CameraScreen.swift b/OpenMerou/UI/CameraScreen.swift
@@ -26,6 +26,29 @@ struct PreviewView: UIViewRepresentable {
func updateUIView(_ view: Host, context: Context) {}
}
+/// Stand-in for the camera preview ("-previewPattern"): the simulator has no camera, and screenshots must
+/// show what is opaque. Deliberately garish.
+struct PreviewPattern: View {
+ var body: some View {
+ Canvas { context, size in
+ let step = 40.0
+ var x = -size.height
+ var i = 0
+ while x < size.width {
+ var stripe = Path()
+ stripe.move(to: CGPoint(x: x, y: size.height))
+ stripe.addLine(to: CGPoint(x: x + size.height, y: 0))
+ stripe.addLine(to: CGPoint(x: x + size.height + step, y: 0))
+ stripe.addLine(to: CGPoint(x: x + step, y: size.height))
+ stripe.closeSubpath()
+ context.fill(stripe, with: .color(i % 2 == 0 ? Color(red: 1, green: 0, blue: 0.8) : Color(red: 0.2, green: 1, blue: 0)))
+ x += step
+ i += 1
+ }
+ }
+ }
+}
+
/// Main screen: the image full screen, the information around it, and on top the vacuum
/// sequence as long as it keeps the buttons.
struct CameraScreen: View {
@@ -39,32 +62,47 @@ struct CameraScreen: View {
var body: some View {
ZStack {
Color.black.ignoresSafeArea()
- PreviewView(layer: model.engine.previewLayer).ignoresSafeArea()
+ if CommandLine.arguments.contains("-previewPattern") {
+ PreviewPattern().ignoresSafeArea()
+ } else {
+ PreviewView(layer: model.engine.previewLayer).ignoresSafeArea()
+ }
// Shutter blink: the image goes dark for an instant at each photo.
Color.black.ignoresSafeArea().opacity(flashing ? 1 : 0).allowsHitTesting(false)
+ // Before and after the camera (home, vacuum sequence, opening), the preview is of no use: those
+ // screens are on plain black, like the dive computer page. During the leak test the camera is
+ // usable, and visible.
+ if !cameraInUse { Color.black.ignoresSafeArea() }
+
// Dive computer alarm: the whole screen flashes red, under the read-outs.
if diveAlarm { AlarmFlash().allowsHitTesting(false) }
if showingComputer { ComputerPage(model: model) }
VStack {
- topBar
+ // The home screen has the whole screen; the bottom bar only describes the camera.
+ if !isHome { topBar }
if model.dive.isComputing, !showingComputer { DiveBand(model: model) }
if model.settings.developer { devOverlay }
Spacer()
if let message = model.toast, !model.menu.isOpen {
Text(message).font(.footnote).padding(8).background(.black.opacity(0.5), in: Capsule())
}
- bottomBar
+ if cameraInUse { bottomBar }
}
.padding()
Group {
if !model.camera.authorized {
card { Text("Allow camera access in Settings → Open Mérou.") }
- } else if housing.vacuum.step == .prepare, !housing.simulated {
- HomeScreen(model: model)
+ } else if isHome {
+ HomeScreen(model: model) { showDiagnostics = true }
+ .overlay(alignment: .bottom) {
+ if let message = model.toast {
+ Text(message).font(.footnote).padding(8).background(.gray.opacity(0.4), in: Capsule()).padding(.bottom, 6)
+ }
+ }
} else if !housing.vacuum.cameraHasButtons {
card {
VacuumView(vacuum: housing.vacuum)
@@ -122,6 +160,11 @@ struct CameraScreen: View {
}
}
+ /// The buttons go to the camera (leak test, sealed dive, simulation): the preview is what matters.
+ private var cameraInUse: Bool { model.camera.authorized && housing.vacuum.cameraHasButtons }
+ /// Home screen: no housing sequence started yet (a simulated housing goes straight to the camera).
+ private var isHome: Bool { model.camera.authorized && housing.vacuum.step == .prepare && !housing.simulated }
+
/// The dive computer is following a dive and raises an alarm (violation, depth unknown).
private var diveAlarm: Bool { model.dive.isComputing && model.dive.monitor.isAlarming }
/// The computer page is a camera-mode page: never over the vacuum sequence.
diff --git a/OpenMerou/UI/HomeScreen.swift b/OpenMerou/UI/HomeScreen.swift
@@ -7,8 +7,14 @@ import SwiftUI
/// One side is the housing: searched from launch, then its right button starts the vacuum sequence (or a
/// simulated housing instead). The other is the home of the optional dive computer, as on the watch: gas
/// and conservatism, settings, last dive and waiting time before flying, dives pending for Sub Rascasse.
+///
+/// It is a full screen on plain black, like the dive computer page: no camera preview behind it, no camera
+/// bars around it. In landscape everything must be visible without scrolling: the regular sizes are tried
+/// first, then the compact ones; scrolling is only the last resort (very large Dynamic Type).
struct HomeScreen: View {
let model: AppModel
+ /// Opens the diagnostics sheet (the ⓘ of the camera's top bar, which the home screen does not show).
+ let showDiagnostics: () -> Void
@Environment(\.openURL) private var openURL
@State private var showSettings = CommandLine.arguments.contains("-showDiveSettings")
@State private var showTerms = CommandLine.arguments.contains("-showTerms")
@@ -17,23 +23,43 @@ struct HomeScreen: View {
/// Sub Rascasse imports the pending dives when it is opened with this URL.
static let subRascasseURL = URL(string: "subrascasse://open-merou")!
+ /// Type sizes and spacing of one way of laying the screen out.
+ struct Metrics {
+ var title: Font, headline: Font, text: Font, note: Font
+ var spacing: CGFloat, columnSpacing: CGFloat, control: ControlSize
+
+ static let regular = Metrics(title: .title2.bold(), headline: .headline, text: .body, note: .footnote,
+ spacing: 10, columnSpacing: 32, control: .regular)
+ static let compact = Metrics(title: .title3.bold(), headline: .subheadline.weight(.semibold), text: .footnote,
+ note: .caption, spacing: 5, columnSpacing: 20, control: .small)
+ }
+
private var dive: DiveSession { model.dive }
+ /// "-demoHomeWorstCase": the fullest home screen there can be (screenshots, to check that it fits).
+ private var worstCase: Bool { CommandLine.arguments.contains("-demoHomeWorstCase") }
var body: some View {
GeometryReader { geometry in
- let layout = geometry.size.width > geometry.size.height
- ? AnyLayout(HStackLayout(alignment: .top, spacing: 28))
- : AnyLayout(VStackLayout(alignment: .leading, spacing: 20))
- ScrollView {
- layout {
- housingColumn.frame(maxWidth: .infinity, alignment: .leading)
- computerColumn.frame(maxWidth: .infinity, alignment: .leading)
+ if geometry.size.width > geometry.size.height {
+ ViewThatFits(in: .vertical) {
+ columns(.regular)
+ columns(.compact)
+ ScrollView { columns(.compact) }
+ }
+ .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
+ } else {
+ // Portrait orientation setting: one column, with room to scroll.
+ ScrollView {
+ VStack(alignment: .leading, spacing: 24) {
+ housingColumn(.regular)
+ computerColumn(.regular)
+ }
+ .frame(maxWidth: .infinity, alignment: .leading)
}
- .padding(20)
}
}
- .background(.black.opacity(0.8), in: RoundedRectangle(cornerRadius: 20))
- .padding(.horizontal, 12).padding(.vertical, 40)
+ .padding(.horizontal, 16).padding(.vertical, 10)
+ .background(Color.black.ignoresSafeArea())
.sheet(isPresented: $showSettings) { settingsSheet }
.sheet(isPresented: $showTerms) { termsSheet }
.task {
@@ -42,45 +68,62 @@ struct HomeScreen: View {
}
}
+ private func columns(_ m: Metrics) -> some View {
+ HStack(alignment: .top, spacing: m.columnSpacing) {
+ housingColumn(m).frame(maxWidth: .infinity, alignment: .leading)
+ computerColumn(m).frame(maxWidth: .infinity, alignment: .leading)
+ }
+ .controlSize(m.control)
+ }
+
// MARK: Housing
/// What is worth fixing before closing the housing.
private var checks: [String] {
var lines: [String] = []
- if let b = model.housing.readings.batteryPercent, b < 30 { lines.append(String(localized: "Housing battery low: \(String(b)) %")) }
- if let b = model.phoneBattery, b < 30 { lines.append(String(localized: "iPhone battery low: \(String(b)) %")) }
- if let minutes = model.videoMinutesLeft, minutes < 20 {
+ let housingBattery = worstCase ? 24 : model.housing.readings.batteryPercent
+ let phoneBattery = worstCase ? 18 : model.phoneBattery
+ let minutes = worstCase ? 12 : model.videoMinutesLeft
+ if let b = housingBattery, b < 30 { lines.append(String(localized: "Housing battery low: \(String(b)) %")) }
+ if let b = phoneBattery, b < 30 { lines.append(String(localized: "iPhone battery low: \(String(b)) %")) }
+ if let minutes, minutes < 20 {
lines.append(String(localized: "Low free space: about \(String(minutes)) min of video in \(model.settings.videoQuality.label)"))
}
- if model.online { lines.append(String(localized: "Airplane mode recommended (keep Bluetooth on)")) }
+ if model.online || worstCase { lines.append(String(localized: "Airplane mode recommended (keep Bluetooth on)")) }
return lines
}
+ private var denied: [String] {
+ worstCase ? [String(localized: "microphone (videos without sound)"), String(localized: "photo library (nothing will be saved)")]
+ : model.camera.denied
+ }
+
/// A real housing answers ("-demoHousingDetected": shown as such for screenshots, nothing else changes).
private var housingDetected: Bool {
- model.housing.isConnected || CommandLine.arguments.contains("-demoHousingDetected")
+ model.housing.isConnected || worstCase || CommandLine.arguments.contains("-demoHousingDetected")
}
/// The housing is searched from launch, nothing to touch: "searching" until it answers, then what to do
/// before closing it and the prompt to press its right button, which starts the vacuum sequence.
- private var housingColumn: some View {
+ private func housingColumn(_ m: Metrics) -> some View {
let housing = model.housing
- return VStack(alignment: .leading, spacing: 12) {
- Text("Open Mérou").font(.title2.bold())
+ return VStack(alignment: .leading, spacing: m.spacing) {
+ Text("Open Mérou").font(m.title)
if housingDetected {
- VStack(alignment: .leading, spacing: 6) {
- Label("Housing detected", systemImage: "checkmark.circle.fill").font(.headline).foregroundStyle(.green)
+ Label("Housing detected", systemImage: "checkmark.circle.fill").font(m.headline).foregroundStyle(.green)
+ Group {
if let p = housing.vacuum.pressurePa, p < VacuumSequence.alreadyUnderVacuumPa {
Text("It is already under vacuum: the leak test will start right away.")
} else {
Text("Put the iPhone in place (airplane mode recommended, Bluetooth on), close the housing and lock the latch.")
}
- ForEach(checks, id: \.self) { line in
- Label(line, systemImage: "exclamationmark.triangle.fill").font(.footnote).foregroundStyle(.orange)
- }
- Text("Press the right button of the housing to continue").font(.headline)
}
+ .font(m.text)
+ ForEach(checks, id: \.self) { line in
+ Label(line, systemImage: "exclamationmark.triangle.fill").font(m.note).foregroundStyle(.orange)
+ }
+ Text("Press the right button of the housing to continue").font(m.headline)
} else {
// Not a real button: it "confirms" by itself when the housing answers.
Button {} label: {
@@ -103,7 +146,7 @@ struct HomeScreen: View {
}
.buttonStyle(.bordered)
.disabled(true)
- Text("Turn the housing on: it will be detected automatically.").font(.footnote).foregroundStyle(.secondary)
+ Text("Turn the housing on: it will be detected automatically.").font(m.note).foregroundStyle(.secondary)
// Only offered while no housing answers: once one is detected the column must fit the screen.
Button { housing.startSimulation() } label: {
Label("Simulate a housing", systemImage: "play.rectangle.fill").frame(maxWidth: .infinity)
@@ -111,13 +154,14 @@ struct HomeScreen: View {
.buttonStyle(.bordered)
}
- ForEach(model.camera.denied, id: \.self) { item in
+ ForEach(denied, id: \.self) { item in
Label("Permission denied: \(item). Settings → Open Mérou.", systemImage: "exclamationmark.triangle.fill")
- .font(.footnote).foregroundStyle(.orange)
+ .font(m.note).foregroundStyle(.orange)
}
Text("Set everything here before closing the housing: once it is closed, only its five buttons work.")
- .font(.footnote).foregroundStyle(.secondary)
+ .font(m.note).foregroundStyle(.secondary)
}
+ .fixedSize(horizontal: false, vertical: true)
}
// MARK: Dive computer
@@ -129,64 +173,76 @@ struct HomeScreen: View {
})
}
- private var computerColumn: some View {
- VStack(alignment: .leading, spacing: 10) {
- Toggle(isOn: enabled) { Text("Dive computer").font(.title2.bold()) }
- .tint(.cyan)
+ private func computerColumn(_ m: Metrics) -> some View {
+ VStack(alignment: .leading, spacing: m.spacing) {
+ HStack(spacing: 12) {
+ Toggle(isOn: enabled) { Text("Dive computer").font(m.title) }
+ .tint(.cyan)
+ // Diagnostics of the housing (the camera's top bar, with its ⓘ, is not shown on this screen).
+ Button(action: showDiagnostics) { Image(systemName: "info.circle").font(m.title) }
+ }
if dive.isActive {
- computerOn
+ computerOn(m)
} else if dive.enabled {
Button { showTerms = true } label: { Label("Read and accept the terms", systemImage: "doc.text") }
.buttonStyle(.bordered)
} else {
Text("Off: the app only shows the depth, the dive time and the temperature inside the housing. Nothing is recorded.")
- .font(.footnote).foregroundStyle(.secondary)
+ .font(m.note).foregroundStyle(.secondary)
}
}
+ .fixedSize(horizontal: false, vertical: true)
}
- @ViewBuilder private var computerOn: some View {
+ @ViewBuilder private func computerOn(_ m: Metrics) -> some View {
let store = dive.store, settings = store.settings
- VStack(alignment: .leading, spacing: 2) {
- Text(verbatim: "\(settings.gas.description) · \(SettingsText.conservatism(settings))").font(.headline)
- Text("max \(Format.depth(settings.maximumOperatingDepth())) m for this gas")
- .font(.footnote).foregroundStyle(.secondary)
+ HStack(alignment: .center, spacing: 10) {
+ VStack(alignment: .leading, spacing: 2) {
+ Text(verbatim: "\(settings.gas.description) · \(SettingsText.conservatism(settings))").font(m.headline)
+ Text("max \(Format.depth(settings.maximumOperatingDepth())) m for this gas")
+ .font(m.note).foregroundStyle(.secondary)
+ }
+ Spacer(minLength: 0)
+ Button { showSettings = true } label: { Label("Settings", systemImage: "gearshape") }
+ .buttonStyle(.bordered)
}
- Button { showSettings = true } label: { Label("Settings", systemImage: "gearshape") }
- .buttonStyle(.bordered)
- if model.housing.isConnected, dive.sensorImplausible {
+ if (model.housing.isConnected && dive.sensorImplausible) || worstCase {
Label("The depth sensor of the housing gives implausible values: no dive computer.", systemImage: "exclamationmark.triangle.fill")
- .font(.footnote).foregroundStyle(.orange)
+ .font(m.note).foregroundStyle(.orange)
}
if let last = store.lastDive {
let fly = store.noFlyHours()
- VStack(alignment: .leading, spacing: 4) {
+ Group {
Text("Last dive: \(Format.dayTime(last.start)) · \(Format.depth(last.maxDepth)) m · \(Format.minutes(last.duration))")
Label(fly > 0 ? "Flying: wait another \(Format.hours(fly))" : "Flying: no more restriction", systemImage: "airplane")
- if store.pending > 0 {
- // Plural forms are in the String Catalog.
- Label("\(store.pending) dives waiting for Sub Rascasse", systemImage: "tray.and.arrow.up")
- } else if store.sharedFolderAvailable {
- Label("All dives are in Sub Rascasse", systemImage: "checkmark.circle")
- }
- if subRascasseInstalled {
- Button { openURL(Self.subRascasseURL) } label: { Label("Open Sub Rascasse", systemImage: "book.pages") }
- .buttonStyle(.bordered)
+ HStack(spacing: 10) {
+ if store.pending > 0 {
+ // Plural forms are in the String Catalog.
+ Label("\(store.pending) dives waiting for Sub Rascasse", systemImage: "tray.and.arrow.up")
+ } else if store.sharedFolderAvailable {
+ Label("All dives are in Sub Rascasse", systemImage: "checkmark.circle")
+ }
+ Spacer(minLength: 0)
+ if subRascasseInstalled || worstCase {
+ Button { openURL(Self.subRascasseURL) } label: { Label("Open Sub Rascasse", systemImage: "book.pages").labelStyle(.iconOnly) }
+ .buttonStyle(.bordered)
+ .accessibilityLabel(Text("Open Sub Rascasse"))
+ }
}
}
- .font(.footnote)
+ .font(m.note)
}
- if !store.sharedFolderAvailable {
- Text("Shared folder unavailable: dives stay in this app.").font(.footnote).foregroundStyle(.orange)
+ if !store.sharedFolderAvailable || worstCase {
+ Text("Shared folder unavailable: dives stay in this app.").font(m.note).foregroundStyle(.orange)
}
- if let error = store.lastError { Text(error).font(.footnote).foregroundStyle(.red) }
+ if let error = store.lastError { Text(error).font(m.note).foregroundStyle(.red) }
Text("Secondary computer, not certified. To be used with a primary dive computer.")
- .font(.footnote).foregroundStyle(.secondary)
- Link(destination: DiveSession.terms.link) { Text("Terms of use").font(.footnote) }
+ .font(m.note).foregroundStyle(.secondary)
+ Link(destination: DiveSession.terms.link) { Text("Terms of use").font(m.note) }
}
// MARK: Sheets
diff --git a/README.md b/README.md
@@ -28,7 +28,7 @@ words, colours and alarms. **It is not a certified dive computer**: a secondary
primary dive computer. The depth comes from the housing's external pressure sensor, which has not been
validated underwater yet.
-- Home screen (touch, before the housing is closed): gas and conservatism, settings, last dive and waiting
+- Home screen (touch, before the housing is closed; full screen on black, no camera preview): gas and conservatism, settings, last dive and waiting
time before flying, dives pending for Sub Rascasse. The housing is searched from launch; once it is
detected, its right button starts the vacuum sequence, then the camera.
- Underwater (housing buttons only): a band over the camera shows depth, dive time, ascent rate and the NDL
@@ -59,12 +59,14 @@ Or work directly on a Mac: run `xcodegen` at the root of the repository and open
English is the source language of the interface; the French translation lives in
`OpenMerou/Localizable.xcstrings` and `OpenMerou/InfoPlist.xcstrings`.
-Launch options: `-simulation` (simulated housing from the start), `-demoMenu` (opens the settings menu).
-For the dive computer: `-diveComputer YES -acceptTerms` (on for this launch), `-simulateDive reef|deep|shallow`
-(simulated housing playing a dive on its pressure sensor; `-diveSkip <seconds>` jumps into it), `-computerPage`,
-`-testAlarm`, `-demoLogbook` (a past dive on the home screen), `-demoHousingDetected` (home screen as with a housing), `-showDiveSettings`, `-showTerms`,
-`-noPermissionPrompts` (screenshots in the simulator). In the simulated housing, "Simulate a dive" does the
-same by touch.
+Launch options: `-simulation` (simulated housing from the start), `-demoMenu` (opens the settings menu). For
+the dive computer: `-diveComputer YES -acceptTerms` (on for this launch), `-simulateDive reef|deep|shallow`
+(simulated housing playing a dive on its pressure sensor; `-diveSkip <seconds>` jumps into it),
+`-computerPage`, `-testAlarm`, `-demoLogbook` (a past dive on the home screen), `-demoHousingDetected` (home
+screen as with a housing), `-demoHomeWorstCase` (the fullest home screen), `-previewPattern` (a test pattern
+instead of the camera preview), `-demoVacuum` (simulated housing at the first card of the vacuum sequence),
+`-showDiveSettings`, `-showTerms`, `-noPermissionPrompts` (screenshots in the simulator). In the simulated
+housing, "Simulate a dive" does the same by touch.
Tools: `tools/pklg.py` decodes an iOS Bluetooth log (PacketLogger, sysdiagnose); `tools/make-sounds.py`
generates the alert tones of `OpenMerou/Sounds`.