Bei lokalen Xcode-Run-Builds wird beim Start automatisch eingeloggt wenn der Keychain leer ist. Spart das manuelle Login bei jedem Re-Install via Xcode. - Sources/Core/Auth/DebugCredentials.swift — #if DEBUG-gewrappte Founder-Credentials (tills95@gmail.com / Aa-123456789) - Sources/Core/Auth/AuthClient+EnsureSignedIn.swift — Extension ensureSignedIn() prüft .signedOut → signIn() in DEBUG - RootView.task ruft auth.ensureSignedIn() — Release-Builds No-Op (Release/TestFlight/App-Store bleiben unverändert, User muss manuell einloggen) Pattern 1:1 von memoro-native (gleiches File-Layout + Klassennamen). Build 9 → 10. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
67 lines
2.1 KiB
Swift
67 lines
2.1 KiB
Swift
import ManaCore
|
|
import SwiftUI
|
|
|
|
/// Top-Level-Switch: Login vs Haupt-App. Haupt-App ist eine TabBar mit
|
|
/// drei Tabs (Decks / Entdecken / Account).
|
|
struct RootView: View {
|
|
@Environment(AuthClient.self) private var auth
|
|
@State private var selectedTab: AppTab = .decks
|
|
@State private var pendingDeepLinkSlug: String?
|
|
|
|
var body: some View {
|
|
Group {
|
|
switch auth.status {
|
|
case .signedIn:
|
|
mainTabs
|
|
.onOpenURL { url in handle(url: url) }
|
|
.onContinueUserActivity(NSUserActivityTypeBrowsingWeb) { activity in
|
|
if let url = activity.webpageURL { handle(url: url) }
|
|
}
|
|
case .unknown, .signedOut, .signingIn, .error:
|
|
LoginView()
|
|
}
|
|
}
|
|
.task {
|
|
await auth.ensureSignedIn()
|
|
}
|
|
}
|
|
|
|
@ViewBuilder
|
|
private var mainTabs: some View {
|
|
TabView(selection: $selectedTab) {
|
|
DeckListView()
|
|
.tabItem { Label("Decks", systemImage: "rectangle.stack") }
|
|
.tag(AppTab.decks)
|
|
|
|
ExploreView(deepLinkSlug: $pendingDeepLinkSlug)
|
|
.tabItem { Label("Entdecken", systemImage: "sparkles") }
|
|
.tag(AppTab.explore)
|
|
|
|
NavigationStack {
|
|
AccountView()
|
|
}
|
|
.tabItem { Label("Account", systemImage: "person.crop.circle") }
|
|
.tag(AppTab.account)
|
|
}
|
|
}
|
|
|
|
/// Universal-Link- und URL-Scheme-Handler:
|
|
/// - `https://cardecky.mana.how/d/<slug>` → Explore-Tab + PublicDeckView
|
|
/// - `cards://study/<deckId>` → später (β-6 Notifications)
|
|
private func handle(url: URL) {
|
|
Log.app.info("Open URL: \(url.absoluteString, privacy: .public)")
|
|
if url.host == "cardecky.mana.how" || url.scheme == "cards" {
|
|
let parts = url.pathComponents.filter { $0 != "/" }
|
|
if parts.count >= 2, parts[0] == "d" {
|
|
pendingDeepLinkSlug = parts[1]
|
|
selectedTab = .explore
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
enum AppTab: Hashable {
|
|
case decks
|
|
case explore
|
|
case account
|
|
}
|