Digital ACT-191 ONEAPP-7013 story: updating pagination buttons while changing pagination properties
This commit is contained in:
parent
bc35186bf6
commit
0fc8c5c530
@ -228,7 +228,25 @@ open class Carousel: View {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.backgroundColor = .clear
|
||||
}
|
||||
|
||||
|
||||
/// Previous button to show previous slide.
|
||||
private var previousButton = ButtonIcon().with {
|
||||
$0.kind = .lowContrast
|
||||
$0.iconName = .leftCaret
|
||||
$0.iconOffset = .init(x: -2, y: 0)
|
||||
$0.icon.size = UIDevice.isIPad ? .small : .xsmall
|
||||
$0.size = UIDevice.isIPad ? .large : .small
|
||||
}
|
||||
|
||||
/// Next button to show next slide.
|
||||
private var nextButton = ButtonIcon().with {
|
||||
$0.kind = .lowContrast
|
||||
$0.iconName = .rightCaret
|
||||
$0.iconOffset = .init(x: 2, y: 0)
|
||||
$0.icon.size = UIDevice.isIPad ? .small : .xsmall
|
||||
$0.size = UIDevice.isIPad ? .large : .small
|
||||
}
|
||||
|
||||
/// A publisher for when the scrubber position changes. Passes parameters (position).
|
||||
open var onChangePublisher = PassthroughSubject<Int, Never>()
|
||||
private var onChangeCancellable: AnyCancellable?
|
||||
@ -277,13 +295,13 @@ open class Carousel: View {
|
||||
scrollContainerView.addSubview(scrollView)
|
||||
|
||||
// add pagination button icons
|
||||
scrollContainerView.addSubview(pagination.previousButton)
|
||||
pagination.previousButton
|
||||
scrollContainerView.addSubview(previousButton)
|
||||
previousButton
|
||||
.pinLeading(paginationInset)
|
||||
.pinCenterY()
|
||||
|
||||
scrollContainerView.addSubview(pagination.nextButton)
|
||||
pagination.nextButton
|
||||
scrollContainerView.addSubview(nextButton)
|
||||
nextButton
|
||||
.pinTrailing(paginationInset)
|
||||
.pinCenterY()
|
||||
|
||||
@ -306,8 +324,12 @@ open class Carousel: View {
|
||||
containerViewHeightConstraint = containerView.heightAnchor.constraint(equalToConstant: 200)
|
||||
containerViewHeightConstraint?.isActive = true
|
||||
|
||||
pagination.previousButton.isHidden = (paginationDisplay == .none)
|
||||
pagination.nextButton.isHidden = (paginationDisplay == .none)
|
||||
previousButton.isHidden = (paginationDisplay == .none)
|
||||
nextButton.isHidden = (paginationDisplay == .none)
|
||||
previousButton.kind = pagination.kind
|
||||
previousButton.floating = pagination.floating
|
||||
nextButton.kind = pagination.kind
|
||||
nextButton.floating = pagination.floating
|
||||
layoutIfNeeded()
|
||||
}
|
||||
|
||||
|
||||
@ -11,30 +11,16 @@ import UIKit
|
||||
/// Custom data type for pagination prop for 'Carousel' component.
|
||||
extension Carousel {
|
||||
public struct CarouselPaginationModel {
|
||||
|
||||
/// Button icon property 'kind' is supported
|
||||
public var kind: ButtonIcon.Kind
|
||||
|
||||
/// Previous button to show previous slide.
|
||||
public var previousButton = ButtonIcon().with {
|
||||
$0.kind = .lowContrast
|
||||
$0.iconName = .leftCaret
|
||||
$0.iconOffset = .init(x: -2, y: 0)
|
||||
$0.icon.size = UIDevice.isIPad ? .small : .xsmall
|
||||
$0.size = UIDevice.isIPad ? .large : .small
|
||||
}
|
||||
|
||||
/// Next button to show next slide.
|
||||
public var nextButton = ButtonIcon().with {
|
||||
$0.kind = .lowContrast
|
||||
$0.iconName = .rightCaret
|
||||
$0.iconOffset = .init(x: 2, y: 0)
|
||||
$0.icon.size = UIDevice.isIPad ? .small : .xsmall
|
||||
$0.size = UIDevice.isIPad ? .large : .small
|
||||
}
|
||||
/// Button icon property 'floating' is supported
|
||||
public var floating: Bool
|
||||
|
||||
public init(kind: ButtonIcon.Kind, floating: Bool) {
|
||||
previousButton.kind = kind
|
||||
nextButton.kind = kind
|
||||
previousButton.floating = floating
|
||||
nextButton.floating = floating
|
||||
self.kind = kind
|
||||
self.floating = floating
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user