PulseCanvas / app · pulsecanvas.ai / mobile / PulseCanvasMobileApp.swift
| 1 | import AVFoundation |
| 2 | import SwiftUI |
| 3 | |
| 4 | @main struct PulseCanvasMobileApp: App { |
| 5 | @StateObject private var editor = { _ = UserBackup.startupError; return MobileEditor() }() |
| 6 | var body: some Scene { |
| 7 | WindowGroup { MobileWorkspace(editor: editor) |
| 8 | .preferredColorScheme(.dark) |
| 9 | .modifier(PulseCanvasOnboardingPresentation(onReplay: { editor.audio.pause() })) |
| 10 | // Prepare while the welcome pages are visible; immediate Skip is |
| 11 | // also safe because both tasks keep their work off the UI thread. |
| 12 | .task { await editor.start() } |
| 13 | .task { CloudSyncService.shared.start() } |
| 14 | .onReceive(NotificationCenter.default.publisher(for: .pulseCanvasCloudDataApplied)) { _ in |
| 15 | editor.studio.reloadCloudPresets(); editor.radio.reloadCloudFavorites() |
| 16 | if !editor.audio.isPlaying { editor.studio.apply(to: editor.render) } |
| 17 | } |
| 18 | .task { try? await VisualizerRenderer.prepareLiveAssets() } } |
| 19 | } |
| 20 | } |