diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift index 691dbfa0..039ece9d 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift @@ -98,6 +98,18 @@ open class BarsIndicatorView: CarouselIndicator { ]) } + open override func layoutSubviews() { + super.layoutSubviews() + + if barReferences.isEmpty { + generateBars() + updateUI(previousIndex: previousIndex, + newIndex: currentIndex, + totalCount: numberOfPages, + isAnimated: false) + } + } + //-------------------------------------------------- // MARK: - Methods //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/NumericIndicatorView.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/NumericIndicatorView.swift index 3585be05..b4991d1e 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/NumericIndicatorView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/NumericIndicatorView.swift @@ -66,6 +66,17 @@ open class NumericIndicatorView: CarouselIndicator { pageCount.updateView(size) } + open override func layoutSubviews() { + super.layoutSubviews() + + if pageCount.text?.isEmpty == nil { + updateUI(previousIndex: previousIndex, + newIndex: currentIndex, + totalCount: numberOfPages, + isAnimated: false) + } + } + //-------------------------------------------------- // MARK: - Setup //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Organisms/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel.swift index 5fd0df36..4cf65f1b 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel.swift @@ -26,10 +26,8 @@ open class Carousel: View { /// The index of the page, does not include dummy cells. public var pageIndex: Int { - get { - return loop ? currentIndex - 2 : currentIndex - } - set(newIndex) { + get { return loop ? currentIndex - 2 : currentIndex } + set (newIndex) { currentIndex = loop ? newIndex + 2 : newIndex } } @@ -90,6 +88,7 @@ open class Carousel: View { } } + //-------------------------------------------------- // MARK: - MVMCoreViewProtocol //-------------------------------------------------- @@ -194,7 +193,7 @@ open class Carousel: View { pagingView = MoleculeObjectMapping.shared()?.createMolecule(molecule, delegateObject: delegateObject) as? (UIView & CarouselPageControlProtocol) } - addPaging(view: pagingView , position: (CGFloat(molecule?.position ?? 20))) + addPaging(view: pagingView, position: (CGFloat(molecule?.position ?? 20))) } /// Registers the cells with the collection view @@ -213,9 +212,7 @@ open class Carousel: View { /// Returns the (identifier, class) of the molecule for the given map. func getMoleculeInfo(with molecule: MoleculeModelProtocol, delegateObject: MVMCoreUIDelegateObject?) -> (identifier: String, class: AnyClass, molecule: MoleculeModelProtocol)? { - guard let className = MoleculeObjectMapping.shared()?.getMoleculeClass(molecule) else { - return nil - } + guard let className = MoleculeObjectMapping.shared()?.getMoleculeClass(molecule) else { return nil } return (className.nameForReuse(with: molecule, delegateObject) ?? molecule.moleculeName, className, molecule) } diff --git a/MVMCoreUI/Atomic/Protocols/MoleculeViewProtocol.swift b/MVMCoreUI/Atomic/Protocols/MoleculeViewProtocol.swift index db0de647..91f461dd 100644 --- a/MVMCoreUI/Atomic/Protocols/MoleculeViewProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/MoleculeViewProtocol.swift @@ -45,8 +45,8 @@ extension MoleculeViewProtocol { } // Do nothing, optionals. - public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {} - public func reset() {} + public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { } + public func reset() { } public static func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return nil