// 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`` draws its own header/title and manages its own scroll regions (palette /// + board canvas), so it is hosted directly — no `NavigationStack`, title, or outer `ScrollView`. /// A fill frame keeps it pinned to the full window so portrait isn't vertically centered. @main struct ShoeGazeBuilderiOSApp: App { @State private var model: ShoeGazeBuilderiOSAppModel = ShoeGazeBuilderiOSAppModel() @State private var showSplash: Bool = true @Environment(\.scenePhase) private var scenePhase var body: some Scene { WindowGroup { ZStack { ShoeGazeBuilderView( shoeGaze: model.shoeGaze, library: model.library, hardwareSampleRate: { model.hardwareSampleRate }, onEnableLiveInput: { model.enableLiveInput() }, midi: model.midi ) .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading) .task { await model.startLibrary() } .onDisappear { model.stop() } .onOpenURL { url in model.importDocument(at: url) } if showSplash { SplashView(isActive: $showSplash) .transition(.opacity) .zIndex(1) } } } .onChange(of: scenePhase) { _, phase in // Persist the rig whenever the app leaves the foreground. if phase != .active { model.save() } } } }