- iOS: Add KeychainHelper.swift for secure token storage - iOS: Add AuthService.swift (CMAuthService) with login/register/refresh/logout - iOS: Add LoginView.swift (CMLoginView) with ChronoMind theme - iOS: Wire auth gate in ChronoMindApp.swift (LoginView vs ContentView) - iOS: Add Account section to SettingsView with email/plan/sign-out - iOS: Add Cloud group + 3 files to Xcode project.pbxproj - Android: Add AuthService.kt with Hilt @Singleton, login/register/refresh/logout - Android: Add LoginScreen.kt with Compose login/register form - Android: Wire auth gate in MainActivity via Hilt-injected AuthService - Android: Add Account section to SettingsScreen via HiltViewModel - Android: Add x-product-id header to PlatformApiClient
48 lines
1.9 KiB
Swift
48 lines
1.9 KiB
Swift
// ── ChronoMind App Entry Point ─────────────────────────────────
|
|
|
|
import SwiftUI
|
|
import WidgetKit
|
|
|
|
@main
|
|
struct ChronoMindApp: App {
|
|
@StateObject private var timerStore = TimerStore()
|
|
@StateObject private var notificationManager = CMNotificationManager.shared
|
|
@StateObject private var gamification = GamificationStore.shared
|
|
@StateObject private var authService = CMAuthService.shared
|
|
|
|
var body: some Scene {
|
|
WindowGroup {
|
|
Group {
|
|
if authService.isLoggedIn {
|
|
ZStack {
|
|
ContentView()
|
|
.environmentObject(timerStore)
|
|
.environmentObject(notificationManager)
|
|
.environmentObject(gamification)
|
|
.preferredColorScheme(.dark)
|
|
.task {
|
|
notificationManager.registerCategories()
|
|
await notificationManager.requestPermission()
|
|
}
|
|
.onReceive(NotificationCenter.default.publisher(for: .chronoMindTimersDidChange)) { _ in
|
|
WidgetCenter.shared.reloadAllTimelines()
|
|
}
|
|
|
|
// Badge celebration overlay
|
|
if let badge = gamification.newBadge {
|
|
BadgeCelebrationOverlay(badge: badge) {
|
|
gamification.clearNewBadge()
|
|
}
|
|
.transition(.opacity)
|
|
.zIndex(100)
|
|
}
|
|
}
|
|
.animation(.easeInOut, value: gamification.newBadge != nil)
|
|
} else {
|
|
CMLoginView(authService: authService)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|