TodosApp.swift 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. SaveSnapshotMenu()
  36. .modelContainer(sharedModelContainer)
  37. ExportMenu()
  38. .modelContainer(sharedModelContainer)
  39. }
  40. }
  41. #if os(macOS)
  42. Settings {
  43. SettingsView()
  44. }
  45. #endif
  46. }
  47. }