From c73c3496fc2d6fc88ae0a0193620a99c301c831b Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 18 Nov 2022 12:58:04 -0600 Subject: [PATCH] reverted code back to pin to parent Signed-off-by: Matt Bruce --- VDS/Components/Badge/Badge.swift | 18 ++---------------- VDS/Components/Toggle/Toggle.swift | 15 +-------------- 2 files changed, 3 insertions(+), 30 deletions(-) diff --git a/VDS/Components/Badge/Badge.swift b/VDS/Components/Badge/Badge.swift index e436bbf4..4aaa4c6c 100644 --- a/VDS/Components/Badge/Badge.swift +++ b/VDS/Components/Badge/Badge.swift @@ -18,11 +18,6 @@ public enum BadgeFillColor: String, Codable, CaseIterable { @objc(VDSBadge) public class Badge: View, Accessable { - private var contentView = UIView().with { - $0.translatesAutoresizingMaskIntoConstraints = false - $0.layer.cornerRadius = 2 - } - private var label = Label().with { $0.setContentCompressionResistancePriority(.required, for: .vertical) $0.adjustsFontSizeToFitWidth = false @@ -71,16 +66,7 @@ public class Badge: View, Accessable { isAccessibilityElement = true accessibilityTraits = .staticText - contentView.addSubview(label) - addSubview(contentView) - - contentView - .pinTop() - .pinBottom() - .pinLeading() - - contentView.trailingAnchor.constraint(lessThanOrEqualTo: trailingAnchor).isActive = true - + addSubview(label) label.pinToSuperView(.init(top: 2, left: 4, bottom: 2, right: 4)) maxWidthConstraint = label.widthAnchor.constraint(lessThanOrEqualToConstant: 100) @@ -188,7 +174,7 @@ public class Badge: View, Accessable { // MARK: - State //-------------------------------------------------- open override func updateView() { - contentView.backgroundColor = backgroundColor() + backgroundColor = backgroundColor() label.textColorConfiguration = textColorConfiguration() label.numberOfLines = numberOfLines diff --git a/VDS/Components/Toggle/Toggle.swift b/VDS/Components/Toggle/Toggle.swift index abf266d2..ab7428f1 100644 --- a/VDS/Components/Toggle/Toggle.swift +++ b/VDS/Components/Toggle/Toggle.swift @@ -62,11 +62,6 @@ open class ToggleBase: Control, Accessable, DataTrackable, BinaryColorable { //-------------------------------------------------- // MARK: - Private Properties //-------------------------------------------------- - private var contentView = UIView().with { - $0.translatesAutoresizingMaskIntoConstraints = false - $0.layer.cornerRadius = 2 - } - private var stackView = UIStackView().with { $0.translatesAutoresizingMaskIntoConstraints = false $0.axis = .horizontal @@ -257,15 +252,7 @@ open class ToggleBase: Control, Accessable, DataTrackable, BinaryColorable { isAccessibilityElement = true accessibilityTraits = .button - addSubview(contentView) - contentView.addSubview(stackView) - - contentView - .pinTop() - .pinBottom() - .pinLeading() - - contentView.trailingAnchor.constraint(lessThanOrEqualTo: trailingAnchor).isActive = true + addSubview(stackView) //set the h/w to container size, since the width "can" grow if text is there //allow this to be greaterThanEqualTo