diff --git a/App/Sources/App/TodosApp.swift b/App/Sources/App/TodosApp.swift index c8ef9ce..ebd7187 100644 --- a/App/Sources/App/TodosApp.swift +++ b/App/Sources/App/TodosApp.swift @@ -1,17 +1,18 @@ -import SwiftUI import SwiftData +import SwiftUI @main struct TodosApp: App { var sharedModelContainer: ModelContainer = { let schema = Schema([ - Item.self, + Item.self ]) let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false) do { return try ModelContainer(for: schema, configurations: [modelConfiguration]) - } catch { + } + catch { fatalError("Could not create ModelContainer: \(error)") } }() diff --git a/App/Sources/Models/Item.swift b/App/Sources/Models/Item.swift index dd0170c..a2f85bf 100644 --- a/App/Sources/Models/Item.swift +++ b/App/Sources/Models/Item.swift @@ -4,7 +4,7 @@ import SwiftData @Model final class Item { var timestamp: Date - + init(timestamp: Date) { self.timestamp = timestamp } diff --git a/App/Sources/Views/ContentView.swift b/App/Sources/Views/ContentView.swift index 69f91e5..e28a317 100644 --- a/App/Sources/Views/ContentView.swift +++ b/App/Sources/Views/ContentView.swift @@ -1,9 +1,13 @@ -import SwiftUI import SwiftData +import SwiftUI struct ContentView: View { - @Environment(\.modelContext) private var modelContext - @Query private var items: [Item] + + @Environment(\.modelContext) + private var modelContext + + @Query + private var items: [Item] var body: some View { NavigationSplitView { @@ -17,15 +21,15 @@ struct ContentView: View { } .onDelete(perform: deleteItems) } -#if os(macOS) + #if os(macOS) .navigationSplitViewColumnWidth(min: 180, ideal: 200) -#endif + #endif .toolbar { -#if os(iOS) + #if os(iOS) ToolbarItem(placement: .navigationBarTrailing) { EditButton() } -#endif + #endif ToolbarItem { Button(action: addItem) { Label("Add Item", systemImage: "plus") diff --git a/UITests/TodosUITestsLaunchTests.swift b/UITests/TodosUITestsLaunchTests.swift index cd2ccdc..b3a45ef 100644 --- a/UITests/TodosUITestsLaunchTests.swift +++ b/UITests/TodosUITestsLaunchTests.swift @@ -23,5 +23,5 @@ final class TodosUITestsLaunchTests: XCTestCase { attachment.lifetime = .keepAlways add(attachment) } -} +} diff --git a/UnitTests/TodosTests.swift b/UnitTests/TodosTests.swift index 89b14c6..7ac4a8a 100644 --- a/UnitTests/TodosTests.swift +++ b/UnitTests/TodosTests.swift @@ -2,8 +2,8 @@ import Testing struct TodosTests { - @Test func example() async throws { + @Test + func example() async throws { // Write your test here and use APIs like `#expect(...)` to check expected conditions. } - }