struct ContentView: View {
@Environment(\.managedObjectContext) private var viewContext
+ @EnvironmentObject var store: AppStore
+
@FetchRequest(
sortDescriptors: [NSSortDescriptor(keyPath: \Map.createdAt, ascending: true)],
animation: .default)
DefaultMapView()
}
ForEach(maps) { map in
- NavigationLink(destination: MapDetailView(map: map)) {
+ NavigationLink(
+ destination: MapDetailView(map: map, title: map.title ?? "", content: map.content ?? "")
+ ) {
HStack {
Text(map.title ?? "Untitled Map")
Spacer()
.foregroundColor(Color.black)
.cornerRadius(2.0)
}.padding(.leading, 8.0)
+ }.contextMenu {
+ Button(
+ action: { store.send(.deleteMap(map: map)) },
+ label: {
+ Image(systemName: "trash")
+ Text("Delete")
+ })
}
}
.onDelete(perform: deleteMaps)
}
}
}
+ DefaultMapView()
}
}