Files
swiftapp/swift/Sources/App/IDPGlobalApp.swift
Jürgen Kunz a6939453f8
Some checks failed
CI / test (push) Has been cancelled
Adopt root-level tsswift app layout
Move the app payload under swift/ while keeping git, package.json, and .smartconfig.json at the repo root. This standardizes the Swift app setup so build, test, run, and watch workflows match the other repos.
2026-04-19 01:21:43 +02:00

55 lines
1.3 KiB
Swift

import SwiftUI
@main
struct IDPGlobalApp: App {
@StateObject private var model = AppViewModel()
var body: some Scene {
WindowGroup {
RootView(model: model)
.tint(AppTheme.accent)
.task {
await model.bootstrap()
}
.alert("Something went wrong", isPresented: errorPresented) {
Button("OK") {
model.errorMessage = nil
}
} message: {
Text(model.errorMessage ?? "")
}
}
#if os(macOS)
.defaultSize(width: 1380, height: 920)
#endif
}
private var errorPresented: Binding<Bool> {
Binding(
get: { model.errorMessage != nil },
set: { isPresented in
if !isPresented {
model.errorMessage = nil
}
}
)
}
}
private struct RootView: View {
@ObservedObject var model: AppViewModel
var body: some View {
Group {
if model.session == nil {
LoginRootView(model: model)
} else {
HomeRootView(model: model)
}
}
.background {
AppBackground()
}
}
}