Digital ACT-191 ONEAPP-7013 story: Refactored code, removing redundant view and adding component to slot.
This commit is contained in:
parent
559423f629
commit
93004f6e12
@ -417,32 +417,29 @@ open class Carousel: View {
|
||||
|
||||
// Add received component
|
||||
let item : CarouselSlotItemModel = .init(component: views[x])
|
||||
let contentViewHeight = estimateHeightFor(item: item, with: minimumSlotWidth)
|
||||
|
||||
// Add subview for content to Carousel Slot
|
||||
let contentView = View().with {
|
||||
$0.clipsToBounds = true
|
||||
}
|
||||
carouselSlot.addSubview(contentView)
|
||||
|
||||
if let component = item.component {
|
||||
carouselSlot.addSubview(component)
|
||||
if slotAlignment != nil {
|
||||
// If slotAlignment exist, should use expected height
|
||||
contentView.widthAnchor.constraint(equalToConstant: minimumSlotWidth).activate()
|
||||
contentView.heightAnchor.constraint(equalToConstant: contentViewHeight).activate()
|
||||
setSlotAlignment(contentView: contentView, parentView: carouselSlot)
|
||||
// If slotAlignment exist, use component's own sizes
|
||||
component.widthAnchor.constraint(lessThanOrEqualTo: carouselSlot.widthAnchor).activate()
|
||||
setSlotAlignment(contentView: component, parentView: carouselSlot)
|
||||
} else {
|
||||
// If no slotAlignment, should use full slot
|
||||
contentView.pinToSuperView()
|
||||
component.pinToSuperView()
|
||||
}
|
||||
carouselSlot.backgroundColor = .clear
|
||||
carouselSlot.layer.cornerRadius = 0
|
||||
contentView.addSubview(component)
|
||||
component.pinToSuperView()
|
||||
if var surfacedView = component as? Surfaceable {
|
||||
contentView.surface = surface
|
||||
surfacedView.surface = surface
|
||||
}
|
||||
|
||||
// TO BE REMOVED AFTER VQA - borderWidth and borderColor below did set only for Testing purpose to VQA
|
||||
carouselSlot.layer.borderWidth = 1.0
|
||||
carouselSlot.layer.borderColor = SurfaceColorConfiguration().with {
|
||||
$0.lightColor = VDSColor.elementsPrimaryOnlight
|
||||
$0.darkColor = VDSColor.elementsPrimaryOndark
|
||||
}.getColor(self).cgColor
|
||||
|
||||
}
|
||||
}
|
||||
scrollView.contentSize = CGSize(width: xPos - gutter.value, height: slotHeight)
|
||||
@ -462,7 +459,7 @@ open class Carousel: View {
|
||||
}
|
||||
|
||||
// Set slot alignment if provided. Used only when slot content have different heights or widths.
|
||||
private func setSlotAlignment(contentView: View, parentView: View) {
|
||||
private func setSlotAlignment(contentView: UIView, parentView: View) {
|
||||
parentView.backgroundColor = .clear
|
||||
switch slotAlignment?.vertical {
|
||||
case .top:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user