arrow color inversion

This commit is contained in:
Kevin G Christiano 2020-05-12 11:50:47 -04:00
parent b83abf673e
commit 1a2d7b2abd
2 changed files with 21 additions and 2 deletions

View File

@ -41,8 +41,20 @@ open class Arrow: View {
}
open var color: UIColor {
get { return arrowModel?.color.uiColor ?? .mvmBlack }
set { arrowModel?.color = Color(uiColor: newValue) }
get {
if let model = arrowModel, model.inverted {
return arrowModel?.color_inverted.uiColor ?? .mvmWhite
} else {
return arrowModel?.color.uiColor ?? .mvmBlack
}
}
set {
if let model = arrowModel, model.inverted {
arrowModel?.color_inverted = Color(uiColor: newValue)
} else {
arrowModel?.color = Color(uiColor: newValue)
}
}
}
open var degrees: Float {

View File

@ -22,11 +22,13 @@ open class ArrowModel: MoleculeModelProtocol {
public var backgroundColor: Color?
public var disabledColor: Color = Color(uiColor: .mvmCoolGray3)
public var color: Color = Color(uiColor: .mvmBlack)
public var color_inverted: Color = Color(uiColor: .mvmWhite)
public var degrees: Float = 0
public var lineWidth: CGFloat = 1
public var height: CGFloat = 12
public var width: CGFloat = 12
public var enabled: Bool = true
public var inverted: Bool = false
//--------------------------------------------------
// MARK: - Enum
@ -64,6 +66,7 @@ open class ArrowModel: MoleculeModelProtocol {
case height
case width
case enabled
case inverted
}
//--------------------------------------------------
@ -79,6 +82,10 @@ open class ArrowModel: MoleculeModelProtocol {
self.disabledColor = disabledColor
}
if let inverted = try typeContainer.decodeIfPresent(Bool.self, forKey: .inverted) {
self.inverted = inverted
}
if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .color) {
self.color = color
}