From 5a4aeb0a4e48aa0d0e3fd8c13d05ade69246a4f7 Mon Sep 17 00:00:00 2001 From: Damodaram Date: Mon, 18 Jan 2021 13:46:46 +0530 Subject: [PATCH 01/25] increased spacing --- .../VerticalCombinationViews/EyebrowHeadlineBodyLink.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift index ca76f0fb..55055e94 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift @@ -29,7 +29,7 @@ open override func setupView() { super.setupView() stack.setAndCreateModel(with: [eyebrow, headline, body, link]) - stack.stackModel?.spacing = 0 + stack.stackModel?.spacing = 2.0 addSubview(stack) NSLayoutConstraint.constraintPinSubview(toSuperview: stack) stack.restack() From 88ff5b2b9dc7d671db35b96ea83b27c4c8c34b4c Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Tue, 16 Feb 2021 23:24:42 +0530 Subject: [PATCH 02/25] Carousel form changes --- .../Atomic/Molecules/Items/CarouselItem.swift | 5 +++ .../Molecules/Items/CarouselItemModel.swift | 4 +++ .../Atomic/Organisms/Carousel/Carousel.swift | 12 +++++++ .../Organisms/Carousel/CarouselModel.swift | 33 +++++++++++++++++-- 4 files changed, 52 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/Items/CarouselItem.swift b/MVMCoreUI/Atomic/Molecules/Items/CarouselItem.swift index a37fe016..235e1f58 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/CarouselItem.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/CarouselItem.swift @@ -8,12 +8,17 @@ import Foundation +@objc public protocol CarouselItemSelected: class { + func itemSelected(fieldValue: String?, index: Int) +} + open class CarouselItem: MoleculeCollectionViewCell, CarouselItemProtocol { open var allowsPeaking = false var peakingLeftArrow = UIImageView(image: MVMCoreUIUtility.imageNamed("peakingRightArrow")?.withRenderingMode(.alwaysTemplate)) var peakingRightArrow = UIImageView(image: MVMCoreUIUtility.imageNamed("peakingRightArrow")?.withRenderingMode(.alwaysTemplate)) var peakingCover = MVMCoreUICommonViewsUtility.commonView() + @objc public weak var carouselDelegate: CarouselItemSelected? open override func addMolecule(_ molecule: MoleculeViewProtocol) { super.addMolecule(molecule) diff --git a/MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift index be67bfca..163909cb 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift @@ -21,6 +21,7 @@ import Foundation public var peakingUI: Bool? public var peakingArrowColor: Color? public var analyticsData: JSONValueDictionary? + public var fieldValue: String? //-------------------------------------------------- // MARK: - Keys @@ -30,6 +31,7 @@ import Foundation case peakingUI case peakingArrowColor case analyticsData + case fieldValue } //-------------------------------------------------- @@ -41,6 +43,7 @@ import Foundation peakingUI = try typeContainer.decodeIfPresent(Bool.self, forKey: .peakingUI) peakingArrowColor = try typeContainer.decodeIfPresent(Color.self, forKey: .peakingArrowColor) analyticsData = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .analyticsData) + fieldValue = try typeContainer.decodeIfPresent(String.self, forKey: .fieldValue) try super.init(from: decoder) } @@ -50,5 +53,6 @@ import Foundation try container.encodeIfPresent(peakingUI, forKey: .peakingUI) try container.encodeIfPresent(peakingArrowColor, forKey: .peakingArrowColor) try container.encodeIfPresent(analyticsData, forKey: .analyticsData) + try container.encodeIfPresent(fieldValue, forKey: .fieldValue) } } diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift index 31222828..d13d8294 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift @@ -167,6 +167,7 @@ open class Carousel: View { registerCells(with: carouselModel, delegateObject: delegateObject) prepareMolecules(with: carouselModel) + FormValidator.setupValidation(for: carouselModel, delegate: delegateObject?.formHolderDelegate) setupPagingMolecule(carouselModel.pagingMolecule, delegateObject: delegateObject) @@ -385,6 +386,7 @@ extension Carousel: UICollectionViewDataSource { protocolCell.set(with: moleculeInfo.molecule, delegateObject, nil) } (cell as? MVMCoreViewProtocol)?.updateView(size ?? collectionView.bounds.width) + (cell as? CarouselItem)?.carouselDelegate = self setAccessiblity(cell, index: indexPath.row) return cell } @@ -624,3 +626,13 @@ class CarouselAccessibilityElement: UIAccessibilityElement { return false } } + +extension Carousel: CarouselItemSelected { + public func itemSelected(fieldValue: String?, index: Int) { + if fieldValue != nil { + (model as? CarouselModel)?.selectedIndex = fieldValue + } else { + (model as? CarouselModel)?.selectedIndex = String(index) + } + } +} diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift index ca0a4a10..caa9f844 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift @@ -9,7 +9,8 @@ import UIKit -@objcMembers public class CarouselModel: MoleculeModelProtocol { +@objcMembers public class CarouselModel: MoleculeModelProtocol, FormFieldProtocol { + //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -33,11 +34,30 @@ import UIKit public var leftPadding: CGFloat? public var rightPadding: CGFloat? public var accessibilityText: String? - + public var selectedIndex: String? + public var baseValue: AnyHashable? + public var fieldKey: String? + public var groupName: String = FormValidator.defaultGroupName + public init(molecules: [MoleculeModelProtocol & CarouselItemModelProtocol]) { self.molecules = molecules } + public func formFieldValue() -> AnyHashable? { + var carouselItemFieldValue: AnyHashable? + guard let visibleCarouselItem = molecules[index] as? CarouselItemModel else { + return nil + } + if selectedIndex != nil { + //For selectableCarouselItem + carouselItemFieldValue = selectedIndex + } else { + //For carouselItem + carouselItemFieldValue = (visibleCarouselItem.fieldValue != nil) ? visibleCarouselItem.fieldValue : String(index) + } + return carouselItemFieldValue + } + //-------------------------------------------------- // MARK: - Keys //-------------------------------------------------- @@ -59,6 +79,8 @@ import UIKit case leftPadding case rightPadding case accessibilityText + case groupName + case fieldKey } //-------------------------------------------------- @@ -86,6 +108,11 @@ import UIKit leftPadding = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .leftPadding) rightPadding = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .rightPadding) accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) + fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) + if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { + self.groupName = groupName + } + baseValue = formFieldValue() } public func encode(to encoder: Encoder) throws { @@ -105,5 +132,7 @@ import UIKit try container.encodeIfPresent(leftPadding, forKey: .leftPadding) try container.encodeIfPresent(rightPadding, forKey: .rightPadding) try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText) + try container.encodeIfPresent(fieldKey, forKey: .fieldKey) + try container.encode(groupName, forKey: .groupName) } } From 1c2cd9ff6487669b9cede0a84cef93cf12905338 Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Fri, 26 Feb 2021 21:30:10 +0530 Subject: [PATCH 03/25] Code changes after review comment. --- .../Atomic/Molecules/Items/CarouselItem.swift | 5 ----- .../Atomic/Organisms/Carousel/Carousel.swift | 21 ++++++++----------- .../CollectionTemplateItemProtocol.swift | 9 ++++++++ .../BaseClasses/CollectionViewCell.swift | 5 +++++ 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/Items/CarouselItem.swift b/MVMCoreUI/Atomic/Molecules/Items/CarouselItem.swift index 235e1f58..a37fe016 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/CarouselItem.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/CarouselItem.swift @@ -8,17 +8,12 @@ import Foundation -@objc public protocol CarouselItemSelected: class { - func itemSelected(fieldValue: String?, index: Int) -} - open class CarouselItem: MoleculeCollectionViewCell, CarouselItemProtocol { open var allowsPeaking = false var peakingLeftArrow = UIImageView(image: MVMCoreUIUtility.imageNamed("peakingRightArrow")?.withRenderingMode(.alwaysTemplate)) var peakingRightArrow = UIImageView(image: MVMCoreUIUtility.imageNamed("peakingRightArrow")?.withRenderingMode(.alwaysTemplate)) var peakingCover = MVMCoreUICommonViewsUtility.commonView() - @objc public weak var carouselDelegate: CarouselItemSelected? open override func addMolecule(_ molecule: MoleculeViewProtocol) { super.addMolecule(molecule) diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift index d13d8294..b9475938 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift @@ -386,7 +386,6 @@ extension Carousel: UICollectionViewDataSource { protocolCell.set(with: moleculeInfo.molecule, delegateObject, nil) } (cell as? MVMCoreViewProtocol)?.updateView(size ?? collectionView.bounds.width) - (cell as? CarouselItem)?.carouselDelegate = self setAccessiblity(cell, index: indexPath.row) return cell } @@ -394,7 +393,15 @@ extension Carousel: UICollectionViewDataSource { extension Carousel: UICollectionViewDelegate { open func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - (collectionView.cellForItem(at: indexPath) as? CollectionTemplateItemProtocol)?.didSelectCell(at: indexPath, delegateObject: delegateObject, additionalData: nil) + guard let cell = collectionView.cellForItem(at: indexPath) as? CollectionTemplateItemProtocol else { + return + } + cell.didSelectCell(at: indexPath, delegateObject: delegateObject, additionalData: nil) + //Check for selectable carousel item + guard let carouselModel = model as? CarouselModel, let selectedCarouselItem = carouselModel.molecules[indexPath.row] as? CarouselItemModel, cell.shouldSelect(at: indexPath, delegateObject: delegateObject, additionalData: nil) else { + return + } + carouselModel.selectedIndex = selectedCarouselItem.fieldValue ?? String(indexPath.row) } } @@ -626,13 +633,3 @@ class CarouselAccessibilityElement: UIAccessibilityElement { return false } } - -extension Carousel: CarouselItemSelected { - public func itemSelected(fieldValue: String?, index: Int) { - if fieldValue != nil { - (model as? CarouselModel)?.selectedIndex = fieldValue - } else { - (model as? CarouselModel)?.selectedIndex = String(index) - } - } -} diff --git a/MVMCoreUI/Atomic/Templates/CollectionTemplateItemProtocol.swift b/MVMCoreUI/Atomic/Templates/CollectionTemplateItemProtocol.swift index 55db2c6d..98c9754e 100644 --- a/MVMCoreUI/Atomic/Templates/CollectionTemplateItemProtocol.swift +++ b/MVMCoreUI/Atomic/Templates/CollectionTemplateItemProtocol.swift @@ -19,6 +19,10 @@ public protocol CollectionTemplateItemProtocol: UICollectionViewCell { /// Called when the cell will display. func willDisplay() + + /// Handle the selection of cell + func shouldSelect(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Bool + } // Default implementation does nothing @@ -26,4 +30,9 @@ extension CollectionTemplateItemProtocol { public func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {} public func willDisplay() {} + + public func shouldSelect(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Bool { + return false + } + } diff --git a/MVMCoreUI/BaseClasses/CollectionViewCell.swift b/MVMCoreUI/BaseClasses/CollectionViewCell.swift index 4ac48dfc..aff6dffb 100644 --- a/MVMCoreUI/BaseClasses/CollectionViewCell.swift +++ b/MVMCoreUI/BaseClasses/CollectionViewCell.swift @@ -132,4 +132,9 @@ open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCo autoLayoutAttributes.frame = newFrame return autoLayoutAttributes } + + // Set default to false + open func shouldSelect(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) -> Bool { + return false + } } From 8465208d0b8f663d57490b0d5bf1f19353993d8e Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 1 Mar 2021 12:41:54 -0500 Subject: [PATCH 04/25] Changes for form validator to work --- .../Molecules/Items/CarouselItemModel.swift | 2 ++ .../Atomic/Organisms/Carousel/Carousel.swift | 28 ++++++++++++++----- .../Organisms/Carousel/CarouselModel.swift | 28 ++++++++++--------- .../CarouselItemModelProtocol.swift | 3 ++ .../CollectionTemplateItemProtocol.swift | 2 -- .../BaseClasses/CollectionViewCell.swift | 15 +++++----- 6 files changed, 48 insertions(+), 30 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift index 163909cb..19348070 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift @@ -23,6 +23,8 @@ import Foundation public var analyticsData: JSONValueDictionary? public var fieldValue: String? + public func formFieldValue() -> AnyHashable? { return fieldValue } + //-------------------------------------------------- // MARK: - Keys //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift index b9475938..a671726c 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift @@ -174,6 +174,10 @@ open class Carousel: View { pageIndex = carouselModel.index pagingView?.currentIndex = carouselModel.index collectionView.reloadData() + if let selectedIndex = carouselModel.selectedIndex { + let adjustedIndex = loop ? selectedIndex + 2 : selectedIndex + collectionView.selectItem(at: IndexPath(row: adjustedIndex, section: 0), animated: false, scrollPosition: []) + } } //-------------------------------------------------- @@ -392,16 +396,25 @@ extension Carousel: UICollectionViewDataSource { } extension Carousel: UICollectionViewDelegate { + public func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool { + guard let cell = collectionView.cellForItem(at: indexPath) as? CollectionTemplateItemProtocol else { return false } + return cell.shouldSelect(at: indexPath, delegateObject: delegateObject, additionalData: nil) + } + open func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - guard let cell = collectionView.cellForItem(at: indexPath) as? CollectionTemplateItemProtocol else { - return + // Set the selection in the model + if let model = model as? CarouselModel { + // Adjust for looping + var adjustedIndex = loop ? indexPath.row - 2 : indexPath.row + if adjustedIndex < 0 { + adjustedIndex = adjustedIndex + numberOfPages + } + model.selectedIndex = adjustedIndex } - cell.didSelectCell(at: indexPath, delegateObject: delegateObject, additionalData: nil) - //Check for selectable carousel item - guard let carouselModel = model as? CarouselModel, let selectedCarouselItem = carouselModel.molecules[indexPath.row] as? CarouselItemModel, cell.shouldSelect(at: indexPath, delegateObject: delegateObject, additionalData: nil) else { - return + if let cell = collectionView.cellForItem(at: indexPath) as? CollectionTemplateItemProtocol { + cell.didSelectCell(at: indexPath, delegateObject: delegateObject, additionalData: nil) } - carouselModel.selectedIndex = selectedCarouselItem.fieldValue ?? String(indexPath.row) + _ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate) } } @@ -423,6 +436,7 @@ extension Carousel: UIScrollViewDelegate { if !animated { scrollViewDidEndScrollingAnimation(collectionView) } + _ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate) } /// Adjusts the current contentOffset if we are going onto buffer cells while looping to help with the endless scrolling appearance. diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift index caa9f844..96e7e3f0 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift @@ -22,6 +22,7 @@ import UIKit public var backgroundColor: Color? public var molecules: [MoleculeModelProtocol & CarouselItemModelProtocol] public var index: Int = 0 + public var selectedIndex: Int? public var spacing: CGFloat? public var border: Bool? public var loop: Bool? @@ -34,7 +35,6 @@ import UIKit public var leftPadding: CGFloat? public var rightPadding: CGFloat? public var accessibilityText: String? - public var selectedIndex: String? public var baseValue: AnyHashable? public var fieldKey: String? public var groupName: String = FormValidator.defaultGroupName @@ -44,18 +44,12 @@ import UIKit } public func formFieldValue() -> AnyHashable? { - var carouselItemFieldValue: AnyHashable? - guard let visibleCarouselItem = molecules[index] as? CarouselItemModel else { - return nil + let indexForForm = selectedIndex ?? index + let item = molecules[indexForForm] + guard let value = item.formFieldValue() else { + return indexForForm } - if selectedIndex != nil { - //For selectableCarouselItem - carouselItemFieldValue = selectedIndex - } else { - //For carouselItem - carouselItemFieldValue = (visibleCarouselItem.fieldValue != nil) ? visibleCarouselItem.fieldValue : String(index) - } - return carouselItemFieldValue + return value } //-------------------------------------------------- @@ -67,6 +61,7 @@ import UIKit case backgroundColor case molecules case index + case selectedIndex case spacing case border case loop @@ -91,6 +86,7 @@ import UIKit let typeContainer = try decoder.container(keyedBy: CodingKeys.self) molecules = try typeContainer.decodeModels(codingKey: .molecules) index = try typeContainer.decodeIfPresent(Int.self, forKey: .index) ?? 0 + selectedIndex = try typeContainer.decodeIfPresent(Int.self, forKey: .selectedIndex) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) spacing = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .spacing) border = try typeContainer.decodeIfPresent(Bool.self, forKey: .border) @@ -112,7 +108,13 @@ import UIKit if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { self.groupName = groupName } - baseValue = formFieldValue() + if let value = formFieldValue() { + baseValue = value + } else if let value = selectedIndex { + baseValue = value + } else { + baseValue = index + } } public func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Atomic/Protocols/ModelProtocols/CarouselItemModelProtocol.swift b/MVMCoreUI/Atomic/Protocols/ModelProtocols/CarouselItemModelProtocol.swift index c2ade02d..2ed2ca5a 100644 --- a/MVMCoreUI/Atomic/Protocols/ModelProtocols/CarouselItemModelProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/ModelProtocols/CarouselItemModelProtocol.swift @@ -11,11 +11,14 @@ import Foundation public protocol CarouselItemModelProtocol: ContainerModelProtocol { var analyticsData: JSONValueDictionary? { get set } + func formFieldValue() -> AnyHashable? } + public extension CarouselItemModelProtocol { var analyticsData: JSONValueDictionary? { get { return nil } set { analyticsData = newValue } } + func formFieldValue() -> AnyHashable? { return nil } } diff --git a/MVMCoreUI/Atomic/Templates/CollectionTemplateItemProtocol.swift b/MVMCoreUI/Atomic/Templates/CollectionTemplateItemProtocol.swift index 98c9754e..4e9ae26d 100644 --- a/MVMCoreUI/Atomic/Templates/CollectionTemplateItemProtocol.swift +++ b/MVMCoreUI/Atomic/Templates/CollectionTemplateItemProtocol.swift @@ -22,7 +22,6 @@ public protocol CollectionTemplateItemProtocol: UICollectionViewCell { /// Handle the selection of cell func shouldSelect(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Bool - } // Default implementation does nothing @@ -34,5 +33,4 @@ extension CollectionTemplateItemProtocol { public func shouldSelect(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Bool { return false } - } diff --git a/MVMCoreUI/BaseClasses/CollectionViewCell.swift b/MVMCoreUI/BaseClasses/CollectionViewCell.swift index aff6dffb..2b4d81d8 100644 --- a/MVMCoreUI/BaseClasses/CollectionViewCell.swift +++ b/MVMCoreUI/BaseClasses/CollectionViewCell.swift @@ -116,11 +116,15 @@ open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCo // MARK: - Override - open func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { - guard let action = model?.action else { return } - Button.performButtonAction(with: action, button: self, delegateObject: delegateObject, additionalData: additionalData) + open func shouldSelect(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Bool { + if let action = model?.action { + Button.performButtonAction(with: action, button: self, delegateObject: delegateObject, additionalData: additionalData) + } + return true } + open func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {} + // Column logic, set width. override open func preferredLayoutAttributesFitting(_ layoutAttributes: UICollectionViewLayoutAttributes) -> UICollectionViewLayoutAttributes { let autoLayoutAttributes = super.preferredLayoutAttributesFitting(layoutAttributes) @@ -132,9 +136,4 @@ open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCo autoLayoutAttributes.frame = newFrame return autoLayoutAttributes } - - // Set default to false - open func shouldSelect(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) -> Bool { - return false - } } From 9b9b7750708e13db8569ba3936b8678a1ece1dae Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 1 Mar 2021 12:58:32 -0500 Subject: [PATCH 05/25] undo testing change --- MVMCoreUI/BaseClasses/CollectionViewCell.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/BaseClasses/CollectionViewCell.swift b/MVMCoreUI/BaseClasses/CollectionViewCell.swift index 2b4d81d8..cfbe4ac7 100644 --- a/MVMCoreUI/BaseClasses/CollectionViewCell.swift +++ b/MVMCoreUI/BaseClasses/CollectionViewCell.swift @@ -120,7 +120,7 @@ open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCo if let action = model?.action { Button.performButtonAction(with: action, button: self, delegateObject: delegateObject, additionalData: additionalData) } - return true + return false } open func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {} From 7aab88c5ecbb0625070c9bdd6b93cc852ad8a39d Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 1 Mar 2021 14:42:58 -0500 Subject: [PATCH 06/25] added selectable flag to match how android validates --- .../Organisms/Carousel/CarouselModel.swift | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift index 96e7e3f0..5bf0728c 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift @@ -22,7 +22,6 @@ import UIKit public var backgroundColor: Color? public var molecules: [MoleculeModelProtocol & CarouselItemModelProtocol] public var index: Int = 0 - public var selectedIndex: Int? public var spacing: CGFloat? public var border: Bool? public var loop: Bool? @@ -39,17 +38,25 @@ import UIKit public var fieldKey: String? public var groupName: String = FormValidator.defaultGroupName + public var selectable = false + public var selectedIndex: Int? + public init(molecules: [MoleculeModelProtocol & CarouselItemModelProtocol]) { self.molecules = molecules } public func formFieldValue() -> AnyHashable? { - let indexForForm = selectedIndex ?? index - let item = molecules[indexForForm] - guard let value = item.formFieldValue() else { - return indexForForm + guard selectable else { + // Use visible item value, else index + if let fieldValue = molecules[index].formFieldValue() { + return fieldValue + } + return index } - return value + // Use selected item value, else index + guard let selectedIndex = selectedIndex else { return nil } + guard let fieldValue = molecules[selectedIndex].formFieldValue() else { return selectedIndex } + return fieldValue } //-------------------------------------------------- @@ -61,7 +68,6 @@ import UIKit case backgroundColor case molecules case index - case selectedIndex case spacing case border case loop @@ -76,6 +82,8 @@ import UIKit case accessibilityText case groupName case fieldKey + case selectable + case selectedIndex } //-------------------------------------------------- @@ -86,6 +94,7 @@ import UIKit let typeContainer = try decoder.container(keyedBy: CodingKeys.self) molecules = try typeContainer.decodeModels(codingKey: .molecules) index = try typeContainer.decodeIfPresent(Int.self, forKey: .index) ?? 0 + selectable = try typeContainer.decodeIfPresent(Bool.self, forKey: .selectable) ?? false selectedIndex = try typeContainer.decodeIfPresent(Int.self, forKey: .selectedIndex) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) spacing = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .spacing) @@ -108,13 +117,7 @@ import UIKit if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { self.groupName = groupName } - if let value = formFieldValue() { - baseValue = value - } else if let value = selectedIndex { - baseValue = value - } else { - baseValue = index - } + baseValue = formFieldValue() } public func encode(to encoder: Encoder) throws { @@ -136,5 +139,8 @@ import UIKit try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText) try container.encodeIfPresent(fieldKey, forKey: .fieldKey) try container.encode(groupName, forKey: .groupName) + try container.encode(index, forKey: .index) + try container.encode(selectable, forKey: .selectable) + try container.encode(selectedIndex, forKey: .selectedIndex) } } From 20778a49860ce86e74f3861ea61b5e244771ea2d Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Tue, 2 Mar 2021 17:32:58 +0530 Subject: [PATCH 07/25] Added keyboardtype in default case. --- .../Atomic/Atoms/FormFields/TextFields/TextEntryField.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift index 6ff196c7..785c986d 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift @@ -350,7 +350,9 @@ import UIKit case .phone: textField.keyboardType = .phonePad - default: break + default: + textField.keyboardType = .default + break } // Override the preset keyboard set in type. From fae969fd1f0435f07daef88f019cdb87a52bad7a Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 5 Mar 2021 11:53:13 -0500 Subject: [PATCH 08/25] validator check --- MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryField.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryField.swift index cc410404..04eeed02 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryField.swift @@ -319,12 +319,14 @@ import UIKit model.updateUIDynamicError = { [weak self] in MVMCoreDispatchUtility.performBlock(onMainThread: { guard let self = self else { return } + let validState = model.isValid ?? false - self.updateValidation(validState) if !validState && model.shouldClearText { self.text = "" model.shouldClearText = false } + _ = FormValidator.validate(delegate: self.delegateObject?.formHolderDelegate) + self.updateValidation(validState) }) } From 80d184753171af45aa3c6d7680f1906ad18e2a3c Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 8 Mar 2021 10:38:21 -0500 Subject: [PATCH 09/25] revised --- .../Atoms/FormFields/TextFields/MdnEntryField.swift | 10 ++++++++++ .../Atoms/FormFields/TextFields/TextEntryField.swift | 1 - 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/MdnEntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/MdnEntryField.swift index fe2c483c..db3c28c4 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/MdnEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/MdnEntryField.swift @@ -147,6 +147,16 @@ import MVMCore MVMCoreNavigationHandler.shared()?.present(picker, animated: true) } + //-------------------------------------------------- + // MARK: - MoleculeViewProtocol + //-------------------------------------------------- + + public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.set(with: model, delegateObject, additionalData) + + textField.keyboardType = .phonePad + } + //-------------------------------------------------- // MARK: - Contact Picker Delegate //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift index 785c986d..76b70b80 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift @@ -352,7 +352,6 @@ import UIKit default: textField.keyboardType = .default - break } // Override the preset keyboard set in type. From e18152174c749a2d14b5e9ad63ecf3d6bd1cf056 Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Tue, 9 Mar 2021 16:07:07 +0530 Subject: [PATCH 10/25] Added isSecureTextEntry as false for number keyboard type. --- .../Atomic/Atoms/FormFields/TextFields/TextEntryField.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift index 76b70b80..536e3364 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift @@ -342,6 +342,7 @@ import UIKit textField.keyboardType = .numberPad case .number: + textField.isSecureTextEntry = false textField.keyboardType = .numberPad case .email: From 3395be059224cd8cd8cbcb4bf71cdaa3cc040e75 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 9 Mar 2021 13:17:55 -0500 Subject: [PATCH 11/25] fix --- MVMCoreUI/BaseControllers/ViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index ecb4089a..a2d82952 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -461,7 +461,7 @@ import UIKit open func handleOpenPage(for requestParameters: MVMCoreRequestParameters, actionInformation: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) { addFormParams(requestParameters) requestParameters.parentPageType = loadObject?.pageJSON?.optionalStringForKey("parentPageType") - MVMCoreActionHandler.defaultHandleOpenPage(for: requestParameters, additionalData: additionalData, delegateObject: delegateObject()) + MVMCoreActionHandler.defaultHandleOpenPage(for: requestParameters, actionInformation: actionInformation, additionalData: additionalData, delegateObject: delegateObject()) } open func logAction(withActionInformation actionInformation: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) { From 724763d50c6c49f0c019c968985adfa26eed63c1 Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Wed, 10 Mar 2021 17:20:06 +0530 Subject: [PATCH 12/25] Added moleculename for encoding. --- .../Item Dropdown/MultiItemDropdownEntryFieldModel.swift | 2 ++ .../Atoms/FormFields/TextFields/TextEntryFieldModel.swift | 2 ++ MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift | 2 ++ .../Atomic/Molecules/OtherContainers/BGImageMoleculeModel.swift | 2 ++ 4 files changed, 8 insertions(+) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/Item Dropdown/MultiItemDropdownEntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/Item Dropdown/MultiItemDropdownEntryFieldModel.swift index 8799f6aa..2f645552 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/Item Dropdown/MultiItemDropdownEntryFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/Item Dropdown/MultiItemDropdownEntryFieldModel.swift @@ -86,6 +86,7 @@ import Foundation //-------------------------------------------------- private enum CodingKeys: String, CodingKey { + case moleculeName case components case selectedIndexes case delimiters @@ -119,6 +120,7 @@ import Foundation public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) try container.encode(components, forKey: .components) try container.encode(selectedIndexesArray, forKey: .selectedIndexes) try container.encodeIfPresent(delimiterArray, forKey: .delimiters) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryFieldModel.swift index ca7543bd..66b3d4bf 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryFieldModel.swift @@ -95,6 +95,7 @@ //-------------------------------------------------- private enum CodingKeys: String, CodingKey { + case moleculeName case placeholder case textAlignment case enabledTextColor @@ -140,6 +141,7 @@ public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(placeholder, forKey: .placeholder) try container.encodeIfPresent(textAlignment, forKey: .textAlignment) try container.encodeIfPresent(type, forKey: .type) diff --git a/MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift index 19348070..018a93d6 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift @@ -30,6 +30,7 @@ import Foundation //-------------------------------------------------- private enum CodingKeys: String, CodingKey { + case moleculeName case peakingUI case peakingArrowColor case analyticsData @@ -52,6 +53,7 @@ import Foundation open override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(peakingUI, forKey: .peakingUI) try container.encodeIfPresent(peakingArrowColor, forKey: .peakingArrowColor) try container.encodeIfPresent(analyticsData, forKey: .analyticsData) diff --git a/MVMCoreUI/Atomic/Molecules/OtherContainers/BGImageMoleculeModel.swift b/MVMCoreUI/Atomic/Molecules/OtherContainers/BGImageMoleculeModel.swift index 56b77e3e..467ae6ac 100644 --- a/MVMCoreUI/Atomic/Molecules/OtherContainers/BGImageMoleculeModel.swift +++ b/MVMCoreUI/Atomic/Molecules/OtherContainers/BGImageMoleculeModel.swift @@ -36,6 +36,7 @@ open class BGImageMoleculeModel: MoleculeContainerModel { } private enum CodingKeys: String, CodingKey { + case moleculeName case image } @@ -53,6 +54,7 @@ open class BGImageMoleculeModel: MoleculeContainerModel { open override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) try container.encode(image, forKey: .image) } } From 4f12ad2f67a05da5b1ef7f8fe862bfefa6a5890f Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 10 Mar 2021 12:24:50 -0500 Subject: [PATCH 13/25] undo label --- MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift | 3 --- 1 file changed, 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index 511fb4dc..7e902d435 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -624,9 +624,6 @@ public typealias ActionBlock = () -> () } else if !MVMCoreGetterUtility.fequal(a: Float(standardFontSize), b: 0.0), let sizeObject = sizeObject ?? MFStyler.sizeObjectGeneric(forCurrentDevice: standardFontSize) { font = font.updateSize(sizeObject.getValueBased(onSize: size)) } - - // Provide the label additional size information to help calculate its intrinsic content. - preferredMaxLayoutWidth = Styler.maxAvailableLayoutWidth(size: size) } @objc public func setFont(_ font: UIFont, scale: Bool) { From 4a997ad801ea0d853cca5d50350f2551e9b35115 Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Thu, 11 Mar 2021 16:23:20 +0530 Subject: [PATCH 14/25] Moved isSecureTextEntry as false to reset method. --- .../Atomic/Atoms/FormFields/TextFields/TextEntryField.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift index 536e3364..3d1b1534 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift @@ -200,6 +200,7 @@ import UIKit open override func reset() { super.reset() + textField.isSecureTextEntry = false textField.font = Styler.Font.RegularBodyLarge.getFont() } @@ -342,7 +343,6 @@ import UIKit textField.keyboardType = .numberPad case .number: - textField.isSecureTextEntry = false textField.keyboardType = .numberPad case .email: From 537da03d2c334974523aa0801f238a0e83db6dcd Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 15 Mar 2021 16:37:32 -0500 Subject: [PATCH 15/25] refactored to use the new handler registration in ModelRestry Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 11 ++++------- MVMCoreUI/Atomic/Organisms/Stack.swift | 2 +- MVMCoreUI/Atomic/Protocols/MoleculeViewProtocol.swift | 3 ++- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index 3dfed18d..f868169d 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -9,9 +9,6 @@ import Foundation @objcMembers public class MoleculeObjectMapping: NSObject { - - public var moleculeMapping: [String: MoleculeViewProtocol.Type] = [:] - /// Returns the mapping object stored in the singleton public static func shared() -> Self? { return MVMCoreActionUtility.initializerClassCheck(CoreUIObject.sharedInstance()?.moleculeMap, classToVerify: self) as? Self @@ -19,18 +16,17 @@ import Foundation /// Registers the model with the model registry and the view with the mapper. public func register(viewClass: V.Type, viewModelClass: M.Type) { - try? ModelRegistry.register(viewModelClass) - moleculeMapping.updateValue(viewClass, forKey: viewModelClass.identifier) + try? ModelRegistry.register(handler: viewClass, for: viewModelClass) } /// Returns the type of molecule view for the given model public func getMoleculeClass(_ model: MoleculeModelProtocol) -> MoleculeViewProtocol.Type? { - return moleculeMapping[model.moleculeName] + return ModelRegistry.getHandler(model) as? MoleculeViewProtocol.Type } /// Creates a molecule with the given model. public func createMolecule(_ model: MoleculeModelProtocol, delegateObject: MVMCoreUIDelegateObject? = nil, additionalData: [AnyHashable: Any]? = nil) -> MoleculeViewProtocol? { - guard let type = moleculeMapping[model.moleculeName] else { return nil } + guard let type = getMoleculeClass(model) else { return nil } return type.init(model: model, delegateObject, additionalData) } @@ -286,3 +282,4 @@ import Foundation } } } + diff --git a/MVMCoreUI/Atomic/Organisms/Stack.swift b/MVMCoreUI/Atomic/Organisms/Stack.swift index 29646f2e..e2772f5d 100644 --- a/MVMCoreUI/Atomic/Organisms/Stack.swift +++ b/MVMCoreUI/Atomic/Organisms/Stack.swift @@ -199,7 +199,7 @@ open class Stack: Container where T: (StackModelProtocol & MoleculeModelProto } var name = "stack<" for case let item in model.molecules { - if let moleculeClass = MoleculeObjectMapping.shared()?.moleculeMapping[item.moleculeName], + if let moleculeClass = MoleculeObjectMapping.shared()?.getMoleculeClass(item), let nameForReuse = moleculeClass.nameForReuse(with: item, delegateObject) { name.append(nameForReuse + ",") } else { diff --git a/MVMCoreUI/Atomic/Protocols/MoleculeViewProtocol.swift b/MVMCoreUI/Atomic/Protocols/MoleculeViewProtocol.swift index a8600c79..e4ebe78a 100644 --- a/MVMCoreUI/Atomic/Protocols/MoleculeViewProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/MoleculeViewProtocol.swift @@ -9,7 +9,7 @@ import UIKit import MVMCore.MVMCoreViewProtocol -public protocol MoleculeViewProtocol: UIView { +public protocol MoleculeViewProtocol: UIView, ModelHandlerProtocol{ /// Initializes the view with the model init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) @@ -31,6 +31,7 @@ public protocol MoleculeViewProtocol: UIView { } extension MoleculeViewProtocol { + /// Calls set with model public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { self.init(frame: .zero) From 431cf25faaf4f92983707f963a43ac762e04b5bf Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Tue, 16 Mar 2021 13:54:51 +0530 Subject: [PATCH 16/25] Added to avoid masked text being replaced with original text when view is reloaded. --- .../Atomic/Atoms/FormFields/TextFields/TextEntryField.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift index 3d1b1534..2d9df0a7 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift @@ -366,6 +366,12 @@ import UIKit setupTextFieldToolbar() if isSelected { startEditing() } + + //Added to override text when view is reloaded. + if let text = textEntryFieldModel?.text, !text.isEmpty { + regexTextFieldOutputIfAvailable() + } + } } From 8ff11f914db0fcd7a9ec68307e28702605252e61 Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Tue, 16 Mar 2021 21:42:50 +0530 Subject: [PATCH 17/25] Code changes as per review comment. --- .../Atomic/Atoms/FormFields/TextFields/TextEntryField.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift index 2d9df0a7..1fa2140e 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift @@ -368,7 +368,7 @@ import UIKit if isSelected { startEditing() } //Added to override text when view is reloaded. - if let text = textEntryFieldModel?.text, !text.isEmpty { + if let text = model.text, !text.isEmpty { regexTextFieldOutputIfAvailable() } From 5e707d29a0bf0ef1502ecbd53157f1f9ed333cde Mon Sep 17 00:00:00 2001 From: Damodaram Date: Wed, 17 Mar 2021 12:02:48 +0530 Subject: [PATCH 18/25] updated spacing --- ...tLeftVariableIconWithRightCaretAllTextLinks.swift | 2 +- .../EyebrowHeadlineBodyLink.swift | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift index 93d1526f..fcd18f68 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift @@ -12,7 +12,7 @@ //-------------------------------------------------- public let leftImage = LoadImageView(pinnedEdges: .all) - public let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink() + public let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink(spacing: 2.0) public let rightLabel = Label(fontStyle: .RegularBodySmall) public lazy var rightLabelStackItem: StackItem = { diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift index 55055e94..a25426d7 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift @@ -22,6 +22,16 @@ get { return model as? EyebrowHeadlineBodyLinkModel } } + //-------------------------------------------------- + // MARK: - Initialization + //-------------------------------------------------- + + public convenience init(spacing: CGFloat) { + self.init(frame: .zero) + stack.stackModel?.spacing = spacing + stack.restack() + } + //-------------------------------------------------- // MARK: - MFViewProtocol //-------------------------------------------------- @@ -29,7 +39,7 @@ open override func setupView() { super.setupView() stack.setAndCreateModel(with: [eyebrow, headline, body, link]) - stack.stackModel?.spacing = 2.0 + stack.stackModel?.spacing = 0 addSubview(stack) NSLayoutConstraint.constraintPinSubview(toSuperview: stack) stack.restack() From 36f5c0f880b11d1eb81ca2ccaebb29c0470680fe Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 17 Mar 2021 15:08:56 -0400 Subject: [PATCH 19/25] refactoring --- MVMCoreUI/Utility/MVMCoreUIUtility.m | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/MVMCoreUI/Utility/MVMCoreUIUtility.m b/MVMCoreUI/Utility/MVMCoreUIUtility.m index fad2378c..9e1070d4 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility.m +++ b/MVMCoreUI/Utility/MVMCoreUIUtility.m @@ -11,6 +11,7 @@ #import "MVMCoreUISession.h" #import "MVMCoreUISplitViewController.h" #import +#import @import MVMCore.MVMCoreNavigationHandler; @import MVMCore.MVMCoreGetterUtility; @@ -23,15 +24,9 @@ return [NSBundle bundleWithIdentifier:@"com.vzw.MVMCoreUI"]; } -+ (BOOL)userPrefersSpanish { - // This should be enough for us to look at what the user prefers. - NSString *preference = [[[[NSLocale preferredLanguages] objectAtIndex:0] substringToIndex:2] lowercaseString]; - return [preference isEqualToString:@"es"] || [preference isEqualToString:@"es-mx"]; -} - + (nullable NSString *)hardcodedStringWithKey:(nonnull NSString *)key { // If the app language is not english... force load from the english file anyway. - if ([MVMCoreUIUtility userPrefersSpanish]) { + if ([MVMCoreGetterUtility userPrefersSpanish]) { return [[NSBundle bundleWithPath:[[MVMCoreUIUtility bundleForMVMCoreUI] pathForResource:@"es" ofType:@"lproj"]] localizedStringForKey:key value:@"" table:nil]; } else { return [[NSBundle bundleWithPath:[[MVMCoreUIUtility bundleForMVMCoreUI] pathForResource:@"en" ofType:@"lproj"]] localizedStringForKey:key value:@"" table:nil]; @@ -40,7 +35,7 @@ + (nullable NSString *)localizedImageName:(nullable NSString *)imageName { if (imageName.length > 0) { - if ([MVMCoreUIUtility userPrefersSpanish]) { + if ([MVMCoreGetterUtility userPrefersSpanish]) { imageName = [NSString stringWithFormat:@"%@_es", imageName]; } else { imageName = [NSString stringWithFormat:@"%@_en", imageName]; From 9b8da4891d4ca1916fb0801083707818a1457510 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 18 Mar 2021 10:50:02 -0400 Subject: [PATCH 20/25] removed --- MVMCoreUI/Utility/MVMCoreUIUtility.h | 2 +- MVMCoreUI/Utility/MVMCoreUIUtility.m | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/MVMCoreUI/Utility/MVMCoreUIUtility.h b/MVMCoreUI/Utility/MVMCoreUIUtility.h index 74b19d0e..6852e936 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility.h +++ b/MVMCoreUI/Utility/MVMCoreUIUtility.h @@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - Getters -//Returns localized imageName +// Returns localized imageName + (nullable NSString *)localizedImageName:(nullable NSString *)imageName; // The bundle for this framework diff --git a/MVMCoreUI/Utility/MVMCoreUIUtility.m b/MVMCoreUI/Utility/MVMCoreUIUtility.m index 9e1070d4..28ed2e0e 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility.m +++ b/MVMCoreUI/Utility/MVMCoreUIUtility.m @@ -11,7 +11,6 @@ #import "MVMCoreUISession.h" #import "MVMCoreUISplitViewController.h" #import -#import @import MVMCore.MVMCoreNavigationHandler; @import MVMCore.MVMCoreGetterUtility; From 7f0cc11f2ab0bfe5f047322cfda61e08b917e22d Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 18 Mar 2021 10:08:19 -0500 Subject: [PATCH 21/25] formatting update Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Protocols/MoleculeViewProtocol.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Protocols/MoleculeViewProtocol.swift b/MVMCoreUI/Atomic/Protocols/MoleculeViewProtocol.swift index e4ebe78a..da90798d 100644 --- a/MVMCoreUI/Atomic/Protocols/MoleculeViewProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/MoleculeViewProtocol.swift @@ -9,7 +9,7 @@ import UIKit import MVMCore.MVMCoreViewProtocol -public protocol MoleculeViewProtocol: UIView, ModelHandlerProtocol{ +public protocol MoleculeViewProtocol: UIView, ModelHandlerProtocol { /// Initializes the view with the model init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) From a90824a23dbdf587c3dc4a1d81ca77c2ef7d5dce Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 18 Mar 2021 11:47:29 -0400 Subject: [PATCH 22/25] redirecting hardcoded key --- MVMCoreUI/Utility/MVMCoreUIUtility.m | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/Utility/MVMCoreUIUtility.m b/MVMCoreUI/Utility/MVMCoreUIUtility.m index 28ed2e0e..dd059fed 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility.m +++ b/MVMCoreUI/Utility/MVMCoreUIUtility.m @@ -24,12 +24,8 @@ } + (nullable NSString *)hardcodedStringWithKey:(nonnull NSString *)key { - // If the app language is not english... force load from the english file anyway. - if ([MVMCoreGetterUtility userPrefersSpanish]) { - return [[NSBundle bundleWithPath:[[MVMCoreUIUtility bundleForMVMCoreUI] pathForResource:@"es" ofType:@"lproj"]] localizedStringForKey:key value:@"" table:nil]; - } else { - return [[NSBundle bundleWithPath:[[MVMCoreUIUtility bundleForMVMCoreUI] pathForResource:@"en" ofType:@"lproj"]] localizedStringForKey:key value:@"" table:nil]; - } + // Redirect key with relevant module. + return [MVMCoreGetterUtility hardcodedStringWithKey:key bundle:[MVMCoreUIUtility bundleForMVMCoreUI]]; } + (nullable NSString *)localizedImageName:(nullable NSString *)imageName { From f37a839b95304b2dc24a27ffd5510d0b0cee3d64 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 22 Mar 2021 09:51:18 -0400 Subject: [PATCH 23/25] expanding image options --- MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index 7e902d435..e8c8446f 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -685,7 +685,7 @@ public typealias ActionBlock = () -> () static func getTextAttachmentImage(name: String = "externalLink", dimension: CGFloat) -> NSTextAttachment { let imageAttachment = NSTextAttachment() - imageAttachment.image = MVMCoreUIUtility.imageNamed(name) + imageAttachment.image = MVMCoreCache.shared()?.getImageFromRegisteredBundles(name) imageAttachment.bounds = CGRect(x: 0, y: 0, width: dimension, height: dimension) return imageAttachment From 9d989c49faba65714cc315bd8df2365e528b8922 Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Mon, 22 Mar 2021 20:28:25 +0530 Subject: [PATCH 24/25] Changed access specifiers of webview attributes for WebViewWithCheckbox component. --- MVMCoreUI/Atomic/Atoms/Views/WebView.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/WebView.swift b/MVMCoreUI/Atomic/Atoms/Views/WebView.swift index 3de42935..e6708055 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/WebView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/WebView.swift @@ -16,8 +16,8 @@ import WebKit var webviewModel: WebViewModel? { return model as? WebViewModel } - var webView: WKWebView? - var overLayer = MVMCoreUICommonViewsUtility.commonView() + open var webView: WKWebView? + open var overLayer = MVMCoreUICommonViewsUtility.commonView() public let loadingSpinner = MFLoadingSpinner(frame: .zero) var delegateObject: MVMCoreUIDelegateObject? var webViewHeight: NSLayoutConstraint? From 8cba2a59d3a4ca5f2a642ff8d4f13e1c645abe65 Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Wed, 24 Mar 2021 21:54:22 +0530 Subject: [PATCH 25/25] Returning moleculeName as type(of: self).identifier due to encoding/decoding error while converting to JsonArray or JsonDict. --- .../Item Dropdown/MultiItemDropdownEntryFieldModel.swift | 2 -- .../Atoms/FormFields/TextFields/TextEntryFieldModel.swift | 2 -- MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift | 2 -- .../Atomic/Molecules/OtherContainers/BGImageMoleculeModel.swift | 2 -- .../Atomic/Protocols/ModelProtocols/MoleculeModelProtocol.swift | 2 +- 5 files changed, 1 insertion(+), 9 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/Item Dropdown/MultiItemDropdownEntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/Item Dropdown/MultiItemDropdownEntryFieldModel.swift index 2f645552..8799f6aa 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/Item Dropdown/MultiItemDropdownEntryFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/Item Dropdown/MultiItemDropdownEntryFieldModel.swift @@ -86,7 +86,6 @@ import Foundation //-------------------------------------------------- private enum CodingKeys: String, CodingKey { - case moleculeName case components case selectedIndexes case delimiters @@ -120,7 +119,6 @@ import Foundation public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(moleculeName, forKey: .moleculeName) try container.encode(components, forKey: .components) try container.encode(selectedIndexesArray, forKey: .selectedIndexes) try container.encodeIfPresent(delimiterArray, forKey: .delimiters) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryFieldModel.swift index 66b3d4bf..ca7543bd 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryFieldModel.swift @@ -95,7 +95,6 @@ //-------------------------------------------------- private enum CodingKeys: String, CodingKey { - case moleculeName case placeholder case textAlignment case enabledTextColor @@ -141,7 +140,6 @@ public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(placeholder, forKey: .placeholder) try container.encodeIfPresent(textAlignment, forKey: .textAlignment) try container.encodeIfPresent(type, forKey: .type) diff --git a/MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift index 018a93d6..19348070 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift @@ -30,7 +30,6 @@ import Foundation //-------------------------------------------------- private enum CodingKeys: String, CodingKey { - case moleculeName case peakingUI case peakingArrowColor case analyticsData @@ -53,7 +52,6 @@ import Foundation open override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(peakingUI, forKey: .peakingUI) try container.encodeIfPresent(peakingArrowColor, forKey: .peakingArrowColor) try container.encodeIfPresent(analyticsData, forKey: .analyticsData) diff --git a/MVMCoreUI/Atomic/Molecules/OtherContainers/BGImageMoleculeModel.swift b/MVMCoreUI/Atomic/Molecules/OtherContainers/BGImageMoleculeModel.swift index 467ae6ac..56b77e3e 100644 --- a/MVMCoreUI/Atomic/Molecules/OtherContainers/BGImageMoleculeModel.swift +++ b/MVMCoreUI/Atomic/Molecules/OtherContainers/BGImageMoleculeModel.swift @@ -36,7 +36,6 @@ open class BGImageMoleculeModel: MoleculeContainerModel { } private enum CodingKeys: String, CodingKey { - case moleculeName case image } @@ -54,7 +53,6 @@ open class BGImageMoleculeModel: MoleculeContainerModel { open override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(moleculeName, forKey: .moleculeName) try container.encode(image, forKey: .image) } } diff --git a/MVMCoreUI/Atomic/Protocols/ModelProtocols/MoleculeModelProtocol.swift b/MVMCoreUI/Atomic/Protocols/ModelProtocols/MoleculeModelProtocol.swift index 4f0cd296..a998b79d 100644 --- a/MVMCoreUI/Atomic/Protocols/ModelProtocols/MoleculeModelProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/ModelProtocols/MoleculeModelProtocol.swift @@ -14,7 +14,7 @@ public protocol MoleculeModelProtocol: ModelProtocol, AccessibilityModelProtocol public extension MoleculeModelProtocol { - var moleculeName: String { Self.identifier } + var moleculeName: String { type(of: self).identifier } static var categoryName: String { "\(MoleculeModelProtocol.self)" }