From cd5d9b0c4aed071be94772b778191f3a6da5c99c Mon Sep 17 00:00:00 2001 From: "Hedden, Kyle Matthew" Date: Tue, 14 May 2024 20:30:11 -0400 Subject: [PATCH] Digital PCT265 story PCT-135: Pager fix. TwoButtonViewModel isEqual. --- .../TwoButtonViewModel.swift | 16 ++++++++++++++++ .../Atomic/Organisms/Carousel/Carousel.swift | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift index dc471e0a..2d978f17 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift @@ -86,4 +86,20 @@ public class TwoButtonViewModel: ParentMoleculeModelProtocol { try container.encodeIfPresent(secondaryButton, forKey: .secondaryButton) try container.encodeIfPresent(fillContainer, forKey: .fillContainer) } + + public func isEqual(to model: any ModelComparisonProtocol) -> Bool { + guard let model = model as? Self else { return false } + return backgroundColor == model.backgroundColor + && fillContainer == model.fillContainer + && primaryButton.isEqual(to: model.primaryButton) + && secondaryButton.isEqual(to: model.secondaryButton) + } + + public func isVisuallyEquivalent(to model: any MoleculeModelComparisonProtocol) -> Bool { + guard let model = model as? Self else { return false } + return backgroundColor == model.backgroundColor + && fillContainer == model.fillContainer + && primaryButton.isVisuallyEquivalent(to: model.primaryButton) + && secondaryButton.isVisuallyEquivalent(to: model.secondaryButton) + } } diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift index 1db78373..acd44595 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift @@ -178,7 +178,8 @@ open class Carousel: View { // Prevents a carousel reset while still updating the cell backing data through reconfigureItems. MVMCoreLoggingHandler.shared()?.handleDebugMessage("[\(Self.self)] Model is visually equivalent. Skipping rebuild...") FormValidator.setupValidation(for: carouselModel, delegate: delegateObject?.formHolderDelegate) - pagingView?.currentIndex = originalModel.index // Trigger a paging view render. + updateModelIndex() // Ensure the new model indexing matches the old. + pagingView?.currentIndex = pageIndex // Trigger a paging view render. collectionView.reconfigureItems(at: collectionView.indexPathsForVisibleItems) return }