Basic application setup #1

Merged
javier merged 6 commits from app/setup into main 2026-02-08 20:20:12 +00:00
5 changed files with 19 additions and 14 deletions
Showing only changes of commit f587893ba6 - Show all commits
+4 -3
View File
@@ -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)")
}
}()
+11 -7
View File
@@ -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")
+1 -1
View File
@@ -23,5 +23,5 @@ final class TodosUITestsLaunchTests: XCTestCase {
attachment.lifetime = .keepAlways
add(attachment)
}
}
}
+2 -2
View File
@@ -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.
}
}