fixed issue with buttons in selector
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
a4598644f7
commit
ee772648b1
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,6 +60,7 @@ public class PickerSelectorView<EnumType: RawRepresentable>: 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<EnumType: RawRepresentable>: 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
|
||||
|
||||
@ -57,7 +57,7 @@ class TabsViewController: BaseViewController<Tabs> {
|
||||
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)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user