0d17ed260b
Persistence (macOS + iOS): - RigStore autosaves the rig (rigData JSON) to Application Support and restores it on launch. App models restore-or-seed at init; macOS saves on terminate + resignActive, iOS saves on scenePhase leaving .active. The builder also autosaves after structural edits (add board/pedal, load, clear). Clear (both platforms): - A Clear button in the builder opens a confirmation dialog: Save & Clear / Clear Without Saving / Cancel. Clear removes all boards and seeds one fresh empty board, then autosaves. Save & Clear triggers the save mechanism and only clears once the save completes (cancelling the save leaves the rig intact). - The rig-save exporter is now cross-platform (was iOS-only) so Save and the Save & Clear flow work on macOS too; macOS keeps its File-menu Load. Tests: RigStore save/restore round-trip across instances; restore is a no-op with no autosave. 186 tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
43 lines
1.5 KiB
Swift
43 lines
1.5 KiB
Swift
// ShoeGazeBuilderiOSApp.swift
|
|
// Lyrebird
|
|
//
|
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import SwiftUI
|
|
import LyrebirdShoeGazeUI
|
|
|
|
/// iOS entry point for the ShoeGaze Builder.
|
|
///
|
|
/// Holds the `ShoeGazeBuilderiOSAppModel` as `@State` so it is created once and owned for the
|
|
/// lifetime of the app. The audio engine is **not** started automatically — the user presses
|
|
/// Start in ``ShoeGazeBuilderView``. The engine is stopped when the view disappears.
|
|
///
|
|
/// ``ShoeGazeBuilderView`` manages its own scroll regions (palette + builder), so it is hosted
|
|
/// directly rather than wrapped in an outer `ScrollView`.
|
|
@main
|
|
struct ShoeGazeBuilderiOSApp: App {
|
|
|
|
@State private var model: ShoeGazeBuilderiOSAppModel = ShoeGazeBuilderiOSAppModel()
|
|
@Environment(\.scenePhase) private var scenePhase
|
|
|
|
var body: some Scene {
|
|
WindowGroup {
|
|
NavigationStack {
|
|
ShoeGazeBuilderView(
|
|
shoeGaze: model.shoeGaze,
|
|
hardwareSampleRate: { model.hardwareSampleRate },
|
|
onEnableLiveInput: { model.enableLiveInput() }
|
|
)
|
|
.navigationTitle("ShoeGaze Builder")
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
}
|
|
.onDisappear { model.stop() }
|
|
}
|
|
.onChange(of: scenePhase) { _, phase in
|
|
// Persist the rig whenever the app leaves the foreground.
|
|
if phase != .active { model.save() }
|
|
}
|
|
}
|
|
}
|