diff options
Diffstat (limited to 'Map/Presentation/Screens')
| -rw-r--r-- | Map/Presentation/Screens/EmptyMapDetailScreen.swift | 16 | ||||
| -rw-r--r-- | Map/Presentation/Screens/MapDetailScreen.swift | 72 |
2 files changed, 0 insertions, 88 deletions
diff --git a/Map/Presentation/Screens/EmptyMapDetailScreen.swift b/Map/Presentation/Screens/EmptyMapDetailScreen.swift deleted file mode 100644 index f3c6d75..0000000 --- a/Map/Presentation/Screens/EmptyMapDetailScreen.swift +++ /dev/null @@ -1,16 +0,0 @@ -import CoreData -import SwiftUI - -struct EmptyMapDetailScreen: View { - - var body: some View { - Text("Select a map from the left hand side, or click on + to create one.") - } -} - -struct DefaultMapView_Previews: PreviewProvider { - static var previews: some View { - EmptyMapDetailScreen().environment( - \.managedObjectContext, PersistenceController.preview.container.viewContext) - } -} diff --git a/Map/Presentation/Screens/MapDetailScreen.swift b/Map/Presentation/Screens/MapDetailScreen.swift deleted file mode 100644 index a5c32fd..0000000 --- a/Map/Presentation/Screens/MapDetailScreen.swift +++ /dev/null @@ -1,72 +0,0 @@ -import Combine -import CoreData -import SwiftUI - -struct MapDetailScreen: View { - @Environment(\.managedObjectContext) private var viewContext - - @EnvironmentObject var store: AppStore - - @ObservedObject var map: Map - - @State var title: String - @State var content: String - - var body: some View { - if map.uuid != nil { - VSplitView { - VStack { - HStack { - TextField( - "Title", text: $title, onCommit: saveModel - ).font(.title2).textFieldStyle(PlainTextFieldStyle()).padding(.vertical, 4.0).padding( - .leading, 4.0) - Button(action: saveText) { - Image(systemName: "doc.text") - }.padding(.vertical, 4.0).padding(.leading, 4.0) - Button(action: saveImage) { - Image(systemName: "photo") - }.padding(.vertical, 4.0).padding(.leading, 4.0).padding(.trailing, 8.0) - } - EvolutionPicker() - - ZStack(alignment: .topLeading) { - MapTextEditor(text: $content, onChange: saveModel) - .background(Color.ui.background) - .foregroundColor(Color.ui.foreground) - .frame(minHeight: 96.0) - }.padding(.top, 8.0).padding(.leading, 8.0).background(Color.ui.background).cornerRadius( - 5.0) - }.padding(.horizontal, 8.0) - ScrollView([.horizontal, .vertical]) { - MapRenderView(content: $content, evolution: .constant(store.state.selectedEvolution)) - } - }.onDisappear { - saveModel() - } - } else { - EmptyMapDetailScreen() - } - } - - private func saveModel() { - map.content = content - map.title = title - try? viewContext.save() - } - - private func saveText() { - store.send(.exportMapAsText(map: map)) - } - - private func saveImage() { - store.send(.exportMapAsImage(map: map)) - } -} - -struct MapDetailView_Previews: PreviewProvider { - static var previews: some View { - MapDetailScreen(map: Map(), title: "", content: "").environment( - \.managedObjectContext, PersistenceController.preview.container.viewContext) - } -} |