TodosApp.swift 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. ])
  21. let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)
  22. do {
  23. return try ModelContainer(for: schema, configurations: [modelConfiguration])
  24. } catch {
  25. fatalError("Could not create ModelContainer: \(error)")
  26. }
  27. }()
  28. var body: some Scene {
  29. WindowGroup {
  30. ContentView()
  31. }
  32. .modelContainer(sharedModelContainer)
  33. .commands {
  34. CommandGroup(replacing: .newItem) {
  35. NewProjectMenu()
  36. .modelContainer(sharedModelContainer)
  37. }
  38. CommandGroup(replacing: .saveItem) {
  39. SaveSnapshotMenu()
  40. .modelContainer(sharedModelContainer)
  41. SaveAsMenu()
  42. .modelContainer(sharedModelContainer)
  43. ExportMenu()
  44. .modelContainer(sharedModelContainer)
  45. ImportMenu()
  46. .modelContainer(sharedModelContainer)
  47. }
  48. }
  49. #if os(macOS)
  50. Settings {
  51. SettingsView()
  52. }
  53. #endif
  54. }
  55. }