Added Publisher for layoutHeight to update collectionViewHeight dynamically
This commit is contained in:
parent
e8a03cbea2
commit
78a63cdc3e
@ -64,6 +64,8 @@ open class ButtonGroup: View {
|
||||
|
||||
private var _childWidth: ChildWidth?
|
||||
|
||||
private var anyCancellable: AnyCancellable?
|
||||
|
||||
/// If provided, width of Button components will be rendered based on this value. If omitted, default button widths are rendered.
|
||||
open var childWidth: ChildWidth? {
|
||||
get { _childWidth }
|
||||
@ -134,6 +136,10 @@ open class ButtonGroup: View {
|
||||
collectionView.pinToSuperView()
|
||||
collectionViewHeight = heightAnchor.constraint(equalToConstant: VDS.Button.Size.large.height)
|
||||
collectionViewHeight?.activate()
|
||||
anyCancellable = positionLayout.$layoutHeight.receive(on: RunLoop.main).sink { [weak self] _ in
|
||||
guard let self else { return }
|
||||
self.collectionViewHeight?.constant = self.collectionView.intrinsicContentSize.height
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
|
||||
@ -149,7 +149,7 @@ class ButtonGroupPositionLayout: UICollectionViewLayout {
|
||||
weak var delegate: ButtongGroupPositionLayoutDelegate?
|
||||
|
||||
// Total height of the content. Will be used to configure the scrollview content
|
||||
var layoutHeight: CGFloat = 0.0
|
||||
@Published var layoutHeight: CGFloat = 0.0
|
||||
var position: ButtonGroup.Alignment = .left
|
||||
var rowQuantity: Int = 0
|
||||
var buttonPercentage: CGFloat?
|
||||
|
||||
Loading…
Reference in New Issue
Block a user