From 8306f901bdc095a20c602a87cd66ade936902915 Mon Sep 17 00:00:00 2001 From: "Hedden, Kyle Matthew" Date: Thu, 21 Dec 2023 22:19:45 -0500 Subject: [PATCH 1/3] Open up progress bar atom for subclassing. --- MVMCoreUI/Atomic/Atoms/Views/ProgressBar.swift | 4 ++-- MVMCoreUI/Atomic/Atoms/Views/ProgressBarModel.swift | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/ProgressBar.swift b/MVMCoreUI/Atomic/Atoms/Views/ProgressBar.swift index a68cdc99..c806ce4b 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/ProgressBar.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/ProgressBar.swift @@ -54,7 +54,7 @@ import Foundation // MARK: - Lifecycle //-------------------------------------------------- - public func setupView() { + open func setupView() { clipsToBounds = true translatesAutoresizingMaskIntoConstraints = false @@ -70,7 +70,7 @@ import Foundation // MARK: - MVMCoreViewProtocol //-------------------------------------------------- - public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + open func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let progressBarModel = model as? ProgressBarModel else { return } diff --git a/MVMCoreUI/Atomic/Atoms/Views/ProgressBarModel.swift b/MVMCoreUI/Atomic/Atoms/Views/ProgressBarModel.swift index 439fad3d..c69e73e4 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/ProgressBarModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/ProgressBarModel.swift @@ -8,8 +8,8 @@ import Foundation -@objcMembers public class ProgressBarModel: MoleculeModelProtocol { - public static var identifier: String = "progressBar" +@objcMembers open class ProgressBarModel: MoleculeModelProtocol { + open class var identifier: String { "progressBar" } public var id: String = UUID().uuidString @Percent public var percent: CGFloat From c2c4e0f1f4cebb8ea1f844e1c4843050f59d2f3b Mon Sep 17 00:00:00 2001 From: "Hedden, Kyle Matthew" Date: Tue, 2 Jan 2024 17:24:42 -0500 Subject: [PATCH 2/3] indexing safety --- MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift | 2 +- MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift index 6b360120..2ad92343 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift @@ -87,7 +87,7 @@ open class Carousel: View { showPeaking(false) // Go to current cell. layoutIfNeeded is needed otherwise cellForItem returns nil for peaking logic. The dispatch is a sad way to ensure the collection view is ready to be scrolled. - guard let model = model as? CarouselModel, + guard let model = model as? CarouselModel, !model.molecules.isEmpty, (model.paging == true || loop == true) else { return } DispatchQueue.main.async { self.collectionView.scrollToItem(at: IndexPath(row: self.currentIndex, section: 0), at: self.itemAlignment, animated: false) diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift index 5bfd8d0f..04e98287 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift @@ -8,7 +8,6 @@ import UIKit - @objcMembers public class CarouselModel: ParentMoleculeModelProtocol, FormFieldProtocol { //-------------------------------------------------- @@ -57,14 +56,14 @@ import UIKit guard selectable else { // Use visible item value, else index - if let fieldValue = molecules[index].formFieldValue() { + if let fieldValue = molecules[safe: index]?.formFieldValue() { return fieldValue } return index } // Use selected item value, else index guard let selectedIndex = selectedIndex else { return nil } - guard let fieldValue = molecules[selectedIndex].formFieldValue() else { return selectedIndex } + guard let fieldValue = molecules[safe: selectedIndex]?.formFieldValue() else { return selectedIndex } return fieldValue } From 8a62065ade07030bc19dd092818ec309360a99a2 Mon Sep 17 00:00:00 2001 From: "Hedden, Kyle Matthew" Date: Thu, 11 Jan 2024 18:17:06 -0500 Subject: [PATCH 3/3] open encoder --- MVMCoreUI/Atomic/Atoms/Views/ProgressBarModel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/ProgressBarModel.swift b/MVMCoreUI/Atomic/Atoms/Views/ProgressBarModel.swift index c69e73e4..5e6a42c1 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/ProgressBarModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/ProgressBarModel.swift @@ -46,7 +46,7 @@ import Foundation thickness = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .thickness) } - public func encode(to encoder: Encoder) throws { + open func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) try container.encode(moleculeName, forKey: .moleculeName)