5 // Created by Ruben Beltran del Rio on 2/1/21.
11 struct MapDetailView: View {
12 @Environment(\.managedObjectContext) private var viewContext
14 @ObservedObject var map: Map
16 @State private var selectedEvolution = StageType.General
21 TextField("Title", text: Binding($map.title, ""), onCommit: {
22 try? viewContext.save()
24 Picker("Evolution", selection: $selectedEvolution) {
25 ForEach(StageType.allCases) { stage in
26 Text(Stage.title(stage)).tag(stage)
29 TextEditor(text: Binding($map.content, "")).onChange(of: map.content) { _ in
30 try? viewContext.save()
31 }.font(Font.system(size: 16, design: .monospaced))
33 ScrollView([.horizontal, .vertical]) {
34 MapRenderView(map: map, evolution: Stage.stages(selectedEvolution))
40 struct MapDetailView_Previews: PreviewProvider {
41 static var previews: some View {
42 MapDetailView(map: Map()).environment(\.managedObjectContext, PersistenceController.preview.container.viewContext)