06/11 Fix some errors: submission datetime incorrect; inspection & issue not linked, etc
This commit is contained in:
@@ -6,6 +6,52 @@ import SwiftUI
|
||||
import SwiftData
|
||||
import BackgroundTasks
|
||||
import UserNotifications
|
||||
import Combine
|
||||
|
||||
// ── AppearanceManager ─────────────────────────────────────────────────────────
|
||||
// Persists the user's preferred colour scheme to UserDefaults and exposes it
|
||||
// as a @Published property so the root view can apply .preferredColorScheme.
|
||||
// "system" (nil) means the app follows iOS system appearance — the default.
|
||||
|
||||
enum AppearanceMode: String, CaseIterable {
|
||||
case system = "system"
|
||||
case light = "light"
|
||||
case dark = "dark"
|
||||
|
||||
var displayName: String {
|
||||
switch self {
|
||||
case .system: return "System"
|
||||
case .light: return "Light"
|
||||
case .dark: return "Dark"
|
||||
}
|
||||
}
|
||||
|
||||
/// The SwiftUI ColorScheme value to pass to .preferredColorScheme().
|
||||
/// nil = follow the OS (system default).
|
||||
var colorScheme: ColorScheme? {
|
||||
switch self {
|
||||
case .system: return nil
|
||||
case .light: return .light
|
||||
case .dark: return .dark
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final class AppearanceManager: ObservableObject {
|
||||
static let shared = AppearanceManager()
|
||||
private static let defaultsKey = "jqc.appearanceMode"
|
||||
|
||||
@Published var mode: AppearanceMode {
|
||||
didSet {
|
||||
UserDefaults.standard.set(mode.rawValue, forKey: Self.defaultsKey)
|
||||
}
|
||||
}
|
||||
|
||||
private init() {
|
||||
let saved = UserDefaults.standard.string(forKey: Self.defaultsKey) ?? ""
|
||||
mode = AppearanceMode(rawValue: saved) ?? .system
|
||||
}
|
||||
}
|
||||
|
||||
// ── AppDelegate — runtime orientation lock ────────────────────────────────────
|
||||
// Info.plist must declare all 4 orientations so iPad multitasking is supported
|
||||
@@ -28,8 +74,9 @@ struct JanitorialQCApp: App {
|
||||
|
||||
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
|
||||
|
||||
@StateObject private var auth = AuthManager.shared
|
||||
@StateObject private var sync = SyncManager.shared
|
||||
@StateObject private var auth = AuthManager.shared
|
||||
@StateObject private var sync = SyncManager.shared
|
||||
@StateObject private var appearance = AppearanceManager.shared
|
||||
|
||||
init() {
|
||||
registerBackgroundTasks()
|
||||
@@ -44,6 +91,8 @@ struct JanitorialQCApp: App {
|
||||
ContentView()
|
||||
.environmentObject(auth)
|
||||
.environmentObject(sync)
|
||||
.environmentObject(appearance)
|
||||
.preferredColorScheme(appearance.mode.colorScheme)
|
||||
}
|
||||
.modelContainer(for: [
|
||||
LocalFacility.self,
|
||||
|
||||
Reference in New Issue
Block a user