updated buttongroup for position
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
deb21d8916
commit
8cd5cd55e6
@ -25,7 +25,7 @@ open class ButtonGroup: View, UICollectionViewDataSource, UICollectionViewDelega
|
||||
public var rowQuantity: Int { UIDevice.isIPad ? rowQuantityTablet : rowQuantityPhone }
|
||||
|
||||
//If provided, aligns TextLink/TextLinkCaret alignment when rowQuantity is set one.
|
||||
open var textPosition: TextPosition = .center { didSet { didChange() }}
|
||||
open var buttonPosition: ButtonPosition = .center { didSet { didChange() }}
|
||||
|
||||
open var buttons: [Buttonable] = [] { didSet { didChange() }}
|
||||
|
||||
@ -49,11 +49,12 @@ open class ButtonGroup: View, UICollectionViewDataSource, UICollectionViewDelega
|
||||
private let estimatedCellHeight: CGFloat = 40.0
|
||||
private let estimatedCellWidth: CGFloat = 150.0
|
||||
|
||||
fileprivate lazy var positionLayout = ButtonGroupPositionLayout().with {
|
||||
$0.position = .center
|
||||
$0.delegate = self
|
||||
}
|
||||
|
||||
fileprivate lazy var collectionView: SelfSizingCollectionView = {
|
||||
let positionLayout = ButtonGroupPositionLayout().with {
|
||||
$0.position = .center
|
||||
$0.delegate = self
|
||||
}
|
||||
|
||||
return SelfSizingCollectionView(frame: .zero, collectionViewLayout: positionLayout).with {
|
||||
$0.backgroundColor = .clear
|
||||
@ -120,6 +121,7 @@ open class ButtonGroup: View, UICollectionViewDataSource, UICollectionViewDelega
|
||||
//--------------------------------------------------
|
||||
open override func updateView() {
|
||||
super.updateView()
|
||||
positionLayout.position = buttonPosition
|
||||
collectionView.reloadData()
|
||||
}
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ class ButtonCollectionViewRow {
|
||||
}) + CGFloat(attributes.count - 1) * spacing
|
||||
}
|
||||
|
||||
func layout(for position: ButtonViewPosition, with collectionViewWidth: CGFloat){
|
||||
func layout(for position: ButtonPosition, with collectionViewWidth: CGFloat){
|
||||
var offset = 0.0
|
||||
|
||||
switch position {
|
||||
@ -45,7 +45,7 @@ class ButtonCollectionViewRow {
|
||||
}
|
||||
}
|
||||
|
||||
public enum ButtonViewPosition: String, CaseIterable {
|
||||
public enum ButtonPosition: String, CaseIterable {
|
||||
case left, center, right
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ class ButtonGroupPositionLayout: UICollectionViewLayout {
|
||||
|
||||
// Total height of the content. Will be used to configure the scrollview content
|
||||
var layoutHeight: CGFloat = 0.0
|
||||
var position: ButtonViewPosition = .left
|
||||
var position: ButtonPosition = .left
|
||||
private var itemCache: [UICollectionViewLayoutAttributes] = []
|
||||
|
||||
override func prepare() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user