X-Git-Url: https://git.r.bdr.sh/rbdr/map/blobdiff_plain/5e8ff4850c4827125fe12788dd5b153c4f636f48..75a0e4509a70055851b085f3f7293ae1cf48164c:/Map/Views/ContentView.swift?ds=sidebyside diff --git a/Map/Views/ContentView.swift b/Map/Views/ContentView.swift index 4f55c27..534c14c 100644 --- a/Map/Views/ContentView.swift +++ b/Map/Views/ContentView.swift @@ -11,6 +11,8 @@ import SwiftUI struct ContentView: View { @Environment(\.managedObjectContext) private var viewContext + @EnvironmentObject var store: AppStore + @FetchRequest( sortDescriptors: [NSSortDescriptor(keyPath: \Map.createdAt, ascending: true)], animation: .default) @@ -23,7 +25,9 @@ struct ContentView: View { 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() @@ -35,6 +39,13 @@ struct ContentView: View { .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) @@ -49,6 +60,7 @@ struct ContentView: View { } } } + DefaultMapView() } }