Repository Public
1// Author: Simon-Pierre Boucher — contact@spboucher.ai2// File: App/SPDriveApp.swift3// Description: Entry point of SP Drive: main windows (several can be open on the same account), the settings window and the menu bar Command Center, all on one model.4import CoreSpotlight5import SwiftUI67@main8struct SPDriveApp: App {9 @NSApplicationDelegateAdaptor(AppDelegate.self) private var delegate10 @State private var model = AppModel()1112 var body: some Scene {13 WindowGroup(AppEnvironment.productName, id: "main") {14 RootView()15 .environment(model)16 .frame(minWidth: 900, minHeight: 540)17 .task { delegate.model = model; await model.bootstrap() }18 .onContinueUserActivity(CSSearchableItemActionType) { activity in19 if let id = activity.userInfo?[CSSearchableItemActivityIdentifier] as? String { model.reveal(itemID: id) } // a Spotlight result of SP Drive20 }21 }22 .defaultSize(width: 1180, height: 760)23 .commands { AppCommands(model: model, bridge: model.menuBridge) }2425 Window("Demander à mon Drive", id: "ask") {26 if model.phase == .signedIn, !model.locked { AskView(model: model, nav: nil, item: nil).frame(minWidth: 520, minHeight: 560) }27 else { SPDEmptyState(symbol: "sparkles", title: "SP Drive AI", message: "Connectez-vous à SP Drive pour poser des questions à vos documents.").frame(minWidth: 520, minHeight: 400) }28 }29 .defaultSize(width: 640, height: 720)3031 Settings { SettingsView().environment(model) }3233 MenuBarExtra(isInserted: Binding(get: { model.settings.showMenuBarIcon }, set: { model.settings.showMenuBarIcon = $0 })) {34 MenuBarView().environment(model)35 } label: { MenuBarLabel().environment(model) }36 .menuBarExtraStyle(.window)37 }38}39