Files
KisaniCal/KisaniCal/KisaniCalApp.swift
Robin Kutesa d424a2a814 Clear demo data, namespace storage by user, add profile setup
- Remove all personal sampleTasks from TaskViewModel (tasks start empty)
- Namespace UserDefaults keys by Apple ID for task and workout data isolation
- Add ProfileSetupView for name capture after first Sign in with Apple
- Add updateDisplayName() to AuthManager
- Route to ProfileSetupView when user has no display name yet

Co-Authored-By: Kutesir <tqwyy79vzn@privaterelay.appleid.com>
2026-06-01 01:31:55 +03:00

61 lines
2.0 KiB
Swift

import SwiftUI
@main
struct KisaniCalApp: App {
@UIApplicationDelegateAdaptor private var appDelegate: AppDelegate
@ObservedObject private var auth = AuthManager.shared
@State private var splashDone = false
var body: some Scene {
WindowGroup {
ZStack {
if auth.isAuthenticated {
let hasName = !(auth.currentUser?.displayName?.trimmingCharacters(in: .whitespaces).isEmpty ?? true)
if hasName {
ContentView()
.transition(.opacity)
} else {
ProfileSetupView()
.transition(.opacity)
}
} else {
AuthView()
.transition(.opacity)
}
if !splashDone {
SplashView { splashDone = true }
.transition(.opacity)
}
}
.animation(.easeIn(duration: 0.25), value: splashDone)
.animation(KisaniSpring.entrance, value: auth.isAuthenticated)
}
}
}
final class AppDelegate: NSObject, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
NotificationManager.shared.requestPermission()
ShortcutHandler.registerShortcuts()
// Cold launch from a shortcut
if let item = launchOptions?[.shortcutItem] as? UIApplicationShortcutItem {
ShortcutHandler.shared.handle(item.type)
return false // tells UIKit we handled it
}
return true
}
func application(
_ application: UIApplication,
performActionFor shortcutItem: UIApplicationShortcutItem,
completionHandler: @escaping (Bool) -> Void
) {
ShortcutHandler.shared.handle(shortcutItem.type)
completionHandler(true)
}
}