Digital ACT-191 ONEAPP-7013 story: update view as per aspect ratio
This commit is contained in:
parent
0840ed5ed3
commit
c51093cfaf
@ -355,6 +355,8 @@ open class Carousel: View {
|
|||||||
$0.backgroundColor = UIColor(red: CGFloat(216) / 255.0, green: CGFloat(218) / 255.0, blue: CGFloat(218) / 255.0, alpha: 1)
|
$0.backgroundColor = UIColor(red: CGFloat(216) / 255.0, green: CGFloat(218) / 255.0, blue: CGFloat(218) / 255.0, alpha: 1)
|
||||||
}
|
}
|
||||||
scrollView.addSubview(carouselSlot)
|
scrollView.addSubview(carouselSlot)
|
||||||
|
let size = ratioSize(for: minimumSlotWidth)
|
||||||
|
slotHeight = size.height
|
||||||
carouselSlot
|
carouselSlot
|
||||||
.pinTop()
|
.pinTop()
|
||||||
.pinBottom()
|
.pinBottom()
|
||||||
@ -382,17 +384,51 @@ open class Carousel: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
open override func reset() {
|
open override func reset() {
|
||||||
for subview in subviews {
|
|
||||||
for recognizer in subview.gestureRecognizers ?? [] {
|
|
||||||
subview.removeGestureRecognizer(recognizer)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
super.reset()
|
super.reset()
|
||||||
|
shouldUpdateView = false
|
||||||
|
aspectRatio = .ratio1x1
|
||||||
|
layout = UIDevice.isIPad ? .threeUP : .oneUP
|
||||||
|
pagination = .init(kind: .lowContrast, floating: true)
|
||||||
|
paginationDisplay = .none
|
||||||
|
paginationInset = UIDevice.isIPad ? VDSLayout.space3X : VDSLayout.space2X
|
||||||
|
gutter = UIDevice.isIPad ? .twentyFourPX : .twelvePX
|
||||||
|
peek = .standard
|
||||||
|
width = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Private Methods
|
// MARK: - Private Methods
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
private func ratioSize(for width: CGFloat) -> CGSize {
|
||||||
|
var height: CGFloat = width
|
||||||
|
|
||||||
|
switch aspectRatio {
|
||||||
|
case .ratio1x1:
|
||||||
|
break;
|
||||||
|
case .ratio3x4:
|
||||||
|
height = (4 / 3) * width
|
||||||
|
case .ratio4x3:
|
||||||
|
height = (3 / 4) * width
|
||||||
|
case .ratio2x3:
|
||||||
|
height = (3 / 2) * width
|
||||||
|
case .ratio3x2:
|
||||||
|
height = (2 / 3) * width
|
||||||
|
case .ratio9x16:
|
||||||
|
height = (16 / 9) * width
|
||||||
|
case .ratio16x9:
|
||||||
|
height = (9 / 16) * width
|
||||||
|
case .ratio1x2:
|
||||||
|
height = (2 / 1) * width
|
||||||
|
case .ratio2x1:
|
||||||
|
height = (1 / 2) * width
|
||||||
|
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
return CGSize(width: width, height: height)
|
||||||
|
}
|
||||||
|
|
||||||
func addlisteners() {
|
func addlisteners() {
|
||||||
nextButton.onClick = { _ in self.nextButtonClick() }
|
nextButton.onClick = { _ in self.nextButtonClick() }
|
||||||
previousButton.onClick = { _ in self.previousButtonClick() }
|
previousButton.onClick = { _ in self.previousButtonClick() }
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user