diff --git a/MVMCoreUI/Atoms/Views/Arrow.swift b/MVMCoreUI/Atoms/Views/Arrow.swift index 7ae112cc..e932dd60 100644 --- a/MVMCoreUI/Atoms/Views/Arrow.swift +++ b/MVMCoreUI/Atoms/Views/Arrow.swift @@ -19,6 +19,21 @@ open class Arrow: View { return model as? ArrowModel } + //-------------------------------------------------- + // MARK: - Constraints + //-------------------------------------------------- + + public var heightConstraint: NSLayoutConstraint? + public var widthConstraint: NSLayoutConstraint? + + public func pinHeightAndWidth(constant: CGFloat = 12) { + + heightConstraint = heightAnchor.constraint(equalToConstant: constant) + widthConstraint = widthAnchor.constraint(equalToConstant: constant) + heightConstraint?.isActive = true + widthConstraint?.isActive = true + } + //-------------------------------------------------- // MARK: - Lifecycle //-------------------------------------------------- diff --git a/MVMCoreUI/Atoms/Views/ArrowModel.swift b/MVMCoreUI/Atoms/Views/ArrowModel.swift index 926a9ea7..2547f8d1 100644 --- a/MVMCoreUI/Atoms/Views/ArrowModel.swift +++ b/MVMCoreUI/Atoms/Views/ArrowModel.swift @@ -20,6 +20,9 @@ open class ArrowModel: MoleculeModelProtocol { public var degrees: Float = 0 public var lineWidth: CGFloat = 1 + public var height: CGFloat = 12 + public var width: CGFloat = 12 + //-------------------------------------------------- // MARK: - Keys //-------------------------------------------------- @@ -31,6 +34,8 @@ open class ArrowModel: MoleculeModelProtocol { case degrees case size case lineWidth + case height + case width } //-------------------------------------------------- @@ -52,6 +57,14 @@ open class ArrowModel: MoleculeModelProtocol { if let lineWidth = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .lineWidth) { self.lineWidth = lineWidth } + + if let height = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .height) { + self.lineWidth = height + } + + if let width = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .width) { + self.width = width + } } public func encode(to encoder: Encoder) throws { @@ -61,5 +74,7 @@ open class ArrowModel: MoleculeModelProtocol { try container.encode(color, forKey: .color) try container.encode(degrees, forKey: .degrees) try container.encodeIfPresent(backgroundColor, forKey: .lineWidth) + try container.encode(width, forKey: .width) + try container.encode(height, forKey: .height) } }