diff options
| author | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2021-02-02 09:16:46 +0100 |
|---|---|---|
| committer | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2021-02-02 09:16:46 +0100 |
| commit | 1b85f723b48d38cf345bb9a4f3fd01aa6039b50b (patch) | |
| tree | b4795a83350b2bdd800e4d2749d1327c17bc385f /Map/MapDetail.swift | |
Initial commit
Diffstat (limited to 'Map/MapDetail.swift')
| -rw-r--r-- | Map/MapDetail.swift | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/Map/MapDetail.swift b/Map/MapDetail.swift new file mode 100644 index 0000000..74e3c8d --- /dev/null +++ b/Map/MapDetail.swift @@ -0,0 +1,44 @@ +// +// ContentView.swift +// Map +// +// Created by Ruben Beltran del Rio on 2/1/21. +// + +import SwiftUI +import CoreData + +struct MapDetailView: View { + @Environment(\.managedObjectContext) private var viewContext + + @ObservedObject var map: Map + + @State private var selectedEvolution = StageType.General + + var body: some View { + VSplitView { + VStack { + TextField("Title", text: Binding($map.title, ""), onCommit: { + try? viewContext.save() + }) + Picker("Evolution", selection: $selectedEvolution) { + ForEach(StageType.allCases) { stage in + Text(Stage.title(stage)).tag(stage) + } + } + TextEditor(text: Binding($map.content, "")).onChange(of: map.content) { _ in + try? viewContext.save() + }.font(Font.system(size: 16, design: .monospaced)) + } + ScrollView([.horizontal, .vertical]) { + MapRenderView(map: map, evolution: Stage.stages(selectedEvolution)) + } + } + } +} + +struct MapDetailView_Previews: PreviewProvider { + static var previews: some View { + MapDetailView(map: Map()).environment(\.managedObjectContext, PersistenceController.preview.container.viewContext) + } +} |