From bd9e8cf7adc5ca762f053da12e89469947509cb1 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Tue, 8 Mar 2022 22:28:35 -0500 Subject: [PATCH 01/15] insert molecule transformation hooks into the list template --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++++ .../TextFields/EntryFieldModel.swift | 6 ++++- .../TextFields/TextEntryField.swift | 4 ++++ .../Atoms/Selectors/RadioBoxesModel.swift | 1 + .../Atomic/Atoms/Views/Label/Label.swift | 6 ++++- .../Atomic/Atoms/Views/Label/LabelModel.swift | 4 ++++ .../Atomic/Atoms/Views/LoadImageView.swift | 2 +- .../MoleculeModelProtocol.swift | 3 +++ .../ModelProtocols/PageModelProtocol.swift | 1 + .../Atomic/Protocols/TemplateProtocol.swift | 1 + .../Protocols/ViewMaskingProtocol.swift | 21 +++++++++++++++++ .../Templates/MoleculeListTemplate.swift | 8 ++++--- .../Atomic/Templates/TemplateModel.swift | 7 ++++++ MVMCoreUI/BaseClasses/TextField.swift | 9 ++++++-- MVMCoreUI/BaseClasses/View.swift | 7 +++++- .../BaseControllers/ViewController.swift | 23 ++++++++++++++++++- .../PageBehaviorHandlerProtocol.swift | 6 +++-- .../Protocols/PageBehaviorProtocol.swift | 9 ++++++++ MVMCoreUI/OtherHandlers/MVMCoreUISession.h | 12 ++++++---- MVMCoreUI/OtherHandlers/MVMCoreUISession.m | 4 ++++ 20 files changed, 122 insertions(+), 16 deletions(-) create mode 100644 MVMCoreUI/Atomic/Protocols/ViewMaskingProtocol.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 2b9c6711..a329075f 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -128,6 +128,7 @@ 0AF60F0926B3316E00AC3DB4 /* MVMCoreUIUtility+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AF60F0826B3316E00AC3DB4 /* MVMCoreUIUtility+Extension.swift */; }; 1D6D258826899B0C00DEBB08 /* ImageButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D6D258626899B0B00DEBB08 /* ImageButtonModel.swift */; }; 1D6D258926899B0C00DEBB08 /* ImageButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D6D258726899B0B00DEBB08 /* ImageButton.swift */; }; + 27559EFC27D691D3000836C1 /* ViewMaskingProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27559EFB27D691D3000836C1 /* ViewMaskingProtocol.swift */; }; 279B1569242BBC2F00921D6C /* ActionModelAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 279B1568242BBC2F00921D6C /* ActionModelAdapter.swift */; }; 27F6B08826051831008529AA /* MoleculeTreeTraversalProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27F6B08726051831008529AA /* MoleculeTreeTraversalProtocol.swift */; }; 27F6B08C26052AFF008529AA /* ParentMoleculeModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27F6B08B26052AFF008529AA /* ParentMoleculeModelProtocol.swift */; }; @@ -711,6 +712,7 @@ 0AF60F0826B3316E00AC3DB4 /* MVMCoreUIUtility+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUIUtility+Extension.swift"; sourceTree = ""; }; 1D6D258626899B0B00DEBB08 /* ImageButtonModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ImageButtonModel.swift; path = MVMCoreUI/Atomic/Atoms/Buttons/ImageButtonModel.swift; sourceTree = SOURCE_ROOT; }; 1D6D258726899B0B00DEBB08 /* ImageButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ImageButton.swift; path = MVMCoreUI/Atomic/Atoms/Buttons/ImageButton.swift; sourceTree = SOURCE_ROOT; }; + 27559EFB27D691D3000836C1 /* ViewMaskingProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewMaskingProtocol.swift; sourceTree = ""; }; 279B1568242BBC2F00921D6C /* ActionModelAdapter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionModelAdapter.swift; sourceTree = ""; }; 27F6B08726051831008529AA /* MoleculeTreeTraversalProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeTreeTraversalProtocol.swift; sourceTree = ""; }; 27F6B08B26052AFF008529AA /* ParentMoleculeModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParentMoleculeModelProtocol.swift; sourceTree = ""; }; @@ -2389,6 +2391,7 @@ D28BA7442481652D00B75CB8 /* TabBarProtocol.swift */, D2B9D0E3265EEE9D0084735C /* MoleculeListProtocol.swift */, 011B58EE23A2AA850085F53C /* ModelProtocols */, + 27559EFB27D691D3000836C1 /* ViewMaskingProtocol.swift */, ); path = Protocols; sourceTree = ""; @@ -2854,6 +2857,7 @@ D23EA800247EBD6C00D60C34 /* LabelBarButtonItem.swift in Sources */, 01EB368F23609801006832FA /* LabelModel.swift in Sources */, 0A6682AC243531C300AD3CA1 /* Padding.swift in Sources */, + 27559EFC27D691D3000836C1 /* ViewMaskingProtocol.swift in Sources */, AA1EC59924373994003D6F50 /* ListThreeColumnSpeedTestDivider.swift in Sources */, AA37CBD52519072F0027344C /* Stars.swift in Sources */, 942C378E2412F5B60066E45E /* ModalMoleculeStackTemplate.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift index 3fed121a..de7dfd74 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift @@ -42,7 +42,8 @@ import Foundation public var wasInitiallySelected: Bool = false public var title: String? public var feedback: String? - + public var shouldMaskRecordedView: Bool = true + //used to drive the EntryFieldView UI public var titleStateLabel: FormLabelModel public var feedbackStateLabel: FormLabelModel @@ -79,6 +80,7 @@ import Foundation case fieldKey case groupName case required + case shouldMaskRecordedView } //-------------------------------------------------- @@ -143,6 +145,7 @@ import Foundation hideBorders = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideBorders) ?? false baseValue = text fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) + shouldMaskRecordedView = try typeContainer.decode(Bool.self, forKey: .shouldMaskRecordedView) if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { self.groupName = groupName } @@ -172,5 +175,6 @@ import Foundation try container.encode(enabled, forKey: .enabled) try container.encode(required, forKey: .required) try container.encode(hideBorders, forKey: .hideBorders) + try container.encode(shouldMaskRecordedView, forKey: .shouldMaskRecordedView) } } diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift index 89e17169..540beb97 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift @@ -338,12 +338,16 @@ import UIKit text = model.text placeholder = model.placeholder + textField.shouldMaskWhileRecording = model.shouldMaskRecordedView + switch model.type { case .password, .secure: textField.isSecureTextEntry = true + textField.shouldMaskWhileRecording = true case .numberSecure: textField.isSecureTextEntry = true + textField.shouldMaskWhileRecording = true textField.keyboardType = .numberPad case .number: diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxesModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxesModel.swift index 7e919553..1b397f5e 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxesModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxesModel.swift @@ -22,6 +22,7 @@ public var baseValue: AnyHashable? public var enabled: Bool = true public var readOnly: Bool = false + //-------------------------------------------------- // MARK: - Methods //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index 687683d7..7a147f13 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -12,7 +12,8 @@ import MVMCore public typealias ActionBlock = () -> () -@objcMembers open class Label: UILabel, MVMCoreViewProtocol, MoleculeViewProtocol, MVMCoreUIViewConstrainingProtocol, MFButtonProtocol { +@objcMembers open class Label: UILabel, MVMCoreViewProtocol, MoleculeViewProtocol, MVMCoreUIViewConstrainingProtocol, MFButtonProtocol, ViewMaskingProtocol { + //------------------------------------------------------ // MARK: - Properties //------------------------------------------------------ @@ -41,6 +42,8 @@ public typealias ActionBlock = () -> () NSRange(location: 0, length: text?.count ?? 0) } + public var shouldMaskWhileRecording: Bool = false + //------------------------------------------------------ // MARK: - Multi-Action Text //------------------------------------------------------ @@ -244,6 +247,7 @@ public typealias ActionBlock = () -> () text = nil attributedText = nil originalAttributedString = nil + shouldMaskWhileRecording = model.shouldMaskRecordedView guard let labelModel = model as? LabelModel else { return } diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift index 2eec132f..de5c3980 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift @@ -26,6 +26,7 @@ public var hero: Int? public var makeWholeViewClickable: Bool? public var numberOfLines: Int? + public var shouldMaskRecordedView: Bool = false //-------------------------------------------------- // MARK: - Keys @@ -46,6 +47,7 @@ case hero case makeWholeViewClickable case numberOfLines + case shouldMaskRecordedView } enum AttributeTypeKey: String, CodingKey { @@ -79,6 +81,7 @@ hero = try typeContainer.decodeIfPresent(Int.self, forKey: .hero) makeWholeViewClickable = try typeContainer.decodeIfPresent(Bool.self, forKey: .makeWholeViewClickable) numberOfLines = try typeContainer.decodeIfPresent(Int.self, forKey: .numberOfLines) + shouldMaskRecordedView = try typeContainer.decodeIfPresent(Bool.self, forKey: .shouldMaskRecordedView) ?? false } open func encode(to encoder: Encoder) throws { @@ -97,5 +100,6 @@ try container.encodeIfPresent(hero, forKey: .hero) try container.encodeIfPresent(makeWholeViewClickable, forKey: .makeWholeViewClickable) try container.encodeIfPresent(numberOfLines, forKey: .numberOfLines) + try container.encodeIfPresent(shouldMaskRecordedView, forKey: .shouldMaskRecordedView) } } diff --git a/MVMCoreUI/Atomic/Atoms/Views/LoadImageView.swift b/MVMCoreUI/Atomic/Atoms/Views/LoadImageView.swift index 8d8ef49e..f3d381bc 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/LoadImageView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/LoadImageView.swift @@ -22,7 +22,7 @@ public var addSizeConstraintsForAspectRatio = true public var shouldNotifyDelegateOnUpdate = true public var shouldNotifyDelegateOnDefaultSizeChange = false - + // Allows for a view to hardcode which height to use if there is none in the json. var imageWidth: CGFloat? var imageHeight: CGFloat? diff --git a/MVMCoreUI/Atomic/Protocols/ModelProtocols/MoleculeModelProtocol.swift b/MVMCoreUI/Atomic/Protocols/ModelProtocols/MoleculeModelProtocol.swift index df3b0dca..240136c2 100644 --- a/MVMCoreUI/Atomic/Protocols/ModelProtocols/MoleculeModelProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/ModelProtocols/MoleculeModelProtocol.swift @@ -8,6 +8,7 @@ public enum MolecularError: Swift.Error { public protocol MoleculeModelProtocol: ModelProtocol, AccessibilityModelProtocol, MoleculeTreeTraversalProtocol { var moleculeName: String { get } var backgroundColor: Color? { get set } + var shouldMaskRecordedView: Bool { get } } public extension MoleculeModelProtocol { @@ -17,6 +18,8 @@ public extension MoleculeModelProtocol { static var categoryName: String { "\(MoleculeModelProtocol.self)" } static var categoryCodingKey: String { "moleculeName" } + + var shouldMaskRecordedView: Bool { return false } } diff --git a/MVMCoreUI/Atomic/Protocols/ModelProtocols/PageModelProtocol.swift b/MVMCoreUI/Atomic/Protocols/ModelProtocols/PageModelProtocol.swift index cfad22df..5796eb0a 100644 --- a/MVMCoreUI/Atomic/Protocols/ModelProtocols/PageModelProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/ModelProtocols/PageModelProtocol.swift @@ -13,4 +13,5 @@ public protocol PageModelProtocol { var screenHeading: String? { get set } var backgroundColor: Color? { get set } var navigationBar: (NavigationItemModelProtocol & MoleculeModelProtocol)? { get set } + var shouldMaskScreenWhileRecording: Bool { get } } diff --git a/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift b/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift index 3d1bea9c..01804b13 100644 --- a/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift @@ -28,6 +28,7 @@ public extension TemplateProtocol where Self: ViewController { traverseAndAddRequiredBehaviors() var behaviorHandler = self behaviorHandler.createBehaviors(for: model, delegateObject: delegateObjectIVar) + MVMCoreUISession.sharedGlobal()?.applyGlobalBehaviors(to: self) } func decodeTemplate(using decoder: JSONDecoder, from data: Data) throws -> TemplateModel { diff --git a/MVMCoreUI/Atomic/Protocols/ViewMaskingProtocol.swift b/MVMCoreUI/Atomic/Protocols/ViewMaskingProtocol.swift new file mode 100644 index 00000000..db3073c8 --- /dev/null +++ b/MVMCoreUI/Atomic/Protocols/ViewMaskingProtocol.swift @@ -0,0 +1,21 @@ +// +// ViewMaskingProtocol.swift +// MVMCoreUI +// +// Created by Kyle on 3/7/22. +// Copyright © 2022 Verizon Wireless. All rights reserved. +// + +import Foundation + +public protocol ViewMaskingProtocol: UIView { + + var shouldMaskWhileRecording: Bool { get } + +} + +public protocol ViewMaskingContainerProtocol { + + var maskedViewsWhileRecording: [UIView] { get } + +} diff --git a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift index fa404172..6ecce3d7 100644 --- a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift @@ -60,7 +60,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol open override func viewForTop() -> UIView { guard let headerModel = templateModel?.header, - let molecule = ModelRegistry.createMolecule(headerModel, delegateObject: delegateObjectIVar) + let molecule = generateMoleculeView(from: headerModel) else { return super.viewForTop() } // Temporary, Default the horizontal padding @@ -73,7 +73,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol override open func viewForBottom() -> UIView { guard let footerModel = templateModel?.footer, - let molecule = ModelRegistry.createMolecule(footerModel, delegateObject: delegateObjectIVar) + let molecule = generateMoleculeView(from: footerModel) else { return super.viewForBottom() } return molecule @@ -142,7 +142,9 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol (cell as? MoleculeViewProtocol)?.reset() (cell as? MoleculeListCellProtocol)?.setLines(with: templateModel?.line, delegateObject: delegateObjectIVar, additionalData: nil, indexPath: indexPath) - (cell as? MoleculeViewProtocol)?.set(with: moleculeInfo.molecule, delegateObjectIVar, nil) + if let moleculeView = cell as? MoleculeViewProtocol { + updateMoleculeView(moleculeView, from: moleculeInfo.molecule) + } (cell as? MVMCoreViewProtocol)?.updateView(tableView.bounds.width) // Neded to fix an apple defect where the cell is not the correct size on certain devices for certain cells cell.layoutIfNeeded() diff --git a/MVMCoreUI/Atomic/Templates/TemplateModel.swift b/MVMCoreUI/Atomic/Templates/TemplateModel.swift index 27cb3183..e5e9ac5a 100644 --- a/MVMCoreUI/Atomic/Templates/TemplateModel.swift +++ b/MVMCoreUI/Atomic/Templates/TemplateModel.swift @@ -10,6 +10,7 @@ import Foundation @objcMembers open class TemplateModel: MVMControllerModelProtocol, TabPageModelProtocol { + //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -30,6 +31,9 @@ import Foundation public var tabBarHidden: Bool = false public var tabBarIndex: Int? + + // By default we mask until the server unlocks the page. + public var shouldMaskScreenWhileRecording: Bool = false //-------------------------------------------------- // MARK: - Initializer @@ -53,6 +57,7 @@ import Foundation case navigationBar case tabBarHidden case tabBarIndex + case shouldMaskScreenWhileRecording } //-------------------------------------------------- @@ -77,6 +82,7 @@ import Foundation self.tabBarHidden = tabBarHidden } tabBarIndex = try typeContainer.decodeIfPresent(Int.self, forKey: .tabBarIndex) + shouldMaskScreenWhileRecording = try typeContainer.decodeIfPresent(Bool.self, forKey: .shouldMaskScreenWhileRecording) ?? shouldMaskScreenWhileRecording } open func encode(to encoder: Encoder) throws { @@ -89,5 +95,6 @@ import Foundation try container.encodeModelIfPresent(navigationBar, forKey: .navigationBar) try container.encode(tabBarHidden, forKey: .tabBarHidden) try container.encodeIfPresent(tabBarIndex, forKey: .tabBarIndex) + try container.encode(shouldMaskScreenWhileRecording, forKey: .shouldMaskScreenWhileRecording) } } diff --git a/MVMCoreUI/BaseClasses/TextField.swift b/MVMCoreUI/BaseClasses/TextField.swift index 9174426d..5b0dc369 100644 --- a/MVMCoreUI/BaseClasses/TextField.swift +++ b/MVMCoreUI/BaseClasses/TextField.swift @@ -8,12 +8,13 @@ import UIKit -public protocol TextInputDidDeleteProtocol: class { +public protocol TextInputDidDeleteProtocol: AnyObject { func textInputDidDelete() } -@objcMembers open class TextField: UITextField { +@objcMembers open class TextField: UITextField, ViewMaskingProtocol { + //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -23,6 +24,8 @@ public protocol TextInputDidDeleteProtocol: class { /// Set to true to hide the blinking textField cursor. public var hideBlinkingCaret = false + public var shouldMaskWhileRecording: Bool = true + //-------------------------------------------------- // MARK: - Delegate //-------------------------------------------------- @@ -97,6 +100,8 @@ extension TextField: MoleculeViewProtocol { if let accessibilityIdentifier = model.accessibilityIdentifier { self.accessibilityIdentifier = accessibilityIdentifier } + + shouldMaskWhileRecording = model.shouldMaskRecordedView } open func reset() { diff --git a/MVMCoreUI/BaseClasses/View.swift b/MVMCoreUI/BaseClasses/View.swift index c4c36ae8..d7b1cd06 100644 --- a/MVMCoreUI/BaseClasses/View.swift +++ b/MVMCoreUI/BaseClasses/View.swift @@ -9,7 +9,8 @@ import UIKit -@objcMembers open class View: UIView, MoleculeViewProtocol { +@objcMembers open class View: UIView, MoleculeViewProtocol, ViewMaskingProtocol { + //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -18,6 +19,10 @@ import UIKit private var initialSetupPerformed = false + public var shouldMaskWhileRecording: Bool { + return model?.shouldMaskRecordedView ?? false + } + //-------------------------------------------------- // MARK: - Initialization //-------------------------------------------------- diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index d7e947db..b385ae29 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -230,7 +230,7 @@ import UIKit let navigationItem = createDefaultLegacyNavigationModel() model?.navigationBar = navigationItem } - + self.model?.template executeBehaviors { (behavior: PageMoleculeTransformationBehavior) in behavior.onPageNew(rootMolecules: getRootMolecules(), delegateObjectIVar) } @@ -254,6 +254,27 @@ import UIKit manager?.newDataReceived?(in: self) } + public func generateMoleculeView(from model: MoleculeModelProtocol) -> MoleculeViewProtocol? { + executeBehaviors { (behavior: PageMoleculeTransformationBehavior) in + behavior.willSetupMolecule(with: model, updating: nil) + } + guard let moleculeView = ModelRegistry.createMolecule(model, delegateObject: delegateObjectIVar) else { return nil } + executeBehaviors { (behavior: PageMoleculeTransformationBehavior) in + behavior.didSetupMolecule(view: moleculeView, withModel: model) + } + return moleculeView + } + + public func updateMoleculeView(_ view: MoleculeViewProtocol, from model: MoleculeModelProtocol) { + executeBehaviors { (behavior: PageMoleculeTransformationBehavior) in + behavior.willSetupMolecule(with: model, updating: view) + } + view.set(with: model, delegateObjectIVar, nil) + executeBehaviors { (behavior: PageMoleculeTransformationBehavior) in + behavior.didSetupMolecule(view: view, withModel: model) + } + } + //-------------------------------------------------- // MARK: - Navigation Item //-------------------------------------------------- diff --git a/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift b/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift index eb244cbf..b8f117d6 100644 --- a/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift +++ b/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift @@ -15,7 +15,6 @@ public extension PageBehaviorHandlerProtocol { /// Creates the behaviors and sets the variable. mutating func createBehaviors(for model: PageBehaviorHandlerModelProtocol, delegateObject: MVMCoreUIDelegateObject?) { guard let behaviorModels = model.behaviors else { - behaviors = nil return } @@ -32,6 +31,9 @@ public extension PageBehaviorHandlerProtocol { } } } - self.behaviors = behaviors.count > 0 ? behaviors : nil + + if behaviors.count > 0 { + self.behaviors = behaviors + (self.behaviors ?? []) + } } } diff --git a/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift b/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift index 3f14f3cc..65773aa0 100644 --- a/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift +++ b/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift @@ -20,6 +20,15 @@ public protocol PageBehaviorProtocol: ModelHandlerProtocol { public protocol PageMoleculeTransformationBehavior: PageBehaviorProtocol { func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject) + func willSetupMolecule(with model: MoleculeModelProtocol, updating view: MoleculeViewProtocol?) + func didSetupMolecule(view: MoleculeViewProtocol, withModel: MoleculeModelProtocol) +} + +public extension PageMoleculeTransformationBehavior { + // All optional. + func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject) {} + func willSetupMolecule(with model: MoleculeModelProtocol, updating view: MoleculeViewProtocol?) {} + func didSetupMolecule(view: MoleculeViewProtocol, withModel: MoleculeModelProtocol) {} } public protocol PageVisibilityBehavior: PageBehaviorProtocol { diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUISession.h b/MVMCoreUI/OtherHandlers/MVMCoreUISession.h index ca2db26e..a81c8ee2 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUISession.h +++ b/MVMCoreUI/OtherHandlers/MVMCoreUISession.h @@ -13,6 +13,7 @@ @class MFViewController; @class MFLoadingViewController; @class NavigationController; + NS_ASSUME_NONNULL_BEGIN @interface MVMCoreUISession : MVMCoreSessionObject @@ -25,18 +26,21 @@ NS_ASSUME_NONNULL_BEGIN /// Tracks the current page type the user is currently viewing. KVO compliant. @property (nonatomic, strong, nullable) NSString *currentPageType; -// for handscroll Animation on subclasses of MFScrollingViewController +/// for handscroll Animation on subclasses of MFScrollingViewController @property (assign, nonatomic) BOOL enableHandScrollAnimation; -//indicates if the app launched successfully +/// indicates if the app launched successfully @property (assign, nonatomic) BOOL launchAppLoadedSuccessfully; -// Allows a global overload of the title view of navigation item. +/// Allows a global overload of the title view of navigation item. - (nullable UIView *)titleViewForController:(nonnull MFViewController *)controller; -// Sets up the session as delegate for standard load view controller. Pass the view controller that will be used to present and will be disabled when load view is presented. +/// Sets up the session as delegate for standard load view controller. Pass the view controller that will be used to present and will be disabled when load view is presented. - (void)setupAsStandardLoadViewDelegate:(nonnull UIViewController *)mainViewController; +/// Applies additional behaviors to a controller according to the session. Allows for packages to add additional cross cutting concerns. +- (void)applyGlobalBehaviorsToController:(nonnull UIViewController *)viewController; + @end NS_ASSUME_NONNULL_END diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUISession.m b/MVMCoreUI/OtherHandlers/MVMCoreUISession.m index 433b1ab1..957b5c19 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUISession.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUISession.m @@ -62,4 +62,8 @@ self.mainViewController.view.userInteractionEnabled = YES; } +- (void)applyGlobalBehaviorsToController:(nonnull UIViewController *)viewController { + // Allow extending frameworks to apply behaviors to add cross cutting concerns to the base controllers. +} + @end From 818afb3dfc84b29cf45d76a0e8fc8f759e90ff20 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Thu, 10 Mar 2022 12:38:31 -0500 Subject: [PATCH 02/15] add molecule generation hooks to other 3 templates --- MVMCoreUI/Atomic/Templates/CollectionTemplate.swift | 8 +++++--- MVMCoreUI/Atomic/Templates/MoleculeStackTemplate.swift | 6 +++--- MVMCoreUI/Atomic/Templates/ThreeLayerTemplate.swift | 6 +++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift b/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift index f3bd5d83..d6d920bb 100644 --- a/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift @@ -47,7 +47,7 @@ open override func viewForTop() -> UIView? { guard let headerModel = templateModel?.header, - let molecule = ModelRegistry.createMolecule(headerModel, delegateObject: delegateObjectIVar) + let molecule = generateMoleculeView(from: headerModel) else { return super.viewForTop() } // Temporary, Default the horizontal padding @@ -60,7 +60,7 @@ override open func viewForBottom() -> UIView? { guard let footerModel = templateModel?.footer, - let molecule = ModelRegistry.createMolecule(footerModel, delegateObject: delegateObjectIVar) + let molecule = generateMoleculeView(from: footerModel) else { return super.viewForBottom() } return molecule @@ -125,7 +125,9 @@ let cell = collectionView.dequeueReusableCell(withReuseIdentifier: moleculeInfo.identifier, for: indexPath) (cell as? MoleculeViewProtocol)?.reset() - (cell as? MoleculeViewProtocol)?.set(with: moleculeInfo.molecule, delegateObjectIVar, nil) + if let molecularCell = cell as? MoleculeViewProtocol { + updateMoleculeView(molecularCell, from: moleculeInfo.molecule) + } update(cell: cell, size: view.frame.width) // Neded to fix an apple defect where the cell is not the correct size on certain devices for certain cells cell.layoutIfNeeded() diff --git a/MVMCoreUI/Atomic/Templates/MoleculeStackTemplate.swift b/MVMCoreUI/Atomic/Templates/MoleculeStackTemplate.swift index 046469a8..c429f620 100644 --- a/MVMCoreUI/Atomic/Templates/MoleculeStackTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/MoleculeStackTemplate.swift @@ -55,7 +55,7 @@ open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol { open override func viewForTop() -> UIView? { guard let headerModel = templateModel?.header, - let molecule = ModelRegistry.createMolecule(headerModel, delegateObject: delegateObjectIVar) + let molecule = generateMoleculeView(from: headerModel) else { return nil } return molecule @@ -74,13 +74,13 @@ open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol { stackItem.useHorizontalMargins = true } - stack.set(with: moleculeStackModel, delegateObject() as? MVMCoreUIDelegateObject, nil) + updateMoleculeView(stack, from: moleculeStackModel) return stack } override open func viewForBottom() -> UIView? { guard let footerModel = templateModel?.footer, - let molecule = ModelRegistry.createMolecule(footerModel, delegateObject: delegateObjectIVar) + let molecule = generateMoleculeView(from: footerModel) else { return nil } return molecule diff --git a/MVMCoreUI/Atomic/Templates/ThreeLayerTemplate.swift b/MVMCoreUI/Atomic/Templates/ThreeLayerTemplate.swift index 502b269f..7fd5651b 100644 --- a/MVMCoreUI/Atomic/Templates/ThreeLayerTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/ThreeLayerTemplate.swift @@ -32,7 +32,7 @@ import UIKit open override func viewForTop() -> UIView? { guard let headerModel = templateModel?.header, - let molecule = ModelRegistry.createMolecule(headerModel, delegateObject: delegateObjectIVar) + let molecule = generateMoleculeView(from: headerModel) else { return nil } return molecule @@ -40,7 +40,7 @@ import UIKit open override func viewForMiddle() -> UIView? { guard let middleModel = templateModel?.middle, - let molecule = ModelRegistry.createMolecule(middleModel, delegateObject: delegateObjectIVar) + let molecule = generateMoleculeView(from: middleModel) else { return nil } return molecule @@ -48,7 +48,7 @@ import UIKit override open func viewForBottom() -> UIView? { guard let footerModel = templateModel?.footer, - let molecule = ModelRegistry.createMolecule(footerModel, delegateObject: delegateObjectIVar) + let molecule = generateMoleculeView(from: footerModel) else { return nil } return molecule From 926ee41277caf66cadfc62b1be202cb054f8280a Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Thu, 10 Mar 2022 21:43:54 -0500 Subject: [PATCH 03/15] will show and will hide --- MVMCoreUI/BaseControllers/ViewController.swift | 16 ++++++++++++++++ .../Protocols/PageBehaviorProtocol.swift | 10 ++++++++++ 2 files changed, 26 insertions(+) diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index b385ae29..2851b479 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -385,6 +385,14 @@ import UIKit } } + open override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + + executeBehaviors { [weak self] (behavior: PageVisibilityBehavior) in + behavior.willShowPage(self?.delegateObjectIVar) + } + } + open override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) @@ -393,6 +401,14 @@ import UIKit } } + open override func viewWillDisappear(_ animated: Bool) { + super.viewWillDisappear(animated) + + executeBehaviors { [weak self] (behavior: PageVisibilityBehavior) in + behavior.willHidePage(self?.delegateObjectIVar) + } + } + open override func viewDidDisappear(_ animated: Bool) { super.viewDidDisappear(animated) diff --git a/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift b/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift index 65773aa0..15b15d68 100644 --- a/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift +++ b/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift @@ -33,10 +33,20 @@ public extension PageMoleculeTransformationBehavior { public protocol PageVisibilityBehavior: PageBehaviorProtocol { + func willShowPage(_ delegateObject: MVMCoreUIDelegateObject?) func onPageShown(_ delegateObject: MVMCoreUIDelegateObject?) + func willHidePage(_ delegateObject: MVMCoreUIDelegateObject?) func onPageHidden(_ delegateObject: MVMCoreUIDelegateObject?) } +public extension PageVisibilityBehavior { + // All optional. + func willShowPage(_ delegateObject: MVMCoreUIDelegateObject?) {} + func onPageShown(_ delegateObject: MVMCoreUIDelegateObject?) {} + func willHidePage(_ delegateObject: MVMCoreUIDelegateObject?) {} + func onPageHidden(_ delegateObject: MVMCoreUIDelegateObject?) {} +} + public protocol PageScrolledBehavior: PageBehaviorProtocol { func pageScrolled(scrollView: UIScrollView, _ delegateObject: MVMCoreUIDelegateObject?) From e7546a9144d4549cccba504746f1e5bb157bdb8c Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Tue, 15 Mar 2022 14:36:52 -0400 Subject: [PATCH 04/15] code comments --- .../Atoms/FormFields/TextFields/EntryFieldModel.swift | 2 +- MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift | 3 +-- MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift | 2 +- MVMCoreUI/BaseControllers/ViewController.swift | 2 +- .../Behaviors/Protocols/PageBehaviorHandlerProtocol.swift | 8 +++----- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift index 405a0081..a2d4ff96 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift @@ -145,7 +145,7 @@ import Foundation hideBorders = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideBorders) ?? false baseValue = text fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) - shouldMaskRecordedView = try typeContainer.decode(Bool.self, forKey: .shouldMaskRecordedView) + shouldMaskRecordedView = try typeContainer.decodeIfPresent(Bool.self, forKey: .shouldMaskRecordedView) ?? shouldMaskRecordedView if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { self.groupName = groupName } diff --git a/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift b/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift index 01804b13..8dc1ded9 100644 --- a/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift @@ -26,8 +26,7 @@ public extension TemplateProtocol where Self: ViewController { model = templateModel as? MVMControllerModelProtocol guard let model = model else { return } traverseAndAddRequiredBehaviors() - var behaviorHandler = self - behaviorHandler.createBehaviors(for: model, delegateObject: delegateObjectIVar) + self.behaviors = createBehaviors(for: model, delegateObject: delegateObjectIVar) MVMCoreUISession.sharedGlobal()?.applyGlobalBehaviors(to: self) } diff --git a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift index 6ecce3d7..0194ecbd 100644 --- a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift @@ -60,7 +60,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol open override func viewForTop() -> UIView { guard let headerModel = templateModel?.header, - let molecule = generateMoleculeView(from: headerModel) + let molecule = generateMoleculeView(from: headerModel) else { return super.viewForTop() } // Temporary, Default the horizontal padding diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 2851b479..b221cf6d 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -230,7 +230,7 @@ import UIKit let navigationItem = createDefaultLegacyNavigationModel() model?.navigationBar = navigationItem } - self.model?.template + executeBehaviors { (behavior: PageMoleculeTransformationBehavior) in behavior.onPageNew(rootMolecules: getRootMolecules(), delegateObjectIVar) } diff --git a/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift b/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift index b8f117d6..9eaddc05 100644 --- a/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift +++ b/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift @@ -13,9 +13,9 @@ public protocol PageBehaviorHandlerProtocol { public extension PageBehaviorHandlerProtocol { /// Creates the behaviors and sets the variable. - mutating func createBehaviors(for model: PageBehaviorHandlerModelProtocol, delegateObject: MVMCoreUIDelegateObject?) { + func createBehaviors(for model: PageBehaviorHandlerModelProtocol, delegateObject: MVMCoreUIDelegateObject?) -> [PageBehaviorProtocol] { guard let behaviorModels = model.behaviors else { - return + return [] } var behaviors: [PageBehaviorProtocol] = [] @@ -32,8 +32,6 @@ public extension PageBehaviorHandlerProtocol { } } - if behaviors.count > 0 { - self.behaviors = behaviors + (self.behaviors ?? []) - } + return behaviors } } From 8ff374045b9c1294808bfcb9c4dccaee59dd3673 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Mon, 28 Mar 2022 08:58:40 -0400 Subject: [PATCH 05/15] change template level masking default to true --- MVMCoreUI/Atomic/Templates/TemplateModel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Templates/TemplateModel.swift b/MVMCoreUI/Atomic/Templates/TemplateModel.swift index e5e9ac5a..50b64383 100644 --- a/MVMCoreUI/Atomic/Templates/TemplateModel.swift +++ b/MVMCoreUI/Atomic/Templates/TemplateModel.swift @@ -33,7 +33,7 @@ import Foundation public var tabBarIndex: Int? // By default we mask until the server unlocks the page. - public var shouldMaskScreenWhileRecording: Bool = false + public var shouldMaskScreenWhileRecording: Bool = true //-------------------------------------------------- // MARK: - Initializer From 241b9d701a7626271cb0d85933d8a76fc8e01870 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Thu, 31 Mar 2022 20:10:05 -0400 Subject: [PATCH 06/15] Allow server to mask imageview models. Unmasked by default. --- MVMCoreUI/Atomic/Atoms/Views/ImageViewModel.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MVMCoreUI/Atomic/Atoms/Views/ImageViewModel.swift b/MVMCoreUI/Atomic/Atoms/Views/ImageViewModel.swift index 65bc978c..9b019207 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/ImageViewModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/ImageViewModel.swift @@ -26,6 +26,7 @@ public var localBundle: Bundle? public var cornerRadius: CGFloat? public var clipsImage: Bool? + public var shouldMaskRecordedView: Bool = false //-------------------------------------------------- // MARK: - Initializer @@ -54,5 +55,6 @@ case contentMode case cornerRadius case clipsImage + case shouldMaskRecordedView } } From 3d11c8abb2a9493332316bd8d89d138bdef58760 Mon Sep 17 00:00:00 2001 From: Subhankar Date: Wed, 11 May 2022 12:10:45 +0530 Subject: [PATCH 07/15] Linkmodel changes --- MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift index 955601ac..91176a50 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift @@ -27,6 +27,7 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode public var disabledColor = Color(uiColor: .mvmCoolGray6) public var disabledColor_inverted = Color(uiColor: .mvmCoolGray10) public var inverted = false + public var shouldMaskRecordedView: Bool = false //-------------------------------------------------- // MARK: - Initializer @@ -54,6 +55,7 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode case disabledColor case disabledColor_inverted case inverted + case shouldMaskRecordedView } //-------------------------------------------------- @@ -92,6 +94,7 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode if let disabledColor_inverted = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledColor_inverted) { self.disabledColor_inverted = disabledColor_inverted } + shouldMaskRecordedView = try typeContainer.decodeIfPresent(Bool.self, forKey: .shouldMaskRecordedView) ?? shouldMaskRecordedView } public func encode(to encoder: Encoder) throws { @@ -107,5 +110,6 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode try container.encode(enabledColor_inverted, forKey: .enabledColor_inverted) try container.encode(disabledColor, forKey: .disabledColor) try container.encode(disabledColor_inverted, forKey: .disabledColor_inverted) + try container.encode(shouldMaskRecordedView, forKey: .shouldMaskRecordedView) } } From 5cbef6731f10eabc15cf75b8511295ce0c1cb8a1 Mon Sep 17 00:00:00 2001 From: Subhankar Acharya Date: Fri, 27 May 2022 12:08:16 +0530 Subject: [PATCH 08/15] added behavior for unmasking --- MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift b/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift index 06660715..485cc0e1 100644 --- a/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift @@ -45,6 +45,9 @@ public extension TemplateProtocol { var behaviorHandler = self as? PageBehaviorHandlerProtocol else { return } behaviorHandlerModel.traverseAndAddRequiredBehaviors() behaviorHandler.createBehaviors(for: behaviorHandlerModel, delegateObject: delegateObject) + if let viewController = self as? UIViewController { + MVMCoreUISession.sharedGlobal()?.applyGlobalBehaviors(to: (viewController)) + } } func decodeTemplate(using decoder: JSONDecoder, from data: Data) throws -> TemplateModel { From 044a103665b2e3d6acab8c2aed766f63216772af Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Wed, 29 Jun 2022 16:16:33 -0400 Subject: [PATCH 09/15] Relax model handling to allow handlers to decide what to do when server doesn't specify masking. Leverage introduced legacy behavior handling over customized direct recording manager calls. Bring in RemoteView molecular masking handling. Fix ImageViewModel decoding requirement. --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++++ .../FormFields/TextFields/EntryFieldModel.swift | 2 +- .../FormFields/TextFields/TextEntryField.swift | 2 +- .../Atomic/Atoms/Views/ImageViewModel.swift | 2 +- MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift | 2 +- .../MoleculeMaskingProtocol.swift | 17 +++++++++++++++++ .../ModelProtocols/MoleculeModelProtocol.swift | 5 +---- .../ModelProtocols/PageModelProtocol.swift | 2 +- .../Atomic/Protocols/ViewMaskingProtocol.swift | 6 ------ .../Atomic/Templates/BaseTemplateModel.swift | 4 ++-- MVMCoreUI/BaseClasses/TextField.swift | 2 +- 11 files changed, 30 insertions(+), 18 deletions(-) create mode 100644 MVMCoreUI/Atomic/Protocols/ModelProtocols/MoleculeMaskingProtocol.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 9998b873..1530665e 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -130,6 +130,7 @@ 1D6D258826899B0C00DEBB08 /* ImageButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D6D258626899B0B00DEBB08 /* ImageButtonModel.swift */; }; 1D6D258926899B0C00DEBB08 /* ImageButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D6D258726899B0B00DEBB08 /* ImageButton.swift */; }; 27559EFC27D691D3000836C1 /* ViewMaskingProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27559EFB27D691D3000836C1 /* ViewMaskingProtocol.swift */; }; + 27577DCD286CA959001EC47E /* MoleculeMaskingProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27577DCC286CA959001EC47E /* MoleculeMaskingProtocol.swift */; }; 279B1569242BBC2F00921D6C /* ActionModelAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 279B1568242BBC2F00921D6C /* ActionModelAdapter.swift */; }; 27F6B08826051831008529AA /* MoleculeTreeTraversalProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27F6B08726051831008529AA /* MoleculeTreeTraversalProtocol.swift */; }; 27F6B08C26052AFF008529AA /* ParentMoleculeModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27F6B08B26052AFF008529AA /* ParentMoleculeModelProtocol.swift */; }; @@ -722,6 +723,7 @@ 1D6D258626899B0B00DEBB08 /* ImageButtonModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ImageButtonModel.swift; path = MVMCoreUI/Atomic/Atoms/Buttons/ImageButtonModel.swift; sourceTree = SOURCE_ROOT; }; 1D6D258726899B0B00DEBB08 /* ImageButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ImageButton.swift; path = MVMCoreUI/Atomic/Atoms/Buttons/ImageButton.swift; sourceTree = SOURCE_ROOT; }; 27559EFB27D691D3000836C1 /* ViewMaskingProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewMaskingProtocol.swift; sourceTree = ""; }; + 27577DCC286CA959001EC47E /* MoleculeMaskingProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeMaskingProtocol.swift; sourceTree = ""; }; 279B1568242BBC2F00921D6C /* ActionModelAdapter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionModelAdapter.swift; sourceTree = ""; }; 27F6B08726051831008529AA /* MoleculeTreeTraversalProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeTreeTraversalProtocol.swift; sourceTree = ""; }; 27F6B08B26052AFF008529AA /* ParentMoleculeModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParentMoleculeModelProtocol.swift; sourceTree = ""; }; @@ -1223,6 +1225,7 @@ D2509ED02472ED9B001BFB9D /* NavigationItemModelProtocol.swift */, D28BA74C248589C800B75CB8 /* TabPageModelProtocol.swift */, 27F6B08B26052AFF008529AA /* ParentMoleculeModelProtocol.swift */, + 27577DCC286CA959001EC47E /* MoleculeMaskingProtocol.swift */, ); path = ModelProtocols; sourceTree = ""; @@ -3072,6 +3075,7 @@ D29DF2AA21E7B2F9003B2FB9 /* MVMCoreUIConstants.m in Sources */, EA41F4AC2787927100F5B377 /* DynamicRuleFormFieldEffectModel.swift in Sources */, 011D95892404249B000E3791 /* FormHolderModelProtocol.swift in Sources */, + 27577DCD286CA959001EC47E /* MoleculeMaskingProtocol.swift in Sources */, BB54C5202434D92F0038326C /* ListRightVariableButtonAllTextAndLinks.swift in Sources */, 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */, 013F801923FB4A8E00AD8013 /* UIContentMode+Extension.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift index a2d4ff96..c3134e19 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift @@ -42,7 +42,7 @@ import Foundation public var wasInitiallySelected: Bool = false public var title: String? public var feedback: String? - public var shouldMaskRecordedView: Bool = true + public var shouldMaskRecordedView: Bool? = true //used to drive the EntryFieldView UI public var titleStateLabel: FormLabelModel diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift index 1f2b8e3a..07260ac1 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift @@ -337,7 +337,7 @@ import UIKit text = model.text placeholder = model.placeholder - textField.shouldMaskWhileRecording = model.shouldMaskRecordedView + textField.shouldMaskWhileRecording = model.shouldMaskRecordedView ?? true switch model.type { case .password, .secure: diff --git a/MVMCoreUI/Atomic/Atoms/Views/ImageViewModel.swift b/MVMCoreUI/Atomic/Atoms/Views/ImageViewModel.swift index 9b019207..03c18491 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/ImageViewModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/ImageViewModel.swift @@ -26,7 +26,7 @@ public var localBundle: Bundle? public var cornerRadius: CGFloat? public var clipsImage: Bool? - public var shouldMaskRecordedView: Bool = false + public var shouldMaskRecordedView: Bool? = false //-------------------------------------------------- // MARK: - Initializer diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index feaaa878..2ad66ede 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -247,7 +247,7 @@ public typealias ActionBlock = () -> () text = nil attributedText = nil originalAttributedString = nil - shouldMaskWhileRecording = model.shouldMaskRecordedView + shouldMaskWhileRecording = model.shouldMaskRecordedView ?? false guard let labelModel = model as? LabelModel else { return } diff --git a/MVMCoreUI/Atomic/Protocols/ModelProtocols/MoleculeMaskingProtocol.swift b/MVMCoreUI/Atomic/Protocols/ModelProtocols/MoleculeMaskingProtocol.swift new file mode 100644 index 00000000..b9e9997e --- /dev/null +++ b/MVMCoreUI/Atomic/Protocols/ModelProtocols/MoleculeMaskingProtocol.swift @@ -0,0 +1,17 @@ +// +// MaskedMoleculeProtocol.swift +// MVMCoreUI +// +// Created by Kyle on 6/29/22. +// Copyright © 2022 Verizon Wireless. All rights reserved. +// + +import Foundation + +public protocol MoleculeMaskingProtocol { + var shouldMaskRecordedView: Bool? { get } +} + +public extension MoleculeMaskingProtocol { + var shouldMaskRecordedView: Bool? { return false } +} diff --git a/MVMCoreUI/Atomic/Protocols/ModelProtocols/MoleculeModelProtocol.swift b/MVMCoreUI/Atomic/Protocols/ModelProtocols/MoleculeModelProtocol.swift index 240136c2..1f1fdc1e 100644 --- a/MVMCoreUI/Atomic/Protocols/ModelProtocols/MoleculeModelProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/ModelProtocols/MoleculeModelProtocol.swift @@ -5,10 +5,9 @@ public enum MolecularError: Swift.Error { } -public protocol MoleculeModelProtocol: ModelProtocol, AccessibilityModelProtocol, MoleculeTreeTraversalProtocol { +public protocol MoleculeModelProtocol: ModelProtocol, AccessibilityModelProtocol, MoleculeTreeTraversalProtocol, MoleculeMaskingProtocol { var moleculeName: String { get } var backgroundColor: Color? { get set } - var shouldMaskRecordedView: Bool { get } } public extension MoleculeModelProtocol { @@ -18,8 +17,6 @@ public extension MoleculeModelProtocol { static var categoryName: String { "\(MoleculeModelProtocol.self)" } static var categoryCodingKey: String { "moleculeName" } - - var shouldMaskRecordedView: Bool { return false } } diff --git a/MVMCoreUI/Atomic/Protocols/ModelProtocols/PageModelProtocol.swift b/MVMCoreUI/Atomic/Protocols/ModelProtocols/PageModelProtocol.swift index 5796eb0a..122adcee 100644 --- a/MVMCoreUI/Atomic/Protocols/ModelProtocols/PageModelProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/ModelProtocols/PageModelProtocol.swift @@ -13,5 +13,5 @@ public protocol PageModelProtocol { var screenHeading: String? { get set } var backgroundColor: Color? { get set } var navigationBar: (NavigationItemModelProtocol & MoleculeModelProtocol)? { get set } - var shouldMaskScreenWhileRecording: Bool { get } + var shouldMaskScreenWhileRecording: Bool? { get } } diff --git a/MVMCoreUI/Atomic/Protocols/ViewMaskingProtocol.swift b/MVMCoreUI/Atomic/Protocols/ViewMaskingProtocol.swift index db3073c8..e8004790 100644 --- a/MVMCoreUI/Atomic/Protocols/ViewMaskingProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/ViewMaskingProtocol.swift @@ -13,9 +13,3 @@ public protocol ViewMaskingProtocol: UIView { var shouldMaskWhileRecording: Bool { get } } - -public protocol ViewMaskingContainerProtocol { - - var maskedViewsWhileRecording: [UIView] { get } - -} diff --git a/MVMCoreUI/Atomic/Templates/BaseTemplateModel.swift b/MVMCoreUI/Atomic/Templates/BaseTemplateModel.swift index 1a4d6bab..b60ca4bc 100644 --- a/MVMCoreUI/Atomic/Templates/BaseTemplateModel.swift +++ b/MVMCoreUI/Atomic/Templates/BaseTemplateModel.swift @@ -32,7 +32,7 @@ import Foundation public var tabBarIndex: Int? // By default we mask until the server unlocks the page. - public var shouldMaskScreenWhileRecording: Bool = true + public var shouldMaskScreenWhileRecording: Bool? //-------------------------------------------------- // MARK: - Initializer @@ -81,7 +81,7 @@ import Foundation self.tabBarHidden = tabBarHidden } tabBarIndex = try typeContainer.decodeIfPresent(Int.self, forKey: .tabBarIndex) - shouldMaskScreenWhileRecording = try typeContainer.decodeIfPresent(Bool.self, forKey: .shouldMaskScreenWhileRecording) ?? shouldMaskScreenWhileRecording + shouldMaskScreenWhileRecording = try typeContainer.decodeIfPresent(Bool.self, forKey: .shouldMaskScreenWhileRecording) } open func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/BaseClasses/TextField.swift b/MVMCoreUI/BaseClasses/TextField.swift index 5b0dc369..306b363f 100644 --- a/MVMCoreUI/BaseClasses/TextField.swift +++ b/MVMCoreUI/BaseClasses/TextField.swift @@ -101,7 +101,7 @@ extension TextField: MoleculeViewProtocol { self.accessibilityIdentifier = accessibilityIdentifier } - shouldMaskWhileRecording = model.shouldMaskRecordedView + shouldMaskWhileRecording = model.shouldMaskRecordedView ?? true } open func reset() { From 2de6783bf08a889cfb7e8384b0f289611be37e8a Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Wed, 29 Jun 2022 16:38:32 -0400 Subject: [PATCH 10/15] Fix models that missed refactor. --- MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift | 2 +- MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift index 40f2e406..38bcb491 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift @@ -32,7 +32,7 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode public var inverted = false public var size:linkFontSize = linkFontSize.small - public var shouldMaskRecordedView: Bool = false + public var shouldMaskRecordedView: Bool? = false //-------------------------------------------------- // MARK: - Initializer diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift index de5c3980..40740194 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift @@ -26,7 +26,7 @@ public var hero: Int? public var makeWholeViewClickable: Bool? public var numberOfLines: Int? - public var shouldMaskRecordedView: Bool = false + public var shouldMaskRecordedView: Bool? = false //-------------------------------------------------- // MARK: - Keys From fe5416560efede0b5ca60234e86a42839df2484a Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Tue, 12 Jul 2022 09:53:18 -0400 Subject: [PATCH 11/15] missed heavy line --- MVMCoreUI/Atomic/Molecules/HeadersAndFooters/Header.swift | 4 +--- .../Atomic/Molecules/HeadersAndFooters/HeaderModel.swift | 3 --- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/Header.swift b/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/Header.swift index 9d061f76..d1c7cf48 100644 --- a/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/Header.swift +++ b/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/Header.swift @@ -51,9 +51,7 @@ open class HeaderView: Container { open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) guard let headerModel = headerModel else { return } - if let lineModel = headerModel.line { - line.set(with: lineModel, delegateObject, additionalData) - } + line.setOptional(with: headerModel.line, delegateObject, additionalData) } open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { diff --git a/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/HeaderModel.swift b/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/HeaderModel.swift index 08c7343f..df1045c2 100644 --- a/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/HeaderModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/HeaderModel.swift @@ -30,9 +30,6 @@ if bottomPadding == nil { bottomPadding = PaddingDefaultVerticalSpacing } - if line == nil { - line = LineModel(type: .heavy) - } } public override init() { From a07f70fb06c7184843f6c169a29af7ea1c976e77 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Tue, 12 Jul 2022 10:58:08 -0400 Subject: [PATCH 12/15] tiny is gone --- .../Headers/H2/HeadersH2TinyButtonModel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButtonModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButtonModel.swift index d4edfd38..ce27740b 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButtonModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButtonModel.swift @@ -41,7 +41,7 @@ public class HeadersH2TinyButtonModel: HeaderModel, MoleculeModelProtocol { } super.setDefaults() button.style = .secondary - button.size = .tiny + button.size = .small } //-------------------------------------------------- From 9cefb94bff14af3635cbf9e40182d538a6ba686f Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Wed, 13 Jul 2022 23:22:44 -0400 Subject: [PATCH 13/15] restore PageBehaviorHandlerProtocol createBehaviors --- MVMCoreUI/Atomic/Templates/BaseTemplateModel.swift | 1 - .../Behaviors/Protocols/PageBehaviorHandlerProtocol.swift | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Atomic/Templates/BaseTemplateModel.swift b/MVMCoreUI/Atomic/Templates/BaseTemplateModel.swift index b60ca4bc..daa3aed1 100644 --- a/MVMCoreUI/Atomic/Templates/BaseTemplateModel.swift +++ b/MVMCoreUI/Atomic/Templates/BaseTemplateModel.swift @@ -31,7 +31,6 @@ import Foundation public var tabBarHidden: Bool = false public var tabBarIndex: Int? - // By default we mask until the server unlocks the page. public var shouldMaskScreenWhileRecording: Bool? //-------------------------------------------------- diff --git a/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift b/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift index ba0e2618..79f3364f 100644 --- a/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift +++ b/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift @@ -13,9 +13,10 @@ public protocol PageBehaviorHandlerProtocol { public extension PageBehaviorHandlerProtocol { /// Creates the behaviors and sets the variable. - func createBehaviors(for model: PageBehaviorHandlerModelProtocol, delegateObject: MVMCoreUIDelegateObject?) -> [PageBehaviorProtocol] { + mutating func createBehaviors(for model: PageBehaviorHandlerModelProtocol, delegateObject: MVMCoreUIDelegateObject?) { guard let behaviorModels = model.behaviors else { - return [] + behaviors = nil + return } var behaviors: [PageBehaviorProtocol] = [] @@ -31,8 +32,7 @@ public extension PageBehaviorHandlerProtocol { } } } - - return behaviors + self.behaviors = behaviors.count > 0 ? behaviors : nil } /// Executes all behaviors of type. From 13113c50ed120901b8b1cf1d5a2285fd93af72e1 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Fri, 15 Jul 2022 12:24:40 -0400 Subject: [PATCH 14/15] behavior transcendence --- MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift | 2 +- .../Protocols/PageBehaviorHandlerProtocol.swift | 9 +++++++-- MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift | 7 +++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift b/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift index ba1db7fb..144001bc 100644 --- a/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift @@ -42,7 +42,7 @@ public extension TemplateProtocol { behaviorHandlerModel.traverseAndAddRequiredBehaviors() behaviorHandler.createBehaviors(for: behaviorHandlerModel, delegateObject: delegateObject) if let viewController = self as? UIViewController { - MVMCoreUISession.sharedGlobal()?.applyGlobalBehaviors(to: (viewController)) + MVMCoreUISession.sharedGlobal()?.applyGlobalBehaviors(to: viewController) } } diff --git a/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift b/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift index 79f3364f..971a052b 100644 --- a/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift +++ b/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift @@ -14,12 +14,17 @@ public protocol PageBehaviorHandlerProtocol { public extension PageBehaviorHandlerProtocol { /// Creates the behaviors and sets the variable. mutating func createBehaviors(for model: PageBehaviorHandlerModelProtocol, delegateObject: MVMCoreUIDelegateObject?) { - guard let behaviorModels = model.behaviors else { + + behaviors = behaviors?.filter { $0.transcendsPageUpdates } + if behaviors?.isEmpty ?? false { behaviors = nil + } + + guard let behaviorModels = model.behaviors else { return } - var behaviors: [PageBehaviorProtocol] = [] + var behaviors: [PageBehaviorProtocol] = behaviors ?? [] for behaviorModel in behaviorModels { do { diff --git a/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift b/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift index 2e8fbd69..453041c2 100644 --- a/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift +++ b/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift @@ -9,10 +9,17 @@ public protocol PageBehaviorProtocol: ModelHandlerProtocol { + /// Should the behavior persist regardless of page behavior model updates. + var transcendsPageUpdates: Bool { get } + /// Initializes the behavior with the model init(model: PageBehaviorModelProtocol, delegateObject: MVMCoreUIDelegateObject?) } +public extension PageBehaviorProtocol { + var transcendsPageUpdates: Bool { return false } +} + /** Behavior conforming protocols. Behaviors will conform to one or more of these protocols to receive page lifecycle events that pertain to them. */ From bfbd6914fbbd58af276ef234a3870cb99f6dda8c Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 18 Jul 2022 17:45:30 -0400 Subject: [PATCH 15/15] Deprecated function removal. --- MVMCoreUI/Alerts/MVMCoreAlertObject.h | 7 -- MVMCoreUI/Alerts/MVMCoreAlertObject.m | 109 -------------------------- 2 files changed, 116 deletions(-) diff --git a/MVMCoreUI/Alerts/MVMCoreAlertObject.h b/MVMCoreUI/Alerts/MVMCoreAlertObject.h index 03748c98..a3a019b3 100644 --- a/MVMCoreUI/Alerts/MVMCoreAlertObject.h +++ b/MVMCoreUI/Alerts/MVMCoreAlertObject.h @@ -62,11 +62,4 @@ typedef void (^TextFieldErrorHandler)(NSArray * _Nonnull fieldErrors); // Will show this alert in it's appropriate type style. - (void)showAlert; -#pragma mark - Deprecated - -// Creates an alert object for an error with the passed in load object response info -+ (nullable instancetype)alertObjectForLoadObject:(nullable MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error actionDelegate:(nullable NSObject *)actionDelegate __deprecated; -+ (nullable instancetype)alertObjectForPageType:(nullable NSString *)pageType responseInfo:(nullable NSDictionary *)responseInfo additionalData:(nullable NSDictionary *)additionalData actionDelegate:(nullable NSObject *)actionDelegate __deprecated; -+ (nullable instancetype)alertObjectWithPage:(nullable NSDictionary *)page isGreedy:(BOOL)isGreedy additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate error:(MVMCoreErrorObject *_Nullable *_Nullable)error __deprecated; - @end diff --git a/MVMCoreUI/Alerts/MVMCoreAlertObject.m b/MVMCoreUI/Alerts/MVMCoreAlertObject.m index 7c61dd08..666745e2 100644 --- a/MVMCoreUI/Alerts/MVMCoreAlertObject.m +++ b/MVMCoreUI/Alerts/MVMCoreAlertObject.m @@ -195,113 +195,4 @@ } } -#pragma mark - Deprecated - -+ (nullable instancetype)alertObjectForLoadObject:(nullable MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error actionDelegate:(nullable NSObject *)actionDelegate { - - MVMCoreAlertObject *alert = nil; - if (!error || [ErrorDomainServer isEqualToString:error.domain]) { - alert = [MVMCoreAlertObject alertObjectForPageType:loadObject.pageType responseInfo:loadObject.responseInfoMap additionalData:loadObject.dataForPage actionDelegate:actionDelegate]; - } else { - alert = [[MVMCoreAlertObject alloc] initPopupAlertWithError:error isGreedy:NO]; - } - - // only if actions are empty, then go inside and set OK as default action - if (alert.type == MFAlertTypePopup && alert.actions.count == 0) { - alert.defaultAction = YES; - alert.actions = @[[UIAlertAction actionWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedOK] style:UIAlertActionStyleDefault handler:nil]]; - } - return alert; -} - -+ (nullable instancetype)alertObjectForPageType:(nullable NSString *)pageType responseInfo:(nullable NSDictionary *)responseInfo additionalData:(nullable NSDictionary *)additionalData actionDelegate:(nullable NSObject *)actionDelegate { - - __block MVMCoreAlertObject *alert = [[MVMCoreAlertObject alloc] init]; - alert.title = [responseInfo string:KeyErrorHeading] ?: [MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle]; - alert.message = [responseInfo string:KeyUserMessage] ?: [MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess]; - NSString *messageStyle = [responseInfo stringForKey:KeyMessageStyle]; - if ([ValueTypeFieldErrors isEqualToString:[responseInfo string:KeyType]]) { - - // field errors. - alert.type = MFAlertTypeField; - alert.fieldErrors = [responseInfo array:ValueTypeFieldErrors]; - } else { - - // Check for top alert (persistent or regular). - if ([messageStyle isEqualToString:ValueMessageStyleTopPersistent] || [messageStyle isEqualToString:ValueMessageStyleTop]) { - - alert.topAlertObject = [[MVMCoreTopAlertObject alloc] initWithResponseInfo:responseInfo]; - if ([actionDelegate conformsToProtocol:@protocol(MVMCoreTopAlertDelegateProtocol)]) { - alert.topAlertObject.delegate = (NSObject *)actionDelegate; - } - alert.topAlertObject.pageType = pageType; - alert.type = MFAlertTypeTop; - } else if ([messageStyle isEqualToString:ValueMessageStylePopup]) { - - // Perform a popup. - alert.type = MFAlertTypePopup; - alert.alertStyle = UIAlertControllerStyleAlert; - - // Check if we have a popup driven by page object (otherwise by default it will just use response info title message with an OK button). - NSString *pageTypeForPopup = [responseInfo stringForKey:@"popupPageType"]; - [[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForPopup queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) { - - MVMCoreErrorObject *error = nil; - MVMCoreAlertObject *popupAlert = [MVMCoreAlertObject alertObjectWithPage:jsonDictionary isGreedy:NO additionalData:additionalData delegate:actionDelegate error:&error]; - if (error) { - - // Error, popup page not found for page type. - popupAlert = [[MVMCoreAlertObject alloc] initPopupAlertWithError:error isGreedy:NO]; - } - - if (popupAlert) { - alert = popupAlert; - } - }]; - } else if (messageStyle.length == 0 && pageType) { - - // No message style! - alert.type = MFAlertTypeNone; - } else { - - // Default to popup - alert.type = MFAlertTypePopup; - alert.alertStyle = UIAlertControllerStyleAlert; - } - } - if ([actionDelegate conformsToProtocol:@protocol(MVMCoreAlertDelegateProtocol)]) { - alert.alertDelegate = (NSObject *)actionDelegate; - } - return alert; -} - -+ (nullable instancetype)alertObjectWithPage:(nullable NSDictionary *)page isGreedy:(BOOL)isGreedy additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate error:(MVMCoreErrorObject *_Nullable *_Nullable)error { - - MVMCoreAlertObject *alert = [[MVMCoreAlertObject alloc] init]; - alert.title = [page string:KeyTitle] ?: [MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle]; - alert.pageJson = page; - alert.message = [page string:KeyMessage] ?: [MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess]; - alert.isGreedy = isGreedy; - alert.type = MFAlertTypePopup; - alert.alertStyle = UIAlertControllerStyleAlert; - - NSArray *actions = [page array:KeyLinks]; - NSMutableArray *actionsForAlert = [NSMutableArray array]; - for (NSDictionary *actionMap in actions) { - [actionsForAlert addObject:[UIAlertAction actionWithTitle:[actionMap stringForKey:KeyTitle] style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { - [[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:additionalData delegate:delegate]; - }]]; - } - alert.actions = actionsForAlert; - - if ((alert.title.length > 0 || alert.message.length > 0) && alert.actions.count > 0) { - return alert; - } else { - if (error) { - *error = [[MVMCoreErrorObject alloc] initWithTitle:nil messageToLog:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodePopupFailed domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_Popup_pageType:%@",NSStringFromClass([delegate class]),[page stringForKey:KeyPageType]]]; - } - return nil; - } -} - @end