more updates on carousel

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-08-27 13:31:48 -05:00
parent ad6291af30
commit 35036ca804
2 changed files with 3 additions and 8 deletions

View File

@ -272,6 +272,7 @@ open class Carousel: View {
super.updateView()
updateScrollbar()
updateCarousel()
collectionView.collectionViewLayout.invalidateLayout()
collectionView.reloadData()
}
@ -516,11 +517,10 @@ extension Carousel: UICollectionViewDelegate, UICollectionViewDataSource, UIColl
public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: CarouselSlotCell.identifier, for: indexPath) as? CarouselSlotCell else { return UICollectionViewCell() }
cell.contentView.subviews.forEach { $0.removeFromSuperview() }
let component = views[indexPath.row]
cell.update(with: component, slotAlignment: slotAlignment, surface: surface)
cell.layoutIfNeeded()
component.setNeedsLayout()
//component.setNeedsLayout()
if hasDebugBorder {
cell.addDebugBorder()
} else {

View File

@ -25,11 +25,6 @@ final class CarouselSlotCell: UICollectionViewCell {
super.init(coder: coder)
setUp()
}
//--------------------------------------------------
// MARK: - Private Properties
//--------------------------------------------------
private var surface: Surface = .light
//--------------------------------------------------
// MARK: - Private Methods
@ -42,7 +37,7 @@ final class CarouselSlotCell: UICollectionViewCell {
/// Updating UI based on data along with surface.
func update(with component: UIView, slotAlignment: Carousel.CarouselSlotAlignmentModel?, surface: Surface) {
self.surface = surface
contentView.subviews.forEach { $0.removeFromSuperview() }
contentView.addSubview(component)
if var surfacedView = component as? Surfaceable {
surfacedView.surface = surface