diff options
Diffstat (limited to 'Map/Presentation/Base Components/MapRender')
| -rw-r--r-- | Map/Presentation/Base Components/MapRender/MapMask.swift | 9 | ||||
| -rw-r--r-- | Map/Presentation/Base Components/MapRender/MapVertices.swift | 9 |
2 files changed, 12 insertions, 6 deletions
diff --git a/Map/Presentation/Base Components/MapRender/MapMask.swift b/Map/Presentation/Base Components/MapRender/MapMask.swift index 2c064b3..b477c0a 100644 --- a/Map/Presentation/Base Components/MapRender/MapMask.swift +++ b/Map/Presentation/Base Components/MapRender/MapMask.swift @@ -19,6 +19,7 @@ struct MapMask: View { let mapSize: CGSize let vertexSize: CGSize let vertices: [Vertex] + let labelPositions: [Int: CGPoint] let padding = CGFloat(5.0) var body: some View { @@ -36,8 +37,9 @@ struct MapMask: View { .clipShape(Capsule()) .offset( CGSize( - width: w(vertex.position.x) + vertexSize.width + padding, - height: h(vertex.position.y) + 7.0) + width: labelPositions[vertex.id]?.x + ?? (w(vertex.position.x) + vertexSize.width + padding), + height: labelPositions[vertex.id]?.y ?? (h(vertex.position.y) + 7.0)) ) .blendMode(.destinationOut) }.zIndex(1) @@ -64,5 +66,6 @@ struct MapMask: View { Vertex(id: 1, label: "A Square", position: CGPoint(x: 10.0, y: 20.0), shape: .square), Vertex(id: 2, label: "A triangle", position: CGPoint(x: 25, y: 32.0), shape: .triangle), Vertex(id: 3, label: "An X", position: CGPoint(x: 70.0, y: 70.0), shape: .x), - ]) + ], + labelPositions: [:]) } diff --git a/Map/Presentation/Base Components/MapRender/MapVertices.swift b/Map/Presentation/Base Components/MapRender/MapVertices.swift index f03bb79..e6617b3 100644 --- a/Map/Presentation/Base Components/MapRender/MapVertices.swift +++ b/Map/Presentation/Base Components/MapRender/MapVertices.swift @@ -19,6 +19,7 @@ struct MapVertices: View { let mapSize: CGSize let vertexSize: CGSize let vertices: [Vertex] + let labelPositions: [Int: CGPoint] let padding = CGFloat(5.0) var onDragVertex: (Vertex, CGFloat, CGFloat) -> Void = { _, _, _ in } @@ -36,8 +37,9 @@ struct MapVertices: View { .foregroundColor(.Theme.Map.labelColor) .offset( CGSize( - width: w(vertex.position.x) + vertexSize.width + padding, - height: h(vertex.position.y) + 7.0)) + width: labelPositions[vertex.id]?.x + ?? (w(vertex.position.x) + vertexSize.width + padding), + height: labelPositions[vertex.id]?.y ?? (h(vertex.position.y) + 7.0))) }.gesture( DragGesture() .onChanged { value in @@ -113,5 +115,6 @@ struct MapVertices: View { Vertex(id: 1, label: "A Square", position: CGPoint(x: 10.0, y: 20.0), shape: .square), Vertex(id: 2, label: "A triangle", position: CGPoint(x: 25, y: 32.0), shape: .triangle), Vertex(id: 3, label: "An X", position: CGPoint(x: 70.0, y: 70.0), shape: .x), - ]) + ], + labelPositions: [:]) } |