Merge branch 'feature/useVerticalLine' into 'develop'
vertical line support for Line atom. See merge request BPHV_MIPS/mvm_core_ui!412
This commit is contained in:
commit
ba8e2479a3
@ -14,23 +14,36 @@ import UIKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
public var heightConstraint: NSLayoutConstraint?
|
public var heightConstraint: NSLayoutConstraint?
|
||||||
|
public var widthConstraint: NSLayoutConstraint?
|
||||||
|
|
||||||
|
open func updateLineConstraints(constant: CGFloat) {
|
||||||
|
if let useVerticalLine = lineModel?.useVerticalLine, useVerticalLine {
|
||||||
|
heightConstraint?.isActive = false
|
||||||
|
widthConstraint?.isActive = true
|
||||||
|
widthConstraint?.constant = constant
|
||||||
|
} else {
|
||||||
|
widthConstraint?.isActive = false
|
||||||
|
heightConstraint?.isActive = true
|
||||||
|
heightConstraint?.constant = constant
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
open func setStyle(_ style: LineModel.Style) {
|
open func setStyle(_ style: LineModel.Style) {
|
||||||
switch style {
|
switch style {
|
||||||
case .standard:
|
case .standard:
|
||||||
heightConstraint?.constant = 1
|
updateLineConstraints(constant: 1)
|
||||||
backgroundColor = .mfSilver()
|
backgroundColor = lineModel?.backgroundColor?.uiColor ?? .mfSilver()
|
||||||
case .thin:
|
case .thin:
|
||||||
heightConstraint?.constant = 1
|
updateLineConstraints(constant: 1)
|
||||||
backgroundColor = .black
|
backgroundColor = lineModel?.backgroundColor?.uiColor ?? .black
|
||||||
case .medium:
|
case .medium:
|
||||||
heightConstraint?.constant = 2
|
updateLineConstraints(constant: 2)
|
||||||
backgroundColor = .black
|
backgroundColor = lineModel?.backgroundColor?.uiColor ?? .black
|
||||||
case .heavy:
|
case .heavy:
|
||||||
heightConstraint?.constant = 4
|
updateLineConstraints(constant: 4)
|
||||||
backgroundColor = .black
|
backgroundColor = lineModel?.backgroundColor?.uiColor ?? .black
|
||||||
case .none:
|
case .none:
|
||||||
heightConstraint?.constant = 0
|
updateLineConstraints(constant: 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,15 +64,17 @@ import UIKit
|
|||||||
super.setupView()
|
super.setupView()
|
||||||
heightConstraint = heightAnchor.constraint(equalToConstant: 1)
|
heightConstraint = heightAnchor.constraint(equalToConstant: 1)
|
||||||
heightConstraint?.isActive = true
|
heightConstraint?.isActive = true
|
||||||
|
widthConstraint = widthAnchor.constraint(equalToConstant: 1)
|
||||||
|
widthConstraint?.isActive = false
|
||||||
setStyle(.standard)
|
setStyle(.standard)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - MoleculeViewProtocol
|
// MARK: - MoleculeViewProtocol
|
||||||
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||||
|
super.set(with: model, delegateObject, additionalData)
|
||||||
if let lineModel = model as? LineModel {
|
if let lineModel = model as? LineModel {
|
||||||
setStyle(lineModel.type)
|
setStyle(lineModel.type)
|
||||||
}
|
}
|
||||||
super.set(with: model, delegateObject, additionalData)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func reset() {
|
open override func reset() {
|
||||||
|
|||||||
@ -48,8 +48,13 @@ import UIKit
|
|||||||
// public var color: Color?
|
// public var color: Color?
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
|
|
||||||
|
// Use this to show vertical line
|
||||||
|
// Default is false
|
||||||
|
public var useVerticalLine: Bool?
|
||||||
|
|
||||||
public init(type: Style) {
|
public init(type: Style) {
|
||||||
self.type = type
|
self.type = type
|
||||||
|
self.useVerticalLine = false
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
@ -58,6 +63,7 @@ import UIKit
|
|||||||
case backgroundColor
|
case backgroundColor
|
||||||
case color
|
case color
|
||||||
case frequency
|
case frequency
|
||||||
|
case useVerticalLine
|
||||||
}
|
}
|
||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
@ -69,6 +75,7 @@ import UIKit
|
|||||||
self.frequency = frequency
|
self.frequency = frequency
|
||||||
}
|
}
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
|
useVerticalLine = try typeContainer.decodeIfPresent(Bool.self, forKey: .useVerticalLine)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
@ -77,5 +84,6 @@ import UIKit
|
|||||||
try container.encode(type, forKey: .type)
|
try container.encode(type, forKey: .type)
|
||||||
try container.encodeIfPresent(frequency, forKey: .frequency)
|
try container.encodeIfPresent(frequency, forKey: .frequency)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
|
try container.encodeIfPresent(useVerticalLine, forKey: .useVerticalLine)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user