diff --git a/VDS/Components/Buttons/ButtonGroup/ButtonGroupConstants.swift b/VDS/Components/Buttons/ButtonGroup/ButtonGroupConstants.swift index 193f5723..015be8b4 100644 --- a/VDS/Components/Buttons/ButtonGroup/ButtonGroupConstants.swift +++ b/VDS/Components/Buttons/ButtonGroup/ButtonGroupConstants.swift @@ -97,11 +97,15 @@ struct ButtonGroupConstants { } //text link caret else if let _ = primary as? TextLinkCaret { - if let _ = neighboring as? TextLinkCaret { - return 24.0 - } else { - return defaultSpace - } + if let neighboringButton = neighboring as? Button, neighboringButton.size == .large { + return 16.0 + } else if let _ = neighboring as? TextLinkCaret { + return 24.0 + } else if let neighboringTextLink = neighboring as? TextLink, neighboringTextLink.size == .large { + return 24.0 + } else { + return defaultSpace + } } //small button else if let button = primary as? Button, button.size == .small { @@ -117,6 +121,8 @@ struct ButtonGroupConstants { else if let textLink = primary as? TextLink, textLink.size == .small { if let neighboringTextLink = neighboring as? TextLink, neighboringTextLink.size == .small { return 32.0 + } else if let neighboringButton = neighboring as? Button, neighboringButton.size == .small { + return 24.0 } else { return defaultSpace } diff --git a/VDS/Components/Buttons/ButtonGroup/ButtonGroupPositionLayout.swift b/VDS/Components/Buttons/ButtonGroup/ButtonGroupPositionLayout.swift index aea4e7f6..5ab5fe37 100644 --- a/VDS/Components/Buttons/ButtonGroup/ButtonGroupPositionLayout.swift +++ b/VDS/Components/Buttons/ButtonGroup/ButtonGroupPositionLayout.swift @@ -32,6 +32,11 @@ class ButtonCollectionViewRow { attributes.compactMap{$0.frame.height}.max() ?? 0 } + var maxHeightIndexPath: IndexPath { + let maxHeight = rowHeight + return attributes.first(where: {$0.frame.height == maxHeight})!.indexPath + } + var rowY: CGFloat = 0 { didSet { for attribute in attributes { @@ -179,10 +184,7 @@ class ButtonGroupPositionLayout: UICollectionViewLayout { } layoutWidthIterator = 0.0 - - // recalculate rows x based off of positions - rows.forEach { $0.layout(for: position, with: collectionViewWidth) } - + // calculate the layoutHeight = 0.0 @@ -194,7 +196,7 @@ class ButtonGroupPositionLayout: UICollectionViewLayout { var rowSpacing = 0.0 if item > 0 { - rowSpacing = row.hasButtons ? ButtonGroupConstants.rowSpacingButton : ButtonGroupConstants.rowSpacingTextLink + rowSpacing = 12.0 row.rowY = layoutHeight + rowSpacing layoutHeight += rowSpacing } @@ -202,6 +204,9 @@ class ButtonGroupPositionLayout: UICollectionViewLayout { layoutHeight += row.rowHeight } + // recalculate rows x based off of positions + rows.forEach { $0.layout(for: position, with: collectionViewWidth) } + let rowAttributes = rows.flatMap { $0.attributes } itemCache = rowAttributes