TodosApp.swift 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. static let Category = root + ".Category"
  14. }
  15. @main
  16. struct TodosApp: App {
  17. var sharedModelContainer: ModelContainer = {
  18. let schema = Schema([
  19. Project.self,
  20. Task.self,
  21. SubTask.self,
  22. Tag.self,
  23. ])
  24. let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)
  25. do {
  26. return try ModelContainer(for: schema, configurations: [modelConfiguration])
  27. } catch {
  28. fatalError("Could not create ModelContainer: \(error)")
  29. }
  30. }()
  31. var body: some Scene {
  32. WindowGroup {
  33. ContentView()
  34. }
  35. .modelContainer(sharedModelContainer)
  36. .commands {
  37. CommandGroup(replacing: .newItem) {
  38. NewProjectMenu()
  39. .modelContainer(sharedModelContainer)
  40. }
  41. CommandGroup(replacing: .saveItem) {
  42. SaveSnapshotMenu()
  43. .modelContainer(sharedModelContainer)
  44. SaveAsMenu()
  45. .modelContainer(sharedModelContainer)
  46. ExportMenu()
  47. .modelContainer(sharedModelContainer)
  48. ImportMenu()
  49. .modelContainer(sharedModelContainer)
  50. }
  51. }
  52. #if os(macOS)
  53. Settings {
  54. SettingsView()
  55. }
  56. #endif
  57. }
  58. }