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

View File

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