enabled/disabled colors.

This commit is contained in:
Kevin G Christiano 2020-01-13 15:46:50 -05:00
parent edddac84a8
commit 8490ef3572

View File

@ -16,6 +16,15 @@ import UIKit
private var additionalData: [AnyHashable: Any]?
public var titleColor: (enabled: UIColor?, disabled: UIColor?) = (.mfTextButton(), .mfSilver())
public override var isEnabled: Bool {
didSet {
setTitleColor(isEnabled ? titleColor.enabled : titleColor.disabled, for: .normal)
setNeedsDisplay()
}
}
//--------------------------------------------------
// MARK: - Delegate
//--------------------------------------------------
@ -50,7 +59,7 @@ import UIKit
let context = UIGraphicsGetCurrentContext()
// Set to the same color as the text
// Set line to the same color as the text
if let color = titleLabel?.textColor?.cgColor {
context?.setStrokeColor(color)
}
@ -108,6 +117,7 @@ extension Link: MVMCoreViewProtocol {
contentMode = .redraw
setTitleColor(.mfTextButton(), for: .normal)
setTitleColor(.mfCharcoal(), for: .highlighted)
titleColor = (.mfTextButton(), .mfSilver())
titleLabel?.numberOfLines = 1
titleLabel?.lineBreakMode = .byTruncatingTail
titleLabel?.textAlignment = .left
@ -125,14 +135,15 @@ extension Link: MVMCoreUIMoleculeViewProtocol {
public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
self.additionalData = additionalData
self.delegateObject = delegateObject
buttonDelegate = delegateObject?.buttonDelegate
guard let dictionary = json else { return }
actionMap = dictionary
buttonDelegate = delegateObject?.buttonDelegate
let color = dictionary.stringForkey(KeyTextColor)
setTitleColor(.mfGet(forHex: color), for: .normal)
if let colorHex = dictionary[KeyTextColor] as? String {
titleColor.enabled = .mfGet(forHex: colorHex)
setTitleColor(titleColor.enabled, for: .normal)
}
if let title = dictionary.optionalStringForKey(KeyTitle) {
setTitle(title, for: .normal)