41 lines
1.5 KiB
Swift
41 lines
1.5 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
|
|
|
|
var body: some Scene {
|
|
WindowGroup {
|
|
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)
|
|
}
|
|
}
|
|
}
|