RootView ohne Hard-Login-Gate — TabBar zeigt sich immer, beim Start wechselt App bei .signedOut automatisch in den anonymen .guest-Modus (mana-swift-core v1.2.0). Auth-Sheets (Login, SignUp, Forgot, Reset) hängen jetzt als ManaAuthGate-Modifier am Root. AccountView zeigt im Guest-Modus eine eigene CTA-Surface („Anmelden / Konto erstellen" + Hinweis was Login bringt). signOut nutzt keepGuestMode: true → App bleibt nach Logout anonym nutzbar, Marketplace und lokale Daten gehen nicht verloren. DeckListView: Empty-State im Guest-Mode mit Login-CTA + Marketplace- Hinweis. Toolbar-„+"-Button via authGate.require gewrappt — Tap aus dem Guest-Modus öffnet erst das Sign-In-Sheet, danach den Editor. DeckListStore.refresh() skippt im Guest-Mode (kein 401-Spam). Cache wird so wie er ist gerendert (heute leer, später Marketplace-Klone). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
37 lines
1.1 KiB
Swift
37 lines
1.1 KiB
Swift
import ManaAuthUI
|
|
import ManaCore
|
|
import SwiftData
|
|
import SwiftUI
|
|
|
|
@main
|
|
struct CardsNativeApp: App {
|
|
let container: ModelContainer
|
|
@State private var auth: AuthClient
|
|
@State private var authGate: ManaAuthGate
|
|
private let mediaCache: MediaCache
|
|
|
|
init() {
|
|
do {
|
|
container = try ModelContainer(for: CachedDeck.self, PendingGrade.self)
|
|
} catch {
|
|
fatalError("Failed to init ModelContainer: \(error)")
|
|
}
|
|
let auth = AuthClient(config: AppConfig.manaAppConfig)
|
|
auth.bootstrap()
|
|
_auth = State(initialValue: auth)
|
|
_authGate = State(initialValue: ManaAuthGate(auth: auth))
|
|
mediaCache = MediaCache(api: CardsAPI(auth: auth))
|
|
Log.app.info("Cardecky starting — auth status: \(String(describing: auth.status), privacy: .public)")
|
|
}
|
|
|
|
var body: some Scene {
|
|
WindowGroup {
|
|
RootView()
|
|
.environment(auth)
|
|
.environment(authGate)
|
|
.environment(\.mediaCache, mediaCache)
|
|
.tint(CardsTheme.primary)
|
|
}
|
|
.modelContainer(container)
|
|
}
|
|
}
|