refactored button group
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
94fcd7bf60
commit
b0f8fbc864
@ -13,7 +13,7 @@ import Combine
|
|||||||
|
|
||||||
/// A button group contains combinations of related CTAs including ``Button``, ``TextLink``, and ``TextLinkCaret``. This group component controls a combination's orientation, spacing, size and allowable size pairings.
|
/// A button group contains combinations of related CTAs including ``Button``, ``TextLink``, and ``TextLinkCaret``. This group component controls a combination's orientation, spacing, size and allowable size pairings.
|
||||||
@objc(VDSButtonGroup)
|
@objc(VDSButtonGroup)
|
||||||
open class ButtonGroup: View, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, UICollectionViewDelegate, ButtongGroupPositionLayoutDelegate {
|
open class ButtonGroup: View {
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Enums
|
// MARK: - Enums
|
||||||
@ -30,23 +30,24 @@ open class ButtonGroup: View, UICollectionViewDataSource, UICollectionViewDelega
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Public Properties
|
// MARK: - Public Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
//An object containing number of Button components per row for iPhones
|
/// An object containing number of Button components per row for iPhones
|
||||||
open var rowQuantityPhone: Int = 0 { didSet { setNeedsUpdate() } }
|
open var rowQuantityPhone: Int = 0 { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
//An object containing number of Button components per row for iPads
|
/// An object containing number of Button components per row for iPads
|
||||||
open var rowQuantityTablet: Int = 0 { didSet { setNeedsUpdate() } }
|
open var rowQuantityTablet: Int = 0 { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
// An object containing number of Button components per row
|
/// An object containing number of Button components per row
|
||||||
open var rowQuantity: Int { UIDevice.isIPad ? rowQuantityTablet : rowQuantityPhone }
|
open var rowQuantity: Int { UIDevice.isIPad ? rowQuantityTablet : rowQuantityPhone }
|
||||||
|
|
||||||
//If provided, aligns TextLink/TextLinkCaret alignment when rowQuantity is set one.
|
/// If provided, aligns TextLink/TextLinkCaret alignment when rowQuantity is set one.
|
||||||
open var alignment: Alignment = .center { didSet { setNeedsUpdate() }}
|
open var alignment: Alignment = .center { didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
/// Array of Buttonable Views that are shown in the group.
|
/// Array of Buttonable Views that are shown in the group.
|
||||||
open var buttons: [Buttonable] = [] { didSet { setNeedsUpdate() }}
|
open var buttons: [Buttonable] = [] { didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
/// If provided, width of Button components will be rendered based on this value. If omitted, default button widths are rendered.
|
|
||||||
private var _childWidth: ChildWidth?
|
private var _childWidth: ChildWidth?
|
||||||
|
|
||||||
|
/// If provided, width of Button components will be rendered based on this value. If omitted, default button widths are rendered.
|
||||||
open var childWidth: ChildWidth? {
|
open var childWidth: ChildWidth? {
|
||||||
get { _childWidth }
|
get { _childWidth }
|
||||||
set {
|
set {
|
||||||
@ -165,7 +166,9 @@ open class ButtonGroup: View, UICollectionViewDataSource, UICollectionViewDelega
|
|||||||
self.collectionView.collectionViewLayout.invalidateLayout()
|
self.collectionView.collectionViewLayout.invalidateLayout()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ButtonGroup: UICollectionViewDataSource, UICollectionViewDelegate {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - UICollectionViewDataSource
|
// MARK: - UICollectionViewDataSource
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -202,8 +205,10 @@ open class ButtonGroup: View, UICollectionViewDataSource, UICollectionViewDelega
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public func collectionView(_ collectionView: UICollectionView, buttonableAtIndexPath indexPath: IndexPath) -> Buttonable {
|
extension ButtonGroup : ButtongGroupPositionLayoutDelegate {
|
||||||
|
func collectionView(_ collectionView: UICollectionView, buttonableAtIndexPath indexPath: IndexPath) -> Buttonable {
|
||||||
buttons[indexPath.row]
|
buttons[indexPath.row]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user