Digital ACT-191 ONEAPP-7013 story: Fixed Constraints issue and refactored Code
This commit is contained in:
parent
de8a2ebdee
commit
a829df86e5
@ -33,20 +33,6 @@ open class Carousel: View {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Enums
|
||||
//--------------------------------------------------
|
||||
/// Enum used to describe the aspect ratios used for this component.
|
||||
public enum AspectRatio: String, CaseIterable {
|
||||
case ratio1x1 = "1:1"
|
||||
case ratio3x4 = "3:4"
|
||||
case ratio4x3 = "4:3"
|
||||
case ratio2x3 = "2:3"
|
||||
case ratio3x2 = "3:2"
|
||||
case ratio9x16 = "9:16"
|
||||
case ratio16x9 = "16:9"
|
||||
case ratio1x2 = "1:2"
|
||||
case ratio2x1 = "2:1"
|
||||
case none
|
||||
}
|
||||
|
||||
/// Space between each tile. The default value will be 24px (6X) in tablet and 12px (3X) in mobile.
|
||||
public enum Gutter: String, CaseIterable {
|
||||
case twelvePX = "12px"
|
||||
@ -73,7 +59,6 @@ open class Carousel: View {
|
||||
case standard, minimum, none
|
||||
}
|
||||
|
||||
// TO DO: move to model class
|
||||
/// Enum used to describe the vertical of slotAlignment.
|
||||
public enum Vertical: String, CaseIterable {
|
||||
case top, middle, bottom
|
||||
@ -94,7 +79,7 @@ open class Carousel: View {
|
||||
// MARK: - Public Properties
|
||||
//--------------------------------------------------
|
||||
/// Aspect-ratio options for tilelet in the carousel. If 'none' is passed, the tilelet will take the height of the tallest item in the carousel.
|
||||
open var aspectRatio: AspectRatio = .ratio1x1 { didSet { setNeedsUpdate() } }
|
||||
open var aspectRatio: Tilelet.AspectRatio = .ratio1x1 { didSet { setNeedsUpdate() } }
|
||||
|
||||
/// Data used to render tilelets in the carousel.
|
||||
open var data: [Any] = [] { didSet { setNeedsUpdate() } }
|
||||
@ -140,7 +125,7 @@ open class Carousel: View {
|
||||
}
|
||||
|
||||
/// A callback when moving the carousel. Returns event object and selectedGroupIndex.
|
||||
open var onChange: ((Int) -> Void)? { // TO DO: return object and index
|
||||
open var onChange: ((Int) -> Void)? {
|
||||
get { nil }
|
||||
set {
|
||||
onChangeCancellable?.cancel()
|
||||
@ -253,6 +238,10 @@ open class Carousel: View {
|
||||
open var onChangePublisher = PassthroughSubject<Int, Never>()
|
||||
private var onChangeCancellable: AnyCancellable?
|
||||
|
||||
/// A publisher for when the carousel moves. Passes parameters (data).
|
||||
open var onScrollPublisher = PassthroughSubject<Array<Any>, Never>()
|
||||
private var onScrollCancellable: AnyCancellable?
|
||||
|
||||
internal var _layout: CarouselScrollbar.Layout = UIDevice.isIPad ? .threeUP : .oneUP
|
||||
internal var _pagination: CarouselPaginationModel = .init(kind: .lowContrast, floating: true)
|
||||
internal var _paginationDisplay: PaginationDisplay = .none
|
||||
@ -320,8 +309,10 @@ open class Carousel: View {
|
||||
.pinBottom()
|
||||
.pinLeading()
|
||||
.pinTrailing()
|
||||
.heightGreaterThanEqualTo(scrollbarTopSpace + containerSize.height)
|
||||
.heightGreaterThanEqualTo(containerSize.height)
|
||||
contentStackView.centerXAnchor.constraint(equalTo: centerXAnchor).activate()
|
||||
|
||||
addlisteners()
|
||||
}
|
||||
|
||||
open override func updateView() {
|
||||
@ -365,7 +356,6 @@ open class Carousel: View {
|
||||
.height(slotHeight)
|
||||
xPos = xPos + minimumSlotWidth + gutter.value
|
||||
}
|
||||
scrollView.heightAnchor.constraint(equalToConstant: slotHeight).isActive = true
|
||||
scrollView.contentSize = CGSize(width: xPos - gutter.value, height: slotHeight)
|
||||
}
|
||||
|
||||
@ -380,7 +370,6 @@ open class Carousel: View {
|
||||
containerViewHeightConstraint?.isActive = true
|
||||
containerStackHeightConstraint?.isActive = true
|
||||
|
||||
addlisteners()
|
||||
layoutIfNeeded()
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user