Digital ACT-191 ONEAPP-7013 story: Using custom container size and custom icon sizes for positioning controls

This commit is contained in:
vasavk 2024-06-13 14:13:27 +05:30
parent ba1ffdf390
commit de8a2ebdee

View File

@ -47,33 +47,6 @@ open class Carousel: View {
case none case none
} }
/// Enum used to describe the number of slides visible in the carousel container at one time. The default value will be 3UP in tablet and 1UP in mobile.
public enum Layout: String, CaseIterable {
case oneUP = "1UP"
case twoUP = "2UP"
case threeUP = "3UP"
case fourUP = "4UP"
case fiveUP = "5UP"
case sixUP = "6UP"
var value: Int {
switch self {
case .oneUP:
1
case .twoUP:
2
case .threeUP:
3
case .fourUP:
4
case .fiveUP:
5
case .sixUP:
6
}
}
}
/// Space between each tile. The default value will be 24px (6X) in tablet and 12px (3X) in mobile. /// Space between each tile. The default value will be 24px (6X) in tablet and 12px (3X) in mobile.
public enum Gutter: String, CaseIterable { public enum Gutter: String, CaseIterable {
case twelvePX = "12px" case twelvePX = "12px"
@ -263,8 +236,8 @@ open class Carousel: View {
$0.kind = .lowContrast $0.kind = .lowContrast
$0.iconName = .leftCaret $0.iconName = .leftCaret
$0.iconOffset = .init(x: -2, y: 0) $0.iconOffset = .init(x: -2, y: 0)
$0.icon.size = UIDevice.isIPad ? .small : .xsmall $0.customContainerSize = UIDevice.isIPad ? 40 : 28
$0.size = UIDevice.isIPad ? .large : .small $0.icon.customSize = UIDevice.isIPad ? 16 : 12
} }
/// Next button to show next slide. /// Next button to show next slide.
@ -272,8 +245,8 @@ open class Carousel: View {
$0.kind = .lowContrast $0.kind = .lowContrast
$0.iconName = .rightCaret $0.iconName = .rightCaret
$0.iconOffset = .init(x: 2, y: 0) $0.iconOffset = .init(x: 2, y: 0)
$0.icon.size = UIDevice.isIPad ? .small : .xsmall $0.customContainerSize = UIDevice.isIPad ? 40 : 28
$0.size = UIDevice.isIPad ? .large : .small $0.icon.customSize = UIDevice.isIPad ? 16 : 12
} }
/// A publisher for when the scrubber position changes. Passes parameters (position). /// A publisher for when the scrubber position changes. Passes parameters (position).
@ -355,10 +328,10 @@ open class Carousel: View {
super.updateView() super.updateView()
carouselScrollBar.numberOfSlides = data.count carouselScrollBar.numberOfSlides = data.count
carouselScrollBar.position = (carouselScrollBar.position == 0 || carouselScrollBar.position > carouselScrollBar.numberOfSlides) ? 1 : carouselScrollBar.position
carouselScrollBar.layout = _layout carouselScrollBar.layout = _layout
carouselScrollBar.isHidden = (Int((Float(carouselScrollBar.numberOfSlides)) * Float(carouselScrollBar._layout.value)) <= 1) ? true : false carouselScrollBar.position = (carouselScrollBar.position == 0 || carouselScrollBar.position > carouselScrollBar.numberOfSlides) ? 1 : carouselScrollBar.position
carouselScrollBar.isHidden = (totalPositions() <= 1) ? true : false
// When peek is set to none, pagination controls are automatically set to persistent. // When peek is set to none, pagination controls are automatically set to persistent.
if peek == .none { if peek == .none {
paginationDisplay = .persistent paginationDisplay = .persistent