From ee772648b197359efdddbbd36a5972751f33b744 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 25 May 2023 14:14:52 -0500 Subject: [PATCH] fixed issue with buttons in selector Signed-off-by: Matt Bruce --- VDSSample/Classes/Helper.swift | 12 +++++++++--- VDSSample/Protocols/PickerBase.swift | 3 ++- VDSSample/ViewControllers/TabsViewController.swift | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/VDSSample/Classes/Helper.swift b/VDSSample/Classes/Helper.swift index 8540dec..4b24467 100644 --- a/VDSSample/Classes/Helper.swift +++ b/VDSSample/Classes/Helper.swift @@ -10,7 +10,7 @@ import VDS import UIKit extension UIView { - public static func makeWrapper(for view: UIView, edgeSpacing: CGFloat = 0.0) -> UIView { + public static func makeWrapper(for view: UIView, edgeSpacing: CGFloat = 0.0, isTrailing: Bool = true) -> UIView { let wrapper = UIView().with { $0.translatesAutoresizingMaskIntoConstraints = false } @@ -18,8 +18,14 @@ extension UIView { view .pinTop(edgeSpacing) .pinBottom(edgeSpacing) - .pinLeading(edgeSpacing) - view.trailingAnchor.constraint(lessThanOrEqualTo: wrapper.trailingAnchor).isActive = true + + if isTrailing { + view.pinLeading(edgeSpacing) + view.trailingAnchor.constraint(lessThanOrEqualTo: wrapper.trailingAnchor).isActive = true + } else { + view.leadingAnchor.constraint(greaterThanOrEqualTo: wrapper.leadingAnchor).isActive = true + view.pinTrailing(edgeSpacing) + } return wrapper } } diff --git a/VDSSample/Protocols/PickerBase.swift b/VDSSample/Protocols/PickerBase.swift index 201b8d4..36ad337 100644 --- a/VDSSample/Protocols/PickerBase.swift +++ b/VDSSample/Protocols/PickerBase.swift @@ -60,6 +60,7 @@ public class PickerSelectorView: UIStackView, Picker public var items: [EnumType] { didSet { selectedIndex = 0 } } + public var onClick: AnyCancellable? public var onPickerDidSelect: ((EnumType) -> Void)? public var scrollToBottom: (()->Void)? public init(title: String, picker: UIPickerView? = nil, items: [EnumType]) { @@ -74,7 +75,7 @@ public class PickerSelectorView: UIStackView, Picker label.text = title updateSelectedIndex() addArrangedSubview(label) - addArrangedSubview(button) + addArrangedSubview(.makeWrapper(for: button, isTrailing: false)) button.onClick = { [weak self] _ in self?.picker?.delegate = self self?.picker?.dataSource = self diff --git a/VDSSample/ViewControllers/TabsViewController.swift b/VDSSample/ViewControllers/TabsViewController.swift index ce37a64..32fd06a 100644 --- a/VDSSample/ViewControllers/TabsViewController.swift +++ b/VDSSample/ViewControllers/TabsViewController.swift @@ -57,7 +57,7 @@ class TabsViewController: BaseViewController { addFormRow(label: "Show Borderline", view: .makeWrapper(for: borderlineSwitch)) addFormRow(label: "Surface", view: surfacePickerSelectorView) addFormRow(label: "Size", view: sizePickerSelectorView) - + if UIDevice.isIPad { addFormRow(label: "Orientation", view: orientationPickerSelectorView) }