refactored out layout subviews, causing infinite loop
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
2f0600eafb
commit
85337833d4
@ -66,6 +66,7 @@ open class Control: UIControl, Handlerable, ViewProtocol, Resettable {
|
||||
if !initialSetupPerformed {
|
||||
initialSetupPerformed = true
|
||||
setup()
|
||||
setupDidChangeEvent()
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,11 +80,6 @@ open class Control: UIControl, Handlerable, ViewProtocol, Resettable {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Overrides
|
||||
//--------------------------------------------------
|
||||
open override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
updateView()
|
||||
}
|
||||
|
||||
open func updateView() {}
|
||||
|
||||
open func reset() {
|
||||
|
||||
@ -65,14 +65,10 @@ open class View: UIView, Handlerable, ViewProtocol, Resettable {
|
||||
if !initialSetupPerformed {
|
||||
initialSetupPerformed = true
|
||||
setup()
|
||||
setupDidChangeEvent()
|
||||
}
|
||||
}
|
||||
|
||||
open override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
updateView()
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Overrides
|
||||
//--------------------------------------------------
|
||||
|
||||
@ -31,7 +31,8 @@ open class Button: UIButton, Handlerable, ViewProtocol, Resettable, Useable {
|
||||
private var minWidthConstraint: NSLayoutConstraint?
|
||||
private var widthConstraint: NSLayoutConstraint?
|
||||
private var heightConstraint: NSLayoutConstraint?
|
||||
|
||||
private var initialSetupPerformed = false
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Properties
|
||||
//--------------------------------------------------
|
||||
@ -120,11 +121,14 @@ open class Button: UIButton, Handlerable, ViewProtocol, Resettable, Useable {
|
||||
// MARK: - Public Functions
|
||||
//--------------------------------------------------
|
||||
open func initialSetup() {
|
||||
backgroundColor = .clear
|
||||
translatesAutoresizingMaskIntoConstraints = false
|
||||
accessibilityCustomActions = []
|
||||
accessibilityTraits = .staticText
|
||||
setup()
|
||||
if !initialSetupPerformed {
|
||||
backgroundColor = .clear
|
||||
translatesAutoresizingMaskIntoConstraints = false
|
||||
accessibilityCustomActions = []
|
||||
accessibilityTraits = .staticText
|
||||
setup()
|
||||
setupDidChangeEvent()
|
||||
}
|
||||
}
|
||||
|
||||
open func setup() {
|
||||
@ -150,11 +154,6 @@ open class Button: UIButton, Handlerable, ViewProtocol, Resettable, Useable {
|
||||
accessibilityCustomActions = []
|
||||
accessibilityTraits = .staticText
|
||||
}
|
||||
|
||||
open override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
updateView()
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Overrides
|
||||
|
||||
@ -26,11 +26,13 @@ open class LabelBase: UILabel, Handlerable, ViewProtocol, Resettable {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Properties
|
||||
//--------------------------------------------------
|
||||
private var initialSetupPerformed = false
|
||||
|
||||
open var surface: Surface = .light { didSet { didChange() }}
|
||||
|
||||
open var disabled: Bool = false { didSet { isEnabled = !disabled } }
|
||||
|
||||
open var attributes: [any LabelAttributeModel]? { didSet { didChange() }}
|
||||
open var attributes: [any LabelAttributeModel]? { didSet { didChange() }}
|
||||
|
||||
open var typograpicalStyle: TypographicalStyle = .defaultStyle { didSet { didChange() }}
|
||||
|
||||
@ -85,13 +87,16 @@ open class LabelBase: UILabel, Handlerable, ViewProtocol, Resettable {
|
||||
// MARK: - Public Functions
|
||||
//--------------------------------------------------
|
||||
open func initialSetup() {
|
||||
backgroundColor = .clear
|
||||
numberOfLines = 0
|
||||
lineBreakMode = .byWordWrapping
|
||||
translatesAutoresizingMaskIntoConstraints = false
|
||||
accessibilityCustomActions = []
|
||||
accessibilityTraits = .staticText
|
||||
setup()
|
||||
if !initialSetupPerformed {
|
||||
backgroundColor = .clear
|
||||
numberOfLines = 0
|
||||
lineBreakMode = .byWordWrapping
|
||||
translatesAutoresizingMaskIntoConstraints = false
|
||||
accessibilityCustomActions = []
|
||||
accessibilityTraits = .staticText
|
||||
setup()
|
||||
setupDidChangeEvent()
|
||||
}
|
||||
}
|
||||
|
||||
open func setup() {}
|
||||
@ -111,12 +116,7 @@ open class LabelBase: UILabel, Handlerable, ViewProtocol, Resettable {
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Overrides
|
||||
//--------------------------------------------------
|
||||
open override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
updateView()
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
open func updateView() {
|
||||
textAlignment = textPosition.textAlignment
|
||||
textColor = textColorConfiguration.getColor(self)
|
||||
|
||||
@ -17,6 +17,12 @@ public protocol Handlerable: AnyObject, Initable, Disabling, Surfaceable {
|
||||
|
||||
extension Handlerable {
|
||||
|
||||
public func setupDidChangeEvent() {
|
||||
handlerPublisher().sink { [weak self] _ in
|
||||
self?.updateView()
|
||||
}.store(in: &subscribers)
|
||||
}
|
||||
|
||||
public func handlerPublisher() -> AnyPublisher<Void, Never> {
|
||||
subject
|
||||
.eraseToAnyPublisher()
|
||||
@ -28,6 +34,5 @@ extension Handlerable {
|
||||
extension Handlerable where Self: UIView {
|
||||
public func didChange() {
|
||||
subject.send()
|
||||
setNeedsLayout()
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user