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.translatesAutoresizingMaskIntoConstraints = false
|
||||||
$0.backgroundColor = .clear
|
$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).
|
/// A publisher for when the scrubber position changes. Passes parameters (position).
|
||||||
open var onChangePublisher = PassthroughSubject<Int, Never>()
|
open var onChangePublisher = PassthroughSubject<Int, Never>()
|
||||||
private var onChangeCancellable: AnyCancellable?
|
private var onChangeCancellable: AnyCancellable?
|
||||||
@ -277,13 +295,13 @@ open class Carousel: View {
|
|||||||
scrollContainerView.addSubview(scrollView)
|
scrollContainerView.addSubview(scrollView)
|
||||||
|
|
||||||
// add pagination button icons
|
// add pagination button icons
|
||||||
scrollContainerView.addSubview(pagination.previousButton)
|
scrollContainerView.addSubview(previousButton)
|
||||||
pagination.previousButton
|
previousButton
|
||||||
.pinLeading(paginationInset)
|
.pinLeading(paginationInset)
|
||||||
.pinCenterY()
|
.pinCenterY()
|
||||||
|
|
||||||
scrollContainerView.addSubview(pagination.nextButton)
|
scrollContainerView.addSubview(nextButton)
|
||||||
pagination.nextButton
|
nextButton
|
||||||
.pinTrailing(paginationInset)
|
.pinTrailing(paginationInset)
|
||||||
.pinCenterY()
|
.pinCenterY()
|
||||||
|
|
||||||
@ -306,8 +324,12 @@ open class Carousel: View {
|
|||||||
containerViewHeightConstraint = containerView.heightAnchor.constraint(equalToConstant: 200)
|
containerViewHeightConstraint = containerView.heightAnchor.constraint(equalToConstant: 200)
|
||||||
containerViewHeightConstraint?.isActive = true
|
containerViewHeightConstraint?.isActive = true
|
||||||
|
|
||||||
pagination.previousButton.isHidden = (paginationDisplay == .none)
|
previousButton.isHidden = (paginationDisplay == .none)
|
||||||
pagination.nextButton.isHidden = (paginationDisplay == .none)
|
nextButton.isHidden = (paginationDisplay == .none)
|
||||||
|
previousButton.kind = pagination.kind
|
||||||
|
previousButton.floating = pagination.floating
|
||||||
|
nextButton.kind = pagination.kind
|
||||||
|
nextButton.floating = pagination.floating
|
||||||
layoutIfNeeded()
|
layoutIfNeeded()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,30 +11,16 @@ import UIKit
|
|||||||
/// Custom data type for pagination prop for 'Carousel' component.
|
/// Custom data type for pagination prop for 'Carousel' component.
|
||||||
extension Carousel {
|
extension Carousel {
|
||||||
public struct CarouselPaginationModel {
|
public struct CarouselPaginationModel {
|
||||||
|
|
||||||
|
/// Button icon property 'kind' is supported
|
||||||
|
public var kind: ButtonIcon.Kind
|
||||||
|
|
||||||
/// Previous button to show previous slide.
|
/// Button icon property 'floating' is supported
|
||||||
public var previousButton = ButtonIcon().with {
|
public var floating: Bool
|
||||||
$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
|
|
||||||
}
|
|
||||||
|
|
||||||
public init(kind: ButtonIcon.Kind, floating: Bool) {
|
public init(kind: ButtonIcon.Kind, floating: Bool) {
|
||||||
previousButton.kind = kind
|
self.kind = kind
|
||||||
nextButton.kind = kind
|
self.floating = floating
|
||||||
previousButton.floating = floating
|
|
||||||
nextButton.floating = floating
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user