diff --git a/VDS/Components/Buttons/ButtonGroup/ButtonGroup.swift b/VDS/Components/Buttons/ButtonGroup/ButtonGroup.swift index 1fdbc56d..296a5224 100644 --- a/VDS/Components/Buttons/ButtonGroup/ButtonGroup.swift +++ b/VDS/Components/Buttons/ButtonGroup/ButtonGroup.swift @@ -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 + } } //-------------------------------------------------- diff --git a/VDS/Components/Buttons/ButtonGroup/ButtonGroupPositionLayout.swift b/VDS/Components/Buttons/ButtonGroup/ButtonGroupPositionLayout.swift index c1a315eb..7c099a7c 100644 --- a/VDS/Components/Buttons/ButtonGroup/ButtonGroupPositionLayout.swift +++ b/VDS/Components/Buttons/ButtonGroup/ButtonGroupPositionLayout.swift @@ -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?