name issue came from property observers. NewValue only appears in willSet, not didSet.
This commit is contained in:
parent
27127aacfb
commit
f68c355527
@ -24,8 +24,6 @@ public typealias CoreObjectActionLoadPresentDelegate = MVMCoreActionDelegateProt
|
|||||||
public var actionBlock: ActionBlock?
|
public var actionBlock: ActionBlock?
|
||||||
public weak var label: MFLabel?
|
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? {
|
public var attributedText: NSAttributedString? {
|
||||||
didSet(newAttributedText) {
|
didSet(newAttributedText) {
|
||||||
if let newAttribText = newAttributedText, !newAttribText.string.isEmpty {
|
if let newAttribText = newAttributedText, !newAttribText.string.isEmpty {
|
||||||
@ -82,14 +80,14 @@ public typealias CoreObjectActionLoadPresentDelegate = MVMCoreActionDelegateProt
|
|||||||
public var backText: String?
|
public var backText: String?
|
||||||
|
|
||||||
public var text: String? {
|
public var text: String? {
|
||||||
didSet(newText) {
|
willSet(newText) {
|
||||||
if newText != nil {
|
// if newText != nil {
|
||||||
attributedText = NSAttributedString(string: newText ?? "")
|
attributedText = NSAttributedString(string: newText ?? "")
|
||||||
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])
|
||||||
setAlternateActionTextAttributes([NSAttributedString.Key.foregroundColor: actionTextColor as Any])
|
setAlternateActionTextAttributes([NSAttributedString.Key.foregroundColor: actionTextColor as Any])
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,7 +194,7 @@ public typealias CoreObjectActionLoadPresentDelegate = MVMCoreActionDelegateProt
|
|||||||
label.sizeToFit()
|
label.sizeToFit()
|
||||||
}
|
}
|
||||||
|
|
||||||
//adding the underline
|
// Adding the underline
|
||||||
setAlternateActionTextAttributes([NSAttributedString.Key.underlineStyle: NSNumber(value: NSUnderlineStyle.single.rawValue)])
|
setAlternateActionTextAttributes([NSAttributedString.Key.underlineStyle: NSNumber(value: NSUnderlineStyle.single.rawValue)])
|
||||||
|
|
||||||
self.label?.attributedText = attributedText
|
self.label?.attributedText = attributedText
|
||||||
@ -423,6 +421,7 @@ public typealias CoreObjectActionLoadPresentDelegate = MVMCoreActionDelegateProt
|
|||||||
self.text = getTextFromStringComponents()
|
self.text = getTextFromStringComponents()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.text = actionRange.revisedText
|
||||||
setup()
|
setup()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -439,9 +438,8 @@ public typealias CoreObjectActionLoadPresentDelegate = MVMCoreActionDelegateProt
|
|||||||
fullText = fullText.replacingOccurrences(of: rightBrace, with: "")
|
fullText = fullText.replacingOccurrences(of: rightBrace, with: "")
|
||||||
}
|
}
|
||||||
|
|
||||||
self.text = fullText
|
|
||||||
actionRange.revisedText = fullText
|
|
||||||
|
|
||||||
|
actionRange.revisedText = fullText
|
||||||
return actionRange
|
return actionRange
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user