TodosApp.swift 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //
  2. // TodosApp.swift
  3. // Todos
  4. //
  5. // Created by Sam Jaffe on 2/28/26.
  6. //
  7. import SwiftUI
  8. import SwiftData
  9. struct UserDefaultsKeys {
  10. private static let root = "leumasjaffe.Todos"
  11. static let UrlHints = root + ".URLHints"
  12. static let WeekStart = root + ".WeekStart"
  13. }
  14. @main
  15. struct TodosApp: App {
  16. var sharedModelContainer: ModelContainer = {
  17. let schema = Schema([
  18. Category.self,
  19. ])
  20. let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)
  21. do {
  22. return try ModelContainer(for: schema, configurations: [modelConfiguration])
  23. } catch {
  24. fatalError("Could not create ModelContainer: \(error)")
  25. }
  26. }()
  27. var body: some Scene {
  28. WindowGroup {
  29. ContentView()
  30. }
  31. .modelContainer(sharedModelContainer)
  32. .commands {
  33. CommandGroup(replacing: .newItem) {
  34. SaveSnapshotMenu()
  35. .modelContainer(sharedModelContainer)
  36. ExportMenu()
  37. .modelContainer(sharedModelContainer)
  38. }
  39. }
  40. #if os(macOS)
  41. Settings {
  42. SettingsView()
  43. }
  44. #endif
  45. }
  46. }