merge from release/6_14_merge

This commit is contained in:
Christiano, Kevin 2019-04-26 14:23:11 -04:00
commit 1ab359e360
3 changed files with 29 additions and 26 deletions

View File

@ -13,8 +13,9 @@ open class CaretButton: MFCustomButton, MVMCoreUIMoleculeViewProtocol {
// MARK: - Constants // MARK: - Constants
//------------------------------------------------------ //------------------------------------------------------
private let CaretViewHeight: Float = 10.8 private let CARET_VIEW_HEIGHT: Float = 10.5
private let CaretViewWidth: Float = 6.6 private let CARET_VIEW_WIDTH: Float = 6.5
//------------------------------------------------------ //------------------------------------------------------
// MARK: - Properties // MARK: - Properties
@ -25,17 +26,11 @@ open class CaretButton: MFCustomButton, MVMCoreUIMoleculeViewProtocol {
@objc public var rightViewWidth: NSNumber? @objc public var rightViewWidth: NSNumber?
@objc public var enabledColor: UIColor = .black { @objc public var enabledColor: UIColor = .black {
didSet { didSet { changeCaretColor() }
setTitleColor(enabledColor, for: .normal)
changeCaretColor()
}
} }
@objc public var disabledColor: UIColor = .mfSilver() { @objc public var disabledColor: UIColor = .mfSilver() {
didSet { didSet { changeCaretColor() }
setTitleColor(disabledColor, for: .disabled)
changeCaretColor()
}
} }
private var caretSpacingConstraint: NSLayoutConstraint? private var caretSpacingConstraint: NSLayoutConstraint?
@ -61,10 +56,11 @@ open class CaretButton: MFCustomButton, MVMCoreUIMoleculeViewProtocol {
//------------------------------------------------------ //------------------------------------------------------
private func changeCaretColor() { private func changeCaretColor() {
setTitleColor(enabledColor, for: .normal)
setTitleColor(disabledColor, for: .disabled)
if let rightCaretView = rightView as? CaretView { if let rightCaretView = rightView as? CaretView {
let lineColor = isEnabled ? enabledColor : disabledColor rightCaretView.setLineColor(isEnabled ? enabledColor : disabledColor)
rightCaretView.setLineColor(lineColor)
} }
} }
@ -72,8 +68,8 @@ open class CaretButton: MFCustomButton, MVMCoreUIMoleculeViewProtocol {
rightView?.removeFromSuperview() rightView?.removeFromSuperview()
let width = CGFloat(rightViewWidth?.floatValue ?? CaretViewWidth) let width = CGFloat(rightViewWidth?.floatValue ?? CARET_VIEW_WIDTH)
let height = CGFloat(rightViewHeight?.floatValue ?? CaretViewHeight) let height = CGFloat(rightViewHeight?.floatValue ?? CARET_VIEW_HEIGHT)
let edgeInsets: UIEdgeInsets = contentEdgeInsets let edgeInsets: UIEdgeInsets = contentEdgeInsets
contentEdgeInsets = UIEdgeInsets(top: edgeInsets.top, left: edgeInsets.left, bottom: edgeInsets.bottom, right: 4 + width) contentEdgeInsets = UIEdgeInsets(top: edgeInsets.top, left: edgeInsets.left, bottom: edgeInsets.bottom, right: 4 + width)

View File

@ -21,7 +21,7 @@ open class CaretView: MFView {
//------------------------------------------------------ //------------------------------------------------------
@objc public init() { @objc public init() {
super.init(frame: CGRect.zero) super.init(frame: .zero)
} }
@objc public override init(frame: CGRect) { @objc public override init(frame: CGRect) {
@ -98,25 +98,25 @@ open class CaretView: MFView {
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) {
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
// Configure class properties with JSON values // Configure class properties with JSON values
guard let jsonDictionary = json else { return } guard let dictionary = json else { return }
if let backgroundColorHex = jsonDictionary[KeyBackgroundColor] as? String { if let backgroundColorHex = dictionary[KeyBackgroundColor] as? String {
backgroundColor = UIColor.mfGet(forHex: backgroundColorHex) backgroundColor = UIColor.mfGet(forHex: backgroundColorHex)
} }
if let strokeColorHex = jsonDictionary["strokeColor"] as? String { if let strokeColorHex = dictionary["strokeColor"] as? String {
strokeColor = UIColor.mfGet(forHex: strokeColorHex) strokeColor = UIColor.mfGet(forHex: strokeColorHex)
} }
if let isHiddenValue = jsonDictionary[KeyIsHidden] as? Bool { if let isHiddenValue = dictionary[KeyIsHidden] as? Bool {
isHidden = isHiddenValue isHidden = isHiddenValue
} }
if let isOpaqueValue = jsonDictionary[KeyIsOpaque] as? Bool { if let isOpaqueValue = dictionary[KeyIsOpaque] as? Bool {
isOpaque = isOpaqueValue isOpaque = isOpaqueValue
} }
if let lineWidthValue = jsonDictionary["lineWidth"] as? CGFloat { if let lineWidthValue = dictionary["lineWidth"] as? CGFloat {
lineWidth = lineWidthValue lineWidth = lineWidthValue
} }
} }

View File

@ -26,7 +26,7 @@ public typealias CoreObjectActionLoadPresentDelegate = MVMCoreActionDelegateProt
public var attributedText: NSAttributedString? { public var attributedText: NSAttributedString? {
willSet(newAttributedText) { willSet(newAttributedText) {
if let newAttribText = newAttributedText, !newAttribText.string.isEmpty { if let newAttribText = newAttributedText {
let mutableAttributedText = NSMutableAttributedString(attributedString: newAttribText) let mutableAttributedText = NSMutableAttributedString(attributedString: newAttribText)
let paragraphStyle = NSMutableParagraphStyle() let paragraphStyle = NSMutableParagraphStyle()
@ -78,9 +78,16 @@ public typealias CoreObjectActionLoadPresentDelegate = MVMCoreActionDelegateProt
public var actionText: String? public var actionText: String?
public var backText: String? public var backText: String?
private var text: String? { private var internalText: String = ""
willSet(newText) {
attributedText = NSAttributedString(string: newText ?? "") public var text: String? {
get {
return internalText
}
set {
guard let text = newValue else { return }
internalText = text
attributedText = NSAttributedString(string: text)
setAlternateNormalTextAttributes([NSAttributedString.Key.font: normalTextFont as Any]) setAlternateNormalTextAttributes([NSAttributedString.Key.font: normalTextFont as Any])
setAlternateActionTextAttributes([NSAttributedString.Key.font: actionTextFont as Any]) setAlternateActionTextAttributes([NSAttributedString.Key.font: actionTextFont as Any])
setAlternateNormalTextAttributes([NSAttributedString.Key.foregroundColor: normalTextColor as Any]) setAlternateNormalTextAttributes([NSAttributedString.Key.foregroundColor: normalTextColor as Any])