// 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, library: model.library, hardwareSampleRate: { model.hardwareSampleRate }, onEnableLiveInput: { model.enableLiveInput() }, midi: model.midi ) .navigationTitle("ShoeGaze Builder") .navigationBarTitleDisplayMode(.inline) .task { await model.startLibrary() } } .onDisappear { model.stop() } .onOpenURL { url in model.importDocument(at: url) } } .onChange(of: scenePhase) { _, phase in // Persist the rig whenever the app leaves the foreground. if phase != .active { model.save() } } } }