From b1ff5b2a648bd49eacdeaaffdc71083b57cf7609 Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Fri, 9 Jul 2021 03:04:16 +0530 Subject: [PATCH] final carousel fixes --- MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift | 8 +++++++- MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift index 151574c7..a433ff1e 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift @@ -41,7 +41,7 @@ open class Carousel: View { open var numberOfPages = 0 /// The models for the molecules. - public var molecules: [MoleculeModelProtocol & CarouselItemModelProtocol]? + public var molecules: [MoleculeModelProtocol & CarouselItemModelProtocol & CollectionItemModelProtocol]? /// The horizontal alignment of the cell in the collection view. Only noticeable if the itemWidthPercent is less than 100%. public var itemAlignment = UICollectionView.ScrollPosition.left @@ -79,6 +79,7 @@ open class Carousel: View { DispatchQueue.main.async { self.layoutCollection() } + collectionView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) } /// Invalidates the layout and ensures we are paged to the correct cell. @@ -398,6 +399,11 @@ extension Carousel: UICollectionViewDelegateFlowLayout { } extension Carousel: UICollectionViewDataSource { + + open func numberOfSections(in collectionView: UICollectionView) -> Int { + return 1 + } + open func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return molecules?.count ?? 0 } diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift index 8721db72..df258324 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift @@ -20,7 +20,7 @@ import UIKit } public var backgroundColor: Color? - public var molecules: [MoleculeModelProtocol & CarouselItemModelProtocol] + public var molecules: [MoleculeModelProtocol & CarouselItemModelProtocol & CollectionItemModelProtocol] public var index: Int = 0 public var spacing: CGFloat? public var border: Bool? @@ -41,7 +41,7 @@ import UIKit public var selectable = false public var selectedIndex: Int? - public init(molecules: [MoleculeModelProtocol & CarouselItemModelProtocol]) { + public init(molecules: [MoleculeModelProtocol & CarouselItemModelProtocol & CollectionItemModelProtocol]) { self.molecules = molecules }