disabled and init
This commit is contained in:
parent
c6a2bbaf74
commit
3f0828fa44
@ -143,11 +143,8 @@ open class CaretLink: Button, MVMCoreUIViewConstrainingProtocol {
|
||||
backgroundColor = color.uiColor
|
||||
}
|
||||
|
||||
enabledColor = (model.inverted ? model.enabled_inverted : model.enabledColor).uiColor
|
||||
|
||||
if let color = model.disabledColor {
|
||||
disabledColor = color.uiColor
|
||||
}
|
||||
enabledColor = (model.inverted ? model.enabledColor_inverted : model.enabledColor).uiColor
|
||||
disabledColor = (model.inverted ? model.disabledColor_inverted : model.disabledColor).uiColor
|
||||
|
||||
isEnabled = model.enabled
|
||||
set(with: model.action, delegateObject: delegateObject, additionalData: additionalData)
|
||||
|
||||
@ -20,8 +20,9 @@ public class CaretLinkModel: ButtonModelProtocol, MoleculeModelProtocol {
|
||||
public var title: String
|
||||
public var action: ActionModelProtocol
|
||||
public var enabledColor: Color = Color(uiColor: .mvmBlack)
|
||||
public var disabledColor: Color? = Color(uiColor: .mvmCoolGray6)
|
||||
public var enabled_inverted: Color = Color(uiColor: .mvmWhite)
|
||||
public var disabledColor: Color = Color(uiColor: .mvmCoolGray6)
|
||||
public var enabledColor_inverted: Color = Color(uiColor: .mvmWhite)
|
||||
public var disabledColor_inverted: Color = Color(uiColor: .mvmCoolGray10)
|
||||
public var enabled = true
|
||||
public var inverted = false
|
||||
|
||||
@ -42,7 +43,8 @@ public class CaretLinkModel: ButtonModelProtocol, MoleculeModelProtocol {
|
||||
case backgroundColor
|
||||
case title
|
||||
case action
|
||||
case enabled_inverted
|
||||
case enabledColor_inverted
|
||||
case disabledColor_inverted
|
||||
case enabledColor
|
||||
case disabledColor
|
||||
case enabled
|
||||
@ -60,8 +62,12 @@ public class CaretLinkModel: ButtonModelProtocol, MoleculeModelProtocol {
|
||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||
title = try typeContainer.decode(String.self, forKey: .title)
|
||||
|
||||
if let enabled_inverted = try typeContainer.decodeIfPresent(Color.self, forKey: .enabled_inverted) {
|
||||
self.enabled_inverted = enabled_inverted
|
||||
if let enabledColor_inverted = try typeContainer.decodeIfPresent(Color.self, forKey: .enabledColor_inverted) {
|
||||
self.enabledColor_inverted = enabledColor_inverted
|
||||
}
|
||||
|
||||
if let disabledColor_inverted = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledColor_inverted) {
|
||||
self.disabledColor_inverted = disabledColor_inverted
|
||||
}
|
||||
|
||||
if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .enabledColor) {
|
||||
@ -92,7 +98,8 @@ public class CaretLinkModel: ButtonModelProtocol, MoleculeModelProtocol {
|
||||
try container.encode(enabled, forKey: .enabledColor)
|
||||
try container.encodeIfPresent(disabledColor, forKey: .disabledColor)
|
||||
try container.encode(enabled, forKey: .enabled)
|
||||
try container.encode(enabled_inverted, forKey: .enabled_inverted)
|
||||
try container.encode(enabledColor_inverted, forKey: .enabledColor_inverted)
|
||||
try container.encode(disabledColor_inverted, forKey: .disabledColor_inverted)
|
||||
try container.encode(inverted, forKey: .inverted)
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,9 +47,7 @@ import UIKit
|
||||
|
||||
public convenience init(pinTo view: UIView, edge: UIRectEdge, useMargin: Bool) {
|
||||
self.init(frame: .zero)
|
||||
|
||||
view.addSubview(self)
|
||||
NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: self, useMargins: useMargin, pinTop: edge != .bottom, pinBottom: edge != .top, pinLeft: edge != .right, pinRight: edge != .left).values))
|
||||
addLine(to: view, edge: edge, useMargin: useMargin)
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -84,10 +82,6 @@ import UIKit
|
||||
//--------------------------------------------------
|
||||
// MARK: - MoleculeViewProtocol
|
||||
//--------------------------------------------------
|
||||
public convenience init(pinTo view: UIView, edge: UIRectEdge, useMargin: Bool) {
|
||||
self.init(frame: .zero)
|
||||
addLine(to: view, edge: edge, useMargin: useMargin)
|
||||
}
|
||||
|
||||
open func addLine(to view: UIView, edge: UIRectEdge, useMargin: Bool) {
|
||||
view.addSubview(self)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user