]> git.r.bdr.sh - rbdr/map/blobdiff - Map/Views/ContentView.swift
Make delete a context action
[rbdr/map] / Map / Views / ContentView.swift
index 4f55c27c0680623d2a9be6724fe18c5d64fd0c79..f439026249988f669b78b118f7d9b4116db2ed10 100644 (file)
@@ -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)
@@ -35,6 +37,11 @@ struct ContentView: View {
                 .foregroundColor(Color.black)
                 .cornerRadius(2.0)
             }.padding(.leading, 8.0)
+          }.contextMenu {
+            Button(action: { store.send(.deleteMap(map: map))}) {
+              Image(systemName: "trash")
+              Text("Delete")
+            }
           }
         }
         .onDelete(perform: deleteMaps)
@@ -49,6 +56,7 @@ struct ContentView: View {
             }
           }
         }
+        DefaultMapView()
     }
   }