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) {
window.makeKeyAndOrderFront(nil)
let renderView = MapRenderView(
- content: map.content ?? "", evolution: Stage.stages(state.selectedEvolution))
+ content: Binding.constant(map.content ?? ""),
+ evolution: Binding.constant(Stage.stages(state.selectedEvolution)))
let view = NSHostingView(rootView: renderView)
window.contentView = view
print("Cancel")
}
}
+ case .deleteMap(let map):
+ let context = PersistenceController.shared.container.viewContext
+ context.delete(map)
+
+ try? context.save()
}
}