Formatted the boilerplated code in the app as well as the unit and UI tests targets.
This commit is contained in:
@@ -1,17 +1,18 @@
|
|||||||
import SwiftUI
|
|
||||||
import SwiftData
|
import SwiftData
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
@main
|
@main
|
||||||
struct TodosApp: App {
|
struct TodosApp: App {
|
||||||
var sharedModelContainer: ModelContainer = {
|
var sharedModelContainer: ModelContainer = {
|
||||||
let schema = Schema([
|
let schema = Schema([
|
||||||
Item.self,
|
Item.self
|
||||||
])
|
])
|
||||||
let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)
|
let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)
|
||||||
|
|
||||||
do {
|
do {
|
||||||
return try ModelContainer(for: schema, configurations: [modelConfiguration])
|
return try ModelContainer(for: schema, configurations: [modelConfiguration])
|
||||||
} catch {
|
}
|
||||||
|
catch {
|
||||||
fatalError("Could not create ModelContainer: \(error)")
|
fatalError("Could not create ModelContainer: \(error)")
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
import SwiftUI
|
|
||||||
import SwiftData
|
import SwiftData
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
struct ContentView: View {
|
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 {
|
var body: some View {
|
||||||
NavigationSplitView {
|
NavigationSplitView {
|
||||||
@@ -17,15 +21,15 @@ struct ContentView: View {
|
|||||||
}
|
}
|
||||||
.onDelete(perform: deleteItems)
|
.onDelete(perform: deleteItems)
|
||||||
}
|
}
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
.navigationSplitViewColumnWidth(min: 180, ideal: 200)
|
.navigationSplitViewColumnWidth(min: 180, ideal: 200)
|
||||||
#endif
|
#endif
|
||||||
.toolbar {
|
.toolbar {
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
ToolbarItem(placement: .navigationBarTrailing) {
|
ToolbarItem(placement: .navigationBarTrailing) {
|
||||||
EditButton()
|
EditButton()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
ToolbarItem {
|
ToolbarItem {
|
||||||
Button(action: addItem) {
|
Button(action: addItem) {
|
||||||
Label("Add Item", systemImage: "plus")
|
Label("Add Item", systemImage: "plus")
|
||||||
|
|||||||
@@ -23,5 +23,5 @@ final class TodosUITestsLaunchTests: XCTestCase {
|
|||||||
attachment.lifetime = .keepAlways
|
attachment.lifetime = .keepAlways
|
||||||
add(attachment)
|
add(attachment)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import Testing
|
|||||||
|
|
||||||
struct TodosTests {
|
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.
|
// Write your test here and use APIs like `#expect(...)` to check expected conditions.
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user