| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- //
- // TodosApp.swift
- // Todos
- //
- // Created by Sam Jaffe on 2/28/26.
- //
- import SwiftUI
- import SwiftData
- struct UserDefaultsKeys {
- private static let root = "leumasjaffe.Todos"
- static let UrlHints = root + ".URLHints"
- static let WeekStart = root + ".WeekStart"
- static let Category = root + ".Category"
- }
- @main
- struct TodosApp: App {
- @State private var isMoveMode = false
- var sharedModelContainer: ModelContainer = {
- let schema = Schema([
- Project.self,
- Task.self,
- SubTask.self,
- Tag.self,
- ])
- let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)
- do {
- return try ModelContainer(for: schema, configurations: [modelConfiguration])
- } catch {
- fatalError("Could not create ModelContainer: \(error)")
- }
- }()
- var body: some Scene {
- WindowGroup {
- ContentView(isMoveMode: $isMoveMode).onAppear {
- // Disable the tab bar options
- NSWindow.allowsAutomaticWindowTabbing = false
- }
- }
- .modelContainer(sharedModelContainer)
- .commands {
- CommandGroup(replacing: .newItem) {
- NewProjectMenu()
- .modelContainer(sharedModelContainer)
- }
- CommandGroup(replacing: .saveItem) {
- SaveSnapshotMenu()
- .modelContainer(sharedModelContainer)
- SaveAsMenu()
- .modelContainer(sharedModelContainer)
- ExportMenu()
- .modelContainer(sharedModelContainer)
- ImportMenu()
- .modelContainer(sharedModelContainer)
- }
- CommandGroup(replacing: .toolbar) {
- Toggle(isOn: $isMoveMode) {
- Label("Move/Delete Tasks", systemImage: "pencil")
- }
- }
- }
-
- #if os(macOS)
- Settings {
- SettingsView()
- }
- #endif
- }
- }
|