From b67d63c159cd211cce2955a7f199e5cb529152ec Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Thu, 8 Jul 2021 00:46:30 +0530 Subject: [PATCH 01/11] Carousel bug fixes: NSADT-89473 & NSADT-88840 --- MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift index 67e024ca..1762b9ce 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift @@ -216,6 +216,8 @@ open class Carousel: View { molecule.moleculeName == pagingMoleculeName { pagingView?.set(with: molecule, delegateObject, nil) pagingView?.numberOfPages = numberOfPages + pagingView?.currentIndex = currentIndex + updateModelIndex() return } From 7441968f41070ad6a4c31c2553d9bcb541edaaee Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Thu, 8 Jul 2021 01:50:49 +0530 Subject: [PATCH 02/11] pagination, model and reset fixes --- .../Views/CarouselIndicator/BarsIndicatorView.swift | 1 + .../Views/CarouselIndicator/CarouselIndicator.swift | 6 ++++++ MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift | 12 ++++++++++++ 3 files changed, 19 insertions(+) diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift index 975c7ebb..8a1f960b 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift @@ -234,6 +234,7 @@ open class BarsIndicatorView: CarouselIndicator { super.reset() barReferences.forEach { $0.removeFromSuperview() } barReferences = [] + currentIndex = 0 } public override func updateUI(previousIndex: Int, newIndex: Int, totalCount: Int, isAnimated: Bool) { diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift index 6a82ef80..5b04d065 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift @@ -248,4 +248,10 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol { bottomConstraint?.constant = constant topConstraint?.constant = constant } + + open override func reset() { + super.reset() + currentIndex = 0 + previousIndex = 0 + } } diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift index 1762b9ce..151574c7 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift @@ -177,6 +177,7 @@ open class Carousel: View { if let selectedIndex = carouselModel.selectedIndex { let adjustedIndex = loop ? selectedIndex + 2 : selectedIndex collectionView.selectItem(at: IndexPath(row: adjustedIndex, section: 0), animated: false, scrollPosition: []) + goTo(adjustedIndex, animated: false) } } @@ -207,6 +208,13 @@ open class Carousel: View { pageIndex = 0 } + open override func reset() { + super.reset() + currentIndex = 0 + pageIndex = 0 + pagingView?.reset() + } + var pagingMoleculeName: String? /// Sets up the paging molecule @@ -425,6 +433,10 @@ extension Carousel: UICollectionViewDelegate { adjustedIndex = adjustedIndex + numberOfPages } model.selectedIndex = adjustedIndex + currentIndex = adjustedIndex + pageIndex = currentIndex + pagingView?.currentIndex = adjustedIndex + updateModelIndex() } if let cell = collectionView.cellForItem(at: indexPath) as? CollectionTemplateItemProtocol { cell.didSelectCell(at: indexPath, delegateObject: delegateObject, additionalData: nil) From b1ff5b2a648bd49eacdeaaffdc71083b57cf7609 Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Fri, 9 Jul 2021 03:04:16 +0530 Subject: [PATCH 03/11] 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 } From f820d8e1504520833bc348c55dd45736e5543c4b Mon Sep 17 00:00:00 2001 From: "Tondapu, Alekhya" Date: Mon, 12 Jul 2021 19:57:09 +0530 Subject: [PATCH 04/11] Fixed scroll reload Index issue --- MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift index a433ff1e..3fd5acf0 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift @@ -226,7 +226,6 @@ open class Carousel: View { pagingView?.set(with: molecule, delegateObject, nil) pagingView?.numberOfPages = numberOfPages pagingView?.currentIndex = currentIndex - updateModelIndex() return } From d7096c5dd1b466590dea13163ccd3752ca0366e3 Mon Sep 17 00:00:00 2001 From: "Tondapu, Alekhya" Date: Mon, 12 Jul 2021 20:23:43 +0530 Subject: [PATCH 05/11] removed unwanted code --- MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift | 6 ------ 1 file changed, 6 deletions(-) diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift index 3fd5acf0..24ae0c06 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift @@ -79,7 +79,6 @@ 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,11 +397,6 @@ 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 } From d567d3315870c48b1230232ecf15828a267a65c0 Mon Sep 17 00:00:00 2001 From: "Tondapu, Alekhya" Date: Wed, 21 Jul 2021 14:09:53 +0530 Subject: [PATCH 06/11] carousel fixes --- MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift index 24ae0c06..98f0e320 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift @@ -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. @@ -386,6 +387,10 @@ open class Carousel: View { } extension Carousel: UICollectionViewDelegateFlowLayout { + open func numberOfSections(in collectionView: UICollectionView) -> Int { + return 1 + } + open func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { let itemWidth = collectionView.bounds.width * itemWidthPercent return CGSize(width: itemWidth, height: collectionView.bounds.height) From 707f256a39aa3d5f9bfc312421d85aa1e673a2b9 Mon Sep 17 00:00:00 2001 From: "Tondapu, Alekhya" Date: Thu, 22 Jul 2021 00:01:53 +0530 Subject: [PATCH 07/11] removed unused code --- MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift | 4 ---- 1 file changed, 4 deletions(-) diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift index 98f0e320..3de10dad 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift @@ -387,10 +387,6 @@ open class Carousel: View { } extension Carousel: UICollectionViewDelegateFlowLayout { - open func numberOfSections(in collectionView: UICollectionView) -> Int { - return 1 - } - open func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { let itemWidth = collectionView.bounds.width * itemWidthPercent return CGSize(width: itemWidth, height: collectionView.bounds.height) From d3e02c3bd0bb48754f1bc1ad5d2aa763bc0fd067 Mon Sep 17 00:00:00 2001 From: "Tondapu, Alekhya" Date: Fri, 23 Jul 2021 00:47:38 +0530 Subject: [PATCH 08/11] Fixes for crash issue in carousel --- MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift index 3de10dad..a693ce2a 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift @@ -79,7 +79,6 @@ 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. @@ -211,9 +210,8 @@ open class Carousel: View { open override func reset() { super.reset() - currentIndex = 0 - pageIndex = 0 pagingView?.reset() + collectionView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) } var pagingMoleculeName: String? @@ -225,7 +223,7 @@ open class Carousel: View { molecule.moleculeName == pagingMoleculeName { pagingView?.set(with: molecule, delegateObject, nil) pagingView?.numberOfPages = numberOfPages - pagingView?.currentIndex = currentIndex + //pagingView?.currentIndex = currentIndex return } @@ -434,7 +432,6 @@ extension Carousel: UICollectionViewDelegate { } model.selectedIndex = adjustedIndex currentIndex = adjustedIndex - pageIndex = currentIndex pagingView?.currentIndex = adjustedIndex updateModelIndex() } From 5c5b0077e1527a3f6eb4d16a41a5b3f010c6f7ac Mon Sep 17 00:00:00 2001 From: "Tondapu, Alekhya" Date: Fri, 23 Jul 2021 00:50:16 +0530 Subject: [PATCH 09/11] Removed unwanted code --- MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift index a693ce2a..102bec40 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift @@ -223,7 +223,6 @@ open class Carousel: View { molecule.moleculeName == pagingMoleculeName { pagingView?.set(with: molecule, delegateObject, nil) pagingView?.numberOfPages = numberOfPages - //pagingView?.currentIndex = currentIndex return } From e42aaec8db58223640feea22a197f775fcf5d526 Mon Sep 17 00:00:00 2001 From: "Tondapu, Alekhya" Date: Fri, 23 Jul 2021 22:21:08 +0530 Subject: [PATCH 10/11] Reverted index code changes in didSelect --- MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift | 3 --- 1 file changed, 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift index 9b1d7b54..8c690b3c 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift @@ -429,9 +429,6 @@ extension Carousel: UICollectionViewDelegate { adjustedIndex = adjustedIndex + numberOfPages } model.selectedIndex = adjustedIndex - currentIndex = adjustedIndex - pagingView?.currentIndex = adjustedIndex - updateModelIndex() } if let cell = collectionView.cellForItem(at: indexPath) as? CollectionTemplateItemProtocol { cell.didSelectCell(at: indexPath, delegateObject: delegateObject, additionalData: nil) From b7479e2f7b1cfd70cd046dd42b1c8b58a695cf00 Mon Sep 17 00:00:00 2001 From: "Tondapu, Alekhya" Date: Fri, 23 Jul 2021 23:42:40 +0530 Subject: [PATCH 11/11] Removed contentInset line --- MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift index 8c690b3c..fcaa1010 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift @@ -210,7 +210,6 @@ open class Carousel: View { open override func reset() { super.reset() pagingView?.reset() - collectionView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) } var pagingMoleculeName: String?