TodosApp.swift 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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().onAppear {
  34. // Disable the tab bar options
  35. NSWindow.allowsAutomaticWindowTabbing = false
  36. }
  37. }
  38. .modelContainer(sharedModelContainer)
  39. .commands {
  40. CommandGroup(replacing: .newItem) {
  41. NewProjectMenu()
  42. .modelContainer(sharedModelContainer)
  43. }
  44. CommandGroup(replacing: .saveItem) {
  45. SaveSnapshotMenu()
  46. .modelContainer(sharedModelContainer)
  47. SaveAsMenu()
  48. .modelContainer(sharedModelContainer)
  49. ExportMenu()
  50. .modelContainer(sharedModelContainer)
  51. ImportMenu()
  52. .modelContainer(sharedModelContainer)
  53. }
  54. }
  55. #if os(macOS)
  56. Settings {
  57. SettingsView()
  58. }
  59. #endif
  60. }
  61. }