fixed bugs in generic
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
f768c6eab6
commit
cd58fc810e
@ -17,7 +17,7 @@ open class LabelBase<ModelType: LabelModel>: UILabel, ModelHandlerable, Initable
|
||||
//--------------------------------------------------
|
||||
// MARK: - Combine Properties
|
||||
//--------------------------------------------------
|
||||
@Published public var model = ModelType()
|
||||
@Published public var model: ModelType
|
||||
private var cancellable: AnyCancellable?
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -58,6 +58,7 @@ open class LabelBase<ModelType: LabelModel>: UILabel, ModelHandlerable, Initable
|
||||
//--------------------------------------------------
|
||||
required public convenience init() {
|
||||
self.init(frame: .zero)
|
||||
self.model = ModelType()
|
||||
}
|
||||
|
||||
public required convenience init(with model: ModelType) {
|
||||
@ -67,11 +68,13 @@ open class LabelBase<ModelType: LabelModel>: UILabel, ModelHandlerable, Initable
|
||||
}
|
||||
|
||||
public override init(frame: CGRect) {
|
||||
self.model = ModelType()
|
||||
super.init(frame: frame)
|
||||
setup()
|
||||
}
|
||||
|
||||
required public init?(coder: NSCoder) {
|
||||
self.model = ModelType()
|
||||
super.init(coder: coder)
|
||||
setup()
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ open class ToggleBase<ModelType: ToggleModel>: Control<ModelType>, Changable {
|
||||
let stackView = UIStackView()
|
||||
stackView.translatesAutoresizingMaskIntoConstraints = false
|
||||
stackView.axis = .horizontal
|
||||
stackView.distribution = .fillProportionally
|
||||
stackView.distribution = .fill
|
||||
return stackView
|
||||
}()
|
||||
|
||||
@ -247,15 +247,19 @@ open class ToggleBase<ModelType: ToggleModel>: Control<ModelType>, Changable {
|
||||
// MARK: - Labels
|
||||
//--------------------------------------------------
|
||||
private func updateLabel(_ viewModel: ModelType) {
|
||||
stackView.spacing = viewModel.showText ? 12 : 0
|
||||
let showText = viewModel.showText
|
||||
stackView.spacing = showText ? 12 : 0
|
||||
|
||||
if stackView.subviews.contains(label) {
|
||||
label.removeFromSuperview()
|
||||
}
|
||||
|
||||
if showText {
|
||||
if textPosition == .left {
|
||||
stackView.insertArrangedSubview(label, at: 0)
|
||||
} else {
|
||||
stackView.addArrangedSubview(label)
|
||||
}
|
||||
} else if stackView.subviews.contains(label) {
|
||||
label.removeFromSuperview()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user