struct AppState {
var selectedEvolution: StageType = .general
- var mapBeingDeleted: Map? = nil
}
enum AppAction {
case selectEvolution(evolution: StageType)
case exportMapAsImage(map: Map)
case exportMapAsText(map: Map)
+ case deleteMap(map: Map)
}
func appStateReducer(state: inout AppState, action: AppAction) {
print("Cancel")
}
}
+ case .deleteMap(map: let map):
+ let context = PersistenceController.shared.container.viewContext
+ context.delete(map)
+
+ try? context.save()
}
}
.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)
}
}
}
+ DefaultMapView()
}
}