diff options
| author | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2021-02-03 23:53:12 +0100 |
|---|---|---|
| committer | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2021-02-03 23:53:12 +0100 |
| commit | 5e8ff4850c4827125fe12788dd5b153c4f636f48 (patch) | |
| tree | f37c90338f33e7ddc84cc855a20dca1ca503476e /Map/Views/MapRender.swift | |
| parent | 1b85f723b48d38cf345bb9a4f3fd01aa6039b50b (diff) | |
Add code for first release
Diffstat (limited to 'Map/Views/MapRender.swift')
| -rw-r--r-- | Map/Views/MapRender.swift | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/Map/Views/MapRender.swift b/Map/Views/MapRender.swift new file mode 100644 index 0000000..b35b724 --- /dev/null +++ b/Map/Views/MapRender.swift @@ -0,0 +1,61 @@ +// +// ContentView.swift +// Map +// +// Created by Ruben Beltran del Rio on 2/1/21. +// + +import CoreData +import CoreGraphics +import SwiftUI + +struct MapRenderView: View { + + @Environment(\.colorScheme) var colorScheme + + @ObservedObject var map: Map + let evolution: Stage + + let mapSize = CGSize(width: 1300.0, height: 1000.0) + + let lineWidth = CGFloat(1.0) + let vertexSize = CGSize(width: 25.0, height: 25.0) + let padding = CGFloat(30.0) + + var parsedMap: ParsedMap { + return map.parse() + } + + var body: some View { + ZStack(alignment: .topLeading) { + + Path { path in + path.addRect( + CGRect( + x: -padding, y: -padding, width: mapSize.width + padding * 2, + height: mapSize.height + padding * 2)) + }.fill(MapColor.colorForScheme(colorScheme).background) + + MapStages(mapSize: mapSize, lineWidth: lineWidth, stages: parsedMap.stages) + MapAxes( + mapSize: mapSize, lineWidth: lineWidth, evolution: evolution, stages: parsedMap.stages) + MapOpportunities( + mapSize: mapSize, lineWidth: lineWidth, vertexSize: vertexSize, + opportunities: parsedMap.opportunities) + MapBlockers(mapSize: mapSize, vertexSize: vertexSize, blockers: parsedMap.blockers) + MapVertices(mapSize: mapSize, vertexSize: vertexSize, vertices: parsedMap.vertices) + MapEdges( + mapSize: mapSize, lineWidth: lineWidth, vertexSize: vertexSize, edges: parsedMap.edges) + }.frame( + width: mapSize.width, + height: mapSize.height, alignment: .topLeading + ).padding(padding) + } +} + +struct MapRenderView_Previews: PreviewProvider { + static var previews: some View { + MapDetailView(map: Map()).environment( + \.managedObjectContext, PersistenceController.preview.container.viewContext) + } +} |