name issue came from property observers. NewValue only appears in willSet, not didSet.

This commit is contained in:
Christiano, Kevin 2019-04-01 10:08:11 -04:00
parent 27127aacfb
commit f68c355527

View File

@ -24,8 +24,6 @@ public typealias CoreObjectActionLoadPresentDelegate = MVMCoreActionDelegateProt
public var actionBlock: ActionBlock?
public weak var label: MFLabel?
// FIXME: I think there are scenarios where attributed text is being set with attributes but there is no text to set.
public var attributedText: NSAttributedString? {
didSet(newAttributedText) {
if let newAttribText = newAttributedText, !newAttribText.string.isEmpty {
@ -82,14 +80,14 @@ public typealias CoreObjectActionLoadPresentDelegate = MVMCoreActionDelegateProt
public var backText: String?
public var text: String? {
didSet(newText) {
if newText != nil {
willSet(newText) {
// if newText != nil {
attributedText = NSAttributedString(string: newText ?? "")
setAlternateNormalTextAttributes([NSAttributedString.Key.font: normalTextFont as Any])
setAlternateActionTextAttributes([NSAttributedString.Key.font: actionTextFont as Any])
setAlternateNormalTextAttributes([NSAttributedString.Key.foregroundColor: normalTextColor as Any])
setAlternateActionTextAttributes([NSAttributedString.Key.foregroundColor: actionTextColor as Any])
}
// }
}
}
@ -196,7 +194,7 @@ public typealias CoreObjectActionLoadPresentDelegate = MVMCoreActionDelegateProt
label.sizeToFit()
}
//adding the underline
// Adding the underline
setAlternateActionTextAttributes([NSAttributedString.Key.underlineStyle: NSNumber(value: NSUnderlineStyle.single.rawValue)])
self.label?.attributedText = attributedText
@ -423,6 +421,7 @@ public typealias CoreObjectActionLoadPresentDelegate = MVMCoreActionDelegateProt
self.text = getTextFromStringComponents()
}
self.text = actionRange.revisedText
setup()
}
@ -439,9 +438,8 @@ public typealias CoreObjectActionLoadPresentDelegate = MVMCoreActionDelegateProt
fullText = fullText.replacingOccurrences(of: rightBrace, with: "")
}
self.text = fullText
actionRange.revisedText = fullText
actionRange.revisedText = fullText
return actionRange
}