From ed762d126fe0745194caa876c43d71c07a90101f Mon Sep 17 00:00:00 2001 From: Subhankar Date: Wed, 18 Nov 2020 16:40:48 +0530 Subject: [PATCH 001/113] changes in access specifier --- MVMCoreUI/Atomic/Templates/TemplateModel.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Templates/TemplateModel.swift b/MVMCoreUI/Atomic/Templates/TemplateModel.swift index bb8bb104..2976134a 100644 --- a/MVMCoreUI/Atomic/Templates/TemplateModel.swift +++ b/MVMCoreUI/Atomic/Templates/TemplateModel.swift @@ -15,7 +15,7 @@ import Foundation // MARK: - Properties //-------------------------------------------------- - public class var identifier: String { + open class var identifier: String { return "" } @@ -76,7 +76,7 @@ import Foundation tabBarIndex = try typeContainer.decodeIfPresent(Int.self, forKey: .tabBarIndex) } - public func encode(to encoder: Encoder) throws { + open func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(pageType, forKey: .pageType) try container.encode(template, forKey: .template) From 81c099d5f9a813f52b67cd7080e40b9106d9542d Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 31 Mar 2021 11:08:56 -0400 Subject: [PATCH 002/113] length check for attrivutes --- MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index e8c8446f..c24c880e 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -828,7 +828,10 @@ extension Label { private func addActionAttributes(range: NSRange, string: NSMutableAttributedString?) { - guard let string = string else { return } + guard let string = string, + string.length >= range.length + else { return } + string.addAttributes([NSAttributedString.Key.underlineStyle: NSUnderlineStyle.single.rawValue], range: range) } From 5297ed5ec0afb380ad772a8739ac22c59fed6d29 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 31 Mar 2021 11:13:57 -0400 Subject: [PATCH 003/113] undo --- MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index c24c880e..b8300459 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -828,9 +828,7 @@ extension Label { private func addActionAttributes(range: NSRange, string: NSMutableAttributedString?) { - guard let string = string, - string.length >= range.length - else { return } + guard let string = string else { return } string.addAttributes([NSAttributedString.Key.underlineStyle: NSUnderlineStyle.single.rawValue], range: range) } From 06a42cfa21d4ffb1f0c6f8462f35fe2d834b8f5b Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 13 Apr 2021 15:07:44 -0400 Subject: [PATCH 004/113] audio behavior --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++ MVMCoreUI/Behaviors/PlayAudioBehavior.swift | 54 +++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 MVMCoreUI/Behaviors/PlayAudioBehavior.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index cb13de6f..fc435de1 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -61,6 +61,7 @@ 01EB369323609801006832FA /* HeaderModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368C23609801006832FA /* HeaderModel.swift */; }; 01EB369423609801006832FA /* HeadlineBodyModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368D23609801006832FA /* HeadlineBodyModel.swift */; }; 01F2A03223A4498200D954D8 /* CaretLinkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A03123A4498200D954D8 /* CaretLinkModel.swift */; }; + 0A01DE272626236300C2CAAC /* PlayAudioBehavior.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A01DE262626236300C2CAAC /* PlayAudioBehavior.swift */; }; 0A0FEC7425D42A5E00AF2548 /* BaseItemPickerEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A0FEC7325D42A5E00AF2548 /* BaseItemPickerEntryField.swift */; }; 0A0FEC7825D42A8500AF2548 /* BaseItemPickerEntryFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A0FEC7725D42A8500AF2548 /* BaseItemPickerEntryFieldModel.swift */; }; 0A1214A022C11A18007C7030 /* ActionDetailWithImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */; }; @@ -622,6 +623,7 @@ 01EB368C23609801006832FA /* HeaderModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeaderModel.swift; sourceTree = ""; }; 01EB368D23609801006832FA /* HeadlineBodyModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeadlineBodyModel.swift; sourceTree = ""; }; 01F2A03123A4498200D954D8 /* CaretLinkModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CaretLinkModel.swift; sourceTree = ""; }; + 0A01DE262626236300C2CAAC /* PlayAudioBehavior.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayAudioBehavior.swift; sourceTree = ""; }; 0A0FEC7325D42A5E00AF2548 /* BaseItemPickerEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseItemPickerEntryField.swift; sourceTree = ""; }; 0A0FEC7725D42A8500AF2548 /* BaseItemPickerEntryFieldModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseItemPickerEntryFieldModel.swift; sourceTree = ""; }; 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionDetailWithImage.swift; sourceTree = ""; }; @@ -1311,6 +1313,7 @@ 0A1C30972620F61A00B47F3B /* Protocols */, 27F97369246750BE00CAB5C5 /* ScreenBrightnessModifierBehavior.swift */, D23A900826125FFB007E14CE /* GetContactBehavior.swift */, + 0A01DE262626236300C2CAAC /* PlayAudioBehavior.swift */, ); path = Behaviors; sourceTree = ""; @@ -2878,6 +2881,7 @@ D2092355244FA0FD0044AD09 /* ThreeLayerTemplateModelProtocol.swift in Sources */, 0AE14F64238315D2005417F8 /* TextField.swift in Sources */, 0A51F3E22475CB73002E08B6 /* LoadingSpinnerModel.swift in Sources */, + 0A01DE272626236300C2CAAC /* PlayAudioBehavior.swift in Sources */, D2169303251E53D9002A6324 /* SectionListTemplateModel.swift in Sources */, 0AB764D124460F6300E7FE72 /* UIDatePicker+Extension.swift in Sources */, BB105859248DEFF70069D008 /* UICollectionViewLeftAlignedLayout.swift in Sources */, diff --git a/MVMCoreUI/Behaviors/PlayAudioBehavior.swift b/MVMCoreUI/Behaviors/PlayAudioBehavior.swift new file mode 100644 index 00000000..9b1e1ba9 --- /dev/null +++ b/MVMCoreUI/Behaviors/PlayAudioBehavior.swift @@ -0,0 +1,54 @@ +// +// PlayAudioBehavior.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 4/9/21. +// Copyright © 2021 Verizon Wireless. All rights reserved. +// + + +public protocol PagePlayAudioBehaviorConsumerProtocol { +// func getMatchParameters() -> (NSPredicate, [CNKeyDescriptor])? +// func consume(contacts: [CNContact]) +} + +public class PagePlayAudioBehaviorModel: PageBehaviorModelProtocol { + public class var identifier: String { "pagePlayAudioBehavior" } + public var shouldAllowMultipleInstances: Bool { false } + + public init() { } +} + +public class PagePlayAudioBehavior: PageVisibilityBehavior { + var delegate: MVMCoreUIDelegateObject? + + public required init(model: PageBehaviorModelProtocol, delegateObject: MVMCoreUIDelegateObject?) { + self.delegate = delegateObject + } + + public func onPageShown(_ delegateObject: MVMCoreUIDelegateObject?) { + // Ask for permission +// CNContactStore().requestAccess(for: .contacts) { [weak self] (access, error) in +// guard access, +// error == nil, +// // TODO: Clean up this interface +// let model = (self?.delegate?.moleculeDelegate as? PageProtocol)?.pageModel as? TemplateModelProtocol else { return } +// // Iterate models and provide contact +// let store = CNContactStore() +// let consumers: [PagePlayAudioBehaviorConsumerProtocol] = model.allMoleculesOfType() +// for consumer in consumers { +// guard let parameters = consumer.getMatchParameters(), +// let contacts = try? store.unifiedContacts(matching: parameters.0, keysToFetch: parameters.1) else { return } +// consumer.consume(contacts: contacts) +// } +// +// // Tell template to update +// MVMCoreDispatchUtility.performBlock(onMainThread: { +// // TODO: move to protocol function instead +// (self?.delegate?.moleculeDelegate as? ViewController)?.handleNewData() +// }) +// } + } + + public func onPageHidden(_ delegateObject: MVMCoreUIDelegateObject?) {} +} From 6b610638112f7b334d3665ed918c5cba22f5eee2 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 14 Apr 2021 11:23:14 -0400 Subject: [PATCH 005/113] Revising for play audio behavior. --- .../BaseControllers/ViewController.swift | 12 ++-- MVMCoreUI/Behaviors/GetContactBehavior.swift | 5 +- MVMCoreUI/Behaviors/PlayAudioBehavior.swift | 61 +++++++++++-------- .../OtherHandlers/CoreUIModelMapping.swift | 1 + 4 files changed, 47 insertions(+), 32 deletions(-) diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 293bd49f..28fb37c5 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -475,10 +475,12 @@ import UIKit addFormParams(requestParameters) requestParameters.parentPageType = loadObject?.pageJSON?.optionalStringForKey("parentPageType") var pageForwardedData = additionalData ?? [:] + executeBehaviors { (behavior: PageLocalDataShareBehavior) in let dataMap = behavior.compileLocalPageDataForTransfer(delegateObjectIVar) - pageForwardedData.merge(dataMap) { (current, _) in current } + pageForwardedData.merge(dataMap) { current, _ in current } } + MVMCoreActionHandler.defaultHandleOpenPage(for: requestParameters, actionInformation: actionInformation, additionalData: pageForwardedData, delegateObject: delegateObject()) } @@ -486,14 +488,16 @@ import UIKit MVMCoreUILoggingHandler.shared()?.defaultLogAction(forController: self, actionInformation: actionInformation, additionalData: additionalData) } - open func handleUnknownActionType(_ actionType: String?, actionInformation: [AnyHashable : Any]?, additionalData: [AnyHashable : Any]?) { + open func handleUnknownActionType(_ actionType: String?, actionInformation: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) { var handled = false + executeBehaviors { (behavior: PageCustomActionHandlerBehavior) in - if (!handled) { + if !handled { handled = behavior.handleAction(type: actionType, information: actionInformation, additionalData: additionalData) } } - if (!handled) { + + if !handled { MVMCoreUIActionHandler.defaultHandleUnknownActionType(actionType, actionInformation: actionInformation, additionalData: additionalData, delegateObject: delegateObjectIVar) } } diff --git a/MVMCoreUI/Behaviors/GetContactBehavior.swift b/MVMCoreUI/Behaviors/GetContactBehavior.swift index 2c6205f2..d62e1ad0 100644 --- a/MVMCoreUI/Behaviors/GetContactBehavior.swift +++ b/MVMCoreUI/Behaviors/GetContactBehavior.swift @@ -9,6 +9,7 @@ import Foundation import Contacts + public protocol PageGetContactBehaviorConsumerProtocol { func getMatchParameters() -> (NSPredicate, [CNKeyDescriptor])? func consume(contacts: [CNContact]) @@ -18,7 +19,7 @@ public class PageGetContactBehaviorModel: PageBehaviorModelProtocol { public class var identifier: String { "pageGetContactBehavior" } public var shouldAllowMultipleInstances: Bool { false } - public init() {} + public init() { } } public class PageGetContactBehavior: PageVisibilityBehavior { @@ -51,5 +52,5 @@ public class PageGetContactBehavior: PageVisibilityBehavior { } } - public func onPageHidden(_ delegateObject: MVMCoreUIDelegateObject?) {} + public func onPageHidden(_ delegateObject: MVMCoreUIDelegateObject?) { } } diff --git a/MVMCoreUI/Behaviors/PlayAudioBehavior.swift b/MVMCoreUI/Behaviors/PlayAudioBehavior.swift index 9b1e1ba9..a9eebd55 100644 --- a/MVMCoreUI/Behaviors/PlayAudioBehavior.swift +++ b/MVMCoreUI/Behaviors/PlayAudioBehavior.swift @@ -8,8 +8,9 @@ public protocol PagePlayAudioBehaviorConsumerProtocol { -// func getMatchParameters() -> (NSPredicate, [CNKeyDescriptor])? -// func consume(contacts: [CNContact]) + func playPause() + func stop() + func isPlaying() } public class PagePlayAudioBehaviorModel: PageBehaviorModelProtocol { @@ -19,36 +20,44 @@ public class PagePlayAudioBehaviorModel: PageBehaviorModelProtocol { public init() { } } -public class PagePlayAudioBehavior: PageVisibilityBehavior { +public class PagePlayAudioBehavior: PageCustomActionHandlerBehavior { + //-------------------------------------------------- + // MARK: - Delegate + //-------------------------------------------------- + var delegate: MVMCoreUIDelegateObject? + //-------------------------------------------------- + // MARK: - Init + //-------------------------------------------------- + public required init(model: PageBehaviorModelProtocol, delegateObject: MVMCoreUIDelegateObject?) { self.delegate = delegateObject } - public func onPageShown(_ delegateObject: MVMCoreUIDelegateObject?) { - // Ask for permission -// CNContactStore().requestAccess(for: .contacts) { [weak self] (access, error) in -// guard access, -// error == nil, -// // TODO: Clean up this interface -// let model = (self?.delegate?.moleculeDelegate as? PageProtocol)?.pageModel as? TemplateModelProtocol else { return } -// // Iterate models and provide contact -// let store = CNContactStore() -// let consumers: [PagePlayAudioBehaviorConsumerProtocol] = model.allMoleculesOfType() -// for consumer in consumers { -// guard let parameters = consumer.getMatchParameters(), -// let contacts = try? store.unifiedContacts(matching: parameters.0, keysToFetch: parameters.1) else { return } -// consumer.consume(contacts: contacts) -// } -// -// // Tell template to update -// MVMCoreDispatchUtility.performBlock(onMainThread: { -// // TODO: move to protocol function instead -// (self?.delegate?.moleculeDelegate as? ViewController)?.handleNewData() -// }) -// } + //-------------------------------------------------- + // MARK: - Custom Action + //-------------------------------------------------- + + public func handleAction(type actionType: String?, information: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) -> Bool { + + let templateModel = (delegate?.moleculeDelegate as? PageProtocol)?.pageModel as? TemplateModelProtocol + + let consumers: [PagePlayAudioBehaviorConsumerProtocol] = templateModel!.allMoleculesOfType() + for consumer in consumers { + consumer.playPause() + } + + // Tell template to update. + MVMCoreDispatchUtility.performBlock(onMainThread: { [weak self] in + // TODO: move to protocol function instead + (self?.delegate?.moleculeDelegate as? ViewController)?.handleNewData() + }) + + return true } - public func onPageHidden(_ delegateObject: MVMCoreUIDelegateObject?) {} + public func onPageHidden(_ delegateObject: MVMCoreUIDelegateObject?) { + // TODO: Stop player + } } diff --git a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift index 45d1b0c4..c77bb77e 100644 --- a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift @@ -224,6 +224,7 @@ open class CoreUIModelMapping: ModelMapping { open class func registerBehaviors() { try? ModelRegistry.register(handler: ScreenBrightnessModifierBehavior.self, for: ScreenBrightnessModifierBehaviorModel.self) try? ModelRegistry.register(handler: PageGetContactBehavior.self, for: PageGetContactBehaviorModel.self) + try? ModelRegistry.register(handler: PagePlayAudioBehavior.self, for: PagePlayAudioBehaviorModel.self) } open override class func registerActions() { From 4fea0eb473a9541b2ea2853ceffa1279d73db912 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 15 Apr 2021 16:54:34 -0400 Subject: [PATCH 006/113] adding play audio action. current implementation. --- .../MoleculeTreeTraversalProtocol.swift | 1 - MVMCoreUI/Behaviors/PlayAudioBehavior.swift | 149 ++++++++++++++++-- 2 files changed, 139 insertions(+), 11 deletions(-) diff --git a/MVMCoreUI/Atomic/Protocols/MoleculeTreeTraversalProtocol.swift b/MVMCoreUI/Atomic/Protocols/MoleculeTreeTraversalProtocol.swift index 4e7efabb..abe4cdd7 100644 --- a/MVMCoreUI/Atomic/Protocols/MoleculeTreeTraversalProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/MoleculeTreeTraversalProtocol.swift @@ -50,5 +50,4 @@ extension MoleculeTreeTraversalProtocol { return accumulator } } - } diff --git a/MVMCoreUI/Behaviors/PlayAudioBehavior.swift b/MVMCoreUI/Behaviors/PlayAudioBehavior.swift index a9eebd55..76d7e64b 100644 --- a/MVMCoreUI/Behaviors/PlayAudioBehavior.swift +++ b/MVMCoreUI/Behaviors/PlayAudioBehavior.swift @@ -8,9 +8,11 @@ public protocol PagePlayAudioBehaviorConsumerProtocol { - func playPause() + func togglePlayPause() + func play() + func pause() func stop() - func isPlaying() + var isPlaying: Bool { get } } public class PagePlayAudioBehaviorModel: PageBehaviorModelProtocol { @@ -21,6 +23,12 @@ public class PagePlayAudioBehaviorModel: PageBehaviorModelProtocol { } public class PagePlayAudioBehavior: PageCustomActionHandlerBehavior { + //-------------------------------------------------- + // MARK: - Active Model + //-------------------------------------------------- + + public static var activeAudioPlayer: PagePlayAudioBehaviorConsumerProtocol? + //-------------------------------------------------- // MARK: - Delegate //-------------------------------------------------- @@ -39,20 +47,33 @@ public class PagePlayAudioBehavior: PageCustomActionHandlerBehavior { // MARK: - Custom Action //-------------------------------------------------- + // Either play or pause public func handleAction(type actionType: String?, information: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) -> Bool { - let templateModel = (delegate?.moleculeDelegate as? PageProtocol)?.pageModel as? TemplateModelProtocol + // TODO: Has to grab the specific model that is active (expanded). Identify model holder of this action. - let consumers: [PagePlayAudioBehaviorConsumerProtocol] = templateModel!.allMoleculesOfType() - for consumer in consumers { - consumer.playPause() - } + // TODO: Update the model. play -> pause OR pause -> play + + // TODO: Download binary + + // TODO: Store audio file in cache using some key (messageID???) to store it. + + // TODO: Actually pause/play + + // TODO: Tell Template to update this cell (needs to be built). Currently it updates all cells. + +// let templateModel = (delegate?.moleculeDelegate as? PageProtocol)?.pageModel as? TemplateModelProtocol + Self.activeAudioPlayer?.play() +// let consumers: [PagePlayAudioBehaviorConsumerProtocol] = templateModel!.allMoleculesOfType() +// for consumer in consumers { +// consumer.playPause() +// } // Tell template to update. - MVMCoreDispatchUtility.performBlock(onMainThread: { [weak self] in +// MVMCoreDispatchUtility.performBlock(onMainThread: { [weak self] in // TODO: move to protocol function instead - (self?.delegate?.moleculeDelegate as? ViewController)?.handleNewData() - }) +// (self?.delegate?.moleculeDelegate as? ViewController)?.handleNewData() +// }) return true } @@ -60,4 +81,112 @@ public class PagePlayAudioBehavior: PageCustomActionHandlerBehavior { public func onPageHidden(_ delegateObject: MVMCoreUIDelegateObject?) { // TODO: Stop player } + + //-------------------------------------------------- + // MARK: - Download Audio File + //-------------------------------------------------- +/* + // https://oneconfluence.verizon.com/pages/viewpage.action?spaceKey=EIM&title=FDV+API + + /// The directory to store all downloaded voicemails. + func voicemailDirectory() -> URL? { + + guard let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else { return nil } + return documentsURL.appendingPathComponent("fios_vm") + } + + func voicemailListQuery(accountId: String, sourceIP: String, mdn: String, mailBoxNo: String, timeZone: String) { + + let url = URL(string: "")! + var request = URLRequest(url: url) + request.httpMethod = "POST" + + let task = URLSession.shared.dataTask(with: request) { data, response, error in + // do something with the result + // print(data) +// if let data = data { + // TODO: Receive List of MDNs + // if let data = data, let dataString = String(data: data, encoding: .utf8) { + // print("Response data string:\n \(dataString)") + // } + // print(String(data: data, encoding: .utf8)) +// } else { + // print("no data") +// } + } + + task.resume() + + } + + func fetchVoicemail(accountId: String, sourceIP: String, mdn: String, mailBoxNo: String) { + +// guard let messageID = messageID else { return } + + let url = URL(string: "")! + var request = URLRequest(url: url) + request.httpMethod = "POST" + + let task = URLSession.shared.dataTask(with: request) { data, response, error in + // do something with the result + // print(data) +// if let data = data { + //body/VoiceMailMessages/Stream/TN/VMID/Audio/bin + // TODO: Receive List of MDNs + // if let data = data, let dataString = String(data: data, encoding: .utf8) { + // print("Response data string:\n \(dataString)") + // } + // print(String(data: data, encoding: .utf8)) +// } else { + // print("no data") +// } + } + + task.resume() + + // TODO: Fetch Audio file. + } + + func downloadVoicemail(url: URL?) { + + let downloadTask = URLSession.shared.downloadTask(with: url!) { [weak self] url, response, error in + guard error == nil, + let fileURL = url + else { return } + + do { + // "data/user/0/com.verizon.myfios/files/VM_INBOX-8711.wav" + let documentsURL = try FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false) + let savedURL = documentsURL.appendingPathComponent(fileURL.lastPathComponent) + try FileManager.default.moveItem(at: fileURL, to: savedURL) + self?.audioFilePath = savedURL + } catch let error as NSError { + MVMCoreLoggingHandler.logDebugMessage(withDelegate: error.debugDescription) + } + } + downloadTask.resume() + } + + func fetchAudioFilePath() { + + guard let messageID = messageID, // "INBOX-8711" + let cleanMDN = cleanMDN, // "4124712342" + let destinationURL = voicemailDirectory() + else { return } + + let uri = "com.verizon.fios.voice2/downloadvm?VM_DOWNLOAD_URI_DATA_MESSAGE_ID=\(messageID)&VM_DOWNLOAD_URI_DATA_TN=\(cleanMDN)" + let url = URL(string: uri) + + + // TODO: First check to see if the file is stored on disk, if not, then downloaded. + createDirectoryIfNeeded(url: destinationURL) + + if FileManager.default.fileExists(atPath: destinationURL.path) { + audioFilePath = destinationURL + + } else { + downloadVoicemail(url: url) + } + } + */ } From ac13ac60259d9e33e43c9bf5a07751de4e7a296e Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 19 Apr 2021 14:03:51 -0400 Subject: [PATCH 007/113] implementing a delegate pattern. --- MVMCoreUI/Behaviors/PlayAudioBehavior.swift | 59 ++++++++++++--------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/MVMCoreUI/Behaviors/PlayAudioBehavior.swift b/MVMCoreUI/Behaviors/PlayAudioBehavior.swift index 76d7e64b..572fac0b 100644 --- a/MVMCoreUI/Behaviors/PlayAudioBehavior.swift +++ b/MVMCoreUI/Behaviors/PlayAudioBehavior.swift @@ -13,6 +13,8 @@ public protocol PagePlayAudioBehaviorConsumerProtocol { func pause() func stop() var isPlaying: Bool { get } + var messageID: String? { get } + var audioFileURL: URL? { get set } } public class PagePlayAudioBehaviorModel: PageBehaviorModelProtocol { @@ -27,7 +29,7 @@ public class PagePlayAudioBehavior: PageCustomActionHandlerBehavior { // MARK: - Active Model //-------------------------------------------------- - public static var activeAudioPlayer: PagePlayAudioBehaviorConsumerProtocol? + public static var activeAudioPlayerDelegate: PagePlayAudioBehaviorConsumerProtocol? //-------------------------------------------------- // MARK: - Delegate @@ -50,31 +52,27 @@ public class PagePlayAudioBehavior: PageCustomActionHandlerBehavior { // Either play or pause public func handleAction(type actionType: String?, information: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) -> Bool { - // TODO: Has to grab the specific model that is active (expanded). Identify model holder of this action. - - // TODO: Update the model. play -> pause OR pause -> play - - // TODO: Download binary - - // TODO: Store audio file in cache using some key (messageID???) to store it. - - // TODO: Actually pause/play + // TODO: Impose Activity Indicator. + // Update the model. play -> pause OR pause -> play + if Self.activeAudioPlayerDelegate?.isPlaying ?? false { + Self.activeAudioPlayerDelegate?.pause() + + } else { + + // Download binary + downloadAudioFile { url in + + // TODO: Actually pause/play + Self.activeAudioPlayerDelegate?.audioFileURL = url + Self.activeAudioPlayerDelegate?.togglePlayPause() + + // TODO: Remove Activity Indicator. + } + } + // TODO: Tell Template to update this cell (needs to be built). Currently it updates all cells. - -// let templateModel = (delegate?.moleculeDelegate as? PageProtocol)?.pageModel as? TemplateModelProtocol - Self.activeAudioPlayer?.play() -// let consumers: [PagePlayAudioBehaviorConsumerProtocol] = templateModel!.allMoleculesOfType() -// for consumer in consumers { -// consumer.playPause() -// } - - // Tell template to update. -// MVMCoreDispatchUtility.performBlock(onMainThread: { [weak self] in - // TODO: move to protocol function instead -// (self?.delegate?.moleculeDelegate as? ViewController)?.handleNewData() -// }) - + return true } @@ -85,6 +83,19 @@ public class PagePlayAudioBehavior: PageCustomActionHandlerBehavior { //-------------------------------------------------- // MARK: - Download Audio File //-------------------------------------------------- + + func downloadAudioFile(_ completion: @escaping (URL) -> ()) { + + // TODO: Check cache. Return if available +// let audioData = MVMCoreCache.shared()?.getCachedData(withName: PagePlayAudioBehavior.activeAudioPlayerDelegate!.messageID!) + + guard let soundFileURL = Bundle.main.url(forResource: "sampleAudio", withExtension: "wav") else { return } + + // TODO: Store audio file in cache using some key (messageID???) to store it. +// MVMCoreCache.shared()?.addData(toCache: soundFileURL.dataRepresentation, withName: PagePlayAudioBehavior.activeAudioPlayerDelegate!.messageID!) + completion(soundFileURL) +// return soundFileURL + } /* // https://oneconfluence.verizon.com/pages/viewpage.action?spaceKey=EIM&title=FDV+API From 2dcf922dfd51dbb6f575552152428fb1ac4d3fa9 Mon Sep 17 00:00:00 2001 From: rajampetS Date: Mon, 17 May 2021 16:26:53 +0530 Subject: [PATCH 008/113] molecule changes --- MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift | 8 +++++++- .../Molecules/HorizontalCombinationViews/Tabs.swift | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift index 4a596a35..9af5b062 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift @@ -8,6 +8,10 @@ import Foundation +public protocol RadioBoxSelectionDelegate: class { + func selectedRadioBox(text: String) +} + open class RadioBoxes: View { public var collectionView: CollectionView! @@ -19,7 +23,7 @@ open class RadioBoxes: View { private var radioBoxesModel: RadioBoxesModel? { return model as? RadioBoxesModel } - + public var radioDelegate: RadioBoxSelectionDelegate? private var delegateObject: MVMCoreUIDelegateObject? /// The models for the molecules. @@ -161,6 +165,8 @@ extension RadioBoxes: UICollectionViewDelegate { cell.radioBox.selectBox() _ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate) cell.updateAccessibility() + guard let nu = boxes?[indexPath.row] else { return } + radioDelegate?.selectedRadioBox(text: nu.text) } open func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) { diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift index 1ddd9412..800fb7d1 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift @@ -13,7 +13,8 @@ import UIKit func didSelectItem(_ indexPath: IndexPath, tabs: Tabs) } -@objcMembers open class Tabs: View, MVMCoreUIViewConstrainingProtocol { +@objcMembers open class Tabs: View, MVMCoreUIViewConstrainingProtocol, MFButtonProtocol { + public var tabsModel: TabsModel? { get { return model as? TabsModel } @@ -81,9 +82,11 @@ import UIKit let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) collectionView.translatesAutoresizingMaskIntoConstraints = false collectionView.register(TabItemCell.self, forCellWithReuseIdentifier: TabCellId) + collectionView.isUserInteractionEnabled = true collectionView.backgroundColor = .clear collectionView.showsVerticalScrollIndicator = false collectionView.showsHorizontalScrollIndicator = false + collectionView.isScrollEnabled = true collectionView.dataSource = self collectionView.delegate = self addSubview(collectionView) @@ -120,6 +123,8 @@ import UIKit //bottom line bottomLine.topAnchor.constraint(equalTo: bottomScrollView.bottomAnchor).isActive = true; NSLayoutConstraint.constraintPinSubview(bottomLine, pinTop: false, pinBottom: true, pinLeft: true, pinRight: true) + + self.collectionView?.delegate = self } //------------------------------------------------- @@ -289,6 +294,7 @@ extension Tabs { public override func setupView() { super.setupView() contentView.addSubview(label) + contentView.isUserInteractionEnabled = true NSLayoutConstraint.constraintPinSubview(label, pinTop: false, topConstant: 0, pinBottom: true, bottomConstant: 6, pinLeft: true, leftConstant: 0, pinRight: true, rightConstant: 0) label.baselineAdjustment = .alignCenters } From 6c51d3ee6570ef0623dc4e84102110f6cc8d12d0 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Fri, 21 May 2021 16:37:23 +0530 Subject: [PATCH 009/113] Enabling downloading option for voicemails --- MVMCoreUI/Behaviors/PlayAudioBehavior.swift | 114 ++++++++++++++++++-- 1 file changed, 103 insertions(+), 11 deletions(-) diff --git a/MVMCoreUI/Behaviors/PlayAudioBehavior.swift b/MVMCoreUI/Behaviors/PlayAudioBehavior.swift index 572fac0b..4ba7aa9f 100644 --- a/MVMCoreUI/Behaviors/PlayAudioBehavior.swift +++ b/MVMCoreUI/Behaviors/PlayAudioBehavior.swift @@ -61,7 +61,7 @@ public class PagePlayAudioBehavior: PageCustomActionHandlerBehavior { } else { // Download binary - downloadAudioFile { url in + downloadAudioFile(information: information) { url in // TODO: Actually pause/play Self.activeAudioPlayerDelegate?.audioFileURL = url @@ -84,18 +84,110 @@ public class PagePlayAudioBehavior: PageCustomActionHandlerBehavior { // MARK: - Download Audio File //-------------------------------------------------- - func downloadAudioFile(_ completion: @escaping (URL) -> ()) { + func downloadAudioFile(information:[AnyHashable: Any]?,_ completion: @escaping (URL) -> ()) { + + guard let extraparams = information?["extraParameters"] as? [AnyHashable:Any] else {return} + guard let requestParams = MVMCoreRequestParameters.init(pageType: "getVoiceMailMessage", extraParameters: extraparams) else { return } - // TODO: Check cache. Return if available -// let audioData = MVMCoreCache.shared()?.getCachedData(withName: PagePlayAudioBehavior.activeAudioPlayerDelegate!.messageID!) - - guard let soundFileURL = Bundle.main.url(forResource: "sampleAudio", withExtension: "wav") else { return } - - // TODO: Store audio file in cache using some key (messageID???) to store it. -// MVMCoreCache.shared()?.addData(toCache: soundFileURL.dataRepresentation, withName: PagePlayAudioBehavior.activeAudioPlayerDelegate!.messageID!) - completion(soundFileURL) -// return soundFileURL + if let voicemailID = extraparams["messageID"] as? String, checkIfFileExists(voicemailID: voicemailID) { + let vmURL = self.constructVoicemailFilePathWithID(voicemailID: voicemailID) + completion(vmURL) + } else { + MVMCoreLoadHandler.sharedGlobal()?.sendRequest(requestParams, locationForError: "PlayAudioRequest", requestFinished: { response, error in + guard let voicemailJSON = response as? [String:AnyHashable] else { return } + guard let voicemail = voicemailJSON["bin"] as? String, let voicemailID = voicemailJSON["vmMessageId"] as? String else { return } + let audioURL = self.saveVoicemailToDocumentDirectory(voicemail: voicemail, voicemailID: voicemailID) + completion(audioURL) + }) + } } + + func checkIfFileExists(voicemailID:String) -> Bool { + var cachePath = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first + cachePath?.appendPathComponent("FiOS.FDV.Voicemails", isDirectory: false) + let fileName = cachePath?.appendingPathComponent("VM_\(voicemailID).wmv") + return FileManager.default.fileExists(atPath: fileName?.path ?? "") + } + + func constructVoicemailFilePathWithID(voicemailID:String) -> URL { + let voicemailUrl = URL(string: "fileNotFound")! + ///Setting Voicemail Path + var cachePath = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first + cachePath?.appendPathComponent("FiOS.FDV.Voicemails", isDirectory: false) + if let path = cachePath?.path, !FileManager.default.fileExists(atPath: path) { + do{ + try FileManager.default.createDirectory(atPath: path, withIntermediateDirectories: false, attributes: nil) + } catch let error as NSError { + MVMCoreLoggingHandler.logDebugMessage(withDelegate: error.debugDescription) + } + } + let fileName = cachePath?.appendingPathComponent("VM_\(voicemailID).wmv") + return fileName ?? voicemailUrl + } + + func saveVoicemailToDocumentDirectory(voicemail:String, voicemailID:String) -> URL { + let voicemailUrl = URL(string: "fileNotFound")! + let fileName = self.constructVoicemailFilePathWithID(voicemailID: voicemailID) + let voicemailData = Data(base64Encoded: voicemail) + do{ + try voicemailData?.write(to: fileName, options: .completeFileProtection) + return fileName + } catch let error as NSError { + MVMCoreLoggingHandler.logDebugMessage(withDelegate: error.debugDescription) + } + return voicemailUrl + } + +// func saveVoicemailToDocumentDirectory(voicemail:String) -> URL { +// let voicemailUrl = URL(string: "fileNotFound")! +// ///Setting Voicemail Path +// +// let cacheDirectory = NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true).first as NSString? +// +// if let cachePath = cacheDirectory?.appendingPathComponent("fdv.voicemails"), !FileManager.default.fileExists(atPath: cachePath) { +// do{ +// try FileManager.default.createDirectory(atPath: cachePath, withIntermediateDirectories: false, attributes: nil) +// } catch let error as NSError { +// MVMCoreLoggingHandler.logDebugMessage(withDelegate: error.debugDescription) +// } +// } +// let fileName = cacheDirectory?.appendingPathComponent("fdv.voicemails").appending("/VM_1.wmv") +//#warning("Pending task to check if we can protect the voicemail data") +// +// let voicemailData = Data(base64Encoded: voicemail) +// do{ +// if let _fileName = fileName, let fileUrl = URL(string: _fileName) { +// try voicemailData?.write(to: fileUrl, options: .completeFileProtection) +// return fileUrl +// } +// } catch let error as NSError { +// MVMCoreLoggingHandler.logDebugMessage(withDelegate: error.debugDescription) +// } +// return voicemailUrl +// } + + +// NSDictionary *completeProtection = [NSDictionary dictionaryWithObject:NSFileProtectionComplete forKey:NSFileProtectionKey]; +// [[NSFileManager defaultManager] setAttributes:completeProtection ofItemAtPath:appFile error:nil]; +// return ([data writeToFile:appFile atomically:YES]); + + +// func downloadVoicemail(url: URL?) { +// +// let downloadTask = URLSession.shared.downloadTask(with: url!) { url, response, error in +// guard error == nil, let fileURL = url else { return } +// do { +// let documentsURL = try FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false) +// let savedURL = documentsURL.appendingPathComponent(fileURL.lastPathComponent) +// try FileManager.default.moveItem(at: fileURL, to: savedURL) +// +// } catch let error as NSError { +// MVMCoreLoggingHandler.logDebugMessage(withDelegate: error.debugDescription) +// } +// } +// downloadTask.resume() +// } + /* // https://oneconfluence.verizon.com/pages/viewpage.action?spaceKey=EIM&title=FDV+API From 6842a08276e172d8694cd695cc8cfb7ebf574656 Mon Sep 17 00:00:00 2001 From: Sourabh Bhardwaj <> Date: Tue, 25 May 2021 23:09:03 +0530 Subject: [PATCH 010/113] Fixed back button not showing in call filter CXTDT-181208 --- MVMCoreUI/Behaviors/GetContactBehavior.swift | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Behaviors/GetContactBehavior.swift b/MVMCoreUI/Behaviors/GetContactBehavior.swift index 1bb27ac7..9b488e68 100644 --- a/MVMCoreUI/Behaviors/GetContactBehavior.swift +++ b/MVMCoreUI/Behaviors/GetContactBehavior.swift @@ -41,7 +41,20 @@ public class PageGetContactBehavior: PageVisibilityBehavior { // Tell template to update MVMCoreDispatchUtility.performBlock(onMainThread: { // TODO: move to protocol function instead - (self?.delegate?.moleculeDelegate as? ViewController)?.handleNewDataAndUpdateUI() + guard let controller = self?.delegate?.moleculeDelegate as? ViewController else { return } + controller.handleNewDataAndUpdateUI() + + if MVMCoreUIUtility.getCurrentVisibleController() == controller { + // Update navigation bar if showing. + controller.setNavigationBar() + controller.manager?.refreshNavigationUI() + } + + // Update splitview properties + if controller == MVMCoreUISplitViewController.main()?.getCurrentDetailViewController() { + MVMCoreUISplitViewController.main()?.setBottomProgressBarProgress(controller.bottomProgress() ?? 0) + controller.updateTabBar() + } }) } } From 2fd72f9ad08072f91825b2ee93f255ac93844f2a Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 2 Jun 2021 15:04:26 -0400 Subject: [PATCH 011/113] panel check --- .../SplitViewController/MVMCoreUISplitViewController.h | 3 +++ .../SplitViewController/MVMCoreUISplitViewController.m | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h index c48c9e8c..9c07374d 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h @@ -126,6 +126,9 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) { - (UIStatusBarStyle)getDefaultStatusBarStyle; - (nullable UIColor *)getDefaultStatusBarBackgroundColor; +/// Returns true if a panel is showing. +- (BOOL)isAPanelShowing; + #pragma mark - Main Subclassables // Can subclass to set threshold for when the drawers are permanently extended. Default is 1000 for the left panel and 2000 for both. diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index 7377701b..3b1de765 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -1029,6 +1029,10 @@ CGFloat const PanelAnimationDuration = 0.2; return nil; } +- (BOOL)isAPanelShowing { + return fabs(self.mainViewLeading.constant) > 1; +} + #pragma mark - Getters // Returns the desired view or falls back. Hot fix until we can get away from using these functions... From bba4cbfb66e0ad3bf7c4b41b4d0a43e309af16bd Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Sat, 5 Jun 2021 00:05:54 +0530 Subject: [PATCH 012/113] Option to set 'numberOfLines' for label from label's json. --- MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift | 4 ++++ .../Atomic/Atoms/Views/Label/LabelModel.swift | 15 +++++++++++++++ ...stLeftVariableIconWithRightCaretBodyText.swift | 3 +++ 3 files changed, 22 insertions(+) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index 026e9acf..09ed3386 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -315,6 +315,10 @@ public typealias ActionBlock = () -> () if let color = labelModel.textColor { textColor = color.uiColor } + + if let numberofLines = labelModel.numberOfLines { + numberOfLines = numberofLines + } if let attributes = labelModel.attributes, let labelText = text { let attributedString = NSMutableAttributedString(string: labelText, attributes: [NSAttributedString.Key.font: font.updateSize(standardFontSize), NSAttributedString.Key.foregroundColor: textColor as UIColor]) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift index fbbc9e03..8aa4c0d6 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift @@ -25,6 +25,7 @@ public var html: String? public var hero: Int? public var makeWholeViewClickable: Bool? + public var numberOfLines:Int? //-------------------------------------------------- // MARK: - Keys @@ -44,18 +45,30 @@ case html case hero case makeWholeViewClickable + case numberOfLines } enum AttributeTypeKey: String, CodingKey { case type } + //----------------------------------------------------- + // MARK: - Methods + //----------------------------------------------------- + + internal func setDefaults() { + if numberOfLines == nil { + numberOfLines = 1 + } + } + //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- public init(text: String) { self.text = text + setDefaults() } //-------------------------------------------------- @@ -76,6 +89,7 @@ html = try typeContainer.decodeIfPresent(String.self, forKey: .html) hero = try typeContainer.decodeIfPresent(Int.self, forKey: .hero) makeWholeViewClickable = try typeContainer.decodeIfPresent(Bool.self, forKey: .makeWholeViewClickable) + numberOfLines = try typeContainer.decodeIfPresent(Int.self, forKey: .numberOfLines) } public func encode(to encoder: Encoder) throws { @@ -93,5 +107,6 @@ try container.encodeIfPresent(html, forKey: .html) try container.encodeIfPresent(hero, forKey: .hero) try container.encodeIfPresent(makeWholeViewClickable, forKey: .makeWholeViewClickable) + try container.encodeIfPresent(numberOfLines, forKey: .numberOfLines) } } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift index b9e4a3e1..feb8694d 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift @@ -73,6 +73,9 @@ headlineBody.set(with: model.headlineBody, delegateObject, additionalData) rightLabel.set(with: model.rightLabel, delegateObject, additionalData) updateAccessibilityLabel() + if let numberOfLines = model.rightLabel.numberOfLines{ + rightLabel.numberOfLines = numberOfLines + } } open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { From 00dc4c2a477e5f009d0ae7596c3a8670426b0bf5 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 8 Jun 2021 15:18:47 -0400 Subject: [PATCH 013/113] need to check action type --- MVMCoreUI/Behaviors/PlayAudioBehavior.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/Behaviors/PlayAudioBehavior.swift b/MVMCoreUI/Behaviors/PlayAudioBehavior.swift index 4ba7aa9f..32dc9727 100644 --- a/MVMCoreUI/Behaviors/PlayAudioBehavior.swift +++ b/MVMCoreUI/Behaviors/PlayAudioBehavior.swift @@ -52,6 +52,7 @@ public class PagePlayAudioBehavior: PageCustomActionHandlerBehavior { // Either play or pause public func handleAction(type actionType: String?, information: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) -> Bool { + guard actionType == "playAudio" else { return false } // TODO: Impose Activity Indicator. // Update the model. play -> pause OR pause -> play From 921df032b29ae0649c3c6ecb831d5824aef343ec Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Wed, 9 Jun 2021 23:12:45 +0530 Subject: [PATCH 014/113] Changes as per review comments --- MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift | 5 +++-- .../Atomic/Atoms/Views/Label/LabelModel.swift | 15 ++------------- ...stLeftVariableIconWithRightCaretBodyText.swift | 4 ---- ...tVariableIconWithRightCaretBodyTextModel.swift | 3 +++ 4 files changed, 8 insertions(+), 19 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index 09ed3386..395ab923 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -316,8 +316,8 @@ public typealias ActionBlock = () -> () textColor = color.uiColor } - if let numberofLines = labelModel.numberOfLines { - numberOfLines = numberofLines + if let lines = labelModel.numberOfLines { + numberOfLines = lines } if let attributes = labelModel.attributes, let labelText = text { @@ -794,6 +794,7 @@ extension Label { accessibilityCustomActions = [] clauses = [] accessibilityTraits = .staticText + numberOfLines = 0 } public func needsToBeConstrained() -> Bool { true } diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift index 8aa4c0d6..5cc07fed 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift @@ -25,7 +25,7 @@ public var html: String? public var hero: Int? public var makeWholeViewClickable: Bool? - public var numberOfLines:Int? + public var numberOfLines: Int? //-------------------------------------------------- // MARK: - Keys @@ -51,24 +51,13 @@ enum AttributeTypeKey: String, CodingKey { case type } - - //----------------------------------------------------- - // MARK: - Methods - //----------------------------------------------------- - - internal func setDefaults() { - if numberOfLines == nil { - numberOfLines = 1 - } - } - + //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- public init(text: String) { self.text = text - setDefaults() } //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift index feb8694d..6174fc4b 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift @@ -55,7 +55,6 @@ leftImage.contentMode = .scaleAspectFit rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) - rightLabel.numberOfLines = 1 addMolecule(stack) stack.restack() } @@ -73,9 +72,6 @@ headlineBody.set(with: model.headlineBody, delegateObject, additionalData) rightLabel.set(with: model.rightLabel, delegateObject, additionalData) updateAccessibilityLabel() - if let numberOfLines = model.rightLabel.numberOfLines{ - rightLabel.numberOfLines = numberOfLines - } } open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift index 891f37f5..5076eb9e 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift @@ -29,6 +29,9 @@ public class ListLeftVariableIconWithRightCaretBodyTextModel: ListItemModel, Mol } headlineBody.style = .item headlineBody.headline?.hero = 0 + if rightLabel.numberOfLines == nil { + rightLabel.numberOfLines = 1 + } } //----------------------------------------------------- From 8d425862f5bbf56ee19473deb2f95299abc01393 Mon Sep 17 00:00:00 2001 From: rajampetS Date: Thu, 10 Jun 2021 11:43:01 +0530 Subject: [PATCH 015/113] editing the naming convention --- MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift index 7ca3056f..64b0644c 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift @@ -166,8 +166,8 @@ extension RadioBoxes: UICollectionViewDelegate { cell.radioBox.selectBox() _ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate) cell.updateAccessibility() - guard let nu = boxes?[indexPath.row] else { return } - radioDelegate?.selectedRadioBox(text: nu.text) + guard let radioB = boxes?[indexPath.row] else { return } + radioDelegate?.selectedRadioBox(text: radioB.text) } open func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) { From 1d556b65630b543148a4f6ab69dc212931e6721d Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 11 Jun 2021 10:31:03 -0400 Subject: [PATCH 016/113] manager changes to allow manager to handle navigation bar logic --- MVMCoreUI.xcodeproj/project.pbxproj | 4 - .../NavigationBarRefreshProtocol.swift | 34 --------- .../BaseControllers/ViewController.swift | 56 ++++---------- MVMCoreUI/Behaviors/GetContactBehavior.swift | 12 --- .../Containers/NavigationController.swift | 74 ++++++++++++++++++- .../MVMCoreUIDetailViewProtocol.h | 3 - ...MCoreUISplitViewController+Extension.swift | 32 +++++++- .../MVMCoreUISplitViewController.m | 17 ++--- MVMCoreUI/Utility/MVMCoreUIUtility.h | 3 + MVMCoreUI/Utility/MVMCoreUIUtility.m | 13 +++- 10 files changed, 136 insertions(+), 112 deletions(-) delete mode 100644 MVMCoreUI/Atomic/Protocols/NavigationBarRefreshProtocol.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index d48fa228..c9833c3f 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -323,7 +323,6 @@ D20C7009250BF99B0095B21C /* TopNotificationModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20C7008250BF99B0095B21C /* TopNotificationModel.swift */; }; D20C700B250BFDE40095B21C /* MVMCoreUITopAlertView+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20C700A250BFDE40095B21C /* MVMCoreUITopAlertView+Extension.swift */; }; D20F3B44252E00E4004B3F56 /* PageProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20F3B43252E00E4004B3F56 /* PageProtocol.swift */; }; - D20F3B5E252F9B5E004B3F56 /* NavigationBarRefreshProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20F3B5D252F9B5D004B3F56 /* NavigationBarRefreshProtocol.swift */; }; D20FB165241A5D75004AFC3A /* NavigationItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20FB164241A5D75004AFC3A /* NavigationItemModel.swift */; }; D213347723843825008E41B3 /* Line.swift in Sources */ = {isa = PBXBuildFile; fileRef = D213347623843825008E41B3 /* Line.swift */; }; D2169301251E51E7002A6324 /* SectionListTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2169300251E51E7002A6324 /* SectionListTemplate.swift */; }; @@ -887,7 +886,6 @@ D20C7008250BF99B0095B21C /* TopNotificationModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TopNotificationModel.swift; sourceTree = ""; }; D20C700A250BFDE40095B21C /* MVMCoreUITopAlertView+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUITopAlertView+Extension.swift"; sourceTree = ""; }; D20F3B43252E00E4004B3F56 /* PageProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageProtocol.swift; sourceTree = ""; }; - D20F3B5D252F9B5D004B3F56 /* NavigationBarRefreshProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationBarRefreshProtocol.swift; sourceTree = ""; }; D20FB164241A5D75004AFC3A /* NavigationItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationItemModel.swift; sourceTree = ""; }; D213347623843825008E41B3 /* Line.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Line.swift; sourceTree = ""; }; D2169300251E51E7002A6324 /* SectionListTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SectionListTemplate.swift; sourceTree = ""; }; @@ -2319,7 +2317,6 @@ D20F3B43252E00E4004B3F56 /* PageProtocol.swift */, 012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */, D28BA7442481652D00B75CB8 /* TabBarProtocol.swift */, - D20F3B5D252F9B5D004B3F56 /* NavigationBarRefreshProtocol.swift */, 011B58EE23A2AA850085F53C /* ModelProtocols */, ); path = Protocols; @@ -2754,7 +2751,6 @@ D22479942316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift in Sources */, D2B18B94236214AD00A9AEDC /* NavigationController.swift in Sources */, 0A9D09222433796500D2E6C0 /* CarouselIndicator.swift in Sources */, - D20F3B5E252F9B5E004B3F56 /* NavigationBarRefreshProtocol.swift in Sources */, D29E28DA23D21AFA00ACEA85 /* StringAndMoleculeModel.swift in Sources */, D260105D23D0BCD400764D80 /* Stack.swift in Sources */, 0A7EF85D23D8A95600B2AAD1 /* TextEntryFieldModel.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Protocols/NavigationBarRefreshProtocol.swift b/MVMCoreUI/Atomic/Protocols/NavigationBarRefreshProtocol.swift deleted file mode 100644 index 2d4002e3..00000000 --- a/MVMCoreUI/Atomic/Protocols/NavigationBarRefreshProtocol.swift +++ /dev/null @@ -1,34 +0,0 @@ -// -// NavigationBarRefreshProtocol.swift -// MVMCoreUI -// -// Created by Scott Pfeil on 10/8/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import Foundation - -/// A protocol to inform that we should refresh the navigation bar ui. -@objc public protocol NavigationBarRefreshProtocol { - @objc func refreshNavigationUI() -} - -extension UIViewController: NavigationBarRefreshProtocol { - - /// Convenience function to refresh the navigation bar ui. A separate function for others to use. - @objc public static func refreshNavigationUI(for viewController: UIViewController) { - guard let model = (viewController as? PageProtocol)?.pageModel?.navigationBar else { return } - if let navigationController = viewController.navigationController { - NavigationController.setNavigationItem(navigationController: navigationController, navigationItemModel: model, viewController: viewController) - MVMCoreUISplitViewController.setNavigationBarUI(for: viewController, navigationController: navigationController, navigationItemModel: model) - } - if let manager = ((viewController as? MVMCoreViewManagerViewControllerProtocol)?.manager as? NavigationBarRefreshProtocol) { - // Refresh the manager if possible. - manager.refreshNavigationUI() - } - } - - public func refreshNavigationUI() { - UIViewController.refreshNavigationUI(for: self) - } -} diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index cd67632f..f86061e5 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -114,17 +114,6 @@ import UIKit try parsePageJSON() MVMCoreDispatchUtility.performBlock(onMainThread: { self.handleNewDataAndUpdateUI() - - if MVMCoreUIUtility.getCurrentVisibleController() == self { - // Update navigation bar if showing. - self.setNavigationBar() - self.manager?.refreshNavigationUI() - } - // Update splitview properties - if self == MVMCoreUISplitViewController.main()?.getCurrentDetailViewController() { - MVMCoreUISplitViewController.main()?.setBottomProgressBarProgress(self.bottomProgress() ?? 0) - self.updateTabBar() - } }) } catch { if let coreError = MVMCoreErrorObject.createErrorObject(for: error, location: "updateJSON for pageType: \(String(describing: pageType))") { @@ -237,6 +226,11 @@ import UIKit /// Processes any new data. Called after the page is loaded the first time and on response updates for this page, open func handleNewData() { + if model?.navigationBar == nil { + let navigationItem = createDefaultLegacyNavigationModel() + model?.navigationBar = navigationItem + } + executeBehaviors { (behavior: PageMoleculeTransformationBehavior) in behavior.onPageNew(rootMolecules: getRootMolecules(), delegateObjectIVar) } @@ -250,8 +244,14 @@ import UIKit view.backgroundColor = backgroundColor.uiColor } - // Sets up the navigation item based on the data. - setNavigationItem() + // Update splitview properties + if self == MVMCoreUISplitViewController.main()?.getCurrentDetailViewController() { + MVMCoreUISplitViewController.main()?.setBottomProgressBarProgress(bottomProgress() ?? 0) + updateTabBar() + } + + // Notify the manager of new data + manager?.newDataReceived?(in: self) } //-------------------------------------------------- @@ -267,28 +267,6 @@ import UIKit return model?.navigationBar } - /// Sets the navigation item for this view controller. - open func setNavigationItem() { - guard let navigationItemModel = getNavigationModel(), - let navigationController = navigationController - else { return } - - // Utilize helper function to set the navigation item state. - NavigationController.setNavigationItem(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: self) - } - - /// Sets the appearance of the navigation bar based on the model. - open func setNavigationBar() { - guard let navigationItemModel = getNavigationModel(), - let navigationController = navigationController else { - MVMCoreUISession.sharedGlobal()?.splitViewController?.parent?.setNeedsStatusBarAppearanceUpdate() - return - } - - // Utilize helper function to set the split view and navigation item state. - MVMCoreUISplitViewController.setNavigationBarUI(for: self, navigationController: navigationController, navigationItemModel: navigationItemModel) - } - //-------------------------------------------------- // MARK: - TabBar //-------------------------------------------------- @@ -378,9 +356,6 @@ import UIKit updateTabBar() } - // Update the navigation bar ui when view is appearing. - setNavigationBar() - // Track. MVMCoreUISession.sharedGlobal()?.currentPageType = pageType MVMCoreUILoggingHandler.shared()?.defaultLogPageState(forController: self) @@ -536,11 +511,6 @@ import UIKit // MARK: - MVMCoreUIDetailViewProtocol //-------------------------------------------------- - // Reset the navigation state. - public func splitViewDidReset() { - setNavigationBar() - } - public func isLeftPanelAccessible() -> Bool { // TODO: Remove when hamburger menu is fully phased out. if loadObject?.pageJSON?.boolForKey(KeyHideMainMenu) ?? false { diff --git a/MVMCoreUI/Behaviors/GetContactBehavior.swift b/MVMCoreUI/Behaviors/GetContactBehavior.swift index 9b488e68..c69bdbce 100644 --- a/MVMCoreUI/Behaviors/GetContactBehavior.swift +++ b/MVMCoreUI/Behaviors/GetContactBehavior.swift @@ -43,18 +43,6 @@ public class PageGetContactBehavior: PageVisibilityBehavior { // TODO: move to protocol function instead guard let controller = self?.delegate?.moleculeDelegate as? ViewController else { return } controller.handleNewDataAndUpdateUI() - - if MVMCoreUIUtility.getCurrentVisibleController() == controller { - // Update navigation bar if showing. - controller.setNavigationBar() - controller.manager?.refreshNavigationUI() - } - - // Update splitview properties - if controller == MVMCoreUISplitViewController.main()?.getCurrentDetailViewController() { - MVMCoreUISplitViewController.main()?.setBottomProgressBarProgress(controller.bottomProgress() ?? 0) - controller.updateTabBar() - } }) } } diff --git a/MVMCoreUI/Containers/NavigationController.swift b/MVMCoreUI/Containers/NavigationController.swift index 331656b7..bcbf927e 100644 --- a/MVMCoreUI/Containers/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController.swift @@ -8,8 +8,9 @@ import UIKit -@objcMembers open class NavigationController: UINavigationController { +@objcMembers open class NavigationController: UINavigationController, MVMCoreViewManagerViewControllerProtocol { public var separatorView: Line? + public var manager: (UIViewController & MVMCoreViewManagerProtocol)? /// Getter for the main navigation controller public static func navigationController() -> Self? { @@ -33,6 +34,7 @@ import UIKit MVMCoreUISession.sharedGlobal()?.navigationController = navigationController MVMCoreNavigationHandler.shared()?.viewControllerToPresentOn = navigationController MVMCoreNavigationHandler.shared()?.navigationController = navigationController + MVMCoreNavigationHandler.shared()?.addDelegate(navigationController) return navigationController } @@ -103,4 +105,74 @@ import UIKit viewController.navigationItem.titleView = molecule } } + + /// Convenience function to return the navigation model of the lowest controller traversing managers + public static func getNavigationModel(from viewController: UIViewController) -> NavigationItemModelProtocol? { + let controller = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController) + guard let model = (controller as? PageProtocol)?.pageModel?.navigationBar else { return nil } + return model + } +} + +extension NavigationController: MVMCoreViewManagerProtocol { + // TODO: change this to optional + public func getCurrentViewController() -> UIViewController { + return topViewController! + } + + public func containsPage(withPageType pageType: String?) -> Bool { + for case let controller as MVMCoreViewControllerProtocol in viewControllers { + if controller.pageType == pageType { + return true + } + } + return false + } + + public func newDataReceived(in viewController: UIViewController) { + if viewController == topViewController, + let model = Self.getNavigationModel(from: viewController) { + Self.setNavigationItem(navigationController: self, navigationItemModel: model, viewController: viewController) + Self.setNavigationBarUI(navigationController: self, navigationItemModel: model, viewController: viewController) + } + manager?.newDataReceived?(in: viewController) + } + + public func willDisplay(_ viewController: UIViewController) { + guard let topViewController = topViewController else { return } + if let model = Self.getNavigationModel(from: viewController) { + Self.setNavigationItem(navigationController: self, navigationItemModel: model, viewController: topViewController) + } + manager?.willDisplay?(viewController) + } + + public func displayedViewController(_ viewController: UIViewController) { + guard let topViewController = topViewController else { return } + if let model = Self.getNavigationModel(from: viewController) { + Self.setNavigationBarUI(navigationController: self, navigationItemModel: model, viewController: topViewController) + } + manager?.displayedViewController?(viewController) + } +} + +extension NavigationController: MVMCorePresentationDelegateProtocol { + public func navigationController(_ navigationController: UINavigationController, willDisplay viewController: UIViewController) { + guard self == navigationController else { return } + if let controller = viewController as? (UIViewController & MVMCoreViewManagerViewControllerProtocol) { + MVMCoreViewManagerViewControllerProtocolHelper.helpSetManager(self, viewController: controller) + controller.viewControllerReady?(inManager: self) + } + if let model = Self.getNavigationModel(from: viewController) { + Self.setNavigationItem(navigationController: self, navigationItemModel: model, viewController: viewController) + } + manager?.willDisplay?(viewController) + } + + public func navigationController(_ navigationController: UINavigationController, displayedViewController viewController: UIViewController) { + guard self == navigationController else { return } + if let model = Self.getNavigationModel(from: viewController) { + Self.setNavigationBarUI(navigationController: self, navigationItemModel: model, viewController: viewController) + } + manager?.displayedViewController?(viewController) + } } diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h b/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h index 60ce0873..bd81fec5 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h @@ -48,9 +48,6 @@ NS_ASSUME_NONNULL_BEGIN - (UIStatusBarStyle)defaultStatusBarStyle; - (nullable UIColor *)defaultStatusBarBackgroundColor; -/// Called when the split view did reset. If this function found, the splitview assumes it is handling the split view state and does not do anything. If you have navigation item buttons, override this function and handle the panels manually. -- (void)splitViewDidReset; - @end NS_ASSUME_NONNULL_END diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift index eb22eccb..835a2df9 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift @@ -24,7 +24,6 @@ public extension MVMCoreUISplitViewController { /// Sets the navigation item for the view controller based on the model and splitview controller private func set(for viewController: UIViewController, navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol) { - NavigationController.setNavigationBarUI(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController) setLeftPanelIsAccessible((viewController as? MVMCoreUIDetailViewProtocol)?.isLeftPanelAccessible?() ?? false, for: viewController, updateNavigationButtons: false) setRightPanelIsAccessible((viewController as? MVMCoreUIDetailViewProtocol)?.isRightPanelAccessible?() ?? false, for: viewController, updateNavigationButtons: false) @@ -104,4 +103,35 @@ public extension MVMCoreUISplitViewController { viewController.navigationItem.setRightBarButtonItems(rightItems.count > 0 ? rightItems : nil, animated: !DisableAnimations.boolValue) } + + @objc func navigationBarModelExists() -> Bool { + // Legacy Navigation + (navigationController?.topViewController as? PageProtocol)?.pageModel?.navigationBar != nil + } + + /// Convenience function to update the navigation + @objc func updateNavigationBarFor(viewController: UIViewController) { + guard viewController == getCurrentDetailViewController(), + let navigationController = navigationController, + let model = NavigationController.getNavigationModel(from: viewController) else { return } + set(for: viewController, navigationController: navigationController, navigationItemModel: model) + } +} + +extension MVMCoreUISplitViewController: MVMCoreViewManagerProtocol { + public func getCurrentViewController() -> UIViewController { + navigationController!.getCurrentViewController() + } + + public func containsPage(withPageType pageType: String?) -> Bool { + navigationController!.containsPage(withPageType: pageType) + } + + public func displayedViewController(_ viewController: UIViewController) { + updateNavigationBarFor(viewController: viewController) + } + + public func newDataReceived(in viewController: UIViewController) { + updateNavigationBarFor(viewController: viewController) + } } diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index 3b1de765..ab44e181 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -857,6 +857,7 @@ CGFloat const PanelAnimationDuration = 0.2; // The main view. NavigationController *navigationController = [NavigationController setupNavigationController]; + navigationController.manager = self; self.navigationController = navigationController; UIView *mainView = navigationController.view; @@ -988,9 +989,11 @@ CGFloat const PanelAnimationDuration = 0.2; } - (void)resetDrawers { - if ([self.navigationItemViewController respondsToSelector:@selector(splitViewDidReset)]) { - [((UIViewController *)self.navigationItemViewController) splitViewDidReset]; + if (!self.navigationItemViewController) { return; } + if ([self navigationBarModelExists]) { + [self updateNavigationBarForViewController:self.navigationItemViewController]; } else { + // Legacy [self setLeftPanelIsAccessible:self.leftPanelIsAccessible forViewController:self.navigationItemViewController updateNavigationButtons:YES]; [self setRightPanelIsAccessible:self.rightPanelIsAccessible forViewController:self.navigationItemViewController updateNavigationButtons:YES]; @@ -1066,10 +1069,7 @@ CGFloat const PanelAnimationDuration = 0.2; } // if it is not presented viewcontroller, existing BAU logic will be working if (!viewController) { - viewController = self.navigationController.topViewController; - if ([viewController conformsToProtocol:@protocol(MVMCoreViewManagerProtocol)]) { - viewController = [viewController performSelector:@selector(getCurrentViewController)]; - } + viewController = [MVMCoreUIUtility getViewControllerTraversingManagers:self.navigationController.topViewController]; } return viewController; } @@ -1077,10 +1077,7 @@ CGFloat const PanelAnimationDuration = 0.2; - (UIViewController *)getCurrentDetailViewController { __block UIViewController *viewController = nil; [MVMCoreDispatchUtility performSyncBlockOnMainThread:^{ - viewController = self.navigationController.topViewController; - if ([viewController conformsToProtocol:@protocol(MVMCoreViewManagerProtocol)]) { - viewController = [viewController performSelector:@selector(getCurrentViewController)]; - } + viewController = [MVMCoreUIUtility getViewControllerTraversingManagers:self.navigationController.topViewController]; }]; return viewController; } diff --git a/MVMCoreUI/Utility/MVMCoreUIUtility.h b/MVMCoreUI/Utility/MVMCoreUIUtility.h index 6852e936..171ebeea 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility.h +++ b/MVMCoreUI/Utility/MVMCoreUIUtility.h @@ -34,6 +34,9 @@ NS_ASSUME_NONNULL_BEGIN /// Gets the current visible view controller. Checks presented view controllers first, and then it checks on the NavigationController in the session object. + (UIViewController *)getCurrentVisibleController; +/// Gets the first non manager controller. ++ (UIViewController *)getViewControllerTraversingManagers:(UIViewController *)viewController; + /// Checks if the view or any descendents of the view is currently focused for voice over. + (BOOL)viewContainsAccessiblityFocus:(nonnull UIView *)view; diff --git a/MVMCoreUI/Utility/MVMCoreUIUtility.m b/MVMCoreUI/Utility/MVMCoreUIUtility.m index dd059fed..01f576c5 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility.m +++ b/MVMCoreUI/Utility/MVMCoreUIUtility.m @@ -63,14 +63,19 @@ } // if it is not presented viewcontroller, existing BAU logic will be working if (!viewController) { - viewController = [MVMCoreUISession sharedGlobal].navigationController.topViewController; - if ([viewController conformsToProtocol:@protocol(MVMCoreViewManagerProtocol)]) { - viewController = [viewController performSelector:@selector(getCurrentViewController)]; - } + viewController = [self getViewControllerTraversingManagers:[MVMCoreUISession sharedGlobal].navigationController.topViewController]; } return viewController; } ++ (UIViewController *)getViewControllerTraversingManagers:(UIViewController *)viewController { + UIViewController *controller = viewController; + while ([controller conformsToProtocol:@protocol(MVMCoreViewManagerProtocol)]) { + controller = [controller performSelector:@selector(getCurrentViewController)]; + } + return controller; +} + + (BOOL)viewContainsAccessiblityFocus:(nonnull UIView *)view { if (!UIAccessibilityIsVoiceOverRunning()) { return NO; From 48d427ec4edd2ce84db768a208086fd1f08d3e67 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 11 Jun 2021 11:04:47 -0400 Subject: [PATCH 017/113] Managers handle navigation bar nullable --- MVMCoreUI/Containers/NavigationController.swift | 8 ++++---- .../MVMCoreUISplitViewController+Extension.swift | 4 ++-- MVMCoreUI/Utility/MVMCoreUIUtility.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/MVMCoreUI/Containers/NavigationController.swift b/MVMCoreUI/Containers/NavigationController.swift index bcbf927e..6176427f 100644 --- a/MVMCoreUI/Containers/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController.swift @@ -108,16 +108,16 @@ import UIKit /// Convenience function to return the navigation model of the lowest controller traversing managers public static func getNavigationModel(from viewController: UIViewController) -> NavigationItemModelProtocol? { - let controller = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController) - guard let model = (controller as? PageProtocol)?.pageModel?.navigationBar else { return nil } + guard let controller = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController), + let model = (controller as? PageProtocol)?.pageModel?.navigationBar else { return nil } return model } } extension NavigationController: MVMCoreViewManagerProtocol { // TODO: change this to optional - public func getCurrentViewController() -> UIViewController { - return topViewController! + public func getCurrentViewController() -> UIViewController? { + return topViewController } public func containsPage(withPageType pageType: String?) -> Bool { diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift index 835a2df9..a62a3788 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift @@ -119,8 +119,8 @@ public extension MVMCoreUISplitViewController { } extension MVMCoreUISplitViewController: MVMCoreViewManagerProtocol { - public func getCurrentViewController() -> UIViewController { - navigationController!.getCurrentViewController() + public func getCurrentViewController() -> UIViewController? { + navigationController?.getCurrentViewController() } public func containsPage(withPageType pageType: String?) -> Bool { diff --git a/MVMCoreUI/Utility/MVMCoreUIUtility.h b/MVMCoreUI/Utility/MVMCoreUIUtility.h index 171ebeea..c6959723 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility.h +++ b/MVMCoreUI/Utility/MVMCoreUIUtility.h @@ -32,10 +32,10 @@ NS_ASSUME_NONNULL_BEGIN + (UIEdgeInsets)getMarginsForView:(nullable UIView *)view; /// Gets the current visible view controller. Checks presented view controllers first, and then it checks on the NavigationController in the session object. -+ (UIViewController *)getCurrentVisibleController; ++ (nullable UIViewController *)getCurrentVisibleController; /// Gets the first non manager controller. -+ (UIViewController *)getViewControllerTraversingManagers:(UIViewController *)viewController; ++ (nullable UIViewController *)getViewControllerTraversingManagers:(UIViewController *)viewController; /// Checks if the view or any descendents of the view is currently focused for voice over. + (BOOL)viewContainsAccessiblityFocus:(nonnull UIView *)view; From f32aff549a7cb22b263ab70d5143f6da1fdf2ba7 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 11 Jun 2021 11:47:59 -0400 Subject: [PATCH 018/113] comment --- .../MVMCoreUISplitViewController+Extension.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift index a62a3788..fcd4e821 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift @@ -8,6 +8,7 @@ import Foundation +// Navigation bar update functions public extension MVMCoreUISplitViewController { /// Convenience function. Sets the navigation and split view properties for the view controller. Panel access is determined if view controller is a detail view protocol. From 080c1c192fc770094b44a66459cce0d77d79f85f Mon Sep 17 00:00:00 2001 From: rajampetS Date: Thu, 17 Jun 2021 10:27:54 +0530 Subject: [PATCH 019/113] fixed as per kevin's comments(NBD Ar) --- MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift | 4 ++-- MVMCoreUI/Atomic/Templates/TemplateModel.swift | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift index 64b0644c..5d9136f4 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift @@ -166,8 +166,8 @@ extension RadioBoxes: UICollectionViewDelegate { cell.radioBox.selectBox() _ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate) cell.updateAccessibility() - guard let radioB = boxes?[indexPath.row] else { return } - radioDelegate?.selectedRadioBox(text: radioB.text) + guard let radioBox = boxes?[indexPath.row] else { return } + radioDelegate?.selectedRadioBox(text: radioBox.text) } open func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) { diff --git a/MVMCoreUI/Atomic/Templates/TemplateModel.swift b/MVMCoreUI/Atomic/Templates/TemplateModel.swift index 5557d0f8..94a2476e 100644 --- a/MVMCoreUI/Atomic/Templates/TemplateModel.swift +++ b/MVMCoreUI/Atomic/Templates/TemplateModel.swift @@ -13,9 +13,7 @@ import Foundation //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - open class var identifier: String { - return "" - } + open class var identifier: String { "" } public var pageType: String From 97ecf292ddac6c52ea86839a38fea9c98c1e083b Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 17 Jun 2021 10:00:36 -0400 Subject: [PATCH 020/113] added new behaviors for select all boxes. --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++ .../Behaviors/SelectAllBoxesBehavior.swift | 60 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 6b5b0a14..5eedcf5b 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -108,6 +108,7 @@ 0A9D09222433796500D2E6C0 /* CarouselIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A9D091C2433796500D2E6C0 /* CarouselIndicator.swift */; }; 0AA33B3A2398524F0067DD0F /* Toggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B392398524F0067DD0F /* Toggle.swift */; }; 0AA4D2E125CAEC72008DB32D /* AccessibilityModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA4D2E025CAEC72008DB32D /* AccessibilityModelProtocol.swift */; }; + 0AAB7855267B86F900DD6437 /* SelectAllBoxesBehavior.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AAB7854267B86F900DD6437 /* SelectAllBoxesBehavior.swift */; }; 0AB000BA24BF63490090C5E7 /* ModalListPageTemplateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AB000B924BF63490090C5E7 /* ModalListPageTemplateModel.swift */; }; 0AB000BC24BF64A50090C5E7 /* ModalStackPageTemplateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AB000BB24BF64A50090C5E7 /* ModalStackPageTemplateModel.swift */; }; 0AB764D124460F6300E7FE72 /* UIDatePicker+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AB764D024460F6300E7FE72 /* UIDatePicker+Extension.swift */; }; @@ -674,6 +675,7 @@ 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Extension.swift"; sourceTree = ""; }; 0AA33B392398524F0067DD0F /* Toggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Toggle.swift; sourceTree = ""; }; 0AA4D2E025CAEC72008DB32D /* AccessibilityModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccessibilityModelProtocol.swift; sourceTree = ""; }; + 0AAB7854267B86F900DD6437 /* SelectAllBoxesBehavior.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectAllBoxesBehavior.swift; sourceTree = ""; }; 0AB000B924BF63490090C5E7 /* ModalListPageTemplateModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalListPageTemplateModel.swift; sourceTree = ""; }; 0AB000BB24BF64A50090C5E7 /* ModalStackPageTemplateModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalStackPageTemplateModel.swift; sourceTree = ""; }; 0AB764D024460F6300E7FE72 /* UIDatePicker+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIDatePicker+Extension.swift"; sourceTree = ""; }; @@ -1316,6 +1318,7 @@ 27F97369246750BE00CAB5C5 /* ScreenBrightnessModifierBehavior.swift */, D23A900826125FFB007E14CE /* GetContactBehavior.swift */, 0A01DE262626236300C2CAAC /* PlayAudioBehavior.swift */, + 0AAB7854267B86F900DD6437 /* SelectAllBoxesBehavior.swift */, ); path = Behaviors; sourceTree = ""; @@ -2718,6 +2721,7 @@ 011D959B240451E3000E3791 /* RuleRequiredModel.swift in Sources */, 526A265C240D1FF700B0D828 /* ListTwoColumnCompareChangesModel.swift in Sources */, D2A92886241ACD99004E01C6 /* ProgrammaticTableViewController.swift in Sources */, + 0AAB7855267B86F900DD6437 /* SelectAllBoxesBehavior.swift in Sources */, BBAA4F05243D8E3B005AAD5F /* RadioBoxesModel.swift in Sources */, 01509D952327ED1900EF99AA /* HeadlineBodyLinkToggle.swift in Sources */, AA104ADA244734DB004D2810 /* HeadersH1LandingPageHeader.swift in Sources */, diff --git a/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift b/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift new file mode 100644 index 00000000..70e5fdf0 --- /dev/null +++ b/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift @@ -0,0 +1,60 @@ +// +// SelectAllBoxesBehavior.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 6/17/21. +// Copyright © 2021 Verizon Wireless. All rights reserved. +// + + +public class SelectAllBoxesBehaviorModel: PageBehaviorModelProtocol { + public class var identifier: String { "selectAllBoxesBehavior" } + public var shouldAllowMultipleInstances: Bool { false } + + public init() { } +} + +public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior { + //-------------------------------------------------- + // MARK: - Active Model + //-------------------------------------------------- + + //-------------------------------------------------- + // MARK: - Delegate + //-------------------------------------------------- + + var delegate: MVMCoreUIDelegateObject? + + //-------------------------------------------------- + // MARK: - Init + //-------------------------------------------------- + + public required init(model: PageBehaviorModelProtocol, delegateObject: MVMCoreUIDelegateObject?) { + self.delegate = delegateObject + } + + //-------------------------------------------------- + // MARK: - Custom Action + //-------------------------------------------------- + + // Either play or pause + public func handleAction(type actionType: String?, information: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) -> Bool { + + guard actionType == "selectAllBoxes" else { return false } + + // Update the model. play -> pause OR pause -> play + if true { + + } else { + + } + + // TODO: Tell Template to update this cell (needs to be built). Currently it updates all cells. + + return true + } + + public func onPageHidden(_ delegateObject: MVMCoreUIDelegateObject?) { + // TODO: Stop player + } +} From 975f3fa012a0e47652ce8982993968c75140dc4a Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 17 Jun 2021 16:54:25 -0400 Subject: [PATCH 021/113] select all behavior. --- .../Behaviors/SelectAllBoxesBehavior.swift | 29 ++++++++++++------- .../OtherHandlers/CoreUIModelMapping.swift | 1 + 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift b/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift index 70e5fdf0..66720d1e 100644 --- a/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift +++ b/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift @@ -10,10 +10,10 @@ public class SelectAllBoxesBehaviorModel: PageBehaviorModelProtocol { public class var identifier: String { "selectAllBoxesBehavior" } public var shouldAllowMultipleInstances: Bool { false } - public init() { } } + public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior { //-------------------------------------------------- // MARK: - Active Model @@ -42,19 +42,26 @@ public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior { guard actionType == "selectAllBoxes" else { return false } - // Update the model. play -> pause OR pause -> play - if true { - - } else { - - } - - // TODO: Tell Template to update this cell (needs to be built). Currently it updates all cells. + let currentVC = MVMCoreUIUtility.getCurrentVisibleController() + + + traverseAndSelectCheckboxes(view: currentVC.view) + + // TODO: A) select all boxes and the change the nav button title to "deselect all" + // TODO: B) deselect all boxes and change nav nutton title to "select all" return true } - public func onPageHidden(_ delegateObject: MVMCoreUIDelegateObject?) { - // TODO: Stop player + private func traverseAndSelectCheckboxes(view: UIView) { + + if let checkbox = view as? Checkbox { + checkbox.isSelected = true + return + } + + for subview in view.subviews { + traverseAndSelectCheckboxes(view: subview) + } } } diff --git a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift index c77bb77e..437b2e01 100644 --- a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift @@ -225,6 +225,7 @@ open class CoreUIModelMapping: ModelMapping { try? ModelRegistry.register(handler: ScreenBrightnessModifierBehavior.self, for: ScreenBrightnessModifierBehaviorModel.self) try? ModelRegistry.register(handler: PageGetContactBehavior.self, for: PageGetContactBehaviorModel.self) try? ModelRegistry.register(handler: PagePlayAudioBehavior.self, for: PagePlayAudioBehaviorModel.self) + try? ModelRegistry.register(handler: SelectAllBoxesBehavior.self, for: SelectAllBoxesBehaviorModel.self) } open override class func registerActions() { From b318474da1faca7ebda3cc7291fcfa1bb1a84876 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Mon, 21 Jun 2021 22:33:39 +0530 Subject: [PATCH 022/113] Moving Downloading Audio file logic to view from Behaviour --- MVMCoreUI/Behaviors/PlayAudioBehavior.swift | 68 +-------------------- 1 file changed, 1 insertion(+), 67 deletions(-) diff --git a/MVMCoreUI/Behaviors/PlayAudioBehavior.swift b/MVMCoreUI/Behaviors/PlayAudioBehavior.swift index 32dc9727..7ea37809 100644 --- a/MVMCoreUI/Behaviors/PlayAudioBehavior.swift +++ b/MVMCoreUI/Behaviors/PlayAudioBehavior.swift @@ -60,16 +60,7 @@ public class PagePlayAudioBehavior: PageCustomActionHandlerBehavior { Self.activeAudioPlayerDelegate?.pause() } else { - - // Download binary - downloadAudioFile(information: information) { url in - - // TODO: Actually pause/play - Self.activeAudioPlayerDelegate?.audioFileURL = url - Self.activeAudioPlayerDelegate?.togglePlayPause() - - // TODO: Remove Activity Indicator. - } + Self.activeAudioPlayerDelegate?.play() } // TODO: Tell Template to update this cell (needs to be built). Currently it updates all cells. @@ -81,63 +72,6 @@ public class PagePlayAudioBehavior: PageCustomActionHandlerBehavior { // TODO: Stop player } - //-------------------------------------------------- - // MARK: - Download Audio File - //-------------------------------------------------- - - func downloadAudioFile(information:[AnyHashable: Any]?,_ completion: @escaping (URL) -> ()) { - - guard let extraparams = information?["extraParameters"] as? [AnyHashable:Any] else {return} - guard let requestParams = MVMCoreRequestParameters.init(pageType: "getVoiceMailMessage", extraParameters: extraparams) else { return } - - if let voicemailID = extraparams["messageID"] as? String, checkIfFileExists(voicemailID: voicemailID) { - let vmURL = self.constructVoicemailFilePathWithID(voicemailID: voicemailID) - completion(vmURL) - } else { - MVMCoreLoadHandler.sharedGlobal()?.sendRequest(requestParams, locationForError: "PlayAudioRequest", requestFinished: { response, error in - guard let voicemailJSON = response as? [String:AnyHashable] else { return } - guard let voicemail = voicemailJSON["bin"] as? String, let voicemailID = voicemailJSON["vmMessageId"] as? String else { return } - let audioURL = self.saveVoicemailToDocumentDirectory(voicemail: voicemail, voicemailID: voicemailID) - completion(audioURL) - }) - } - } - - func checkIfFileExists(voicemailID:String) -> Bool { - var cachePath = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first - cachePath?.appendPathComponent("FiOS.FDV.Voicemails", isDirectory: false) - let fileName = cachePath?.appendingPathComponent("VM_\(voicemailID).wmv") - return FileManager.default.fileExists(atPath: fileName?.path ?? "") - } - - func constructVoicemailFilePathWithID(voicemailID:String) -> URL { - let voicemailUrl = URL(string: "fileNotFound")! - ///Setting Voicemail Path - var cachePath = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first - cachePath?.appendPathComponent("FiOS.FDV.Voicemails", isDirectory: false) - if let path = cachePath?.path, !FileManager.default.fileExists(atPath: path) { - do{ - try FileManager.default.createDirectory(atPath: path, withIntermediateDirectories: false, attributes: nil) - } catch let error as NSError { - MVMCoreLoggingHandler.logDebugMessage(withDelegate: error.debugDescription) - } - } - let fileName = cachePath?.appendingPathComponent("VM_\(voicemailID).wmv") - return fileName ?? voicemailUrl - } - - func saveVoicemailToDocumentDirectory(voicemail:String, voicemailID:String) -> URL { - let voicemailUrl = URL(string: "fileNotFound")! - let fileName = self.constructVoicemailFilePathWithID(voicemailID: voicemailID) - let voicemailData = Data(base64Encoded: voicemail) - do{ - try voicemailData?.write(to: fileName, options: .completeFileProtection) - return fileName - } catch let error as NSError { - MVMCoreLoggingHandler.logDebugMessage(withDelegate: error.debugDescription) - } - return voicemailUrl - } // func saveVoicemailToDocumentDirectory(voicemail:String) -> URL { // let voicemailUrl = URL(string: "fileNotFound")! From 76787545acb425929170bdfd94d64224789ae336 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 21 Jun 2021 14:07:37 -0400 Subject: [PATCH 023/113] Further development of the select all behavior. --- .../Atoms/Selectors/CheckboxModel.swift | 20 +++++-- .../Protocols/MoleculeDelegateProtocol.swift | 22 ++++--- .../BaseControllers/ViewController.swift | 2 +- .../Behaviors/SelectAllBoxesBehavior.swift | 57 ++++++++++++------- 4 files changed, 67 insertions(+), 34 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift index c2d9f14e..9ed1c849 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift @@ -6,10 +6,8 @@ // Copyright © 2020 Verizon Wireless. All rights reserved. // -import Foundation - -@objcMembers public class CheckboxModel: MoleculeModelProtocol, FormFieldProtocol { +@objcMembers public class CheckboxModel: MoleculeModelProtocol, SelectableModel, FormFieldProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -66,13 +64,25 @@ import Foundation case groupName case offAction } - + //-------------------------------------------------- - // MARK: - Methods + // MARK: - Form Validation //-------------------------------------------------- public func formFieldValue() -> AnyHashable? { checked } + //-------------------------------------------------- + // MARK: - Selectable Protocol + //-------------------------------------------------- + + public func select(as isSelected: Bool) { + checked = isSelected + } + + public var selectedValue: Bool { + checked + } + //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Protocols/MoleculeDelegateProtocol.swift b/MVMCoreUI/Atomic/Protocols/MoleculeDelegateProtocol.swift index e61ea662..0435cf66 100644 --- a/MVMCoreUI/Atomic/Protocols/MoleculeDelegateProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/MoleculeDelegateProtocol.swift @@ -6,30 +6,34 @@ // Copyright © 2019 Verizon Wireless. All rights reserved. // -import Foundation public protocol MoleculeDelegateProtocol: AnyObject { - + func getRootMolecules() -> [MoleculeModelProtocol] /// returns a module for the corresponding module name. - func getModuleWithName(_ name: String?) -> [AnyHashable : Any]? + func getModuleWithName(_ name: String?) -> [AnyHashable: Any]? + func getModuleWithName(_ moleculeName: String) -> MoleculeModelProtocol? - + /// Notifies the delegate that the molecule layout update. Should be called when the layout may change due to an async method. Mainly used for list or collections. func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) //optional - + /// Asks the delegate to add or remove molecules. Mainly used for list or collections. func getIndexPath(for molecule: ListItemModelProtocol & MoleculeModelProtocol) -> IndexPath? + func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], indexPath: IndexPath, animation: UITableView.RowAnimation) + func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], animation: UITableView.RowAnimation) } extension MoleculeDelegateProtocol { - public func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) {} + public func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) { } - public func getIndexPath(for molecule: ListItemModelProtocol & MoleculeModelProtocol) -> IndexPath? { return nil } - public func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], indexPath: IndexPath, animation: UITableView.RowAnimation) {} - public func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], animation: UITableView.RowAnimation) {} + public func getIndexPath(for molecule: ListItemModelProtocol & MoleculeModelProtocol) -> IndexPath? { nil } + + public func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], indexPath: IndexPath, animation: UITableView.RowAnimation) { } + + public func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], animation: UITableView.RowAnimation) { } } diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 9745b3f4..06efad05 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -507,7 +507,7 @@ import UIKit //-------------------------------------------------- open func getRootMolecules() -> [MoleculeModelProtocol] { - return model?.rootMolecules ?? [] + model?.rootMolecules ?? [] } open func getModuleWithName(_ name: String?) -> [AnyHashable: Any]? { diff --git a/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift b/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift index 66720d1e..a197a4d7 100644 --- a/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift +++ b/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift @@ -6,9 +6,13 @@ // Copyright © 2021 Verizon Wireless. All rights reserved. // +public protocol SelectableModel { + var selectedValue: Bool { get } + func select(as isSelected: Bool) +} public class SelectAllBoxesBehaviorModel: PageBehaviorModelProtocol { - public class var identifier: String { "selectAllBoxesBehavior" } + public class var identifier: String { "pageSelectAllBoxesBehavior" } public var shouldAllowMultipleInstances: Bool { false } public init() { } } @@ -16,9 +20,11 @@ public class SelectAllBoxesBehaviorModel: PageBehaviorModelProtocol { public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior { //-------------------------------------------------- - // MARK: - Active Model + // MARK: - Properties //-------------------------------------------------- + var didSelectAll = false + //-------------------------------------------------- // MARK: - Delegate //-------------------------------------------------- @@ -37,31 +43,44 @@ public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior { // MARK: - Custom Action //-------------------------------------------------- - // Either play or pause + // To select or deselect all controls adhereing to public func handleAction(type actionType: String?, information: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) -> Bool { - guard actionType == "selectAllBoxes" else { return false } + guard actionType == "selectAllBoxes", + let selectableModels: [SelectableModel] = delegate?.moleculeDelegate?.getRootMolecules().allMoleculesOfType(), + !selectableModels.isEmpty + else { return false } - let currentVC = MVMCoreUIUtility.getCurrentVisibleController() + didSelectAll.toggle() + let navButtonTitle: String? = (didSelectAll ? information!["deSelectAllTitle"] : information!["selectAllTitle"]) as? String - traverseAndSelectCheckboxes(view: currentVC.view) + for selectableModel in selectableModels { + if toSelect(model: selectableModel) || toDeselect(model: selectableModel) { + selectableModel.select(as: didSelectAll) + } + } + + MVMCoreDispatchUtility.performBlock(onMainThread: { + // TODO: move to protocol function instead + guard let controller = self.delegate?.moleculeDelegate as? ViewController else { return } + controller.handleNewDataAndUpdateUI() + + if MVMCoreUIUtility.getCurrentVisibleController() == controller { + // Update navigation bar if showing. + controller.navigationItem.rightBarButtonItem?.title = navButtonTitle + controller.manager?.refreshNavigationUI() + } + }) - // TODO: A) select all boxes and the change the nav button title to "deselect all" - // TODO: B) deselect all boxes and change nav nutton title to "select all" - return true } - private func traverseAndSelectCheckboxes(view: UIView) { - - if let checkbox = view as? Checkbox { - checkbox.isSelected = true - return - } - - for subview in view.subviews { - traverseAndSelectCheckboxes(view: subview) - } + func toSelect(model: SelectableModel) -> Bool { + didSelectAll && !model.selectedValue + } + + func toDeselect(model: SelectableModel) -> Bool { + !didSelectAll && model.selectedValue } } From cf8d0f967e1eed3c5649588f9d361400b7b56f0a Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 21 Jun 2021 15:27:22 -0400 Subject: [PATCH 024/113] move titles into behavior. changed selectable protocol name. --- .../Atoms/Selectors/CheckboxModel.swift | 2 +- .../Atomic/Atoms/Selectors/ToggleModel.swift | 16 +++- .../Behaviors/SelectAllBoxesBehavior.swift | 85 +++++++++++++++---- 3 files changed, 83 insertions(+), 20 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift index 9ed1c849..0b98d1fc 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift @@ -7,7 +7,7 @@ // -@objcMembers public class CheckboxModel: MoleculeModelProtocol, SelectableModel, FormFieldProtocol { +@objcMembers public class CheckboxModel: MoleculeModelProtocol, SelectableMoleculeModel, FormFieldProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift index 4990df73..e59a4738 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift @@ -7,7 +7,7 @@ // -public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableModelProtocol { +public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableModelProtocol, SelectableMoleculeModel { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -53,11 +53,23 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableMo } //-------------------------------------------------- - // MARK: - Methods + // MARK: - Form Valdiation //-------------------------------------------------- public func formFieldValue() -> AnyHashable? { state } + //-------------------------------------------------- + // MARK: - Selectable Protocol + //-------------------------------------------------- + + public func select(as isSelected: Bool) { + state = isSelected + } + + public var selectedValue: Bool { + state + } + //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- diff --git a/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift b/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift index a197a4d7..93d7367e 100644 --- a/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift +++ b/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift @@ -6,7 +6,10 @@ // Copyright © 2021 Verizon Wireless. All rights reserved. // -public protocol SelectableModel { +/// Protocol to apply to any model of a UI Control with a binary on/off nature. +/// +/// Example classes: Checkbox or Switch. +public protocol SelectableMoleculeModel { var selectedValue: Bool { get } func select(as isSelected: Bool) } @@ -14,16 +17,48 @@ public protocol SelectableModel { public class SelectAllBoxesBehaviorModel: PageBehaviorModelProtocol { public class var identifier: String { "pageSelectAllBoxesBehavior" } public var shouldAllowMultipleInstances: Bool { false } + public var selectAllTitle: String = "Select All" + public var deselectAllTitle: String = "Deselect All" public init() { } + + //-------------------------------------------------- + // MARK: - Codable + //-------------------------------------------------- + + private enum CodingKeys: String, CodingKey { + case selectAllTitle + case deselectAllTitle + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + + if let selectAllTitle = try typeContainer.decodeIfPresent(String.self, forKey: .selectAllTitle) { + self.selectAllTitle = selectAllTitle + } + + if let deselectAllTitle = try typeContainer.decodeIfPresent(String.self, forKey: .deselectAllTitle) { + self.deselectAllTitle = deselectAllTitle + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(selectAllTitle, forKey: .selectAllTitle) + try container.encode(deselectAllTitle, forKey: .deselectAllTitle) + } } - +/// Selects all the control models presented on a page. public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - var didSelectAll = false + /// Status of the select all behavior. Initially false as the action has not been enaged. + var selectAllState = false + + var model: PageBehaviorModelProtocol //-------------------------------------------------- // MARK: - Delegate @@ -35,7 +70,8 @@ public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior { // MARK: - Init //-------------------------------------------------- - public required init(model: PageBehaviorModelProtocol, delegateObject: MVMCoreUIDelegateObject?) { + required public init(model: PageBehaviorModelProtocol, delegateObject: MVMCoreUIDelegateObject?) { + self.model = model self.delegate = delegateObject } @@ -43,31 +79,40 @@ public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior { // MARK: - Custom Action //-------------------------------------------------- - // To select or deselect all controls adhereing to + /// To select or deselect all controls adhereing to `SelectableMoleculeModel` + /// + /// - Parameters: + /// - actionType: The action type of the passed action model. + /// - information: information of the passed action model. + /// - additionalData: Additional information of the + /// - Returns: Boolean determines if the action has been handled. public func handleAction(type actionType: String?, information: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) -> Bool { + // Verify we have the correct action type and necessary values. guard actionType == "selectAllBoxes", - let selectableModels: [SelectableModel] = delegate?.moleculeDelegate?.getRootMolecules().allMoleculesOfType(), - !selectableModels.isEmpty + let selectableModels: [SelectableMoleculeModel] = delegate?.moleculeDelegate?.getRootMolecules().allMoleculesOfType(), + !selectableModels.isEmpty, + let model = model as? SelectAllBoxesBehaviorModel else { return false } - didSelectAll.toggle() - - let navButtonTitle: String? = (didSelectAll ? information!["deSelectAllTitle"] : information!["selectAllTitle"]) as? String + // Flip the selected state of the behavior. + selectAllState.toggle() + // Iterate through selectable molecules. for selectableModel in selectableModels { if toSelect(model: selectableModel) || toDeselect(model: selectableModel) { - selectableModel.select(as: didSelectAll) + selectableModel.select(as: selectAllState) } } + // Get title to update the nav button title. + let navButtonTitle: String? = selectAllState ? model.deselectAllTitle : model.selectAllTitle + MVMCoreDispatchUtility.performBlock(onMainThread: { - // TODO: move to protocol function instead guard let controller = self.delegate?.moleculeDelegate as? ViewController else { return } controller.handleNewDataAndUpdateUI() if MVMCoreUIUtility.getCurrentVisibleController() == controller { - // Update navigation bar if showing. controller.navigationItem.rightBarButtonItem?.title = navButtonTitle controller.manager?.refreshNavigationUI() } @@ -76,11 +121,17 @@ public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior { return true } - func toSelect(model: SelectableModel) -> Bool { - didSelectAll && !model.selectedValue + /// Convenience function making it easier to read if a current selectable model should be acted on. + /// - Parameter model: A model object assined to the SelectableModel protocol + /// - Returns: Boolean determining if the passed model should be selected. + func toSelect(model: SelectableMoleculeModel) -> Bool { + selectAllState && !model.selectedValue } - func toDeselect(model: SelectableModel) -> Bool { - !didSelectAll && model.selectedValue + /// Convenience function making it easier to read if a current selectable model should be acted on. + /// - Parameter model: A model object assined to the SelectableModel protocol + /// - Returns: Boolean determining if the passed model should be deselected. + func toDeselect(model: SelectableMoleculeModel) -> Bool { + !selectAllState && model.selectedValue } } From f09892b4c6b2e35c0f8303d75664aae6999e0bb5 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Tue, 22 Jun 2021 17:27:41 +0530 Subject: [PATCH 025/113] Changes as per review comments - Default 'numberOfLines' for all Designed components --- .../Headers/H2/HeadersH2PricingTwoRows.swift | 3 --- .../H2/HeadersH2PricingTwoRowsModel.swift | 17 +++++++++++++++++ ...VariableIconWithRightCaretAllTextLinks.swift | 1 - ...bleIconWithRightCaretAllTextLinksModel.swift | 4 ++++ .../List/ListProgressBarThin.swift | 1 - .../List/ListProgressBarThinModel.swift | 4 ++++ .../List/Miscellaneous/ListStoreLocator.swift | 1 - .../Miscellaneous/ListStoreLocatorModel.swift | 11 +++++++++++ ...ightVariablePriceChangeAllTextAndLinks.swift | 1 - ...ariablePriceChangeAllTextAndLinksModel.swift | 11 +++++++++++ .../ListRightVariablePriceChangeBodyText.swift | 1 - ...tRightVariablePriceChangeBodyTextModel.swift | 3 +++ ...RightVariableRightCaretAlltextAndLinks.swift | 1 - ...VariableRightCaretAlltextAndLinksModel.swift | 11 +++++++++++ .../ListThreeColumnBillChanges.swift | 3 --- .../ListThreeColumnBillChangesModel.swift | 17 +++++++++++++++++ .../ListTwoColumnPriceDescription.swift | 3 --- .../ListTwoColumnPriceDescriptionModel.swift | 12 ++++++++++++ 18 files changed, 90 insertions(+), 15 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift index a6d69e24..1baf057c 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift @@ -48,11 +48,8 @@ import Foundation open override func setupView() { super.setupView() setDefaults() - body.numberOfLines = 1 body.lineBreakMode = .byTruncatingTail - body2.numberOfLines = 1 body2.lineBreakMode = .byTruncatingTail - body3.numberOfLines = 1 body3.lineBreakMode = .byTruncatingTail verticalLine1.widthConstraint?.isActive = true diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRowsModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRowsModel.swift index 01bd72e4..b608ba41 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRowsModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRowsModel.swift @@ -21,6 +21,23 @@ public class HeadersH2PricingTwoRowsModel: HeaderModel, MoleculeModelProtocol { public var body3: LabelModel public var subBody3: LabelModel? + //----------------------------------------------------- + // MARK: - Methods + //----------------------------------------------------- + + override public func setDefaults() { + super.setDefaults() + if body.numberOfLines == nil { + body.numberOfLines = 1 + } + if body2.numberOfLines == nil { + body2.numberOfLines = 1 + } + if body3.numberOfLines == nil { + body3.numberOfLines = 1 + } + } + //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift index fcd18f68..0c09e9e3 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift @@ -50,7 +50,6 @@ leftImage.contentMode = .scaleAspectFit rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) - rightLabel.numberOfLines = 1 addMolecule(stack) stack.restack() } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinksModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinksModel.swift index 3129776b..a4fed00e 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinksModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinksModel.swift @@ -31,6 +31,10 @@ public class ListLeftVariableIconWithRightCaretAllTextLinksModel: ListItemModel, image.width = 30 image.height = 30 } + + if rightLabel.numberOfLines == nil { + rightLabel.numberOfLines = 1 + } } //----------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift index 79530eb6..9b85dc4f 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift @@ -71,7 +71,6 @@ rightBar.widthAnchor.constraint(equalToConstant: 20).isActive = true rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) - rightLabel.numberOfLines = 1 addMolecule(stack) stack.restack() horizontalStack.restack() diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift index 5309ebe1..52c175df 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift @@ -45,6 +45,10 @@ public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol { rightBar.backgroundColor = Color(uiColor: .gray) } + if rightLabel.numberOfLines == nil { + rightLabel.numberOfLines = 1 + } + leftHeadline.hero = 0 } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift index b10b3069..1e271e87 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift @@ -39,7 +39,6 @@ rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) - rightLabel.numberOfLines = 1 addMolecule(stack) stack.restack() horizontalStack.restack() diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift index 10a0cd29..d690d681 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift @@ -18,6 +18,17 @@ public class ListStoreLocatorModel: ListItemModel, MoleculeModelProtocol { public var leftSubBody: LabelModel public var rightLabel: LabelModel + //----------------------------------------------------- + // MARK: - Methods + //----------------------------------------------------- + + override public func setDefaults() { + super.setDefaults() + if rightLabel.numberOfLines == nil { + rightLabel.numberOfLines = 1 + } + } + //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinks.swift index ec58684c..d0b2ff70 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinks.swift @@ -61,7 +61,6 @@ rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) - rightLabel.numberOfLines = 1 addMolecule(stack) stack.restack() } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinksModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinksModel.swift index 7b1e065a..8d6ba0cb 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinksModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinksModel.swift @@ -17,6 +17,17 @@ public class ListRightVariablePriceChangeAllTextAndLinksModel: ListItemModel, Mo public var rightLabel: LabelModel public var arrow: ArrowModel + //----------------------------------------------------- + // MARK: - Methods + //----------------------------------------------------- + + override public func setDefaults() { + super.setDefaults() + if rightLabel.numberOfLines == nil { + rightLabel.numberOfLines = 1 + } + } + //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeBodyText.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeBodyText.swift index b503b57a..a03b676d 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeBodyText.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeBodyText.swift @@ -46,7 +46,6 @@ rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) - rightLabel.numberOfLines = 1 addMolecule(stack) stack.restack() diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeBodyTextModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeBodyTextModel.swift index e3b325b6..c7efdb07 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeBodyTextModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeBodyTextModel.swift @@ -37,6 +37,9 @@ public class ListRightVariablePriceChangeBodyTextModel: ListItemModel, MoleculeM if let headline = headlineBody.headline { headline.hero = 0 } + if rightLabel.numberOfLines == nil { + rightLabel.numberOfLines = 1 + } } //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinks.swift index 3a342b6a..12f11b9e 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinks.swift @@ -38,7 +38,6 @@ super.setupView() rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) - rightLabel.numberOfLines = 1 addMolecule(stack) stack.restack() } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinksModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinksModel.swift index d3725ed1..f16daf2b 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinksModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinksModel.swift @@ -16,6 +16,17 @@ public class ListRightVariableRightCaretAllTextAndLinksModel: ListItemModel, Mol public var rightLabel: LabelModel public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel + //----------------------------------------------------- + // MARK: - Methods + //----------------------------------------------------- + + override public func setDefaults() { + super.setDefaults() + if rightLabel.numberOfLines == nil { + rightLabel.numberOfLines = 1 + } + } + //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnBillChanges.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnBillChanges.swift index 3db13a01..ddb202b6 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnBillChanges.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnBillChanges.swift @@ -39,9 +39,6 @@ open override func setupView() { super.setupView() - leftLabel.numberOfLines = 1 - centerLabel.numberOfLines = 1 - rightLabel.numberOfLines = 1 addMolecule(stack) stack.restack() } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnBillChangesModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnBillChangesModel.swift index 00bf689c..9b121926 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnBillChangesModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnBillChangesModel.swift @@ -17,6 +17,23 @@ public class ListThreeColumnBillChangesModel: ListItemModel, MoleculeModelProtoc public var centerLabel: LabelModel public var rightLabel: LabelModel + //----------------------------------------------------- + // MARK: - Methods + //----------------------------------------------------- + + override public func setDefaults() { + super.setDefaults() + if rightLabel.numberOfLines == nil { + rightLabel.numberOfLines = 1 + } + if centerLabel.numberOfLines == nil { + centerLabel.numberOfLines = 1 + } + if leftLabel.numberOfLines == nil { + leftLabel.numberOfLines = 1 + } + } + //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescription.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescription.swift index c083e457..b211c918 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescription.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescription.swift @@ -74,9 +74,6 @@ view.addSubview(rightVerticalStack) NSLayoutConstraint.pinViews(leftView: leftVerticalStack, rightView: rightVerticalStack, alignTop: true) - leftHeadline.numberOfLines = 1 - rightLabel.numberOfLines = 1 - rightSubLabel.numberOfLines = 1 } //---------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescriptionModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescriptionModel.swift index 822b5074..f88677a8 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescriptionModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescriptionModel.swift @@ -34,6 +34,18 @@ public class ListTwoColumnPriceDescriptionModel: ListItemModel, MoleculeModelPro if rightSubLabel.attributes == nil { rightSubLabel.attributes = [LabelAttributeStrikeThroughModel(0, rightSubLabel.text.count)] } + + if rightLabel.numberOfLines == nil { + rightLabel.numberOfLines = 1 + } + + if rightSubLabel.numberOfLines == nil { + rightSubLabel.numberOfLines = 1 + } + + if leftHeadline.numberOfLines == nil { + leftHeadline.numberOfLines = 1 + } } //-------------------------------------------------- From f3f65763fc1c76c14255dd5e4def849ac9802c30 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 22 Jun 2021 11:55:26 -0400 Subject: [PATCH 026/113] bug fixes --- MVMCoreUI/Containers/NavigationController.swift | 14 ++++++++------ .../MVMCoreUISplitViewController+Extension.swift | 7 ++++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/MVMCoreUI/Containers/NavigationController.swift b/MVMCoreUI/Containers/NavigationController.swift index 6176427f..776bfe2a 100644 --- a/MVMCoreUI/Containers/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController.swift @@ -130,11 +130,11 @@ extension NavigationController: MVMCoreViewManagerProtocol { } public func newDataReceived(in viewController: UIViewController) { - if viewController == topViewController, - let model = Self.getNavigationModel(from: viewController) { - Self.setNavigationItem(navigationController: self, navigationItemModel: model, viewController: viewController) - Self.setNavigationBarUI(navigationController: self, navigationItemModel: model, viewController: viewController) - } + guard let topViewController = topViewController, + viewController == MVMCoreUIUtility.getViewControllerTraversingManagers(topViewController), + let model = Self.getNavigationModel(from: viewController) else { return } + Self.setNavigationItem(navigationController: self, navigationItemModel: model, viewController: viewController) + Self.setNavigationBarUI(navigationController: self, navigationItemModel: model, viewController: viewController) manager?.newDataReceived?(in: viewController) } @@ -160,7 +160,6 @@ extension NavigationController: MVMCorePresentationDelegateProtocol { guard self == navigationController else { return } if let controller = viewController as? (UIViewController & MVMCoreViewManagerViewControllerProtocol) { MVMCoreViewManagerViewControllerProtocolHelper.helpSetManager(self, viewController: controller) - controller.viewControllerReady?(inManager: self) } if let model = Self.getNavigationModel(from: viewController) { Self.setNavigationItem(navigationController: self, navigationItemModel: model, viewController: viewController) @@ -174,5 +173,8 @@ extension NavigationController: MVMCorePresentationDelegateProtocol { Self.setNavigationBarUI(navigationController: self, navigationItemModel: model, viewController: viewController) } manager?.displayedViewController?(viewController) + if let controller = viewController as? (UIViewController & MVMCoreViewManagerViewControllerProtocol) { + controller.viewControllerReady?(inManager: self) + } } } diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift index fcd4e821..4c389bd3 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift @@ -75,7 +75,7 @@ public extension MVMCoreUISplitViewController { leftItems.append(contentsOf: additionalLeftButtons) } - viewController.navigationItem.setLeftBarButtonItems(leftItems.count > 0 ? leftItems : nil, animated: !DisableAnimations.boolValue) + navigationController.topViewController?.navigationItem.setLeftBarButtonItems(leftItems.count > 0 ? leftItems : nil, animated: !DisableAnimations.boolValue) } /// Sets the right navigation items for the view controller based on model and splitview. @@ -102,7 +102,7 @@ public extension MVMCoreUISplitViewController { rightItems.append(contentsOf: additionalRightButtons) } - viewController.navigationItem.setRightBarButtonItems(rightItems.count > 0 ? rightItems : nil, animated: !DisableAnimations.boolValue) + navigationController.topViewController?.navigationItem.setRightBarButtonItems(rightItems.count > 0 ? rightItems : nil, animated: !DisableAnimations.boolValue) } @objc func navigationBarModelExists() -> Bool { @@ -129,7 +129,8 @@ extension MVMCoreUISplitViewController: MVMCoreViewManagerProtocol { } public func displayedViewController(_ viewController: UIViewController) { - updateNavigationBarFor(viewController: viewController) + guard let controller = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController) else { return } + updateNavigationBarFor(viewController: controller) } public func newDataReceived(in viewController: UIViewController) { From be196a289e9a5d4102d18918fd963e321c3aa80c Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 22 Jun 2021 13:10:06 -0400 Subject: [PATCH 027/113] aligns behavior for user intiaited corner cases. --- .../Atoms/Selectors/CheckboxModel.swift | 4 +- .../Behaviors/SelectAllBoxesBehavior.swift | 108 +++++++++++++++--- 2 files changed, 94 insertions(+), 18 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift index 0b98d1fc..34f0fd22 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift @@ -7,7 +7,7 @@ // -@objcMembers public class CheckboxModel: MoleculeModelProtocol, SelectableMoleculeModel, FormFieldProtocol { +@objcMembers public class CheckboxModel: NSObject, MoleculeModelProtocol, SelectableMoleculeModel, FormFieldProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -15,7 +15,7 @@ public static var identifier: String = "checkbox" public var backgroundColor: Color? public var accessibilityIdentifier: String? - public var checked: Bool = false + public dynamic var checked: Bool = false public var enabled: Bool = true public var animated: Bool = true public var inverted: Bool = false diff --git a/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift b/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift index 93d7367e..27cbe69a 100644 --- a/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift +++ b/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift @@ -24,7 +24,7 @@ public class SelectAllBoxesBehaviorModel: PageBehaviorModelProtocol { //-------------------------------------------------- // MARK: - Codable //-------------------------------------------------- - + private enum CodingKeys: String, CodingKey { case selectAllTitle case deselectAllTitle @@ -41,7 +41,7 @@ public class SelectAllBoxesBehaviorModel: PageBehaviorModelProtocol { self.deselectAllTitle = deselectAllTitle } } - + public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(selectAllTitle, forKey: .selectAllTitle) @@ -50,16 +50,23 @@ public class SelectAllBoxesBehaviorModel: PageBehaviorModelProtocol { } /// Selects all the control models presented on a page. -public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior { +public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior, PageMoleculeTransformationBehavior { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- /// Status of the select all behavior. Initially false as the action has not been enaged. - var selectAllState = false + var didSelectAllState = false + /// Reference to the general PageBehaviorModel. var model: PageBehaviorModelProtocol + /// Dictionary of KVOs to observing the selected property of each `SelectableMoleculeModel`. + private var observers = [String: NSKeyValueObservation?]() + + /// A store representing the values of the `SelectableMoleculeModel`. + private var valuesMirror = [String: Bool]() + //-------------------------------------------------- // MARK: - Delegate //-------------------------------------------------- @@ -75,6 +82,45 @@ public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior { self.delegate = delegateObject } + public func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject) { + + let selectableModels: [SelectableMoleculeModel] = rootMolecules.allMoleculesOfType() + + guard !selectableModels.isEmpty else { return } + + for model in selectableModels { + if let checkboxModel = model as? CheckboxModel, let key = checkboxModel.fieldKey { + + valuesMirror[key] = checkboxModel.checked + + observers[key] = checkboxModel.observe(\.checked, options: [.new]) { [weak self] model, change in + guard let self = self, + let isChecked = change.newValue, + let key = model.fieldKey + else { return } + + self.valuesMirror[key] = isChecked + + // If all are models are in the opposite state of the behavior, then realign. + if self.selectAllIsMisaligned() { + self.realignPageBehavior(asSelectAll: true) + + } else if self.deselectAllIsMisaligned() { + self.realignPageBehavior(asSelectAll: false) + } + } + } + } + } + + //-------------------------------------------------- + // MARK: - Deinit + //-------------------------------------------------- + + deinit { + observers.values.forEach { $0?.invalidate() } + } + //-------------------------------------------------- // MARK: - Custom Action //-------------------------------------------------- @@ -91,25 +137,45 @@ public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior { // Verify we have the correct action type and necessary values. guard actionType == "selectAllBoxes", let selectableModels: [SelectableMoleculeModel] = delegate?.moleculeDelegate?.getRootMolecules().allMoleculesOfType(), - !selectableModels.isEmpty, - let model = model as? SelectAllBoxesBehaviorModel + !selectableModels.isEmpty else { return false } // Flip the selected state of the behavior. - selectAllState.toggle() + didSelectAllState.toggle() // Iterate through selectable molecules. for selectableModel in selectableModels { if toSelect(model: selectableModel) || toDeselect(model: selectableModel) { - selectableModel.select(as: selectAllState) + selectableModel.select(as: didSelectAllState) } } - // Get title to update the nav button title. - let navButtonTitle: String? = selectAllState ? model.deselectAllTitle : model.selectAllTitle + updatePageNavigationUI() + return true + } + + //-------------------------------------------------- + // MARK: - Methods + //-------------------------------------------------- + + /// In the event that the user manually selects or deselects all `SelectableMoleculeModel` + /// the behavior will need to reflect the inverse of its previously expected action. + /// Initiates the navigation and page behavior realignment + /// - Parameter asSelectAll: The actual value didSelectAllState ought to be. + func realignPageBehavior(asSelectAll: Bool) { + didSelectAllState = asSelectAll + updatePageNavigationUI() + } + + /// Updates the navigation UI to correctly reflect the behavior's state. + func updatePageNavigationUI() { - MVMCoreDispatchUtility.performBlock(onMainThread: { - guard let controller = self.delegate?.moleculeDelegate as? ViewController else { return } + guard let model = model as? SelectAllBoxesBehaviorModel else { return } + + let navButtonTitle: String? = didSelectAllState ? model.deselectAllTitle : model.selectAllTitle + + MVMCoreDispatchUtility.performBlock(onMainThread: { [weak self] in + guard let controller = self?.delegate?.moleculeDelegate as? ViewController else { return } controller.handleNewDataAndUpdateUI() if MVMCoreUIUtility.getCurrentVisibleController() == controller { @@ -117,21 +183,31 @@ public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior { controller.manager?.refreshNavigationUI() } }) - - return true + } + + /// Convenience function for readability to confirmt he state of the behavior. + /// - Returns: Boolean indicating that the behavior's `didSelectAllState` is false while all model values are true (selected). + func selectAllIsMisaligned() -> Bool { + !didSelectAllState && valuesMirror.values.allSatisfy { $0 == true } + } + + /// Convenience function for readability to confirmt he state of the behavior. + /// - Returns: Boolean indicating that the behavior's `didSelectAllState` is true while all model values are false (deselected). + func deselectAllIsMisaligned() -> Bool { + didSelectAllState && valuesMirror.values.allSatisfy { $0 == false } } /// Convenience function making it easier to read if a current selectable model should be acted on. /// - Parameter model: A model object assined to the SelectableModel protocol /// - Returns: Boolean determining if the passed model should be selected. func toSelect(model: SelectableMoleculeModel) -> Bool { - selectAllState && !model.selectedValue + didSelectAllState && !model.selectedValue } /// Convenience function making it easier to read if a current selectable model should be acted on. /// - Parameter model: A model object assined to the SelectableModel protocol /// - Returns: Boolean determining if the passed model should be deselected. func toDeselect(model: SelectableMoleculeModel) -> Bool { - !selectAllState && model.selectedValue + !didSelectAllState && model.selectedValue } } From f6c672e22dba34ff4b89f4babc8396b11495a3b1 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 22 Jun 2021 14:36:52 -0400 Subject: [PATCH 028/113] fix explicit --- .../MVMCoreUISplitViewController+Extension.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift index 4c389bd3..77f9126d 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift @@ -125,7 +125,7 @@ extension MVMCoreUISplitViewController: MVMCoreViewManagerProtocol { } public func containsPage(withPageType pageType: String?) -> Bool { - navigationController!.containsPage(withPageType: pageType) + navigationController?.containsPage(withPageType: pageType) ?? false } public func displayedViewController(_ viewController: UIViewController) { From 5af484daad932b931efa90565148dbc5ce0fe548 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 22 Jun 2021 14:39:21 -0400 Subject: [PATCH 029/113] remove check --- .../MVMCoreUISplitViewController+Extension.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift index 77f9126d..b7e6ce6d 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift @@ -129,8 +129,7 @@ extension MVMCoreUISplitViewController: MVMCoreViewManagerProtocol { } public func displayedViewController(_ viewController: UIViewController) { - guard let controller = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController) else { return } - updateNavigationBarFor(viewController: controller) + updateNavigationBarFor(viewController: viewController) } public func newDataReceived(in viewController: UIViewController) { From 2b378f55973d1894c3210f84ba7a61df79e3574c Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 22 Jun 2021 15:05:04 -0400 Subject: [PATCH 030/113] generalizing the observing behavior --- .../Atomic/Atoms/Selectors/Checkbox.swift | 6 +-- .../Atoms/Selectors/CheckboxModel.swift | 20 +++---- MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift | 4 +- .../Atomic/Atoms/Selectors/ToggleModel.swift | 20 +++---- .../Behaviors/SelectAllBoxesBehavior.swift | 52 ++++++++++--------- 5 files changed, 48 insertions(+), 54 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift index f1fd5fed..a5657dd4 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift @@ -124,7 +124,7 @@ import MVMCore didSet { if !updateSelectionOnly { layoutIfNeeded() - (model as? CheckboxModel)?.checked = isSelected + (model as? CheckboxModel)?.selected = isSelected shapeLayer?.removeAllAnimations() updateCheckboxUI(isSelected: isSelected, isAnimated: isAnimated) _ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate) @@ -419,8 +419,8 @@ import MVMCore isAnimated = model.animated isRound = model.round - if model.checked { - checkAndBypassAnimations(selected: model.checked) + if model.selected { + checkAndBypassAnimations(selected: model.selected) } isEnabled = model.enabled diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift index 34f0fd22..b7d79570 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift @@ -15,7 +15,7 @@ public static var identifier: String = "checkbox" public var backgroundColor: Color? public var accessibilityIdentifier: String? - public dynamic var checked: Bool = false + public dynamic var selected: Bool = false public var enabled: Bool = true public var animated: Bool = true public var inverted: Bool = false @@ -69,26 +69,22 @@ // MARK: - Form Validation //-------------------------------------------------- - public func formFieldValue() -> AnyHashable? { checked } + public func formFieldValue() -> AnyHashable? { selected } //-------------------------------------------------- // MARK: - Selectable Protocol //-------------------------------------------------- public func select(as isSelected: Bool) { - checked = isSelected + selected = isSelected } - - public var selectedValue: Bool { - checked - } - + //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- public init(isChecked: Bool = false) { - self.checked = isChecked + self.selected = isChecked baseValue = isChecked } @@ -142,10 +138,10 @@ } if let checked = try typeContainer.decodeIfPresent(Bool.self, forKey: .checked) { - self.checked = checked + self.selected = checked } - baseValue = checked + baseValue = selected if let animated = try typeContainer.decodeIfPresent(Bool.self, forKey: .animated) { self.animated = animated @@ -179,7 +175,7 @@ try container.encodeIfPresent(fieldKey, forKey: .fieldKey) try container.encodeIfPresent(borderColor, forKey: .borderColor) try container.encode(borderWidth, forKey: .borderWidth) - try container.encode(checked, forKey: .checked) + try container.encode(selected, forKey: .checked) try container.encode(inverted, forKey: .inverted) try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encodeIfPresent(checkColor, forKey: .checkColor) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift index 304b23c4..3513a03b 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift @@ -98,7 +98,7 @@ public typealias ActionBlockConfirmation = () -> (Bool) self.constrainKnob() } - toggleModel?.state = isOn + toggleModel?.selected = isOn _ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate) accessibilityValue = isOn ? MVMCoreUIUtility.hardcodedString(withKey: "AccOn") : MVMCoreUIUtility.hardcodedString(withKey: "AccOff") setNeedsLayout() @@ -381,7 +381,7 @@ public typealias ActionBlockConfirmation = () -> (Bool) containerTintColor.off = model.offTintColor.uiColor knobTintColor.on = model.onKnobTintColor.uiColor knobTintColor.off = model.offKnobTintColor.uiColor - isOn = model.state + isOn = model.selected changeStateNoAnimation(isOn) isAnimated = model.animated isEnabled = model.enabled diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift index e59a4738..565d8d43 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift @@ -7,7 +7,7 @@ // -public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableModelProtocol, SelectableMoleculeModel { +public class ToggleModel: NSObject, MoleculeModelProtocol, FormFieldProtocol, EnableableModelProtocol, SelectableMoleculeModel { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -15,7 +15,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableMo public static var identifier: String = "toggle" public var accessibilityIdentifier: String? public var backgroundColor: Color? - public var state: Bool = false + public dynamic var selected: Bool = false public var animated: Bool = true public var enabled: Bool = true public var action: ActionModelProtocol? @@ -56,18 +56,14 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableMo // MARK: - Form Valdiation //-------------------------------------------------- - public func formFieldValue() -> AnyHashable? { state } + public func formFieldValue() -> AnyHashable? { selected } //-------------------------------------------------- // MARK: - Selectable Protocol //-------------------------------------------------- public func select(as isSelected: Bool) { - state = isSelected - } - - public var selectedValue: Bool { - state + selected = isSelected } //-------------------------------------------------- @@ -75,7 +71,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableMo //-------------------------------------------------- public init(_ state: Bool) { - self.state = state + self.selected = state baseValue = state } @@ -87,7 +83,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableMo let typeContainer = try decoder.container(keyedBy: CodingKeys.self) if let state = try typeContainer.decodeIfPresent(Bool.self, forKey: .state) { - self.state = state + self.selected = state } if let enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) { @@ -121,7 +117,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableMo accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) - baseValue = state + baseValue = selected fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { self.groupName = groupName @@ -135,7 +131,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableMo try container.encodeModelIfPresent(action, forKey: .action) try container.encodeModelIfPresent(alternateAction, forKey: .alternateAction) try container.encode(moleculeName, forKey: .moleculeName) - try container.encode(state, forKey: .state) + try container.encode(selected, forKey: .state) try container.encode(animated, forKey: .animated) try container.encode(enabled, forKey: .enabled) try container.encode(onTintColor, forKey: .onTintColor) diff --git a/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift b/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift index 27cbe69a..b4db84d5 100644 --- a/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift +++ b/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift @@ -9,8 +9,8 @@ /// Protocol to apply to any model of a UI Control with a binary on/off nature. /// /// Example classes: Checkbox or Switch. -public protocol SelectableMoleculeModel { - var selectedValue: Bool { get } +@objc public protocol SelectableMoleculeModel: AnyObject { + @objc dynamic var selected: Bool { get set } func select(as isSelected: Bool) } @@ -84,31 +84,33 @@ public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior, PageMolecu public func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject) { - let selectableModels: [SelectableMoleculeModel] = rootMolecules.allMoleculesOfType() + let selectableModels: [(NSObject & SelectableMoleculeModel)] = rootMolecules.allMoleculesOfType() guard !selectableModels.isEmpty else { return } - + for model in selectableModels { - if let checkboxModel = model as? CheckboxModel, let key = checkboxModel.fieldKey { + if let key = (model as? FormFieldProtocol)?.fieldKey { + valuesMirror[key] = model.selected + setObserver(model, fieldKey: key) + } + } + } + + func setObserver(_ model: T, fieldKey: String) where T: (NSObject & SelectableMoleculeModel) { + + observers[fieldKey] = model.observe(\.selected, options: [.new]) { [weak self] model, change in + guard let self = self, + let isChecked = change.newValue + else { return } + + self.valuesMirror[fieldKey] = isChecked + + // If all are models are in the opposite state of the behavior, then realign. + if self.selectAllIsMisaligned() { + self.realignPageBehavior(asSelectAll: true) - valuesMirror[key] = checkboxModel.checked - - observers[key] = checkboxModel.observe(\.checked, options: [.new]) { [weak self] model, change in - guard let self = self, - let isChecked = change.newValue, - let key = model.fieldKey - else { return } - - self.valuesMirror[key] = isChecked - - // If all are models are in the opposite state of the behavior, then realign. - if self.selectAllIsMisaligned() { - self.realignPageBehavior(asSelectAll: true) - - } else if self.deselectAllIsMisaligned() { - self.realignPageBehavior(asSelectAll: false) - } - } + } else if self.deselectAllIsMisaligned() { + self.realignPageBehavior(asSelectAll: false) } } } @@ -201,13 +203,13 @@ public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior, PageMolecu /// - Parameter model: A model object assined to the SelectableModel protocol /// - Returns: Boolean determining if the passed model should be selected. func toSelect(model: SelectableMoleculeModel) -> Bool { - didSelectAllState && !model.selectedValue + didSelectAllState && !model.selected } /// Convenience function making it easier to read if a current selectable model should be acted on. /// - Parameter model: A model object assined to the SelectableModel protocol /// - Returns: Boolean determining if the passed model should be deselected. func toDeselect(model: SelectableMoleculeModel) -> Bool { - !didSelectAllState && model.selectedValue + !didSelectAllState && model.selected } } From f27e3cd680a1ec473054a5e6ef9cb495ffd67388 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 22 Jun 2021 15:22:27 -0400 Subject: [PATCH 031/113] updated protocol --- MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift | 8 -------- MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift | 8 -------- MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift | 5 ++--- 3 files changed, 2 insertions(+), 19 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift index b7d79570..4efa53ec 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift @@ -71,14 +71,6 @@ public func formFieldValue() -> AnyHashable? { selected } - //-------------------------------------------------- - // MARK: - Selectable Protocol - //-------------------------------------------------- - - public func select(as isSelected: Bool) { - selected = isSelected - } - //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift index 565d8d43..88f193f5 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift @@ -58,14 +58,6 @@ public class ToggleModel: NSObject, MoleculeModelProtocol, FormFieldProtocol, En public func formFieldValue() -> AnyHashable? { selected } - //-------------------------------------------------- - // MARK: - Selectable Protocol - //-------------------------------------------------- - - public func select(as isSelected: Bool) { - selected = isSelected - } - //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- diff --git a/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift b/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift index b4db84d5..e9ffce2c 100644 --- a/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift +++ b/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift @@ -8,10 +8,9 @@ /// Protocol to apply to any model of a UI Control with a binary on/off nature. /// -/// Example classes: Checkbox or Switch. +/// Example classes: Checkbox or Toggle. @objc public protocol SelectableMoleculeModel: AnyObject { @objc dynamic var selected: Bool { get set } - func select(as isSelected: Bool) } public class SelectAllBoxesBehaviorModel: PageBehaviorModelProtocol { @@ -148,7 +147,7 @@ public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior, PageMolecu // Iterate through selectable molecules. for selectableModel in selectableModels { if toSelect(model: selectableModel) || toDeselect(model: selectableModel) { - selectableModel.select(as: didSelectAllState) + selectableModel.selected = didSelectAllState } } From 4bdd6fa775c93d138b8825f48d4890285ceecd2a Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 22 Jun 2021 17:00:52 -0400 Subject: [PATCH 032/113] flow fixes for manager propagation. Navigation fixes. --- .../Containers/NavigationController.swift | 51 +++++++++++-------- ...MCoreUISplitViewController+Extension.swift | 23 +++++---- .../MVMCoreUISplitViewController.m | 8 +-- 3 files changed, 46 insertions(+), 36 deletions(-) diff --git a/MVMCoreUI/Containers/NavigationController.swift b/MVMCoreUI/Containers/NavigationController.swift index 776bfe2a..eb378b08 100644 --- a/MVMCoreUI/Containers/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController.swift @@ -106,23 +106,28 @@ import UIKit } } - /// Convenience function to return the navigation model of the lowest controller traversing managers - public static func getNavigationModel(from viewController: UIViewController) -> NavigationItemModelProtocol? { - guard let controller = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController), - let model = (controller as? PageProtocol)?.pageModel?.navigationBar else { return nil } + /// Convenience function to return the navigation model of the lowest controller traversing managers if applicable. + public func getNavigationModel(from viewController: UIViewController) -> NavigationItemModelProtocol? { + guard let topViewController = topViewController, + viewController == MVMCoreUIUtility.getViewControllerTraversingManagers(topViewController), + let model = (viewController as? PageProtocol)?.pageModel?.navigationBar else { return nil } return model } } extension NavigationController: MVMCoreViewManagerProtocol { - // TODO: change this to optional public func getCurrentViewController() -> UIViewController? { - return topViewController + guard let topViewController = topViewController else { return nil } + return MVMCoreUIUtility.getViewControllerTraversingManagers(topViewController) } public func containsPage(withPageType pageType: String?) -> Bool { - for case let controller as MVMCoreViewControllerProtocol in viewControllers { - if controller.pageType == pageType { + for controller in viewControllers { + if let manager = controller as? MVMCoreViewManagerProtocol, + manager.containsPage(withPageType: pageType) { + return true + } else if let controller = controller as? MVMCoreViewControllerProtocol, + controller.pageType == pageType { return true } } @@ -130,25 +135,25 @@ extension NavigationController: MVMCoreViewManagerProtocol { } public func newDataReceived(in viewController: UIViewController) { - guard let topViewController = topViewController, - viewController == MVMCoreUIUtility.getViewControllerTraversingManagers(topViewController), - let model = Self.getNavigationModel(from: viewController) else { return } - Self.setNavigationItem(navigationController: self, navigationItemModel: model, viewController: viewController) - Self.setNavigationBarUI(navigationController: self, navigationItemModel: model, viewController: viewController) + if let topViewController = topViewController, + let model = getNavigationModel(from: viewController) { + Self.setNavigationItem(navigationController: self, navigationItemModel: model, viewController: topViewController) + Self.setNavigationBarUI(navigationController: self, navigationItemModel: model, viewController: topViewController) + } manager?.newDataReceived?(in: viewController) } public func willDisplay(_ viewController: UIViewController) { - guard let topViewController = topViewController else { return } - if let model = Self.getNavigationModel(from: viewController) { + if let topViewController = topViewController, + let model = getNavigationModel(from: viewController) { Self.setNavigationItem(navigationController: self, navigationItemModel: model, viewController: topViewController) } manager?.willDisplay?(viewController) } public func displayedViewController(_ viewController: UIViewController) { - guard let topViewController = topViewController else { return } - if let model = Self.getNavigationModel(from: viewController) { + if let topViewController = topViewController, + let model = getNavigationModel(from: viewController) { Self.setNavigationBarUI(navigationController: self, navigationItemModel: model, viewController: topViewController) } manager?.displayedViewController?(viewController) @@ -161,18 +166,20 @@ extension NavigationController: MVMCorePresentationDelegateProtocol { if let controller = viewController as? (UIViewController & MVMCoreViewManagerViewControllerProtocol) { MVMCoreViewManagerViewControllerProtocolHelper.helpSetManager(self, viewController: controller) } - if let model = Self.getNavigationModel(from: viewController) { + guard let newViewController = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController) else { return } + if let model = getNavigationModel(from: newViewController) { Self.setNavigationItem(navigationController: self, navigationItemModel: model, viewController: viewController) } - manager?.willDisplay?(viewController) + manager?.willDisplay?(newViewController) } public func navigationController(_ navigationController: UINavigationController, displayedViewController viewController: UIViewController) { - guard self == navigationController else { return } - if let model = Self.getNavigationModel(from: viewController) { + guard self == navigationController, + let newViewController = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController) else { return } + if let model = getNavigationModel(from: newViewController) { Self.setNavigationBarUI(navigationController: self, navigationItemModel: model, viewController: viewController) } - manager?.displayedViewController?(viewController) + manager?.displayedViewController?(newViewController) if let controller = viewController as? (UIViewController & MVMCoreViewManagerViewControllerProtocol) { controller.viewControllerReady?(inManager: self) } diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift index b7e6ce6d..b1d1deac 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift @@ -15,9 +15,8 @@ public extension MVMCoreUISplitViewController { static func setNavigationBarUI(for viewController: UIViewController, navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol) { guard let splitView = MVMCoreUISplitViewController.main(), navigationController == splitView.navigationController, - navigationController.topViewController == viewController else { + viewController == MVMCoreUISplitViewController.main()?.getCurrentDetailViewController() else { /// Not the split view navigation controller, skip split functions. - NavigationController.setNavigationBarUI(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController) return } splitView.set(for: viewController, navigationController: navigationController, navigationItemModel: navigationItemModel) @@ -25,7 +24,6 @@ public extension MVMCoreUISplitViewController { /// Sets the navigation item for the view controller based on the model and splitview controller private func set(for viewController: UIViewController, navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol) { - setLeftPanelIsAccessible((viewController as? MVMCoreUIDetailViewProtocol)?.isLeftPanelAccessible?() ?? false, for: viewController, updateNavigationButtons: false) setRightPanelIsAccessible((viewController as? MVMCoreUIDetailViewProtocol)?.isRightPanelAccessible?() ?? false, for: viewController, updateNavigationButtons: false) @@ -37,6 +35,8 @@ public extension MVMCoreUISplitViewController { /// Sets the left navigation items for the view controller based on model and splitview. func setLeftNavigationButtons(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol?, viewController: UIViewController) { + guard let topViewController = navigationController.topViewController else { return } + var leftItems: [UIBarButtonItem] = [] let delegate = (viewController as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject @@ -75,11 +75,13 @@ public extension MVMCoreUISplitViewController { leftItems.append(contentsOf: additionalLeftButtons) } - navigationController.topViewController?.navigationItem.setLeftBarButtonItems(leftItems.count > 0 ? leftItems : nil, animated: !DisableAnimations.boolValue) + topViewController.navigationItem.setLeftBarButtonItems(leftItems.count > 0 ? leftItems : nil, animated: !DisableAnimations.boolValue) } /// Sets the right navigation items for the view controller based on model and splitview. func setRightNavigationButtons(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol?, viewController: UIViewController) { + guard let topViewController = navigationController.topViewController else { return } + let delegate = (viewController as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject var rightItems: [UIBarButtonItem] = [] @@ -102,19 +104,20 @@ public extension MVMCoreUISplitViewController { rightItems.append(contentsOf: additionalRightButtons) } - navigationController.topViewController?.navigationItem.setRightBarButtonItems(rightItems.count > 0 ? rightItems : nil, animated: !DisableAnimations.boolValue) + topViewController.navigationItem.setRightBarButtonItems(rightItems.count > 0 ? rightItems : nil, animated: !DisableAnimations.boolValue) } @objc func navigationBarModelExists() -> Bool { // Legacy Navigation - (navigationController?.topViewController as? PageProtocol)?.pageModel?.navigationBar != nil + guard let currentViewController = getCurrentDetailViewController(), + let _ = navigationController?.getNavigationModel(from: currentViewController) else { return false } + return true } - /// Convenience function to update the navigation + /// Convenience function to update the navigation bar for the @objc func updateNavigationBarFor(viewController: UIViewController) { - guard viewController == getCurrentDetailViewController(), - let navigationController = navigationController, - let model = NavigationController.getNavigationModel(from: viewController) else { return } + guard let navigationController = navigationController, + let model = navigationController.getNavigationModel(from: viewController) else { return } set(for: viewController, navigationController: navigationController, navigationItemModel: model) } } diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index ab44e181..5cc7156d 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -240,7 +240,7 @@ CGFloat const PanelAnimationDuration = 0.2; - (void)setLeftNavigationItemForViewController:(UIViewController * _Nonnull)viewController accessible:(BOOL)accessible extended:(BOOL)extended { NSMutableArray *leftBarButtonItems = [NSMutableArray array]; - if (viewController.navigationController && [MVMCoreNavigationHandler.sharedNavigationHandler getViewControllersForNavigationController:viewController.navigationController].count > 1) { + if (self.navigationController && [MVMCoreNavigationHandler.sharedNavigationHandler getViewControllersForNavigationController:self.navigationController].count > 1) { [leftBarButtonItems addObject:self.backButton]; } if ((accessible && !extended) && self.leftPanelButton) { @@ -250,7 +250,7 @@ CGFloat const PanelAnimationDuration = 0.2; if (extraButtons) { [leftBarButtonItems addObjectsFromArray:extraButtons]; } - [viewController.navigationItem setLeftBarButtonItems:(leftBarButtonItems.count > 0 ? leftBarButtonItems : nil) animated:!DisableAnimations]; + [self.navigationController.topViewController.navigationItem setLeftBarButtonItems:(leftBarButtonItems.count > 0 ? leftBarButtonItems : nil) animated:!DisableAnimations]; } - (void)setLeftPanelIsAccessible:(BOOL)leftPanelIsAccessible forViewController:(UIViewController *)viewController updateNavigationButtons:(BOOL)updateNavigationButtons { @@ -422,7 +422,7 @@ CGFloat const PanelAnimationDuration = 0.2; if (extraButtons) { [navigationItems addObjectsFromArray:extraButtons]; } - [viewController.navigationItem setRightBarButtonItems:(navigationItems.count > 0 ? navigationItems : nil) animated:!DisableAnimations]; + [self.navigationController.topViewController.navigationItem setRightBarButtonItems:(navigationItems.count > 0 ? navigationItems : nil) animated:!DisableAnimations]; } - (BOOL)shouldExtendRightPanel { @@ -991,7 +991,7 @@ CGFloat const PanelAnimationDuration = 0.2; - (void)resetDrawers { if (!self.navigationItemViewController) { return; } if ([self navigationBarModelExists]) { - [self updateNavigationBarForViewController:self.navigationItemViewController]; + [self updateNavigationBarForViewController:[MVMCoreUIUtility getViewControllerTraversingManagers:self.navigationItemViewController]]; } else { // Legacy [self setLeftPanelIsAccessible:self.leftPanelIsAccessible forViewController:self.navigationItemViewController updateNavigationButtons:YES]; From eb94c7eaff5b1ef33c3610209c74e944b1b972f1 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 22 Jun 2021 17:54:35 -0400 Subject: [PATCH 033/113] undo needless change --- .../SplitViewController/MVMCoreUISplitViewController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index 5cc7156d..20f0d227 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -991,7 +991,7 @@ CGFloat const PanelAnimationDuration = 0.2; - (void)resetDrawers { if (!self.navigationItemViewController) { return; } if ([self navigationBarModelExists]) { - [self updateNavigationBarForViewController:[MVMCoreUIUtility getViewControllerTraversingManagers:self.navigationItemViewController]]; + [self updateNavigationBarForViewController:self.navigationItemViewController]; } else { // Legacy [self setLeftPanelIsAccessible:self.leftPanelIsAccessible forViewController:self.navigationItemViewController updateNavigationButtons:YES]; From e372195f1584b4abc201b068128af668e692ce23 Mon Sep 17 00:00:00 2001 From: rajampetS Date: Wed, 23 Jun 2021 11:01:49 +0530 Subject: [PATCH 034/113] Removed tab changes --- .../Atomic/Molecules/HorizontalCombinationViews/Tabs.swift | 5 ----- 1 file changed, 5 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift index 7b59a6cb..804075ff 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift @@ -82,11 +82,9 @@ import UIKit let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) collectionView.translatesAutoresizingMaskIntoConstraints = false collectionView.register(TabItemCell.self, forCellWithReuseIdentifier: TabCellId) - collectionView.isUserInteractionEnabled = true collectionView.backgroundColor = .clear collectionView.showsVerticalScrollIndicator = false collectionView.showsHorizontalScrollIndicator = false - collectionView.isScrollEnabled = true collectionView.dataSource = self collectionView.delegate = self addSubview(collectionView) @@ -123,8 +121,6 @@ import UIKit //bottom line bottomLine.topAnchor.constraint(equalTo: bottomScrollView.bottomAnchor).isActive = true; NSLayoutConstraint.constraintPinSubview(bottomLine, pinTop: false, pinBottom: true, pinLeft: true, pinRight: true) - - self.collectionView?.delegate = self } //------------------------------------------------- @@ -296,7 +292,6 @@ extension Tabs { public override func setupView() { super.setupView() contentView.addSubview(label) - contentView.isUserInteractionEnabled = true NSLayoutConstraint.constraintPinSubview(label, pinTop: false, topConstant: 0, pinBottom: true, bottomConstant: 6, pinLeft: true, leftConstant: 0, pinRight: true, rightConstant: 0) label.baselineAdjustment = .alignCenters } From 8b3b4964b887b9128f461b802fb1abbdf631646f Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 23 Jun 2021 10:02:40 -0400 Subject: [PATCH 035/113] add missing number of lines --- MVMCoreUI/Atomic/Atoms/FormFields/Tags/Tag.swift | 1 - MVMCoreUI/Atomic/Atoms/FormFields/Tags/TagModel.swift | 6 ++++++ MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift | 1 + .../TopNotification/CollapsableNotificationModel.swift | 3 +++ .../TopNotification/CollapsableNotificationTopView.swift | 1 - 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/Tags/Tag.swift b/MVMCoreUI/Atomic/Atoms/FormFields/Tags/Tag.swift index bc905a79..c6f7144f 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/Tags/Tag.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/Tags/Tag.swift @@ -24,7 +24,6 @@ import Foundation super.setupView() layer.borderColor = UIColor.mvmCoolGray6.cgColor layer.borderWidth = 1 - label.numberOfLines = 1 addSubview(label) NSLayoutConstraint.constraintPinSubview(label, pinTop: true, topConstant: 13, pinBottom: true, bottomConstant: 13, pinLeft: true, leftConstant: 15, pinRight: true, rightConstant: 15) } diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/Tags/TagModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/Tags/TagModel.swift index e0247e71..56a86742 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/Tags/TagModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/Tags/TagModel.swift @@ -21,6 +21,12 @@ import Foundation case backgroundColor } + public func setDefaults() { + if label.numberOfLines == nil { + label.numberOfLines = 1 + } + } + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) label = try typeContainer.decode(LabelModel.self, forKey: .label) diff --git a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift index 18de25f1..065c502a 100644 --- a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift +++ b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift @@ -64,6 +64,7 @@ open class DoughnutChart: View { open override func reset() { super.reset() titleLabel.reset() + titleLabel.numberOfLines = 1 subTitleLabel.reset() clearLayers() } diff --git a/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationModel.swift b/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationModel.swift index bdcd3fe1..511f41a5 100644 --- a/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationModel.swift +++ b/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationModel.swift @@ -26,6 +26,9 @@ open class CollapsableNotificationModel: NotificationModel { open override func setDefaults() { super.setDefaults() + if topLabel.numberOfLines == nil { + topLabel.numberOfLines = 1 + } if topLabel.textColor == nil { topLabel.textColor = Color(uiColor: .white) } diff --git a/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationTopView.swift b/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationTopView.swift index c23edeae..b3223fc7 100644 --- a/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationTopView.swift +++ b/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationTopView.swift @@ -11,7 +11,6 @@ import Foundation @objcMembers open class CollapsableNotificationTopView: View { public let label: Label = { let label = Label(fontStyle: .BoldBodySmall) - label.numberOfLines = 1 label.textAlignment = .center label.setContentHuggingPriority(.defaultHigh, for: .vertical) return label From 91df3b197d9ea47ab306da45943016bd26b5d903 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 23 Jun 2021 10:18:08 -0400 Subject: [PATCH 036/113] comment fix --- .../MVMCoreUISplitViewController+Extension.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift index b1d1deac..bb1b24d5 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift @@ -114,7 +114,7 @@ public extension MVMCoreUISplitViewController { return true } - /// Convenience function to update the navigation bar for the + /// Convenience function to update the navigation bar if the controller is the current lowest controller. @objc func updateNavigationBarFor(viewController: UIViewController) { guard let navigationController = navigationController, let model = navigationController.getNavigationModel(from: viewController) else { return } From cb2fabd282a8cf50af8dac83dc9b5180904ccccf Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 23 Jun 2021 11:50:26 -0400 Subject: [PATCH 037/113] fixes --- .../H2/HeadersH2PricingTwoRowsModel.swift | 26 +++++++------------ .../Miscellaneous/ListStoreLocatorModel.swift | 14 +++------- 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRowsModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRowsModel.swift index b608ba41..5ca1eae1 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRowsModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRowsModel.swift @@ -21,23 +21,6 @@ public class HeadersH2PricingTwoRowsModel: HeaderModel, MoleculeModelProtocol { public var body3: LabelModel public var subBody3: LabelModel? - //----------------------------------------------------- - // MARK: - Methods - //----------------------------------------------------- - - override public func setDefaults() { - super.setDefaults() - if body.numberOfLines == nil { - body.numberOfLines = 1 - } - if body2.numberOfLines == nil { - body2.numberOfLines = 1 - } - if body3.numberOfLines == nil { - body3.numberOfLines = 1 - } - } - //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- @@ -66,6 +49,15 @@ public class HeadersH2PricingTwoRowsModel: HeaderModel, MoleculeModelProtocol { subBody?.attributes = [LabelAttributeStrikeThroughModel(0, subBody?.text.count ?? 0)] subBody2?.attributes = [LabelAttributeStrikeThroughModel(0, subBody2?.text.count ?? 0)] subBody3?.attributes = [LabelAttributeStrikeThroughModel(0, subBody3?.text.count ?? 0)] + if body.numberOfLines == nil { + body.numberOfLines = 1 + } + if body2.numberOfLines == nil { + body2.numberOfLines = 1 + } + if body3.numberOfLines == nil { + body3.numberOfLines = 1 + } } //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift index d690d681..44c4ef90 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift @@ -18,17 +18,6 @@ public class ListStoreLocatorModel: ListItemModel, MoleculeModelProtocol { public var leftSubBody: LabelModel public var rightLabel: LabelModel - //----------------------------------------------------- - // MARK: - Methods - //----------------------------------------------------- - - override public func setDefaults() { - super.setDefaults() - if rightLabel.numberOfLines == nil { - rightLabel.numberOfLines = 1 - } - } - //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- @@ -49,6 +38,9 @@ public class ListStoreLocatorModel: ListItemModel, MoleculeModelProtocol { override public func setDefaults() { super.setDefaults() leftHeadline.hero = 0 + if rightLabel.numberOfLines == nil { + rightLabel.numberOfLines = 1 + } } //-------------------------------------------------- From 5947e5c1ade83b90cbdfe80ea5296f71ff2d1a85 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 24 Jun 2021 12:12:54 -0400 Subject: [PATCH 038/113] updated name --- MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift b/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift index e9ffce2c..d16c6cd6 100644 --- a/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift +++ b/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift @@ -9,7 +9,7 @@ /// Protocol to apply to any model of a UI Control with a binary on/off nature. /// /// Example classes: Checkbox or Toggle. -@objc public protocol SelectableMoleculeModel: AnyObject { +@objc public protocol SelectableMoleculeModelProtocol: AnyObject { @objc dynamic var selected: Bool { get set } } From 90e6dfd08429b38e63e90110acb827230c1ab017 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 24 Jun 2021 13:59:37 -0400 Subject: [PATCH 039/113] nav dev --- MVMCoreUI.xcodeproj/project.pbxproj | 4 + .../Atoms/Selectors/CheckboxModel.swift | 2 +- .../Atomic/Atoms/Selectors/ToggleModel.swift | 2 +- .../SelectAllNavigationLabelButton.swift | 82 +++++++++++++++++++ .../Behaviors/SelectAllBoxesBehavior.swift | 61 ++++---------- .../OtherHandlers/CoreUIModelMapping.swift | 1 + 6 files changed, 105 insertions(+), 47 deletions(-) create mode 100644 MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/SelectAllNavigationLabelButton.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index b90b6f5e..281a6ffc 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -74,6 +74,7 @@ 0A25209824645B76000FA9F6 /* TextViewEntryFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A25209724645B76000FA9F6 /* TextViewEntryFieldModel.swift */; }; 0A41BA6E2344FCD400D4C0BC /* CATransaction+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */; }; 0A41BA7F23453A6400D4C0BC /* TextEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A41BA7E23453A6400D4C0BC /* TextEntryField.swift */; }; + 0A423A202684E7A0008EC258 /* SelectAllNavigationLabelButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A423A1F2684E7A0008EC258 /* SelectAllNavigationLabelButton.swift */; }; 0A51F3E22475CB73002E08B6 /* LoadingSpinnerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A51F3E02475CB73002E08B6 /* LoadingSpinnerModel.swift */; }; 0A51F3E32475CB73002E08B6 /* LoadingSpinner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A51F3E12475CB73002E08B6 /* LoadingSpinner.swift */; }; 0A5D59C223AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */; }; @@ -636,6 +637,7 @@ 0A25209724645B76000FA9F6 /* TextViewEntryFieldModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextViewEntryFieldModel.swift; sourceTree = ""; }; 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CATransaction+Extension.swift"; sourceTree = ""; }; 0A41BA7E23453A6400D4C0BC /* TextEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextEntryField.swift; sourceTree = ""; }; + 0A423A1F2684E7A0008EC258 /* SelectAllNavigationLabelButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectAllNavigationLabelButton.swift; sourceTree = ""; }; 0A51F3E02475CB73002E08B6 /* LoadingSpinnerModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoadingSpinnerModel.swift; sourceTree = ""; }; 0A51F3E12475CB73002E08B6 /* LoadingSpinner.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoadingSpinner.swift; sourceTree = ""; }; 0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppleGuidelinesProtocol.swift; sourceTree = ""; }; @@ -1755,6 +1757,7 @@ D23EA801247EBED400D60C34 /* ImageBarButtonItem.swift */, D23EA7FD247EBBB700D60C34 /* NavigationLabelButtonModel.swift */, D23EA7FF247EBD6C00D60C34 /* LabelBarButtonItem.swift */, + 0A423A1F2684E7A0008EC258 /* SelectAllNavigationLabelButton.swift */, ); path = Buttons; sourceTree = ""; @@ -2730,6 +2733,7 @@ D264FA8E243BCD9A00D98315 /* CollectionTemplate.swift in Sources */, 0A7EF85B23D8A52800B2AAD1 /* EntryFieldModel.swift in Sources */, AA633B3124989EC000731E80 /* HeadersH2PricingTwoRowsModel.swift in Sources */, + 0A423A202684E7A0008EC258 /* SelectAllNavigationLabelButton.swift in Sources */, 8DEFA95C243DAC20000D27E5 /* ListThreeColumnDataUsageDividerModel.swift in Sources */, D2092357244FA1EF0044AD09 /* ThreeLayerModelBase.swift in Sources */, D2FD4A4925199BD9000C28A9 /* AccessibilityProtocol.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift index 4efa53ec..87c4568d 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift @@ -7,7 +7,7 @@ // -@objcMembers public class CheckboxModel: NSObject, MoleculeModelProtocol, SelectableMoleculeModel, FormFieldProtocol { +@objcMembers public class CheckboxModel: NSObject, MoleculeModelProtocol, SelectableMoleculeModelProtocol, FormFieldProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift index 88f193f5..0fb42632 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift @@ -7,7 +7,7 @@ // -public class ToggleModel: NSObject, MoleculeModelProtocol, FormFieldProtocol, EnableableModelProtocol, SelectableMoleculeModel { +public class ToggleModel: NSObject, MoleculeModelProtocol, FormFieldProtocol, EnableableModelProtocol, SelectableMoleculeModelProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/SelectAllNavigationLabelButton.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/SelectAllNavigationLabelButton.swift new file mode 100644 index 00000000..f166e9fb --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/SelectAllNavigationLabelButton.swift @@ -0,0 +1,82 @@ +// +// SelectAllNavigationLabelButton.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 6/24/21. +// Copyright © 2021 Verizon Wireless. All rights reserved. +// + + +public class SelectAllNavigationLabelButton: NavigationButtonModelProtocol, MoleculeModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public var backgroundColor: Color? + public static var identifier: String = "selectAllNavigationLabelButton" + public var accessibilityIdentifier: String? + public var willSelect: Bool + public var selectAllTitle: String = "Select All" + public var deselectAllTitle: String = "Deselect All" + public var action: ActionModelProtocol + + public var selectionTitle: String { + willSelect ? selectAllTitle : deselectAllTitle + } + + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(willSelect: Bool, selectAllTitle: String, deselectAllTitle: String, action: ActionModelProtocol) { + self.willSelect = willSelect + self.action = action + self.selectAllTitle = selectAllTitle + self.deselectAllTitle = deselectAllTitle + } + + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + + private enum CodingKeys: String, CodingKey { + case moleculeName + case accessibilityIdentifier + case willSelect + case selectAllTitle + case deselectAllTitle + case action + } + + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier) + selectAllTitle = try typeContainer.decode(String.self, forKey: .selectAllTitle) + deselectAllTitle = try typeContainer.decode(String.self, forKey: .deselectAllTitle) + willSelect = try typeContainer.decode(Bool.self, forKey: .willSelect) + action = try typeContainer.decodeModel(codingKey: .action) + } + + open func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) + try container.encode(selectAllTitle, forKey: .selectAllTitle) + try container.encode(deselectAllTitle, forKey: .deselectAllTitle) + try container.encode(willSelect, forKey: .willSelect) + try container.encodeModel(action, forKey: .action) + } + + //-------------------------------------------------- + // MARK: - Methods + //-------------------------------------------------- + + /// Convenience function that creates a BarButtonItem for the model. + public func createNavigationItemButton(delegateObject: MVMCoreUIDelegateObject? = nil, additionalData: [AnyHashable: Any]? = nil) -> UIBarButtonItem { + LabelBarButtonItem.create(with: selectionTitle, actionModel: action, delegateObject: delegateObject, additionalData: additionalData) + } +} diff --git a/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift b/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift index d16c6cd6..9b50a4a2 100644 --- a/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift +++ b/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift @@ -16,36 +16,7 @@ public class SelectAllBoxesBehaviorModel: PageBehaviorModelProtocol { public class var identifier: String { "pageSelectAllBoxesBehavior" } public var shouldAllowMultipleInstances: Bool { false } - public var selectAllTitle: String = "Select All" - public var deselectAllTitle: String = "Deselect All" public init() { } - - //-------------------------------------------------- - // MARK: - Codable - //-------------------------------------------------- - - private enum CodingKeys: String, CodingKey { - case selectAllTitle - case deselectAllTitle - } - - required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - - if let selectAllTitle = try typeContainer.decodeIfPresent(String.self, forKey: .selectAllTitle) { - self.selectAllTitle = selectAllTitle - } - - if let deselectAllTitle = try typeContainer.decodeIfPresent(String.self, forKey: .deselectAllTitle) { - self.deselectAllTitle = deselectAllTitle - } - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(selectAllTitle, forKey: .selectAllTitle) - try container.encode(deselectAllTitle, forKey: .deselectAllTitle) - } } /// Selects all the control models presented on a page. @@ -83,7 +54,7 @@ public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior, PageMolecu public func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject) { - let selectableModels: [(NSObject & SelectableMoleculeModel)] = rootMolecules.allMoleculesOfType() + let selectableModels: [(NSObject & SelectableMoleculeModelProtocol)] = rootMolecules.allMoleculesOfType() guard !selectableModels.isEmpty else { return } @@ -95,7 +66,7 @@ public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior, PageMolecu } } - func setObserver(_ model: T, fieldKey: String) where T: (NSObject & SelectableMoleculeModel) { + func setObserver(_ model: T, fieldKey: String) where T: (NSObject & SelectableMoleculeModelProtocol) { observers[fieldKey] = model.observe(\.selected, options: [.new]) { [weak self] model, change in guard let self = self, @@ -137,7 +108,7 @@ public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior, PageMolecu // Verify we have the correct action type and necessary values. guard actionType == "selectAllBoxes", - let selectableModels: [SelectableMoleculeModel] = delegate?.moleculeDelegate?.getRootMolecules().allMoleculesOfType(), + let selectableModels: [SelectableMoleculeModelProtocol] = delegate?.moleculeDelegate?.getRootMolecules().allMoleculesOfType(), !selectableModels.isEmpty else { return false } @@ -170,20 +141,20 @@ public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior, PageMolecu /// Updates the navigation UI to correctly reflect the behavior's state. func updatePageNavigationUI() { - guard let model = model as? SelectAllBoxesBehaviorModel else { return } - let navButtonTitle: String? = didSelectAllState ? model.deselectAllTitle : model.selectAllTitle +// let navButtonTitle: String? = didSelectAllState ? model.deselectAllTitle : model.selectAllTitle + // TODO: update - MVMCoreDispatchUtility.performBlock(onMainThread: { [weak self] in - guard let controller = self?.delegate?.moleculeDelegate as? ViewController else { return } - controller.handleNewDataAndUpdateUI() - - if MVMCoreUIUtility.getCurrentVisibleController() == controller { - controller.navigationItem.rightBarButtonItem?.title = navButtonTitle - controller.manager?.refreshNavigationUI() - } - }) +// MVMCoreDispatchUtility.performBlock(onMainThread: { [weak self] in +// guard let controller = self?.delegate?.moleculeDelegate as? PageProtocol else { return } +// controller.handleNewDataAndUpdateUI() +// let n = controller.getNavigationModel() +// let r = n?.additionalRightButtons +// for i in r! { +// i.moleculeName +// } +// }) } /// Convenience function for readability to confirmt he state of the behavior. @@ -201,14 +172,14 @@ public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior, PageMolecu /// Convenience function making it easier to read if a current selectable model should be acted on. /// - Parameter model: A model object assined to the SelectableModel protocol /// - Returns: Boolean determining if the passed model should be selected. - func toSelect(model: SelectableMoleculeModel) -> Bool { + func toSelect(model: SelectableMoleculeModelProtocol) -> Bool { didSelectAllState && !model.selected } /// Convenience function making it easier to read if a current selectable model should be acted on. /// - Parameter model: A model object assined to the SelectableModel protocol /// - Returns: Boolean determining if the passed model should be deselected. - func toDeselect(model: SelectableMoleculeModel) -> Bool { + func toDeselect(model: SelectableMoleculeModelProtocol) -> Bool { !didSelectAllState && model.selected } } diff --git a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift index 437b2e01..f33943e1 100644 --- a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift @@ -129,6 +129,7 @@ open class CoreUIModelMapping: ModelMapping { try? ModelRegistry.register(NavigationItemModel.self) try? ModelRegistry.register(NavigationImageButtonModel.self) try? ModelRegistry.register(NavigationLabelButtonModel.self) + try? ModelRegistry.register(SelectAllNavigationLabelButton.self) // MARK:- Other Organisms try? ModelRegistry.register(handler: Carousel.self, for: CarouselModel.self) From 1109931d8e6f294a8c5340ba90351ae16194034d Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 24 Jun 2021 14:30:49 -0400 Subject: [PATCH 040/113] removed commented code. --- MVMCoreUI/Behaviors/PlayAudioBehavior.swift | 156 -------------------- 1 file changed, 156 deletions(-) diff --git a/MVMCoreUI/Behaviors/PlayAudioBehavior.swift b/MVMCoreUI/Behaviors/PlayAudioBehavior.swift index 7ea37809..b555eb01 100644 --- a/MVMCoreUI/Behaviors/PlayAudioBehavior.swift +++ b/MVMCoreUI/Behaviors/PlayAudioBehavior.swift @@ -71,160 +71,4 @@ public class PagePlayAudioBehavior: PageCustomActionHandlerBehavior { public func onPageHidden(_ delegateObject: MVMCoreUIDelegateObject?) { // TODO: Stop player } - - -// func saveVoicemailToDocumentDirectory(voicemail:String) -> URL { -// let voicemailUrl = URL(string: "fileNotFound")! -// ///Setting Voicemail Path -// -// let cacheDirectory = NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true).first as NSString? -// -// if let cachePath = cacheDirectory?.appendingPathComponent("fdv.voicemails"), !FileManager.default.fileExists(atPath: cachePath) { -// do{ -// try FileManager.default.createDirectory(atPath: cachePath, withIntermediateDirectories: false, attributes: nil) -// } catch let error as NSError { -// MVMCoreLoggingHandler.logDebugMessage(withDelegate: error.debugDescription) -// } -// } -// let fileName = cacheDirectory?.appendingPathComponent("fdv.voicemails").appending("/VM_1.wmv") -//#warning("Pending task to check if we can protect the voicemail data") -// -// let voicemailData = Data(base64Encoded: voicemail) -// do{ -// if let _fileName = fileName, let fileUrl = URL(string: _fileName) { -// try voicemailData?.write(to: fileUrl, options: .completeFileProtection) -// return fileUrl -// } -// } catch let error as NSError { -// MVMCoreLoggingHandler.logDebugMessage(withDelegate: error.debugDescription) -// } -// return voicemailUrl -// } - - -// NSDictionary *completeProtection = [NSDictionary dictionaryWithObject:NSFileProtectionComplete forKey:NSFileProtectionKey]; -// [[NSFileManager defaultManager] setAttributes:completeProtection ofItemAtPath:appFile error:nil]; -// return ([data writeToFile:appFile atomically:YES]); - - -// func downloadVoicemail(url: URL?) { -// -// let downloadTask = URLSession.shared.downloadTask(with: url!) { url, response, error in -// guard error == nil, let fileURL = url else { return } -// do { -// let documentsURL = try FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false) -// let savedURL = documentsURL.appendingPathComponent(fileURL.lastPathComponent) -// try FileManager.default.moveItem(at: fileURL, to: savedURL) -// -// } catch let error as NSError { -// MVMCoreLoggingHandler.logDebugMessage(withDelegate: error.debugDescription) -// } -// } -// downloadTask.resume() -// } - -/* - // https://oneconfluence.verizon.com/pages/viewpage.action?spaceKey=EIM&title=FDV+API - - /// The directory to store all downloaded voicemails. - func voicemailDirectory() -> URL? { - - guard let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else { return nil } - return documentsURL.appendingPathComponent("fios_vm") - } - - func voicemailListQuery(accountId: String, sourceIP: String, mdn: String, mailBoxNo: String, timeZone: String) { - - let url = URL(string: "")! - var request = URLRequest(url: url) - request.httpMethod = "POST" - - let task = URLSession.shared.dataTask(with: request) { data, response, error in - // do something with the result - // print(data) -// if let data = data { - // TODO: Receive List of MDNs - // if let data = data, let dataString = String(data: data, encoding: .utf8) { - // print("Response data string:\n \(dataString)") - // } - // print(String(data: data, encoding: .utf8)) -// } else { - // print("no data") -// } - } - - task.resume() - - } - - func fetchVoicemail(accountId: String, sourceIP: String, mdn: String, mailBoxNo: String) { - -// guard let messageID = messageID else { return } - - let url = URL(string: "")! - var request = URLRequest(url: url) - request.httpMethod = "POST" - - let task = URLSession.shared.dataTask(with: request) { data, response, error in - // do something with the result - // print(data) -// if let data = data { - //body/VoiceMailMessages/Stream/TN/VMID/Audio/bin - // TODO: Receive List of MDNs - // if let data = data, let dataString = String(data: data, encoding: .utf8) { - // print("Response data string:\n \(dataString)") - // } - // print(String(data: data, encoding: .utf8)) -// } else { - // print("no data") -// } - } - - task.resume() - - // TODO: Fetch Audio file. - } - - func downloadVoicemail(url: URL?) { - - let downloadTask = URLSession.shared.downloadTask(with: url!) { [weak self] url, response, error in - guard error == nil, - let fileURL = url - else { return } - - do { - // "data/user/0/com.verizon.myfios/files/VM_INBOX-8711.wav" - let documentsURL = try FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false) - let savedURL = documentsURL.appendingPathComponent(fileURL.lastPathComponent) - try FileManager.default.moveItem(at: fileURL, to: savedURL) - self?.audioFilePath = savedURL - } catch let error as NSError { - MVMCoreLoggingHandler.logDebugMessage(withDelegate: error.debugDescription) - } - } - downloadTask.resume() - } - - func fetchAudioFilePath() { - - guard let messageID = messageID, // "INBOX-8711" - let cleanMDN = cleanMDN, // "4124712342" - let destinationURL = voicemailDirectory() - else { return } - - let uri = "com.verizon.fios.voice2/downloadvm?VM_DOWNLOAD_URI_DATA_MESSAGE_ID=\(messageID)&VM_DOWNLOAD_URI_DATA_TN=\(cleanMDN)" - let url = URL(string: uri) - - - // TODO: First check to see if the file is stored on disk, if not, then downloaded. - createDirectoryIfNeeded(url: destinationURL) - - if FileManager.default.fileExists(atPath: destinationURL.path) { - audioFilePath = destinationURL - - } else { - downloadVoicemail(url: url) - } - } - */ } From e79c1591387c1ade95bcf2586713d67ceec96988 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 24 Jun 2021 16:30:52 -0400 Subject: [PATCH 041/113] select all behavior. --- .../SelectAllNavigationLabelButton.swift | 8 +-- .../Behaviors/SelectAllBoxesBehavior.swift | 68 +++++++++++-------- 2 files changed, 42 insertions(+), 34 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/SelectAllNavigationLabelButton.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/SelectAllNavigationLabelButton.swift index f166e9fb..59bf6136 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/SelectAllNavigationLabelButton.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/SelectAllNavigationLabelButton.swift @@ -15,7 +15,7 @@ public class SelectAllNavigationLabelButton: NavigationButtonModelProtocol, Mole public var backgroundColor: Color? public static var identifier: String = "selectAllNavigationLabelButton" public var accessibilityIdentifier: String? - public var willSelect: Bool + public var willSelect: Bool = true public var selectAllTitle: String = "Select All" public var deselectAllTitle: String = "Deselect All" public var action: ActionModelProtocol @@ -44,7 +44,7 @@ public class SelectAllNavigationLabelButton: NavigationButtonModelProtocol, Mole case accessibilityIdentifier case willSelect case selectAllTitle - case deselectAllTitle + case deSelectAllTitle case action } @@ -56,7 +56,7 @@ public class SelectAllNavigationLabelButton: NavigationButtonModelProtocol, Mole let typeContainer = try decoder.container(keyedBy: CodingKeys.self) accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier) selectAllTitle = try typeContainer.decode(String.self, forKey: .selectAllTitle) - deselectAllTitle = try typeContainer.decode(String.self, forKey: .deselectAllTitle) + deselectAllTitle = try typeContainer.decode(String.self, forKey: .deSelectAllTitle) willSelect = try typeContainer.decode(Bool.self, forKey: .willSelect) action = try typeContainer.decodeModel(codingKey: .action) } @@ -66,7 +66,7 @@ public class SelectAllNavigationLabelButton: NavigationButtonModelProtocol, Mole try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encode(selectAllTitle, forKey: .selectAllTitle) - try container.encode(deselectAllTitle, forKey: .deselectAllTitle) + try container.encode(deselectAllTitle, forKey: .deSelectAllTitle) try container.encode(willSelect, forKey: .willSelect) try container.encodeModel(action, forKey: .action) } diff --git a/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift b/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift index 9b50a4a2..1f7326fd 100644 --- a/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift +++ b/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift @@ -26,7 +26,10 @@ public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior, PageMolecu //-------------------------------------------------- /// Status of the select all behavior. Initially false as the action has not been enaged. - var didSelectAllState = false + var willSelectAllState: Bool { + get { getSelectAllNavbutton()?.willSelect ?? false } + set { getSelectAllNavbutton()?.willSelect = newValue } + } /// Reference to the general PageBehaviorModel. var model: PageBehaviorModelProtocol @@ -57,7 +60,7 @@ public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior, PageMolecu let selectableModels: [(NSObject & SelectableMoleculeModelProtocol)] = rootMolecules.allMoleculesOfType() guard !selectableModels.isEmpty else { return } - + for model in selectableModels { if let key = (model as? FormFieldProtocol)?.fieldKey { valuesMirror[key] = model.selected @@ -77,10 +80,10 @@ public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior, PageMolecu // If all are models are in the opposite state of the behavior, then realign. if self.selectAllIsMisaligned() { - self.realignPageBehavior(asSelectAll: true) + self.realignPageBehaviorAs(willSelectAll: false) } else if self.deselectAllIsMisaligned() { - self.realignPageBehavior(asSelectAll: false) + self.realignPageBehaviorAs(willSelectAll: true) } } } @@ -112,13 +115,13 @@ public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior, PageMolecu !selectableModels.isEmpty else { return false } - // Flip the selected state of the behavior. - didSelectAllState.toggle() + // Hold value dues to asynch behavior of page refreshing. + let newSelectedState = willSelectAllState // Iterate through selectable molecules. for selectableModel in selectableModels { if toSelect(model: selectableModel) || toDeselect(model: selectableModel) { - selectableModel.selected = didSelectAllState + selectableModel.selected = newSelectedState } } @@ -130,56 +133,61 @@ public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior, PageMolecu // MARK: - Methods //-------------------------------------------------- + func getSelectAllNavbutton() -> SelectAllNavigationLabelButton? { + guard let controller = self.delegate?.moleculeDelegate as? PageProtocol, + let rightNavButtonModels = controller.pageModel?.navigationBar?.additionalRightButtons + else { return nil } + + var navButton: SelectAllNavigationLabelButton? = nil + + for navModel in rightNavButtonModels { + if let model = navModel as? SelectAllNavigationLabelButton { + navButton = model + } + } + + return navButton + } + /// In the event that the user manually selects or deselects all `SelectableMoleculeModel` /// the behavior will need to reflect the inverse of its previously expected action. /// Initiates the navigation and page behavior realignment - /// - Parameter asSelectAll: The actual value didSelectAllState ought to be. - func realignPageBehavior(asSelectAll: Bool) { - didSelectAllState = asSelectAll + /// - Parameter asSelectAll: The actual value willSelectAllState ought to be. + func realignPageBehaviorAs(willSelectAll: Bool) { + willSelectAllState = willSelectAll updatePageNavigationUI() } /// Updates the navigation UI to correctly reflect the behavior's state. func updatePageNavigationUI() { - guard let model = model as? SelectAllBoxesBehaviorModel else { return } - -// let navButtonTitle: String? = didSelectAllState ? model.deselectAllTitle : model.selectAllTitle - // TODO: update - -// MVMCoreDispatchUtility.performBlock(onMainThread: { [weak self] in -// guard let controller = self?.delegate?.moleculeDelegate as? PageProtocol else { return } -// controller.handleNewDataAndUpdateUI() -// let n = controller.getNavigationModel() -// let r = n?.additionalRightButtons -// for i in r! { -// i.moleculeName -// } -// }) + MVMCoreDispatchUtility.performBlock(onMainThread: { [weak self] in + (self?.delegate?.moleculeDelegate as? ViewController)?.handleNewDataAndUpdateUI() + }) } /// Convenience function for readability to confirmt he state of the behavior. - /// - Returns: Boolean indicating that the behavior's `didSelectAllState` is false while all model values are true (selected). + /// - Returns: Boolean indicating that the behavior's `willSelectAllState` is false while all model values are true (selected). func selectAllIsMisaligned() -> Bool { - !didSelectAllState && valuesMirror.values.allSatisfy { $0 == true } + willSelectAllState && valuesMirror.values.allSatisfy { $0 == true } } /// Convenience function for readability to confirmt he state of the behavior. - /// - Returns: Boolean indicating that the behavior's `didSelectAllState` is true while all model values are false (deselected). + /// - Returns: Boolean indicating that the behavior's `willSelectAllState` is true while all model values are false (deselected). func deselectAllIsMisaligned() -> Bool { - didSelectAllState && valuesMirror.values.allSatisfy { $0 == false } + !willSelectAllState && valuesMirror.values.allSatisfy { $0 == false } } /// Convenience function making it easier to read if a current selectable model should be acted on. /// - Parameter model: A model object assined to the SelectableModel protocol /// - Returns: Boolean determining if the passed model should be selected. func toSelect(model: SelectableMoleculeModelProtocol) -> Bool { - didSelectAllState && !model.selected + willSelectAllState && !model.selected } /// Convenience function making it easier to read if a current selectable model should be acted on. /// - Parameter model: A model object assined to the SelectableModel protocol /// - Returns: Boolean determining if the passed model should be deselected. func toDeselect(model: SelectableMoleculeModelProtocol) -> Bool { - !didSelectAllState && model.selected + !willSelectAllState && model.selected } } From ada936eff64f28e884a734c17f780a5331c32fff Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Mon, 28 Jun 2021 22:39:22 +0530 Subject: [PATCH 042/113] Comments update --- MVMCoreUI/Behaviors/PlayAudioBehavior.swift | 4 ---- 1 file changed, 4 deletions(-) diff --git a/MVMCoreUI/Behaviors/PlayAudioBehavior.swift b/MVMCoreUI/Behaviors/PlayAudioBehavior.swift index b555eb01..4775d131 100644 --- a/MVMCoreUI/Behaviors/PlayAudioBehavior.swift +++ b/MVMCoreUI/Behaviors/PlayAudioBehavior.swift @@ -53,7 +53,6 @@ public class PagePlayAudioBehavior: PageCustomActionHandlerBehavior { public func handleAction(type actionType: String?, information: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) -> Bool { guard actionType == "playAudio" else { return false } - // TODO: Impose Activity Indicator. // Update the model. play -> pause OR pause -> play if Self.activeAudioPlayerDelegate?.isPlaying ?? false { @@ -62,9 +61,6 @@ public class PagePlayAudioBehavior: PageCustomActionHandlerBehavior { } else { Self.activeAudioPlayerDelegate?.play() } - - // TODO: Tell Template to update this cell (needs to be built). Currently it updates all cells. - return true } From ffa4719a950c120e643d249ef7352bc640cc3ccc Mon Sep 17 00:00:00 2001 From: rajampetS Date: Tue, 29 Jun 2021 13:54:49 +0530 Subject: [PATCH 043/113] moved image button to coreui --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ++ .../Atomic/Atoms/Buttons/ImageButton.swift | 54 +++++++++++ .../Atoms/Buttons/ImageButtonModel.swift | 95 +++++++++++++++++++ .../OtherHandlers/CoreUIModelMapping.swift | 1 + 4 files changed, 158 insertions(+) create mode 100644 MVMCoreUI/Atomic/Atoms/Buttons/ImageButton.swift create mode 100644 MVMCoreUI/Atomic/Atoms/Buttons/ImageButtonModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index c9833c3f..15f22974 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -121,6 +121,8 @@ 0AE98BB323FF0934004C5109 /* ExternalLinkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE98BB223FF0934004C5109 /* ExternalLinkModel.swift */; }; 0AE98BB523FF18D2004C5109 /* Arrow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE98BB423FF18D2004C5109 /* Arrow.swift */; }; 0AE98BB723FF18E9004C5109 /* ArrowModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE98BB623FF18E9004C5109 /* ArrowModel.swift */; }; + 1D6D258826899B0C00DEBB08 /* ImageButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D6D258626899B0B00DEBB08 /* ImageButtonModel.swift */; }; + 1D6D258926899B0C00DEBB08 /* ImageButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D6D258726899B0B00DEBB08 /* ImageButton.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 */; }; @@ -684,6 +686,8 @@ 0AE98BB223FF0934004C5109 /* ExternalLinkModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExternalLinkModel.swift; sourceTree = ""; }; 0AE98BB423FF18D2004C5109 /* Arrow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Arrow.swift; sourceTree = ""; }; 0AE98BB623FF18E9004C5109 /* ArrowModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArrowModel.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; }; 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 = ""; }; @@ -1289,6 +1293,8 @@ 0AE98BAD23FEF92B004C5109 /* Link */ = { isa = PBXGroup; children = ( + 1D6D258726899B0B00DEBB08 /* ImageButton.swift */, + 1D6D258626899B0B00DEBB08 /* ImageButtonModel.swift */, D28A838823CCCFCB00DFE4FC /* LinkModel.swift */, C07065C32395677300FBF997 /* Link.swift */, 0AE98BB223FF0934004C5109 /* ExternalLinkModel.swift */, @@ -2884,6 +2890,7 @@ D2C78CD224228BBD00B69FDE /* ActionOpenPanelModel.swift in Sources */, AA617AB02453010A00910B8F /* ListDeviceComplexLinkSmall.swift in Sources */, D23A8FD9260CE004007E14CE /* MFStyler+PaddingExtension.swift in Sources */, + 1D6D258926899B0C00DEBB08 /* ImageButton.swift in Sources */, C695A68123C9830D00BFB94E /* NumberedListModel.swift in Sources */, 01EB3684236097C0006832FA /* MoleculeModelProtocol.swift in Sources */, D27CD4102339057800C1DC07 /* EyebrowHeadlineBodyLink.swift in Sources */, @@ -2928,6 +2935,7 @@ BB2BF0EC2452A9D5001D0FC2 /* ListDeviceComplexButtonSmallModel.swift in Sources */, 943784F6236B77BB006A1E82 /* WheelAnimationHandler.swift in Sources */, 011D95A1240453D0000E3791 /* RuleEqualsModel.swift in Sources */, + 1D6D258826899B0C00DEBB08 /* ImageButtonModel.swift in Sources */, AA07EA912510A442009A2AE3 /* StarModel.swift in Sources */, D29DF2AA21E7B2F9003B2FB9 /* MVMCoreUIConstants.m in Sources */, 011D95892404249B000E3791 /* FormHolderModelProtocol.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ImageButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ImageButton.swift new file mode 100644 index 00000000..2d71ee6e --- /dev/null +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ImageButton.swift @@ -0,0 +1,54 @@ +// +// ImageButton.swift +// MobileFirstFramework +// +// Created by Chintakrinda, Arun Kumar (Arun) on 07/10/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers open class ImageButton: Button { + + public let image = LoadImageView(pinnedEdges: .all) + + open override func setupView() { + super.setupView() + insertSubview(image, at: 0) + image.isUserInteractionEnabled = false + NSLayoutConstraint.constraintPinSubview(toSuperview: image) + } + + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + guard let castModel = model as? ImageButtonModel else { + super.set(with: model, delegateObject, additionalData) + return + } + image.setOptional(with: castModel.image, delegateObject, additionalData) + castModel.updateUI = { [weak self] in + MVMCoreDispatchUtility.performBlock(onMainThread: { + self?.setState() + }) + } + + super.set(with: model, delegateObject, additionalData) + FormValidator.setupValidation(for: castModel, delegate: delegateObject?.formHolderDelegate) + + } + + private func setState() { + guard let castModel = model as? ImageButtonModel else { + return + } + if castModel.enabled { + if let enabledTintColor = castModel.enabledTintColor { + image.imageView.tintColor = enabledTintColor.uiColor + } + } else if let disabledTintColor = castModel.disabledTintColor { + image.imageView.tintColor = disabledTintColor.uiColor + } + } + + + +} diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ImageButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ImageButtonModel.swift new file mode 100644 index 00000000..d8217d0d --- /dev/null +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ImageButtonModel.swift @@ -0,0 +1,95 @@ +// +// ImageButtonModel.swift +// MobileFirstFramework +// +// Created by Chintakrinda, Arun Kumar (Arun) on 07/10/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +open class ImageButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWatcherFieldProtocol, EnableableModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public static var identifier: String = "imageButton" + public var backgroundColor: Color? + + public var image: ImageViewModel? + + public var accessibilityText: String? + public var action: ActionModelProtocol + public var enabled: Bool = true + public var enabledTintColor: Color? + public var disabledTintColor: Color? + + public var groupName: String = "" + + public func setValidity(_ valid: Bool, group: FormGroupRule) { + enabled = valid + updateUI?() + } + + public var updateUI: ActionBlock? + + public init(image: ImageViewModel?, action: ActionModelProtocol) { + self.image = image + self.action = action + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case image + case backgroundColor + case accessibilityText + case action + case enabled + case groupName + case enabledTintColor + case disabledTintColor + } + + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + image = try typeContainer.decodeIfPresent(ImageViewModel.self, forKey: .image) + accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) + action = try typeContainer.decodeModel(codingKey: .action) + + if let enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) { + self.enabled = enabled + } + + if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { + self.groupName = groupName + } + + if let enabledTintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .enabledTintColor) { + self.enabledTintColor = enabledTintColor + } + + if let disabledTintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledTintColor) { + self.disabledTintColor = disabledTintColor + } + + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(image, forKey: .image) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText) + try container.encode(enabled, forKey: .enabled) + try container.encodeModel(action, forKey: .action) + try container.encodeIfPresent(groupName, forKey: .groupName) + try container.encodeIfPresent(enabledTintColor, forKey: .enabledTintColor) + try container.encodeIfPresent(disabledTintColor, forKey: .disabledTintColor) + } +} diff --git a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift index 45d1b0c4..30e497ee 100644 --- a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift @@ -86,6 +86,7 @@ open class CoreUIModelMapping: ModelMapping { try? ModelRegistry.register(handler: HeadlineBodyLink.self, for: HeadlineBodyLinkModel.self) try? ModelRegistry.register(handler: HeadlineBodyButton.self, for: HeadlineBodyButtonModel.self) try? ModelRegistry.register(handler: BGImageHeadlineBodyButton.self, for: BGImageHeadlineBodyButtonModel.self) + try? ModelRegistry.register(handler: ImageButton.self, for: ImageButtonModel.self) try? ModelRegistry.register(handler: ThreeHeadlineBodyLink.self, for: ThreeHeadlineBodyLinkModel.self) // MARK:- Left Right Molecules From f8dce8503b95212ae8d6c84f67a97e7c3cc2c432 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 29 Jun 2021 13:11:40 -0400 Subject: [PATCH 044/113] changed behavior to align with android. --- .../Atoms/Selectors/CheckboxModel.swift | 12 ++- .../Atomic/Atoms/Selectors/ToggleModel.swift | 4 +- .../Behaviors/SelectAllBoxesBehavior.swift | 89 +++++++++---------- 3 files changed, 52 insertions(+), 53 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift index 87c4568d..31f19bae 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift @@ -7,7 +7,7 @@ // -@objcMembers public class CheckboxModel: NSObject, MoleculeModelProtocol, SelectableMoleculeModelProtocol, FormFieldProtocol { +@objcMembers public class CheckboxModel: MoleculeModelProtocol, SelectableMoleculeModelProtocol, FormFieldProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -15,7 +15,7 @@ public static var identifier: String = "checkbox" public var backgroundColor: Color? public var accessibilityIdentifier: String? - public dynamic var selected: Bool = false + public var selected: Bool = false public var enabled: Bool = true public var animated: Bool = true public var inverted: Bool = false @@ -80,6 +80,14 @@ baseValue = isChecked } + //-------------------------------------------------- + // MARK: - Behavior + //-------------------------------------------------- + + public func getRequiredBehaviors() -> [PageBehaviorModelProtocol] { + [SelectAllBoxesBehaviorModel()] + } + //-------------------------------------------------- // MARK: - Codec //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift index 0fb42632..056035b4 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift @@ -7,7 +7,7 @@ // -public class ToggleModel: NSObject, MoleculeModelProtocol, FormFieldProtocol, EnableableModelProtocol, SelectableMoleculeModelProtocol { +public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableModelProtocol, SelectableMoleculeModelProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -15,7 +15,7 @@ public class ToggleModel: NSObject, MoleculeModelProtocol, FormFieldProtocol, En public static var identifier: String = "toggle" public var accessibilityIdentifier: String? public var backgroundColor: Color? - public dynamic var selected: Bool = false + public var selected: Bool = false public var animated: Bool = true public var enabled: Bool = true public var action: ActionModelProtocol? diff --git a/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift b/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift index 1f7326fd..3837eaa9 100644 --- a/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift +++ b/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift @@ -9,8 +9,8 @@ /// Protocol to apply to any model of a UI Control with a binary on/off nature. /// /// Example classes: Checkbox or Toggle. -@objc public protocol SelectableMoleculeModelProtocol: AnyObject { - @objc dynamic var selected: Bool { get set } +@objc public protocol SelectableMoleculeModelProtocol { + var selected: Bool { get set } } public class SelectAllBoxesBehaviorModel: PageBehaviorModelProtocol { @@ -34,9 +34,6 @@ public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior, PageMolecu /// Reference to the general PageBehaviorModel. var model: PageBehaviorModelProtocol - /// Dictionary of KVOs to observing the selected property of each `SelectableMoleculeModel`. - private var observers = [String: NSKeyValueObservation?]() - /// A store representing the values of the `SelectableMoleculeModel`. private var valuesMirror = [String: Bool]() @@ -57,45 +54,17 @@ public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior, PageMolecu public func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject) { - let selectableModels: [(NSObject & SelectableMoleculeModelProtocol)] = rootMolecules.allMoleculesOfType() + let selectableModels: [SelectableMoleculeModelProtocol] = rootMolecules.allMoleculesOfType() guard !selectableModels.isEmpty else { return } for model in selectableModels { if let key = (model as? FormFieldProtocol)?.fieldKey { valuesMirror[key] = model.selected - setObserver(model, fieldKey: key) } } } - func setObserver(_ model: T, fieldKey: String) where T: (NSObject & SelectableMoleculeModelProtocol) { - - observers[fieldKey] = model.observe(\.selected, options: [.new]) { [weak self] model, change in - guard let self = self, - let isChecked = change.newValue - else { return } - - self.valuesMirror[fieldKey] = isChecked - - // If all are models are in the opposite state of the behavior, then realign. - if self.selectAllIsMisaligned() { - self.realignPageBehaviorAs(willSelectAll: false) - - } else if self.deselectAllIsMisaligned() { - self.realignPageBehaviorAs(willSelectAll: true) - } - } - } - - //-------------------------------------------------- - // MARK: - Deinit - //-------------------------------------------------- - - deinit { - observers.values.forEach { $0?.invalidate() } - } - //-------------------------------------------------- // MARK: - Custom Action //-------------------------------------------------- @@ -110,23 +79,45 @@ public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior, PageMolecu public func handleAction(type actionType: String?, information: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) -> Bool { // Verify we have the correct action type and necessary values. - guard actionType == "selectAllBoxes", - let selectableModels: [SelectableMoleculeModelProtocol] = delegate?.moleculeDelegate?.getRootMolecules().allMoleculesOfType(), - !selectableModels.isEmpty - else { return false } - - // Hold value dues to asynch behavior of page refreshing. - let newSelectedState = willSelectAllState - - // Iterate through selectable molecules. - for selectableModel in selectableModels { - if toSelect(model: selectableModel) || toDeselect(model: selectableModel) { - selectableModel.selected = newSelectedState + if actionType == "selectAllBoxes" { + guard let selectableModels: [SelectableMoleculeModelProtocol] = delegate?.moleculeDelegate?.getRootMolecules().allMoleculesOfType(), + !selectableModels.isEmpty + else { return false } + + // Hold value dues to asynch behavior of page refreshing. + let newSelectedState = willSelectAllState + + // Iterate through selectable molecules. + for selectableModel in selectableModels { + if toSelect(model: selectableModel) || toDeselect(model: selectableModel) { + selectableModel.selected = newSelectedState + } } + + willSelectAllState.toggle() + updatePageNavigationUI() + return true + + } else if actionType == "boxSelected" { + guard let checkboxModel = (additionalData?["sourceModel"] as? CheckboxModel), + let fieldKey = checkboxModel.fieldKey + else { return false } + + self.valuesMirror[fieldKey] = checkboxModel.selected + + // If all are models are in the opposite state of the behavior, then realign. + if self.selectAllIsMisaligned() { + self.realignPageBehaviorAs(willSelectAll: false) + + } else if self.deselectAllIsMisaligned() { + self.realignPageBehaviorAs(willSelectAll: true) + } + + return true + + } else { + return false } - - updatePageNavigationUI() - return true } //-------------------------------------------------- From c79b687be3eb5a7e37fbae51b2a07ac223293d70 Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Tue, 29 Jun 2021 20:04:21 +0000 Subject: [PATCH 045/113] Updating registry for logging --- .../OtherHandlers/CoreUIModelMapping.swift | 351 +++++++++--------- 1 file changed, 174 insertions(+), 177 deletions(-) diff --git a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift index 45d1b0c4..f45d3aac 100644 --- a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift @@ -20,229 +20,226 @@ open class CoreUIModelMapping: ModelMapping { open class func registerMolecules() { // MARK:- Stacks - try? ModelRegistry.register(handler: MoleculeStackView.self, for: StackModel.self) - try? ModelRegistry.register(handler: UnOrderedList.self, for: UnOrderedListModel.self) - try? ModelRegistry.register(handler: NumberedList.self, for: NumberedListModel.self) + ModelRegistry.register(handler: MoleculeStackView.self, for: StackModel.self) + ModelRegistry.register(handler: UnOrderedList.self, for: UnOrderedListModel.self) + ModelRegistry.register(handler: NumberedList.self, for: NumberedListModel.self) // MARK:- Label - try? ModelRegistry.register(handler: Label.self, for: LabelModel.self) + ModelRegistry.register(handler: Label.self, for: LabelModel.self) // MARK:- TextView - try? ModelRegistry.register(handler: TextViewEntryField.self, for: TextViewEntryFieldModel.self) + ModelRegistry.register(handler: TextViewEntryField.self, for: TextViewEntryFieldModel.self) // MARK:- Buttons - try? ModelRegistry.register(handler: PillButton.self, for: ButtonModel.self) - try? ModelRegistry.register(handler: TwoButtonView.self, for: TwoButtonViewModel.self) - try? ModelRegistry.register(handler: ExternalLink.self, for: ExternalLinkModel.self) - try? ModelRegistry.register(handler: Link.self, for: LinkModel.self) - try? ModelRegistry.register(handler: CaretLink.self, for: CaretLinkModel.self) + ModelRegistry.register(handler: PillButton.self, for: ButtonModel.self) + ModelRegistry.register(handler: TwoButtonView.self, for: TwoButtonViewModel.self) + ModelRegistry.register(handler: ExternalLink.self, for: ExternalLinkModel.self) + ModelRegistry.register(handler: Link.self, for: LinkModel.self) + ModelRegistry.register(handler: CaretLink.self, for: CaretLinkModel.self) // MARK:- Entry Field - try? ModelRegistry.register(handler: TextEntryField.self, for: TextEntryFieldModel.self) - try? ModelRegistry.register(handler: MdnEntryField.self, for: MdnEntryFieldModel.self) - try? ModelRegistry.register(handler: DigitEntryField.self, for: DigitEntryFieldModel.self) - try? ModelRegistry.register(handler: ItemDropdownEntryField.self, for: ItemDropdownEntryFieldModel.self) - try? ModelRegistry.register(handler: DateDropdownEntryField.self, for: DateDropdownEntryFieldModel.self) - try? ModelRegistry.register(handler: MultiItemDropdownEntryField.self, for: MultiItemDropdownEntryFieldModel.self) + ModelRegistry.register(handler: TextEntryField.self, for: TextEntryFieldModel.self) + ModelRegistry.register(handler: MdnEntryField.self, for: MdnEntryFieldModel.self) + ModelRegistry.register(handler: DigitEntryField.self, for: DigitEntryFieldModel.self) + ModelRegistry.register(handler: ItemDropdownEntryField.self, for: ItemDropdownEntryFieldModel.self) + ModelRegistry.register(handler: DateDropdownEntryField.self, for: DateDropdownEntryFieldModel.self) + ModelRegistry.register(handler: MultiItemDropdownEntryField.self, for: MultiItemDropdownEntryFieldModel.self) // MARK:- Selectors - try? ModelRegistry.register(handler: RadioButton.self, for: RadioButtonModel.self) - try? ModelRegistry.register(handler: RadioBoxes.self, for: RadioBoxesModel.self) - try? ModelRegistry.register(handler: Checkbox.self, for: CheckboxModel.self) - try? ModelRegistry.register(handler: RadioSwatches.self, for: RadioSwatchesModel.self) - try? ModelRegistry.register(handler: Tags.self, for: TagsModel.self) - try? ModelRegistry.register(handler: Tag.self, for: TagModel.self) - try? ModelRegistry.register(handler: Heart.self, for: HeartModel.self) - try? ModelRegistry.register(handler: Stars.self, for: StarsModel.self) - try? ModelRegistry.register(handler: Star.self, for: StarModel.self) - - + ModelRegistry.register(handler: RadioButton.self, for: RadioButtonModel.self) + ModelRegistry.register(handler: RadioBoxes.self, for: RadioBoxesModel.self) + ModelRegistry.register(handler: Checkbox.self, for: CheckboxModel.self) + ModelRegistry.register(handler: RadioSwatches.self, for: RadioSwatchesModel.self) + ModelRegistry.register(handler: Tags.self, for: TagsModel.self) + ModelRegistry.register(handler: Tag.self, for: TagModel.self) + ModelRegistry.register(handler: Heart.self, for: HeartModel.self) + ModelRegistry.register(handler: Stars.self, for: StarsModel.self) + ModelRegistry.register(handler: Star.self, for: StarModel.self) + // MARK:- Other Atoms - try? ModelRegistry.register(handler: ProgressBar.self, for: ProgressBarModel.self) - try? ModelRegistry.register(handler: MultiProgress.self, for: MultiProgressBarModel.self) - try? ModelRegistry.register(handler: CaretView.self, for: CaretViewModel.self) - try? ModelRegistry.register(handler: DashLine.self, for: DashLineModel.self) - try? ModelRegistry.register(handler: LoadImageView.self, for: ImageViewModel.self) - try? ModelRegistry.register(handler: Line.self, for: LineModel.self) - try? ModelRegistry.register(handler: Wheel.self, for: WheelModel.self) - try? ModelRegistry.register(handler: Toggle.self, for: ToggleModel.self) - try? ModelRegistry.register(handler: CheckboxLabel.self, for: CheckboxLabelModel.self) - try? ModelRegistry.register(handler: Arrow.self, for: ArrowModel.self) - try? ModelRegistry.register(handler: RadioButtonLabel.self, for: RadioButtonLabelModel.self) - try? ModelRegistry.register(handler: WebView.self, for: WebViewModel.self) - try? ModelRegistry.register(handler: LoadingSpinner.self, for: LoadingSpinnerModel.self) - try? ModelRegistry.register(handler: Video.self, for: VideoModel.self) + ModelRegistry.register(handler: ProgressBar.self, for: ProgressBarModel.self) + ModelRegistry.register(handler: MultiProgress.self, for: MultiProgressBarModel.self) + ModelRegistry.register(handler: CaretView.self, for: CaretViewModel.self) + ModelRegistry.register(handler: DashLine.self, for: DashLineModel.self) + ModelRegistry.register(handler: LoadImageView.self, for: ImageViewModel.self) + ModelRegistry.register(handler: Line.self, for: LineModel.self) + ModelRegistry.register(handler: Wheel.self, for: WheelModel.self) + ModelRegistry.register(handler: Toggle.self, for: ToggleModel.self) + ModelRegistry.register(handler: CheckboxLabel.self, for: CheckboxLabelModel.self) + ModelRegistry.register(handler: Arrow.self, for: ArrowModel.self) + ModelRegistry.register(handler: RadioButtonLabel.self, for: RadioButtonLabelModel.self) + ModelRegistry.register(handler: WebView.self, for: WebViewModel.self) + ModelRegistry.register(handler: LoadingSpinner.self, for: LoadingSpinnerModel.self) + ModelRegistry.register(handler: Video.self, for: VideoModel.self) // MARK:- Horizontal Combination Molecules - try? ModelRegistry.register(handler: StringAndMoleculeView.self, for: StringAndMoleculeModel.self) - try? ModelRegistry.register(handler: ImageHeadlineBody.self, for: ImageHeadlineBodyModel.self) - try? ModelRegistry.register(handler: Tabs.self, for: TabsModel.self) - try? ModelRegistry.register(handler: TwoLinkView.self, for: TwoLinkViewModel.self) + ModelRegistry.register(handler: StringAndMoleculeView.self, for: StringAndMoleculeModel.self) + ModelRegistry.register(handler: ImageHeadlineBody.self, for: ImageHeadlineBodyModel.self) + ModelRegistry.register(handler: Tabs.self, for: TabsModel.self) + ModelRegistry.register(handler: TwoLinkView.self, for: TwoLinkViewModel.self) // MARK:- Vertical Combination Molecules - try? ModelRegistry.register(handler: HeadlineBody.self, for: HeadlineBodyModel.self) - try? ModelRegistry.register(handler: HeadLineBodyCaretLinkImage.self, for: HeadlineBodyCaretLinkImageModel.self) - try? ModelRegistry.register(handler: EyebrowHeadlineBodyLink.self, for: EyebrowHeadlineBodyLinkModel.self) - try? ModelRegistry.register(handler: HeadlineBodyLink.self, for: HeadlineBodyLinkModel.self) - try? ModelRegistry.register(handler: HeadlineBodyButton.self, for: HeadlineBodyButtonModel.self) - try? ModelRegistry.register(handler: BGImageHeadlineBodyButton.self, for: BGImageHeadlineBodyButtonModel.self) - try? ModelRegistry.register(handler: ThreeHeadlineBodyLink.self, for: ThreeHeadlineBodyLinkModel.self) - + ModelRegistry.register(handler: HeadlineBody.self, for: HeadlineBodyModel.self) + ModelRegistry.register(handler: HeadLineBodyCaretLinkImage.self, for: HeadlineBodyCaretLinkImageModel.self) + ModelRegistry.register(handler: EyebrowHeadlineBodyLink.self, for: EyebrowHeadlineBodyLinkModel.self) + ModelRegistry.register(handler: HeadlineBodyLink.self, for: HeadlineBodyLinkModel.self) + ModelRegistry.register(handler: HeadlineBodyButton.self, for: HeadlineBodyButtonModel.self) + ModelRegistry.register(handler: BGImageHeadlineBodyButton.self, for: BGImageHeadlineBodyButtonModel.self) + ModelRegistry.register(handler: ThreeHeadlineBodyLink.self, for: ThreeHeadlineBodyLinkModel.self) + // MARK:- Left Right Molecules - try? ModelRegistry.register(handler: CornerLabels.self, for: CornerLabelsModel.self) - try? ModelRegistry.register(handler: LeftRightLabelView.self, for: LeftRightLabelModel.self) - try? ModelRegistry.register(handler: LabelToggle.self, for: LabelToggleModel.self) - try? ModelRegistry.register(handler: HeadlineBodyToggle.self, for: HeadlineBodyToggleModel.self) - try? ModelRegistry.register(handler: HeadlineBodyLinkToggle.self, for: HeadlineBodyLinkToggleModel.self) - try? ModelRegistry.register(handler: ActionDetailWithImage.self, for: ActionDetailWithImageModel.self) - + ModelRegistry.register(handler: CornerLabels.self, for: CornerLabelsModel.self) + ModelRegistry.register(handler: LeftRightLabelView.self, for: LeftRightLabelModel.self) + ModelRegistry.register(handler: LabelToggle.self, for: LabelToggleModel.self) + ModelRegistry.register(handler: HeadlineBodyToggle.self, for: HeadlineBodyToggleModel.self) + ModelRegistry.register(handler: HeadlineBodyLinkToggle.self, for: HeadlineBodyLinkToggleModel.self) + ModelRegistry.register(handler: ActionDetailWithImage.self, for: ActionDetailWithImageModel.self) + // MARK:- List items - try? ModelRegistry.register(handler: MoleculeTableViewCell.self, for: MoleculeListItemModel.self) - try? ModelRegistry.register(handler: DropDownFilterTableViewCell.self, for: DropDownListItemModel.self) - try? ModelRegistry.register(handler: AccordionMoleculeTableViewCell.self, for: AccordionListItemModel.self) - try? ModelRegistry.register(handler: TabsTableViewCell.self, for: TabsListItemModel.self) - try? ModelRegistry.register(handler: ListProgressBarData.self, for: ListProgressBarDataModel.self) + ModelRegistry.register(handler: MoleculeTableViewCell.self, for: MoleculeListItemModel.self) + ModelRegistry.register(handler: DropDownFilterTableViewCell.self, for: DropDownListItemModel.self) + ModelRegistry.register(handler: AccordionMoleculeTableViewCell.self, for: AccordionListItemModel.self) + ModelRegistry.register(handler: TabsTableViewCell.self, for: TabsListItemModel.self) + ModelRegistry.register(handler: ListProgressBarData.self, for: ListProgressBarDataModel.self) // MARK:- Other Items - try? ModelRegistry.register(handler: MoleculeStackItem.self, for: MoleculeStackItemModel.self) - try? ModelRegistry.register(handler: StackItem.self, for: StackItemModel.self) - try? ModelRegistry.register(handler: MoleculeCollectionViewCell.self, for: MoleculeCollectionItemModel.self) - try? ModelRegistry.register(handler: CarouselItem.self, for: CarouselItemModel.self) - - + ModelRegistry.register(handler: MoleculeStackItem.self, for: MoleculeStackItemModel.self) + ModelRegistry.register(handler: StackItem.self, for: StackItemModel.self) + ModelRegistry.register(handler: MoleculeCollectionViewCell.self, for: MoleculeCollectionItemModel.self) + ModelRegistry.register(handler: CarouselItem.self, for: CarouselItemModel.self) + // MARK:- Other Container Molecules - try? ModelRegistry.register(handler: MoleculeContainer.self, for: MoleculeContainerModel.self) - try? ModelRegistry.register(handler: MoleculeHeaderView.self, for: MoleculeHeaderModel.self) - try? ModelRegistry.register(handler: FooterView.self, for: FooterModel.self) - try? ModelRegistry.register(handler: Scroller.self, for: ScrollerModel.self) - try? ModelRegistry.register(handler: ModuleMolecule.self, for: ModuleMoleculeModel.self) - try? ModelRegistry.register(handler: BGImageMolecule.self, for: BGImageMoleculeModel.self) - try? ModelRegistry.register(handler: BGVideoImageMolecule.self, for: BGVideoImageMoleculeModel.self) - try? ModelRegistry.register(handler: MoleculeSectionHeader.self, for: MoleculeSectionHeaderModel.self) - try? ModelRegistry.register(handler: MoleculeSectionFooter.self, for: MoleculeSectionFooterModel.self) - - + ModelRegistry.register(handler: MoleculeContainer.self, for: MoleculeContainerModel.self) + ModelRegistry.register(handler: MoleculeHeaderView.self, for: MoleculeHeaderModel.self) + ModelRegistry.register(handler: FooterView.self, for: FooterModel.self) + ModelRegistry.register(handler: Scroller.self, for: ScrollerModel.self) + ModelRegistry.register(handler: ModuleMolecule.self, for: ModuleMoleculeModel.self) + ModelRegistry.register(handler: BGImageMolecule.self, for: BGImageMoleculeModel.self) + ModelRegistry.register(handler: BGVideoImageMolecule.self, for: BGVideoImageMoleculeModel.self) + ModelRegistry.register(handler: MoleculeSectionHeader.self, for: MoleculeSectionHeaderModel.self) + ModelRegistry.register(handler: MoleculeSectionFooter.self, for: MoleculeSectionFooterModel.self) + // MARK:- Other Molecules - try? ModelRegistry.register(handler: DoughnutChartView.self, for: DoughnutChartModel.self) + ModelRegistry.register(handler: DoughnutChartView.self, for: DoughnutChartModel.self) // Navigation Molecules - try? ModelRegistry.register(NavigationItemModel.self) - try? ModelRegistry.register(NavigationImageButtonModel.self) - try? ModelRegistry.register(NavigationLabelButtonModel.self) - + ModelRegistry.register(NavigationItemModel.self) + ModelRegistry.register(NavigationImageButtonModel.self) + ModelRegistry.register(NavigationLabelButtonModel.self) + // MARK:- Other Organisms - try? ModelRegistry.register(handler: Carousel.self, for: CarouselModel.self) - try? ModelRegistry.register(handler: BarsIndicatorView.self, for: BarsCarouselIndicatorModel.self) - try? ModelRegistry.register(handler: NumericIndicatorView.self, for: NumericCarouselIndicatorModel.self) + ModelRegistry.register(handler: Carousel.self, for: CarouselModel.self) + ModelRegistry.register(handler: BarsIndicatorView.self, for: BarsCarouselIndicatorModel.self) + ModelRegistry.register(handler: NumericIndicatorView.self, for: NumericCarouselIndicatorModel.self) // MARK:- Designed List Items - try? ModelRegistry.register(handler: ListLeftVariableIconWithRightCaret.self, for: ListLeftVariableIconWithRightCaretModel.self) - try? ModelRegistry.register(handler: ListLeftVariableIconWithRightCaretBodyText.self, for: ListLeftVariableIconWithRightCaretBodyTextModel.self) - try? ModelRegistry.register(handler: ListLeftVariableIconWithRightCaretAllTextLinks.self, for: ListLeftVariableIconWithRightCaretAllTextLinksModel.self) - try? ModelRegistry.register(handler: ListLeftVariableCheckboxAllTextAndLinks.self, for: ListLeftVariableCheckboxAllTextAndLinksModel.self) - try? ModelRegistry.register(handler: ListLeftVariableRadioButtonAndPaymentMethod.self, for: ListLeftVariableRadioButtonAndPaymentMethodModel.self) - try? ModelRegistry.register(handler: ListLeftVariableRadioButtonBodyText.self, for: ListLeftVariableRadioButtonBodyTextModel.self) - try? ModelRegistry.register(handler: ListLeftVariableRadioButtonAllTextAndLinks.self, for: ListLeftVariableRadioButtonAllTextAndLinksModel.self) - try? ModelRegistry.register(handler: ListLeftVariableCheckboxBodyText.self, for: ListLeftVariableCheckboxBodyTextModel.self) - try? ModelRegistry.register(handler: ListLeftVariableIconAllTextLinks.self, for: ListLeftVariableIconAllTextLinksModel.self) - try? ModelRegistry.register(handler: ListLeftVariableNumberedListAllTextAndLinks.self, for: ListLeftVariableNumberedListAllTextAndLinksModel.self) - try? ModelRegistry.register(handler: ListLeftVariableNumberedListBodyText.self, for: ListLeftVariableNumberedListBodyTextModel.self) - try? ModelRegistry.register(handler: ListRVWheel.self, for: ListRVWheelModel.self) - try? ModelRegistry.register(handler: ListRightVariablePayments.self, for: ListRightVariablePaymentsModel.self) - try? ModelRegistry.register(handler: ListRightVariableTotalData.self, for: ListRightVariableTotalDataModel.self) - try? ModelRegistry.register(handler: ListRightVariableTextLinkAllTextAndLinks.self, for: ListRightVariableTextLinkAllTextAndLinksModel.self) - try? ModelRegistry.register(handler: ListRightVariableButtonAllTextAndLinks.self, for: ListRightVariableButtonAllTextAndLinksModel.self) - try? ModelRegistry.register(handler: ListRightVariablePriceChangeBodyText.self, for: ListRightVariablePriceChangeBodyTextModel.self) - try? ModelRegistry.register(handler: ListRightVariablePriceChangeAllTextAndLinks.self, for: ListRightVariablePriceChangeAllTextAndLinksModel.self) - try? ModelRegistry.register(handler: ListRightVariableToggleAllTextAndLinks.self, for: ListRightVariableToggleAllTextAndLinksModel.self) - try? ModelRegistry.register(handler: ListRightVariableRightCaretAllTextAndLinks.self, for: ListRightVariableRightCaretAllTextAndLinksModel.self) - try? ModelRegistry.register(handler: ListOneColumnFullWidthTextAllTextAndLinks.self, for: ListOneColumnFullWidthTextAllTextAndLinksModel.self) - try? ModelRegistry.register(handler: ListOneColumnFullWidthTextBodyText.self, for: ListOneColumnFullWidthTextBodyTextModel.self) - try? ModelRegistry.register(handler: ListTwoColumnCompareChanges.self, for: ListTwoColumnCompareChangesModel.self) - try? ModelRegistry.register(handler: ListTwoColumnPriceDetails.self, for: ListTwoColumnPriceDetailsModel.self) - try? ModelRegistry.register(handler: ListTwoColumnPriceDescription.self, for: ListTwoColumnPriceDescriptionModel.self) - try? ModelRegistry.register(handler: ListTwoColumnDropdownSelectors.self, for: ListTwoColumnDropdownSelectorsModel.self) - try? ModelRegistry.register(handler: ListThreeColumnInternationalData.self, for: ListThreeColumnInternationalDataModel.self) - try? ModelRegistry.register(handler: ListThreeColumnDataUsage.self, for: ListThreeColumnDataUsageModel.self) - try? ModelRegistry.register(handler: ListThreeColumnBillChanges.self, for: ListThreeColumnBillChangesModel.self) - try? ModelRegistry.register(handler: ListThreeColumnBillHistory.self, for: ListThreeColumnBillHistoryModel.self) - try? ModelRegistry.register(handler: ListThreeColumnSpeedTest.self, for: ListThreeColumnSpeedTestModel.self) - try? ModelRegistry.register(handler: ListFourColumnDataUsageListItem.self, for: ListFourColumnDataUsageListItemModel.self) - try? ModelRegistry.register(handler: ListProgressBarThin.self, for: ListProgressBarThinModel.self) - try? ModelRegistry.register(handler: ListStoreLocator.self, for: ListStoreLocatorModel.self) - try? ModelRegistry.register(handler: ListStarRating.self, for: ListStarRatingModel.self) + ModelRegistry.register(handler: ListLeftVariableIconWithRightCaret.self, for: ListLeftVariableIconWithRightCaretModel.self) + ModelRegistry.register(handler: ListLeftVariableIconWithRightCaretBodyText.self, for: ListLeftVariableIconWithRightCaretBodyTextModel.self) + ModelRegistry.register(handler: ListLeftVariableIconWithRightCaretAllTextLinks.self, for: ListLeftVariableIconWithRightCaretAllTextLinksModel.self) + ModelRegistry.register(handler: ListLeftVariableCheckboxAllTextAndLinks.self, for: ListLeftVariableCheckboxAllTextAndLinksModel.self) + ModelRegistry.register(handler: ListLeftVariableRadioButtonAndPaymentMethod.self, for: ListLeftVariableRadioButtonAndPaymentMethodModel.self) + ModelRegistry.register(handler: ListLeftVariableRadioButtonBodyText.self, for: ListLeftVariableRadioButtonBodyTextModel.self) + ModelRegistry.register(handler: ListLeftVariableRadioButtonAllTextAndLinks.self, for: ListLeftVariableRadioButtonAllTextAndLinksModel.self) + ModelRegistry.register(handler: ListLeftVariableCheckboxBodyText.self, for: ListLeftVariableCheckboxBodyTextModel.self) + ModelRegistry.register(handler: ListLeftVariableIconAllTextLinks.self, for: ListLeftVariableIconAllTextLinksModel.self) + ModelRegistry.register(handler: ListLeftVariableNumberedListAllTextAndLinks.self, for: ListLeftVariableNumberedListAllTextAndLinksModel.self) + ModelRegistry.register(handler: ListLeftVariableNumberedListBodyText.self, for: ListLeftVariableNumberedListBodyTextModel.self) + ModelRegistry.register(handler: ListRVWheel.self, for: ListRVWheelModel.self) + ModelRegistry.register(handler: ListRightVariablePayments.self, for: ListRightVariablePaymentsModel.self) + ModelRegistry.register(handler: ListRightVariableTotalData.self, for: ListRightVariableTotalDataModel.self) + ModelRegistry.register(handler: ListRightVariableTextLinkAllTextAndLinks.self, for: ListRightVariableTextLinkAllTextAndLinksModel.self) + ModelRegistry.register(handler: ListRightVariableButtonAllTextAndLinks.self, for: ListRightVariableButtonAllTextAndLinksModel.self) + ModelRegistry.register(handler: ListRightVariablePriceChangeBodyText.self, for: ListRightVariablePriceChangeBodyTextModel.self) + ModelRegistry.register(handler: ListRightVariablePriceChangeAllTextAndLinks.self, for: ListRightVariablePriceChangeAllTextAndLinksModel.self) + ModelRegistry.register(handler: ListRightVariableToggleAllTextAndLinks.self, for: ListRightVariableToggleAllTextAndLinksModel.self) + ModelRegistry.register(handler: ListRightVariableRightCaretAllTextAndLinks.self, for: ListRightVariableRightCaretAllTextAndLinksModel.self) + ModelRegistry.register(handler: ListOneColumnFullWidthTextAllTextAndLinks.self, for: ListOneColumnFullWidthTextAllTextAndLinksModel.self) + ModelRegistry.register(handler: ListOneColumnFullWidthTextBodyText.self, for: ListOneColumnFullWidthTextBodyTextModel.self) + ModelRegistry.register(handler: ListTwoColumnCompareChanges.self, for: ListTwoColumnCompareChangesModel.self) + ModelRegistry.register(handler: ListTwoColumnPriceDetails.self, for: ListTwoColumnPriceDetailsModel.self) + ModelRegistry.register(handler: ListTwoColumnPriceDescription.self, for: ListTwoColumnPriceDescriptionModel.self) + ModelRegistry.register(handler: ListTwoColumnDropdownSelectors.self, for: ListTwoColumnDropdownSelectorsModel.self) + ModelRegistry.register(handler: ListThreeColumnInternationalData.self, for: ListThreeColumnInternationalDataModel.self) + ModelRegistry.register(handler: ListThreeColumnDataUsage.self, for: ListThreeColumnDataUsageModel.self) + ModelRegistry.register(handler: ListThreeColumnBillChanges.self, for: ListThreeColumnBillChangesModel.self) + ModelRegistry.register(handler: ListThreeColumnBillHistory.self, for: ListThreeColumnBillHistoryModel.self) + ModelRegistry.register(handler: ListThreeColumnSpeedTest.self, for: ListThreeColumnSpeedTestModel.self) + ModelRegistry.register(handler: ListFourColumnDataUsageListItem.self, for: ListFourColumnDataUsageListItemModel.self) + ModelRegistry.register(handler: ListProgressBarThin.self, for: ListProgressBarThinModel.self) + ModelRegistry.register(handler: ListStoreLocator.self, for: ListStoreLocatorModel.self) + ModelRegistry.register(handler: ListStarRating.self, for: ListStarRatingModel.self) // MARK:- Designed Section Dividers - try? ModelRegistry.register(handler: ListFourColumnDataUsageDivider.self, for: ListFourColumnDataUsageDividerModel.self) - try? ModelRegistry.register(handler: ListThreeColumnPlanDataDivider.self, for: ListThreeColumnPlanDataDividerModel.self) - try? ModelRegistry.register(handler: ListOneColumnTextWithWhitespaceDividerShort.self, for: ListOneColumnTextWithWhitespaceDividerShortModel.self) - try? ModelRegistry.register(handler: ListOneColumnTextWithWhitespaceDividerTall.self, for: ListOneColumnTextWithWhitespaceDividerTallModel.self) - try? ModelRegistry.register(handler: ListOneColumnFullWidthTextDividerSubsection.self, for: ListOneColumnFullWidthTextDividerSubsectionModel.self) - try? ModelRegistry.register(handler: ListTwoColumnSubsectionDivider.self, for: ListTwoColumnSubsectionDividerModel.self) - try? ModelRegistry.register(handler: ListThreeColumnInternationalDataDivider.self, for: ListThreeColumnInternationalDataDividerModel.self) - try? ModelRegistry.register(handler: ListThreeColumnSpeedTestDivider.self, for: ListThreeColumnSpeedTestDividerModel.self) - try? ModelRegistry.register(handler: ListThreeColumnBillChangesDivider.self, for: ListThreeColumnBillChangesDividerModel.self) - try? ModelRegistry.register(handler: ListThreeColumnDataUsageDivider.self, for: ListThreeColumnDataUsageDividerModel.self) - try? ModelRegistry.register(handler: ListThreeColumnBillHistoryDivider.self, for: ListThreeColumnBillHistoryDividerModel.self) - + ModelRegistry.register(handler: ListFourColumnDataUsageDivider.self, for: ListFourColumnDataUsageDividerModel.self) + ModelRegistry.register(handler: ListThreeColumnPlanDataDivider.self, for: ListThreeColumnPlanDataDividerModel.self) + ModelRegistry.register(handler: ListOneColumnTextWithWhitespaceDividerShort.self, for: ListOneColumnTextWithWhitespaceDividerShortModel.self) + ModelRegistry.register(handler: ListOneColumnTextWithWhitespaceDividerTall.self, for: ListOneColumnTextWithWhitespaceDividerTallModel.self) + ModelRegistry.register(handler: ListOneColumnFullWidthTextDividerSubsection.self, for: ListOneColumnFullWidthTextDividerSubsectionModel.self) + ModelRegistry.register(handler: ListTwoColumnSubsectionDivider.self, for: ListTwoColumnSubsectionDividerModel.self) + ModelRegistry.register(handler: ListThreeColumnInternationalDataDivider.self, for: ListThreeColumnInternationalDataDividerModel.self) + ModelRegistry.register(handler: ListThreeColumnSpeedTestDivider.self, for: ListThreeColumnSpeedTestDividerModel.self) + ModelRegistry.register(handler: ListThreeColumnBillChangesDivider.self, for: ListThreeColumnBillChangesDividerModel.self) + ModelRegistry.register(handler: ListThreeColumnDataUsageDivider.self, for: ListThreeColumnDataUsageDividerModel.self) + ModelRegistry.register(handler: ListThreeColumnBillHistoryDivider.self, for: ListThreeColumnBillHistoryDividerModel.self) + // MARK:- Designed Headers - try? ModelRegistry.register(handler: HeadersH1Button.self, for: HeadersH1ButtonModel.self) - try? ModelRegistry.register(handler: HeadersH1LandingPageHeader.self, for: HeadersH1LandingPageHeaderModel.self) - try? ModelRegistry.register(handler: HeadersH1NoButtonsBodyText.self, for: HeadersH1NoButtonsBodyTextModel.self) - try? ModelRegistry.register(handler: HeadersH2NoButtonsBodyText.self, for: HeadersH2NoButtonsBodyTextModel.self) - try? ModelRegistry.register(handler: HeadersH2TinyButton.self, for: HeadersH2TinyButtonModel.self) - try? ModelRegistry.register(handler: HeadersH2Buttons.self, for: HeadersH2ButtonsModel.self) - try? ModelRegistry.register(handler: HeadersH2PricingTwoRows.self, for: HeadersH2PricingTwoRowsModel.self) - try? ModelRegistry.register(handler: HeadersH2Link.self, for: HeadersH2LinkModel.self) - try? ModelRegistry.register(handler: HeadersH2CaretLink.self, for: HeadersH2CaretLinkModel.self) + ModelRegistry.register(handler: HeadersH1Button.self, for: HeadersH1ButtonModel.self) + ModelRegistry.register(handler: HeadersH1LandingPageHeader.self, for: HeadersH1LandingPageHeaderModel.self) + ModelRegistry.register(handler: HeadersH1NoButtonsBodyText.self, for: HeadersH1NoButtonsBodyTextModel.self) + ModelRegistry.register(handler: HeadersH2NoButtonsBodyText.self, for: HeadersH2NoButtonsBodyTextModel.self) + ModelRegistry.register(handler: HeadersH2TinyButton.self, for: HeadersH2TinyButtonModel.self) + ModelRegistry.register(handler: HeadersH2Buttons.self, for: HeadersH2ButtonsModel.self) + ModelRegistry.register(handler: HeadersH2PricingTwoRows.self, for: HeadersH2PricingTwoRowsModel.self) + ModelRegistry.register(handler: HeadersH2Link.self, for: HeadersH2LinkModel.self) + ModelRegistry.register(handler: HeadersH2CaretLink.self, for: HeadersH2CaretLinkModel.self) // MARK:- Device Items - try? ModelRegistry.register(handler: ListDeviceComplexButtonMedium.self, for: ListDeviceComplexButtonMediumModel.self) - try? ModelRegistry.register(handler: ListDeviceComplexButtonSmall.self, for: ListDeviceComplexButtonSmallModel.self) - - try? ModelRegistry.register(handler: ListDeviceComplexLinkSmall.self, for: ListDeviceComplexLinkSmallModel.self) - try? ModelRegistry.register(handler: ListDeviceComplexLinkMedium.self, for: ListDeviceComplexLinkMediumModel.self) + ModelRegistry.register(handler: ListDeviceComplexButtonMedium.self, for: ListDeviceComplexButtonMediumModel.self) + ModelRegistry.register(handler: ListDeviceComplexButtonSmall.self, for: ListDeviceComplexButtonSmallModel.self) + + ModelRegistry.register(handler: ListDeviceComplexLinkSmall.self, for: ListDeviceComplexLinkSmallModel.self) + ModelRegistry.register(handler: ListDeviceComplexLinkMedium.self, for: ListDeviceComplexLinkMediumModel.self) // MARK:- LockUps - try? ModelRegistry.register(handler: LockUpsPlanNames.self, for: LockUpsPlanNamesModel.self) - try? ModelRegistry.register(handler: LockupsPlanSMLXL.self, for: LockupsPlanSMLXLModel.self) - + ModelRegistry.register(handler: LockUpsPlanNames.self, for: LockUpsPlanNamesModel.self) + ModelRegistry.register(handler: LockupsPlanSMLXL.self, for: LockupsPlanSMLXLModel.self) + // MARK: - Top Notifications - try? ModelRegistry.register(handler: NotificationView.self, for: NotificationModel.self) - try? ModelRegistry.register(handler: CollapsableNotification.self, for: CollapsableNotificationModel.self) + ModelRegistry.register(handler: NotificationView.self, for: NotificationModel.self) + ModelRegistry.register(handler: CollapsableNotification.self, for: CollapsableNotificationModel.self) } open class func registerLabelAttributes() { - try? ModelRegistry.register(LabelAttributeFontModel.self) - try? ModelRegistry.register(LabelAttributeColorModel.self) - try? ModelRegistry.register(LabelAttributeImageModel.self) - try? ModelRegistry.register(LabelAttributeUnderlineModel.self) - try? ModelRegistry.register(LabelAttributeStrikeThroughModel.self) - try? ModelRegistry.register(LabelAttributeActionModel.self) + ModelRegistry.register(LabelAttributeFontModel.self) + ModelRegistry.register(LabelAttributeColorModel.self) + ModelRegistry.register(LabelAttributeImageModel.self) + ModelRegistry.register(LabelAttributeUnderlineModel.self) + ModelRegistry.register(LabelAttributeStrikeThroughModel.self) + ModelRegistry.register(LabelAttributeActionModel.self) } open class func registerBehaviors() { - try? ModelRegistry.register(handler: ScreenBrightnessModifierBehavior.self, for: ScreenBrightnessModifierBehaviorModel.self) - try? ModelRegistry.register(handler: PageGetContactBehavior.self, for: PageGetContactBehaviorModel.self) + ModelRegistry.register(handler: ScreenBrightnessModifierBehavior.self, for: ScreenBrightnessModifierBehaviorModel.self) + ModelRegistry.register(handler: PageGetContactBehavior.self, for: PageGetContactBehaviorModel.self) } open override class func registerActions() { super.registerActions() - try? ModelRegistry.register(ActionPopupModel.self) - try? ModelRegistry.register(ActionAlertModel.self) - try? ModelRegistry.register(ActionTopAlertModel.self) - try? ModelRegistry.register(ActionCollapseNotificationModel.self) - try? ModelRegistry.register(ActionOpenPanelModel.self) - try? ModelRegistry.register(ActionTopNotificationModel.self) + ModelRegistry.register(ActionPopupModel.self) + ModelRegistry.register(ActionAlertModel.self) + ModelRegistry.register(ActionTopAlertModel.self) + ModelRegistry.register(ActionCollapseNotificationModel.self) + ModelRegistry.register(ActionOpenPanelModel.self) + ModelRegistry.register(ActionTopNotificationModel.self) } open class func registerRules() { - try? ModelRegistry.register(RuleRequiredModel.self) - try? ModelRegistry.register(RuleAnyRequiredModel.self) - try? ModelRegistry.register(RuleAnyValueChangedModel.self) - try? ModelRegistry.register(RuleAllValueChangedModel.self) - try? ModelRegistry.register(RuleEqualsModel.self) - try? ModelRegistry.register(RuleEqualsIgnoreCaseModel.self) - try? ModelRegistry.register(RuleRegexModel.self) + ModelRegistry.register(RuleRequiredModel.self) + ModelRegistry.register(RuleAnyRequiredModel.self) + ModelRegistry.register(RuleAnyValueChangedModel.self) + ModelRegistry.register(RuleAllValueChangedModel.self) + ModelRegistry.register(RuleEqualsModel.self) + ModelRegistry.register(RuleEqualsIgnoreCaseModel.self) + ModelRegistry.register(RuleRegexModel.self) } } From 9af3b5f71edebada66ab780e71921477ca0457a4 Mon Sep 17 00:00:00 2001 From: rajampetS Date: Wed, 30 Jun 2021 14:52:19 +0530 Subject: [PATCH 046/113] removing spaces --- MVMCoreUI/Atomic/Templates/TemplateModel.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Templates/TemplateModel.swift b/MVMCoreUI/Atomic/Templates/TemplateModel.swift index 94a2476e..45c2ed1a 100644 --- a/MVMCoreUI/Atomic/Templates/TemplateModel.swift +++ b/MVMCoreUI/Atomic/Templates/TemplateModel.swift @@ -13,8 +13,7 @@ import Foundation //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - open class var identifier: String { "" } - + open class var identifier: String { "" } public var pageType: String public var template: String { From 7566d9365936973fcc0d0fc863bebb589322f135 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Wed, 30 Jun 2021 18:51:41 +0530 Subject: [PATCH 047/113] Registering PlayAudio, SelectAllBoxes behaviors --- MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift index 5cf71a75..be621811 100644 --- a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift @@ -222,6 +222,8 @@ open class CoreUIModelMapping: ModelMapping { open class func registerBehaviors() { ModelRegistry.register(handler: ScreenBrightnessModifierBehavior.self, for: ScreenBrightnessModifierBehaviorModel.self) ModelRegistry.register(handler: PageGetContactBehavior.self, for: PageGetContactBehaviorModel.self) + ModelRegistry.register(handler: PagePlayAudioBehavior.self, for: PagePlayAudioBehaviorModel.self) + ModelRegistry.register(handler: SelectAllBoxesBehavior.self, for: SelectAllBoxesBehaviorModel.self) } open override class func registerActions() { From 14fc5bfd72edb3b3b1011a42de85c0c7e1f773bf Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 30 Jun 2021 10:54:50 -0400 Subject: [PATCH 048/113] add aggregate --- MVMCoreUI.xcodeproj/project.pbxproj | 66 +++++++++++++++++++++ Scripts/download_dependencies.sh | 17 ++++++ Scripts/upload_core_frameworks.sh | 24 ++++++++ Scripts/upload_framework.sh | 90 +++++++++++++++++++++++++++++ 4 files changed, 197 insertions(+) create mode 100755 Scripts/download_dependencies.sh create mode 100755 Scripts/upload_core_frameworks.sh create mode 100755 Scripts/upload_framework.sh diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index d48fa228..8a03744c 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -6,6 +6,20 @@ objectVersion = 48; objects = { +/* Begin PBXAggregateTarget section */ + D23F60FA268CBB5E007914AB /* MVMCoreUIAggregate */ = { + isa = PBXAggregateTarget; + buildConfigurationList = D23F60FD268CBB5E007914AB /* Build configuration list for PBXAggregateTarget "MVMCoreUIAggregate" */; + buildPhases = ( + D23F6100268CBB71007914AB /* ShellScript */, + ); + dependencies = ( + ); + name = MVMCoreUIAggregate; + productName = MVMCoreUIAggregate; + }; +/* End PBXAggregateTarget section */ + /* Begin PBXBuildFile section */ 01004F3022721C3800991ECC /* RadioButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01004F2F22721C3800991ECC /* RadioButton.swift */; }; 0103B84E23D7E33A009C315C /* HeadlineBodyToggleModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0103B84D23D7E33A009C315C /* HeadlineBodyToggleModel.swift */; }; @@ -2469,6 +2483,10 @@ LastUpgradeCheck = 1010; ORGANIZATIONNAME = "Verizon Wireless"; TargetAttributes = { + D23F60FA268CBB5E007914AB = { + CreatedOnToolsVersion = 12.4; + ProvisioningStyle = Automatic; + }; D29DF0CB21E404D4003B2FB9 = { CreatedOnToolsVersion = 10.1; LastSwiftMigration = 1010; @@ -2491,6 +2509,7 @@ projectRoot = ""; targets = ( D29DF0CB21E404D4003B2FB9 /* MVMCoreUI */, + D23F60FA268CBB5E007914AB /* MVMCoreUIAggregate */, ); }; /* End PBXProject section */ @@ -2513,6 +2532,26 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + D23F6100268CBB71007914AB /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "unset TOOLCHAINS #Xcode 7.3 BUG FIX http://stackoverflow.com/questions/36184930/xcodebuild-7-3-cant-enable-bitcode\n\n# define output folder environment variable\nC_PROJECT_NAME=\"MVMCoreUI\"\nPHONE_CONFIGURATION=\"Release\"\nSIMULATOR_CONFIGURATION=\"Debug\"\n\nUNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal\n\n# Step 1. Build Device and Simulator versions\nxcodebuild -scheme \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath \"${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}\" archive SKIP_INSTALL=false\n\nxcodebuild -target \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator -arch x86_64 BUILD_DIR=\"${BUILD_DIR}\"\n\nmkdir -p \"${UNIVERSAL_OUTPUTFOLDER}\"\n\nrm -rf ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework\ncp -R ${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/\"${C_PROJECT_NAME}\".xcarchive/Products/Library/Frameworks/${C_PROJECT_NAME}.framework ${UNIVERSAL_OUTPUTFOLDER}\n\n# Step 2. Create universal binary file using lipo\n\nlipo -create -output \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}\" \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\" \"${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\"\n\nmv ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME} ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\n"; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ D29DF0C821E404D4003B2FB9 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -3042,6 +3081,24 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ + D23F60FB268CBB5E007914AB /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = FCMA4QKS77; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + D23F60FC268CBB5E007914AB /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = FCMA4QKS77; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; D29DF0D221E404D4003B2FB9 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -3221,6 +3278,15 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + D23F60FD268CBB5E007914AB /* Build configuration list for PBXAggregateTarget "MVMCoreUIAggregate" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + D23F60FB268CBB5E007914AB /* Debug */, + D23F60FC268CBB5E007914AB /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; D29DF0C621E404D4003B2FB9 /* Build configuration list for PBXProject "MVMCoreUI" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/Scripts/download_dependencies.sh b/Scripts/download_dependencies.sh new file mode 100755 index 00000000..dfa64ff5 --- /dev/null +++ b/Scripts/download_dependencies.sh @@ -0,0 +1,17 @@ +#!/bin/sh -e + +# download_dependencies.sh +# +# Downloads all compiled framework flavors in from Artifactory. +# +# + +# Create new aggregate builds + +if [ -z $ARTIFACTORY_URL ]; then + ARTIFACTORY_URL="https://oneartifactoryprod.verizon.com/artifactory" +fi + +# Remote View Versions +BUILD_DIR=$(xcodebuild -showBuildSettings -project ../MVMCore/MVMCore.xcodeproj | grep -w -o 'BUILD_DIR = .*' | cut -d\ -f3-) +./upload_framework.sh $ARTIFACTORY_URL "${BUILD_DIR}/universal/MVMCore.framework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMCore/[VER]/MVMCore-[VER]-Debug-SNAPSHOT diff --git a/Scripts/upload_core_frameworks.sh b/Scripts/upload_core_frameworks.sh new file mode 100755 index 00000000..714cf163 --- /dev/null +++ b/Scripts/upload_core_frameworks.sh @@ -0,0 +1,24 @@ +#!/bin/sh -e + +# upload_core_frameworks.sh +# +# Uploads all compiled framework flavors in MVMCore to Artifactory with the SNAPSHOT classifier. This is to avoid accidently clobbering a release build of a particular version. Remove the classifier in Artificatory to make a release. +# +# Copied from Hedden, Kyle Matthew on 3/2/18. +# + +FRAMEWORK_VERSION=$(cd ../MVMCore && agvtool vers -terse) +if [ $(git tag --list | grep "v${FRAMEWORK_VERSION}") ]; then + echo This version tag has already been committed! Aborting! + exit 1 +fi + +# Create new aggregate builds + +if [ -z $ARTIFACTORY_URL ]; then + ARTIFACTORY_URL="https://oneartifactoryprod.verizon.com/artifactory" +fi + +# Remote View Versions +BUILD_DIR=$(xcodebuild -showBuildSettings -project ../MVMCore/MVMCore.xcodeproj | grep -w -o 'BUILD_DIR = .*' | cut -d\ -f3-) +./upload_framework.sh $ARTIFACTORY_URL "${BUILD_DIR}/universal/MVMCore.framework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMCore/[VER]/MVMCore-[VER]-Debug-SNAPSHOT diff --git a/Scripts/upload_framework.sh b/Scripts/upload_framework.sh new file mode 100755 index 00000000..94a6007b --- /dev/null +++ b/Scripts/upload_framework.sh @@ -0,0 +1,90 @@ +#!/bin/bash -e + +# upload_framework.sh +# +# Uploads an iOS framework to Artificatory given the local path as the first argument and the remote project name in Verizon OneArtifactory for the second argument. +# +# An API key from Artifcatory is required in the api_key.private file before uploading. +# +# The script will replace [VER] in the provided remote path with the version found in the framework bundle. +# +# Copied from Hedden, Kyle Matthew on 3/2/18. +# Copyright © 2018 Verizon. All rights reserved. + +URL=$1 +LOCALPATH=$2 +REMOTEPATH=$3 + +if [ -z $URL ]; then + echo "The artifactory instance url must be specified as the first argument!" + exit 1 +fi + +echo ">>> UPLOAD START <<<" +echo "Local path: ${LOCALPATH}" +echo "Remote path: ${REMOTEPATH}" + +cat "${LOCALPATH}/Info.plist" + +LOCALBASE=$(basename "${LOCALPATH}") +LOCALDIR=$(dirname "${LOCALPATH}") + +# Grab the framework version from the bundled Info.plist. +FRAMEWORKVER=$(/usr/libexec/plistbuddy -c "Print :CFBundleShortVersionString" "${LOCALPATH}/Info.plist") +echo -e "\nFramework version: \t${FRAMEWORKVER}" + +# Replace the [VER] placeholders with the found version. +REMOTEPATH="${REMOTEPATH//\[VER\]/$FRAMEWORKVER}" +echo -e "Resolved path: \t\t${REMOTEPATH}" + +if [ -z $ARTIFACTORY_APIKEY ]; then + # Read the API key from a private file. + read -r APIKEY < "api_key.private" +else + APIKEY=$ARTIFACTORY_APIKEY +fi + +if [ -z $APIKEY ]; then + read -p "Artifactory API Key:" APIKEY + echo $APIKEY >> api_key.private +fi + +echo -e "API Key: \t\t${APIKEY}" + +# Zip the framework & DSYM for uploading. +pushd $LOCALDIR +echo -e "---------\nZipping: \t\t${LOCALBASE}.zip" +zip -r -X "${LOCALBASE}.zip" $LOCALBASE +# Generate framework's SHA-1 checksum. +CHECKSUM=$(shasum -a 1 "${LOCALBASE}.zip" | cut -d " " -f 1) +echo -e "SHA-1 Checksum: \t${CHECKSUM}" +if [ -e ${LOCALBASE}.dSYM ]; then +echo -e "---------\nZipping: \t\t${LOCALBASE}.dSYM.zip" +zip -r -X "${LOCALBASE}.dSYM.zip" $LOCALBASE.dSYM +# Generate its SHA-1 checksum for dsym. +DSYM_CHECKSUM=$(shasum -a 1 "${LOCALBASE}.dSYM.zip" | cut -d " " -f 1) +echo -e "SHA-1 Checksum: \t${DSYM_CHECKSUM}" +fi +popd +mv ${LOCALPATH}.zip . +if [ -e ${LOCALPATH}.dSYM.zip ]; then +mv ${LOCALPATH}.dSYM.zip . +fi + +# Upload framework to Artifactory. +echo -e "---------\nUploading to: \t\t${URL}/${REMOTEPATH}.zip" +curl --header "X-JFrog-Art-Api: ${APIKEY}" --header "X-Checksum-Sha1: ${CHECKSUM}" -X PUT "${URL}/${REMOTEPATH}.zip" -T "${LOCALBASE}.zip" + +# Cleanup. +rm "${LOCALBASE}.zip" + +if [ -e ${LOCALBASE}.dSYM.zip ]; then +# Upload dsym Artifactory. +echo -e "---------\nUploading to: \t\t${URL}/${REMOTEPATH}.dSYM.zip" +curl --header "X-JFrog-Art-Api: ${APIKEY}" --header "X-Checksum-Sha1: ${DSYM_CHECKSUM}" -X PUT "${URL}/${REMOTEPATH}.dSYM.zip" -T "${LOCALBASE}.dSYM.zip" +# Cleanup dsym. +rm ${LOCALBASE}.dSYM.zip +fi + + +echo -e "\n\n<<< UPLOAD COMPLETE >>>\n\n" From 40785aee632440e1b32dfe0d4dd986f4f71a9e88 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 30 Jun 2021 12:02:42 -0400 Subject: [PATCH 049/113] testing --- .gitlab-ci.yml | 92 +++++++++++++++++++++++++++++ MVMCoreUI.xcodeproj/project.pbxproj | 2 +- Scripts/download_dependencies.sh | 5 +- Scripts/download_framework.sh | 85 ++++++++++++++++++++++++++ 4 files changed, 180 insertions(+), 4 deletions(-) create mode 100644 .gitlab-ci.yml create mode 100755 Scripts/download_framework.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..20a59212 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,92 @@ +stages: +# - test + - download +# - build +# - deploy + +#test: +# stage: test +# script: +# - echo "This job tests something" +# tags: +# - xcode_12_2 + +download_artifacts: + stage: download + script: + - cd Scripts && ./download_dependencies.sh + # - ./Scripts/download_dependencies.sh + only: + - branches + - feature/script_to_upload + tags: + - bash_shell + environment: + name: oneartifactory + url: https://oneartifactoryprod.verizon.com/artifactory + variables: + ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory + +#build_project: +# stage: build +# script: +# - xcodebuild build -project MVMCore/MVMCore.xcodeproj -scheme FatLibrary | xcpretty +# - BUILD_DIR=$(xcodebuild -showBuildSettings -project MVMCore/MVMCore.xcodeproj | grep BUILD_DIR) +# only: +# - branches +# - develop +# tags: +# - xcode_12_2 +# +#deploy_snapshot: +# stage: deploy +# script: +# - cd Scripts && ./upload_core_frameworks.sh +# only: +# - branches +# - develop +# tags: +# - bash_shell +# environment: +# name: oneartifactory +# url: https://oneartifactoryprod.verizon.com/artifactory +# variables: +# ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory + +#promote_snapshot: +# stage: go live +# # Prevent artifacts from needing to re-download. Everything we need is in Artifactory. +# dependencies: [] +# script: +# # Grab the framework version from the xcode project. +# - framework_ver=$(cd RemoteView && agvtool vers -terse) +# - cd Scripts && ./promote_remote_view_frameworks.sh $framework_ver +# only: +# - tags +# tags: +# - bash_shell +# environment: +# name: oneartifactory +# url: https://oneartifactoryprod.verizon.com/artifactory +# variables: +# ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory +# +#create_version_tag: +# stage: tag +# when: manual +# # Prevent artifacts from needing to re-download. +# dependencies: [] +# script: +# # Grab the framework version from the xcode project and create a tag of the version. +# - framework_ver=$(cd RemoteView && agvtool vers -terse) +# - git tag -a "v${framework_ver}" -m "Version ${framework_ver} created by gitlab-ci Build" +# # Extract the git repo url to ssh version (git@gitlab.verizon.com) +# - ci_push_repo="git@${CI_SERVER_HOST}:${CI_PROJECT_PATH}.git" +# - echo $ci_push_repo +# # Set the remote url for pushing assuming the gitlab runner has SSH access to the repo. +# - git remote set-url --push origin $ci_push_repo +# - git push origin "v${framework_ver}" +# only: +# - develop +# tags: +# - bash_shell diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 9785a981..b53e6ceb 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -2545,7 +2545,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "unset TOOLCHAINS #Xcode 7.3 BUG FIX http://stackoverflow.com/questions/36184930/xcodebuild-7-3-cant-enable-bitcode\n\n# define output folder environment variable\nC_PROJECT_NAME=\"MVMCoreUI\"\nPHONE_CONFIGURATION=\"Release\"\nSIMULATOR_CONFIGURATION=\"Debug\"\n\nUNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal\n\n# Step 1. Build Device and Simulator versions\nxcodebuild -scheme \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath \"${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}\" archive SKIP_INSTALL=false\n\nxcodebuild -target \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator -arch x86_64 BUILD_DIR=\"${BUILD_DIR}\"\n\nmkdir -p \"${UNIVERSAL_OUTPUTFOLDER}\"\n\nrm -rf ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework\ncp -R ${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/\"${C_PROJECT_NAME}\".xcarchive/Products/Library/Frameworks/${C_PROJECT_NAME}.framework ${UNIVERSAL_OUTPUTFOLDER}\n\n# Step 2. Create universal binary file using lipo\n\nlipo -create -output \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}\" \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\" \"${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\"\n\nmv ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME} ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\n"; + shellScript = "unset TOOLCHAINS #Xcode 7.3 BUG FIX http://stackoverflow.com/questions/36184930/xcodebuild-7-3-cant-enable-bitcode\n\n# define output folder environment variable\nC_PROJECT_NAME=\"MVMCoreUI\"\nPHONE_CONFIGURATION=\"Release\"\nSIMULATOR_CONFIGURATION=\"Debug\"\n\nUNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal\n\n# Step 1. Build Device and Simulator versions\nxcodebuild -scheme \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath \"${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}\" archive SKIP_INSTALL=false\n\n#xcodebuild -target \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator -arch x86_64 BUILD_DIR=\"${BUILD_DIR}\"\n\n#mkdir -p \"${UNIVERSAL_OUTPUTFOLDER}\"\n\n#rm -rf ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework\n#cp -R ${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/\"${C_PROJECT_NAME}\".xcarchive/Products/Library/Frameworks/${C_PROJECT_NAME}.framework ${UNIVERSAL_OUTPUTFOLDER}\n\n# Step 2. Create universal binary file using lipo\n\n#lipo -create -output \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}\" \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\" \"${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\"\n\n#mv ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME} ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\n"; }; /* End PBXShellScriptBuildPhase section */ diff --git a/Scripts/download_dependencies.sh b/Scripts/download_dependencies.sh index dfa64ff5..250bba40 100755 --- a/Scripts/download_dependencies.sh +++ b/Scripts/download_dependencies.sh @@ -4,7 +4,6 @@ # # Downloads all compiled framework flavors in from Artifactory. # -# # Create new aggregate builds @@ -13,5 +12,5 @@ if [ -z $ARTIFACTORY_URL ]; then fi # Remote View Versions -BUILD_DIR=$(xcodebuild -showBuildSettings -project ../MVMCore/MVMCore.xcodeproj | grep -w -o 'BUILD_DIR = .*' | cut -d\ -f3-) -./upload_framework.sh $ARTIFACTORY_URL "${BUILD_DIR}/universal/MVMCore.framework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMCore/[VER]/MVMCore-[VER]-Debug-SNAPSHOT +#BUILD_DIR=$(xcodebuild -showBuildSettings -project ../MVMCore/MVMCore.xcodeproj | grep -w -o 'BUILD_DIR = .*' | cut -d\ -f3-) +./download_framework.sh $ARTIFACTORY_URL "./MVMCore.framework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMCore/1.0/MVMCore-1.0-Debug-SNAPSHOT diff --git a/Scripts/download_framework.sh b/Scripts/download_framework.sh new file mode 100755 index 00000000..cbcee2c9 --- /dev/null +++ b/Scripts/download_framework.sh @@ -0,0 +1,85 @@ +#!/bin/bash -e + +# upload_framework.sh +# +# Downloads an iOS framework from Artificatory. +# +# An API key from Artifcatory is required in the api_key.private file before uploading. +# + +URL=$1 +LOCALPATH="${2}" +REMOTEPATH="${3}" +LOGFILE=$3 +LOCALDIR=$(dirname "${LOCALPATH}") +LOCALBASE=$(basename "${LOCALPATH}") +NEWFILEPATH="${LOCALDIR}"/$(basename "${REMOTEPATH}") +VERSIONFILE=./Checksums/"${LOCALBASE}".txt + +if [ -z $URL ]; then + echo "The artifactory instance url must be specified as the first argument!" + exit 1 +fi + +if [ -z $LOGFILE ]; then +LOGFILE="/tmp/${LOCALBASE}.txt" +fi + +#first argument is error message. +exit_with_error () { +echo "Error: $1" >> "${LOGFILE}" +if [ -f "${NEWFILEPATH}" ]; then +rm -rf "${NEWFILEPATH}" 2>>"${LOGFILE}" +fi +exit 1 +} + +echo "----------------------------------------------------------" >> $LOGFILE +echo "Logs for ${LOCALBASE}" >> $LOGFILE + +echo -e "Local Target: ${LOCALPATH}" >> $LOGFILE +echo -e "Remote Source: ${REMOTEPATH}" >> $LOGFILE + +if [ -z "$LOCALPATH" ]; then +exit_with_error "Missing local path argument" +fi + +if [ -z "$REMOTEPATH" ]; then +exit_with_error "Missing filename path argument" +fi + +#get local and remote checksums for comparison +echo -e "Getting checksums..." >> $LOGFILE +echo -e "URL: ${URL}/api/storage/${REMOTEPATH}" >> $LOGFILE +JSON=$(curl --header "X-JFrog-Art-Api: ${APITOKEN}" -X GET "${URL}/api/storage/${REMOTEPATH}" 2>>"${LOGFILE}") +CHECKSUM=$(echo "$JSON" | python -c 'import sys, json; print json.load(sys.stdin)["checksums"]["sha1"]') 2>>"${LOGFILE}" +if [[ -z "$CHECKSUM" ]]; then +exit_with_error "No Checksum found in json: ${JSON}" +fi +echo "Remote checksum ${CHECKSUM}" >> "${LOGFILE}" +OLDCHECKSUM=$(cat "${VERSIONFILE}" 2>/dev/null) +echo "Local checksum ${OLDCHECKSUM}" >> "${LOGFILE}" + +#get new framework if no original framework, no local checksum, or remote checksum is different from local. +if [ ! -e "${LOCALPATH}" ] || [ -z "$OLDCHECKSUM" ] || [ "$CHECKSUM" != "$OLDCHECKSUM" ]; then +echo "Downloading..." >> "${LOGFILE}" +echo -e "URL: ${URL}/${REMOTEPATH}" >> $LOGFILE +curl --header "X-JFrog-Art-Api: ${APITOKEN}" -f -X GET "$URL/$REMOTEPATH" --output "${NEWFILEPATH}" 2>>"${LOGFILE}" +if [ $? -eq 0 ] && [ -e "${NEWFILEPATH}" ]; then +echo "Finished Downloading, begin unzip" >> "${LOGFILE}" +unzip -q -o "${NEWFILEPATH}" -d "${LOCALDIR}" 2>>"${LOGFILE}" +if [ $? -eq 0 ]; then +echo "Finished unzipping, remove zip" >> "${LOGFILE}" +rm -rf "${NEWFILEPATH}" 2>>"${LOGFILE}" +echo "Writing new checksum to file" >> "${LOGFILE}" +echo "${CHECKSUM}" > "${VERSIONFILE}" 2>>"${LOGFILE}" +echo "Successfully downloaded and unzipped archive." >> "${LOGFILE}" +else +exit_with_error "Error unzipping" +fi +else +exit_with_error "Failed to download" +fi +else +echo "Successful, No New Version" >> "${LOGFILE}" +fi From 3b258efefec82333916ff93243be950888f71293 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 30 Jun 2021 12:07:20 -0400 Subject: [PATCH 050/113] testing --- Scripts/download_framework.sh | 50 ++++++++++++++++------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/Scripts/download_framework.sh b/Scripts/download_framework.sh index cbcee2c9..079deed0 100755 --- a/Scripts/download_framework.sh +++ b/Scripts/download_framework.sh @@ -21,24 +21,20 @@ if [ -z $URL ]; then exit 1 fi -if [ -z $LOGFILE ]; then -LOGFILE="/tmp/${LOCALBASE}.txt" -fi - #first argument is error message. exit_with_error () { -echo "Error: $1" >> "${LOGFILE}" +echo "Error: $1" if [ -f "${NEWFILEPATH}" ]; then -rm -rf "${NEWFILEPATH}" 2>>"${LOGFILE}" +rm -rf "${NEWFILEPATH}" 2 fi exit 1 } -echo "----------------------------------------------------------" >> $LOGFILE -echo "Logs for ${LOCALBASE}" >> $LOGFILE +echo "----------------------------------------------------------" +echo "Logs for ${LOCALBASE}" -echo -e "Local Target: ${LOCALPATH}" >> $LOGFILE -echo -e "Remote Source: ${REMOTEPATH}" >> $LOGFILE +echo -e "Local Target: ${LOCALPATH}" +echo -e "Remote Source: ${REMOTEPATH}" if [ -z "$LOCALPATH" ]; then exit_with_error "Missing local path argument" @@ -49,31 +45,31 @@ exit_with_error "Missing filename path argument" fi #get local and remote checksums for comparison -echo -e "Getting checksums..." >> $LOGFILE -echo -e "URL: ${URL}/api/storage/${REMOTEPATH}" >> $LOGFILE -JSON=$(curl --header "X-JFrog-Art-Api: ${APITOKEN}" -X GET "${URL}/api/storage/${REMOTEPATH}" 2>>"${LOGFILE}") -CHECKSUM=$(echo "$JSON" | python -c 'import sys, json; print json.load(sys.stdin)["checksums"]["sha1"]') 2>>"${LOGFILE}" +echo -e "Getting checksums..." +echo -e "URL: ${URL}/api/storage/${REMOTEPATH}" +JSON=$(curl --header "X-JFrog-Art-Api: ${APITOKEN}" -X GET "${URL}/api/storage/${REMOTEPATH}") +CHECKSUM=$(echo "$JSON" | python -c 'import sys, json; print json.load(sys.stdin)["checksums"]["sha1"]')" if [[ -z "$CHECKSUM" ]]; then exit_with_error "No Checksum found in json: ${JSON}" fi -echo "Remote checksum ${CHECKSUM}" >> "${LOGFILE}" +echo "Remote checksum ${CHECKSUM}" OLDCHECKSUM=$(cat "${VERSIONFILE}" 2>/dev/null) -echo "Local checksum ${OLDCHECKSUM}" >> "${LOGFILE}" +echo "Local checksum ${OLDCHECKSUM}" #get new framework if no original framework, no local checksum, or remote checksum is different from local. if [ ! -e "${LOCALPATH}" ] || [ -z "$OLDCHECKSUM" ] || [ "$CHECKSUM" != "$OLDCHECKSUM" ]; then -echo "Downloading..." >> "${LOGFILE}" -echo -e "URL: ${URL}/${REMOTEPATH}" >> $LOGFILE -curl --header "X-JFrog-Art-Api: ${APITOKEN}" -f -X GET "$URL/$REMOTEPATH" --output "${NEWFILEPATH}" 2>>"${LOGFILE}" +echo "Downloading..." +echo -e "URL: ${URL}/${REMOTEPATH}" +curl --header "X-JFrog-Art-Api: ${APITOKEN}" -f -X GET "$URL/$REMOTEPATH" --output "${NEWFILEPATH}" if [ $? -eq 0 ] && [ -e "${NEWFILEPATH}" ]; then -echo "Finished Downloading, begin unzip" >> "${LOGFILE}" -unzip -q -o "${NEWFILEPATH}" -d "${LOCALDIR}" 2>>"${LOGFILE}" +echo "Finished Downloading, begin unzip" +unzip -q -o "${NEWFILEPATH}" -d "${LOCALDIR}" if [ $? -eq 0 ]; then -echo "Finished unzipping, remove zip" >> "${LOGFILE}" -rm -rf "${NEWFILEPATH}" 2>>"${LOGFILE}" -echo "Writing new checksum to file" >> "${LOGFILE}" -echo "${CHECKSUM}" > "${VERSIONFILE}" 2>>"${LOGFILE}" -echo "Successfully downloaded and unzipped archive." >> "${LOGFILE}" +echo "Finished unzipping, remove zip" +rm -rf "${NEWFILEPATH}" +echo "Writing new checksum to file" +echo "${CHECKSUM}" > "${VERSIONFILE}" +echo "Successfully downloaded and unzipped archive." else exit_with_error "Error unzipping" fi @@ -81,5 +77,5 @@ else exit_with_error "Failed to download" fi else -echo "Successful, No New Version" >> "${LOGFILE}" +echo "Successful, No New Version" fi From 291a956bdd98e870bad8d88b758783420596f166 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 30 Jun 2021 12:10:33 -0400 Subject: [PATCH 051/113] testing --- Scripts/download_framework.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/download_framework.sh b/Scripts/download_framework.sh index 079deed0..e4f97a2b 100755 --- a/Scripts/download_framework.sh +++ b/Scripts/download_framework.sh @@ -48,7 +48,7 @@ fi echo -e "Getting checksums..." echo -e "URL: ${URL}/api/storage/${REMOTEPATH}" JSON=$(curl --header "X-JFrog-Art-Api: ${APITOKEN}" -X GET "${URL}/api/storage/${REMOTEPATH}") -CHECKSUM=$(echo "$JSON" | python -c 'import sys, json; print json.load(sys.stdin)["checksums"]["sha1"]')" +CHECKSUM=$(echo "$JSON" | python -c 'import sys, json; print json.load(sys.stdin)["checksums"]["sha1"]') if [[ -z "$CHECKSUM" ]]; then exit_with_error "No Checksum found in json: ${JSON}" fi From 9a90b6d96bc0e7e0136c22db0c59df759246c3b6 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 30 Jun 2021 12:12:00 -0400 Subject: [PATCH 052/113] testing --- Scripts/download_framework.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/Scripts/download_framework.sh b/Scripts/download_framework.sh index e4f97a2b..45a4b416 100755 --- a/Scripts/download_framework.sh +++ b/Scripts/download_framework.sh @@ -48,6 +48,7 @@ fi echo -e "Getting checksums..." echo -e "URL: ${URL}/api/storage/${REMOTEPATH}" JSON=$(curl --header "X-JFrog-Art-Api: ${APITOKEN}" -X GET "${URL}/api/storage/${REMOTEPATH}") +echo "$JSON" CHECKSUM=$(echo "$JSON" | python -c 'import sys, json; print json.load(sys.stdin)["checksums"]["sha1"]') if [[ -z "$CHECKSUM" ]]; then exit_with_error "No Checksum found in json: ${JSON}" From 6808076d8d5b4ddc25f8db4fb664220d09149bbe Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 30 Jun 2021 12:13:57 -0400 Subject: [PATCH 053/113] testing --- Scripts/download_dependencies.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/download_dependencies.sh b/Scripts/download_dependencies.sh index 250bba40..76fb5db9 100755 --- a/Scripts/download_dependencies.sh +++ b/Scripts/download_dependencies.sh @@ -13,4 +13,4 @@ fi # Remote View Versions #BUILD_DIR=$(xcodebuild -showBuildSettings -project ../MVMCore/MVMCore.xcodeproj | grep -w -o 'BUILD_DIR = .*' | cut -d\ -f3-) -./download_framework.sh $ARTIFACTORY_URL "./MVMCore.framework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMCore/1.0/MVMCore-1.0-Debug-SNAPSHOT +./download_framework.sh $ARTIFACTORY_URL "./MVMCore.framework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMCore/1.0/MVMCore-1.0-Debug-SNAPSHOT.zip From 00a29ccc5dee8927a46d043821b94bd33b4432fe Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 30 Jun 2021 12:38:57 -0400 Subject: [PATCH 054/113] testing --- Scripts/download_framework.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Scripts/download_framework.sh b/Scripts/download_framework.sh index 45a4b416..1d52486a 100755 --- a/Scripts/download_framework.sh +++ b/Scripts/download_framework.sh @@ -54,7 +54,11 @@ if [[ -z "$CHECKSUM" ]]; then exit_with_error "No Checksum found in json: ${JSON}" fi echo "Remote checksum ${CHECKSUM}" -OLDCHECKSUM=$(cat "${VERSIONFILE}" 2>/dev/null) +if [[ -f "${VERSIONFILE}" ]]; then +OLDCHECKSUM=$(cat "${VERSIONFILE}") +else +OLDCHECKSUM="none" +fi echo "Local checksum ${OLDCHECKSUM}" #get new framework if no original framework, no local checksum, or remote checksum is different from local. From 60b67e33509478754405b23d39be85144a65a539 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 30 Jun 2021 16:39:02 -0400 Subject: [PATCH 055/113] testing --- Scripts/download_framework.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/Scripts/download_framework.sh b/Scripts/download_framework.sh index 1d52486a..27e408c4 100755 --- a/Scripts/download_framework.sh +++ b/Scripts/download_framework.sh @@ -58,6 +58,7 @@ if [[ -f "${VERSIONFILE}" ]]; then OLDCHECKSUM=$(cat "${VERSIONFILE}") else OLDCHECKSUM="none" +mkdir -p $(dirname ${VERSIONFILE}) && touch "$VERSIONFILE" fi echo "Local checksum ${OLDCHECKSUM}" From 323d44deb6ffa55499debee95f974ec00e6126d4 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 30 Jun 2021 17:14:45 -0400 Subject: [PATCH 056/113] build and deploy --- .gitlab-ci.yml | 56 ++++++++++++++-------------- Scripts/build_aggregate.sh | 26 +++++++++++++ Scripts/download_dependencies.sh | 7 +++- Scripts/upload_core_frameworks.sh | 24 ------------ Scripts/upload_core_ui_frameworks.sh | 24 ++++++++++++ 5 files changed, 82 insertions(+), 55 deletions(-) create mode 100755 Scripts/build_aggregate.sh delete mode 100755 Scripts/upload_core_frameworks.sh create mode 100755 Scripts/upload_core_ui_frameworks.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 20a59212..006d149e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,8 +1,8 @@ stages: # - test - download -# - build -# - deploy + - build + - deploy #test: # stage: test @@ -14,8 +14,7 @@ stages: download_artifacts: stage: download script: - - cd Scripts && ./download_dependencies.sh - # - ./Scripts/download_dependencies.sh + - ./Scripts/download_dependencies.sh only: - branches - feature/script_to_upload @@ -27,31 +26,30 @@ download_artifacts: variables: ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory -#build_project: -# stage: build -# script: -# - xcodebuild build -project MVMCore/MVMCore.xcodeproj -scheme FatLibrary | xcpretty -# - BUILD_DIR=$(xcodebuild -showBuildSettings -project MVMCore/MVMCore.xcodeproj | grep BUILD_DIR) -# only: -# - branches -# - develop -# tags: -# - xcode_12_2 -# -#deploy_snapshot: -# stage: deploy -# script: -# - cd Scripts && ./upload_core_frameworks.sh -# only: -# - branches -# - develop -# tags: -# - bash_shell -# environment: -# name: oneartifactory -# url: https://oneartifactoryprod.verizon.com/artifactory -# variables: -# ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory +build_project: + stage: build + script: + - ./Scripts/build_aggregate.sh + only: + - branches + - develop + tags: + - xcode_12_2 + +deploy_snapshot: + stage: deploy + script: + - cd Scripts && ./upload_core_ui_frameworks.sh + only: + - branches + - develop + tags: + - bash_shell + environment: + name: oneartifactory + url: https://oneartifactoryprod.verizon.com/artifactory + variables: + ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory #promote_snapshot: # stage: go live diff --git a/Scripts/build_aggregate.sh b/Scripts/build_aggregate.sh new file mode 100755 index 00000000..ec355f66 --- /dev/null +++ b/Scripts/build_aggregate.sh @@ -0,0 +1,26 @@ +unset TOOLCHAINS #Xcode 7.3 BUG FIX http://stackoverflow.com/questions/36184930/xcodebuild-7-3-cant-enable-bitcode + +# define output folder environment variable +C_PROJECT_NAME="MVMCoreUI" +PHONE_CONFIGURATION="Release" +SIMULATOR_CONFIGURATION="Debug" + +BUILD_DIR=$(xcodebuild -showBuildSettings -project ./MVMCoreUI.xcodeproj | grep -w -o 'BUILD_DIR = .*' | cut -d\ -f3-) + +UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal + +# Step 1. Build Device and Simulator versions +xcodebuild -scheme "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath "${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}" archive SKIP_INSTALL=false FRAMEWORK_SEARCH_PATHS=./Frameworks + +xcodebuild -target "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator -arch x86_64 BUILD_DIR="${BUILD_DIR}" FRAMEWORK_SEARCH_PATHS=./Frameworks + +mkdir -p "${UNIVERSAL_OUTPUTFOLDER}" + +rm -rf ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework +cp -R ${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/"${C_PROJECT_NAME}".xcarchive/Products/Library/Frameworks/${C_PROJECT_NAME}.framework ${UNIVERSAL_OUTPUTFOLDER} + +# Step 2. Create universal binary file using lipo + +lipo -create -output "${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}" "${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}" "${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}" + +mv ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME} ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME} diff --git a/Scripts/download_dependencies.sh b/Scripts/download_dependencies.sh index 76fb5db9..3aa8e879 100755 --- a/Scripts/download_dependencies.sh +++ b/Scripts/download_dependencies.sh @@ -11,6 +11,9 @@ if [ -z $ARTIFACTORY_URL ]; then ARTIFACTORY_URL="https://oneartifactoryprod.verizon.com/artifactory" fi +[ ! -d "./Frameworks" ] && echo mkdir "Frameworks" + # Remote View Versions -#BUILD_DIR=$(xcodebuild -showBuildSettings -project ../MVMCore/MVMCore.xcodeproj | grep -w -o 'BUILD_DIR = .*' | cut -d\ -f3-) -./download_framework.sh $ARTIFACTORY_URL "./MVMCore.framework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMCore/1.0/MVMCore-1.0-Debug-SNAPSHOT.zip +./Scripts/download_framework.sh $ARTIFACTORY_URL "./Frameworks/MVMCore.framework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMCore/1.0/MVMCore-1.0-Debug-SNAPSHOT.zip + +./Scripts/download_framework.sh $ARTIFACTORY_URL "./Frameworks/MVMAnimationFramework.framework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMAnimationFramework.framework/1.9/MVMAnimationFramework.framework-1.9.zip diff --git a/Scripts/upload_core_frameworks.sh b/Scripts/upload_core_frameworks.sh deleted file mode 100755 index 714cf163..00000000 --- a/Scripts/upload_core_frameworks.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -e - -# upload_core_frameworks.sh -# -# Uploads all compiled framework flavors in MVMCore to Artifactory with the SNAPSHOT classifier. This is to avoid accidently clobbering a release build of a particular version. Remove the classifier in Artificatory to make a release. -# -# Copied from Hedden, Kyle Matthew on 3/2/18. -# - -FRAMEWORK_VERSION=$(cd ../MVMCore && agvtool vers -terse) -if [ $(git tag --list | grep "v${FRAMEWORK_VERSION}") ]; then - echo This version tag has already been committed! Aborting! - exit 1 -fi - -# Create new aggregate builds - -if [ -z $ARTIFACTORY_URL ]; then - ARTIFACTORY_URL="https://oneartifactoryprod.verizon.com/artifactory" -fi - -# Remote View Versions -BUILD_DIR=$(xcodebuild -showBuildSettings -project ../MVMCore/MVMCore.xcodeproj | grep -w -o 'BUILD_DIR = .*' | cut -d\ -f3-) -./upload_framework.sh $ARTIFACTORY_URL "${BUILD_DIR}/universal/MVMCore.framework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMCore/[VER]/MVMCore-[VER]-Debug-SNAPSHOT diff --git a/Scripts/upload_core_ui_frameworks.sh b/Scripts/upload_core_ui_frameworks.sh new file mode 100755 index 00000000..4a16396c --- /dev/null +++ b/Scripts/upload_core_ui_frameworks.sh @@ -0,0 +1,24 @@ +#!/bin/sh -e + +# upload_core_ui_frameworks.sh +# +# Uploads all compiled framework flavors in MVMCoreUI to Artifactory with the SNAPSHOT classifier. This is to avoid accidently clobbering a release build of a particular version. Remove the classifier in Artificatory to make a release. +# +# Copied from Hedden, Kyle Matthew on 3/2/18. +# + +FRAMEWORK_VERSION=$(cd .. && agvtool vers -terse) +if [ $(git tag --list | grep "v${FRAMEWORK_VERSION}") ]; then + echo This version tag has already been committed! Aborting! + exit 1 +fi + +# Create new aggregate builds + +if [ -z $ARTIFACTORY_URL ]; then + ARTIFACTORY_URL="https://oneartifactoryprod.verizon.com/artifactory" +fi + +# Upload +BUILD_DIR=$(xcodebuild -showBuildSettings -project ../MVMCoreUI.xcodeproj | grep -w -o 'BUILD_DIR = .*' | cut -d\ -f3-) +./upload_framework.sh $ARTIFACTORY_URL "${BUILD_DIR}/universal/MVMCoreUI.framework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMCoreUI/[VER]/MVMCoreUI-[VER]-Debug-SNAPSHOT From de8c4b8e8d876a7473c6c9bbfed6ab8e46345088 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 30 Jun 2021 17:18:29 -0400 Subject: [PATCH 057/113] build and deploy --- Scripts/download_dependencies.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/download_dependencies.sh b/Scripts/download_dependencies.sh index 3aa8e879..5bf6342d 100755 --- a/Scripts/download_dependencies.sh +++ b/Scripts/download_dependencies.sh @@ -11,7 +11,7 @@ if [ -z $ARTIFACTORY_URL ]; then ARTIFACTORY_URL="https://oneartifactoryprod.verizon.com/artifactory" fi -[ ! -d "./Frameworks" ] && echo mkdir "Frameworks" +[ ! -d "./Frameworks" ] && mkdir "Frameworks" # Remote View Versions ./Scripts/download_framework.sh $ARTIFACTORY_URL "./Frameworks/MVMCore.framework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMCore/1.0/MVMCore-1.0-Debug-SNAPSHOT.zip From 67e2ccafb4a4efea7bcdfdc261f4fdbbc7c3e396 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 30 Jun 2021 17:22:05 -0400 Subject: [PATCH 058/113] build and deploy --- Scripts/download_dependencies.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Scripts/download_dependencies.sh b/Scripts/download_dependencies.sh index 5bf6342d..5fbcc8ad 100755 --- a/Scripts/download_dependencies.sh +++ b/Scripts/download_dependencies.sh @@ -11,7 +11,12 @@ if [ -z $ARTIFACTORY_URL ]; then ARTIFACTORY_URL="https://oneartifactoryprod.verizon.com/artifactory" fi -[ ! -d "./Frameworks" ] && mkdir "Frameworks" +if [ ! -d "./Frameworks" ]; then +echo "make frameworks folder at $(pwd)/Frameworks" +mkdir "Frameworks" +else +pwd +fi # Remote View Versions ./Scripts/download_framework.sh $ARTIFACTORY_URL "./Frameworks/MVMCore.framework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMCore/1.0/MVMCore-1.0-Debug-SNAPSHOT.zip From be01a1c2b3b67d8732f33ce8774d6875707c7b35 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 30 Jun 2021 17:24:42 -0400 Subject: [PATCH 059/113] build and deploy --- Scripts/download_dependencies.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Scripts/download_dependencies.sh b/Scripts/download_dependencies.sh index 5fbcc8ad..7ef0e7be 100755 --- a/Scripts/download_dependencies.sh +++ b/Scripts/download_dependencies.sh @@ -13,7 +13,8 @@ fi if [ ! -d "./Frameworks" ]; then echo "make frameworks folder at $(pwd)/Frameworks" -mkdir "Frameworks" +mkdir "./Frameworks" +ls else pwd fi From b86c1994d868e2a6e86c8a183ce2157548e5f81a Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 30 Jun 2021 17:28:23 -0400 Subject: [PATCH 060/113] build and deploy --- Scripts/download_dependencies.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Scripts/download_dependencies.sh b/Scripts/download_dependencies.sh index 7ef0e7be..74da129b 100755 --- a/Scripts/download_dependencies.sh +++ b/Scripts/download_dependencies.sh @@ -14,7 +14,7 @@ fi if [ ! -d "./Frameworks" ]; then echo "make frameworks folder at $(pwd)/Frameworks" mkdir "./Frameworks" -ls +ls "./" else pwd fi @@ -23,3 +23,5 @@ fi ./Scripts/download_framework.sh $ARTIFACTORY_URL "./Frameworks/MVMCore.framework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMCore/1.0/MVMCore-1.0-Debug-SNAPSHOT.zip ./Scripts/download_framework.sh $ARTIFACTORY_URL "./Frameworks/MVMAnimationFramework.framework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMAnimationFramework.framework/1.9/MVMAnimationFramework.framework-1.9.zip + +ls "./Frameworks" From 794e5ea5534d4424f4aa32b67842fcf32752487d Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 30 Jun 2021 17:40:01 -0400 Subject: [PATCH 061/113] build and deploy --- Scripts/build_aggregate.sh | 5 +++-- Scripts/download_dependencies.sh | 18 +++++++----------- Scripts/download_framework.sh | 2 +- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Scripts/build_aggregate.sh b/Scripts/build_aggregate.sh index ec355f66..a9fb4d3a 100755 --- a/Scripts/build_aggregate.sh +++ b/Scripts/build_aggregate.sh @@ -6,13 +6,14 @@ PHONE_CONFIGURATION="Release" SIMULATOR_CONFIGURATION="Debug" BUILD_DIR=$(xcodebuild -showBuildSettings -project ./MVMCoreUI.xcodeproj | grep -w -o 'BUILD_DIR = .*' | cut -d\ -f3-) +FRAMEWORKS_DIR=$BUILD_DIR/Frameworks UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal # Step 1. Build Device and Simulator versions -xcodebuild -scheme "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath "${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}" archive SKIP_INSTALL=false FRAMEWORK_SEARCH_PATHS=./Frameworks +xcodebuild -scheme "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath "${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}" archive SKIP_INSTALL=false FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR -xcodebuild -target "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator -arch x86_64 BUILD_DIR="${BUILD_DIR}" FRAMEWORK_SEARCH_PATHS=./Frameworks +xcodebuild -target "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator -arch x86_64 BUILD_DIR="${BUILD_DIR}" FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR mkdir -p "${UNIVERSAL_OUTPUTFOLDER}" diff --git a/Scripts/download_dependencies.sh b/Scripts/download_dependencies.sh index 74da129b..66742216 100755 --- a/Scripts/download_dependencies.sh +++ b/Scripts/download_dependencies.sh @@ -11,17 +11,13 @@ if [ -z $ARTIFACTORY_URL ]; then ARTIFACTORY_URL="https://oneartifactoryprod.verizon.com/artifactory" fi -if [ ! -d "./Frameworks" ]; then -echo "make frameworks folder at $(pwd)/Frameworks" -mkdir "./Frameworks" -ls "./" -else -pwd +BUILD_DIR=$(xcodebuild -showBuildSettings -project ./MVMCoreUI.xcodeproj | grep -w -o 'BUILD_DIR = .*' | cut -d\ -f3-) +FRAMEWORKS_DIR=$BUILD_DIR/Frameworks + +if [ ! -d $FRAMEWORKS_DIR ]; then +mkdir $FRAMEWORKS_DIR fi -# Remote View Versions -./Scripts/download_framework.sh $ARTIFACTORY_URL "./Frameworks/MVMCore.framework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMCore/1.0/MVMCore-1.0-Debug-SNAPSHOT.zip +./Scripts/download_framework.sh $ARTIFACTORY_URL "$FRAMEWORKS_DIR/MVMCore.framework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMCore/1.0/MVMCore-1.0-Debug-SNAPSHOT.zip -./Scripts/download_framework.sh $ARTIFACTORY_URL "./Frameworks/MVMAnimationFramework.framework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMAnimationFramework.framework/1.9/MVMAnimationFramework.framework-1.9.zip - -ls "./Frameworks" +./Scripts/download_framework.sh $ARTIFACTORY_URL "$FRAMEWORKS_DIR/MVMAnimationFramework.framework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMAnimationFramework.framework/1.9/MVMAnimationFramework.framework-1.9.zip diff --git a/Scripts/download_framework.sh b/Scripts/download_framework.sh index 27e408c4..f4a18693 100755 --- a/Scripts/download_framework.sh +++ b/Scripts/download_framework.sh @@ -14,7 +14,7 @@ LOGFILE=$3 LOCALDIR=$(dirname "${LOCALPATH}") LOCALBASE=$(basename "${LOCALPATH}") NEWFILEPATH="${LOCALDIR}"/$(basename "${REMOTEPATH}") -VERSIONFILE=./Checksums/"${LOCALBASE}".txt +VERSIONFILE=$LOCALDIR/../Checksums/"${LOCALBASE}".txt if [ -z $URL ]; then echo "The artifactory instance url must be specified as the first argument!" From 495eb1d4bd2838f06ade6f4500c7600249986187 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Thu, 1 Jul 2021 11:56:12 +0530 Subject: [PATCH 062/113] Making ListLeftVariableIconWithRightCaretBodyTextModel class open to subclass --- .../ListLeftVariableIconWithRightCaretBodyTextModel.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift index 5076eb9e..9e93b01d 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift @@ -7,12 +7,12 @@ // -public class ListLeftVariableIconWithRightCaretBodyTextModel: ListItemModel, MoleculeModelProtocol { +open class ListLeftVariableIconWithRightCaretBodyTextModel: ListItemModel, MoleculeModelProtocol { //----------------------------------------------------- // MARK: - Properties //----------------------------------------------------- - public static var identifier: String = "listLVImgBdy" + open class var identifier: String { return "listLVImgBdy" } public var image: ImageViewModel public var headlineBody: HeadlineBodyModel public var rightLabel: LabelModel From a1ba6cd7b1de805814e42973f48f27080a4fb43e Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 1 Jul 2021 09:22:41 -0400 Subject: [PATCH 063/113] build and deploy --- MVMCoreUI.xcodeproj/project.pbxproj | 2 +- Scripts/build_aggregate.sh | 2 +- Scripts/download_framework.sh | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index b53e6ceb..9785a981 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -2545,7 +2545,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "unset TOOLCHAINS #Xcode 7.3 BUG FIX http://stackoverflow.com/questions/36184930/xcodebuild-7-3-cant-enable-bitcode\n\n# define output folder environment variable\nC_PROJECT_NAME=\"MVMCoreUI\"\nPHONE_CONFIGURATION=\"Release\"\nSIMULATOR_CONFIGURATION=\"Debug\"\n\nUNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal\n\n# Step 1. Build Device and Simulator versions\nxcodebuild -scheme \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath \"${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}\" archive SKIP_INSTALL=false\n\n#xcodebuild -target \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator -arch x86_64 BUILD_DIR=\"${BUILD_DIR}\"\n\n#mkdir -p \"${UNIVERSAL_OUTPUTFOLDER}\"\n\n#rm -rf ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework\n#cp -R ${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/\"${C_PROJECT_NAME}\".xcarchive/Products/Library/Frameworks/${C_PROJECT_NAME}.framework ${UNIVERSAL_OUTPUTFOLDER}\n\n# Step 2. Create universal binary file using lipo\n\n#lipo -create -output \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}\" \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\" \"${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\"\n\n#mv ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME} ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\n"; + shellScript = "unset TOOLCHAINS #Xcode 7.3 BUG FIX http://stackoverflow.com/questions/36184930/xcodebuild-7-3-cant-enable-bitcode\n\n# define output folder environment variable\nC_PROJECT_NAME=\"MVMCoreUI\"\nPHONE_CONFIGURATION=\"Release\"\nSIMULATOR_CONFIGURATION=\"Debug\"\n\nUNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal\n\n# Step 1. Build Device and Simulator versions\nxcodebuild -scheme \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath \"${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}\" archive SKIP_INSTALL=false\n\nxcodebuild -target \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator -arch x86_64 BUILD_DIR=\"${BUILD_DIR}\"\n\nmkdir -p \"${UNIVERSAL_OUTPUTFOLDER}\"\n\nrm -rf ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework\ncp -R ${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/\"${C_PROJECT_NAME}\".xcarchive/Products/Library/Frameworks/${C_PROJECT_NAME}.framework ${UNIVERSAL_OUTPUTFOLDER}\n\n# Step 2. Create universal binary file using lipo\n\nlipo -create -output \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}\" \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\" \"${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\"\n\nmv ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME} ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\n"; }; /* End PBXShellScriptBuildPhase section */ diff --git a/Scripts/build_aggregate.sh b/Scripts/build_aggregate.sh index a9fb4d3a..7b5a57c7 100755 --- a/Scripts/build_aggregate.sh +++ b/Scripts/build_aggregate.sh @@ -13,7 +13,7 @@ UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal # Step 1. Build Device and Simulator versions xcodebuild -scheme "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath "${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}" archive SKIP_INSTALL=false FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR -xcodebuild -target "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator -arch x86_64 BUILD_DIR="${BUILD_DIR}" FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR +xcodebuild -target "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator -arch x86_64 FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR mkdir -p "${UNIVERSAL_OUTPUTFOLDER}" diff --git a/Scripts/download_framework.sh b/Scripts/download_framework.sh index f4a18693..a9660d7f 100755 --- a/Scripts/download_framework.sh +++ b/Scripts/download_framework.sh @@ -48,7 +48,6 @@ fi echo -e "Getting checksums..." echo -e "URL: ${URL}/api/storage/${REMOTEPATH}" JSON=$(curl --header "X-JFrog-Art-Api: ${APITOKEN}" -X GET "${URL}/api/storage/${REMOTEPATH}") -echo "$JSON" CHECKSUM=$(echo "$JSON" | python -c 'import sys, json; print json.load(sys.stdin)["checksums"]["sha1"]') if [[ -z "$CHECKSUM" ]]; then exit_with_error "No Checksum found in json: ${JSON}" From 997a3c96b74bb9a847d7ef6414da8f580fc6185b Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 1 Jul 2021 09:33:35 -0400 Subject: [PATCH 064/113] build and deploy --- Scripts/build_aggregate.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/Scripts/build_aggregate.sh b/Scripts/build_aggregate.sh index 7b5a57c7..8f8d4e6e 100755 --- a/Scripts/build_aggregate.sh +++ b/Scripts/build_aggregate.sh @@ -7,6 +7,7 @@ SIMULATOR_CONFIGURATION="Debug" BUILD_DIR=$(xcodebuild -showBuildSettings -project ./MVMCoreUI.xcodeproj | grep -w -o 'BUILD_DIR = .*' | cut -d\ -f3-) FRAMEWORKS_DIR=$BUILD_DIR/Frameworks +echo $FRAMEWORKS_DIR UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal From dafe8e316043e8f21b802404de8b23d8549aa401 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 1 Jul 2021 11:44:33 -0400 Subject: [PATCH 065/113] build and deploy --- Scripts/build_aggregate.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Scripts/build_aggregate.sh b/Scripts/build_aggregate.sh index 8f8d4e6e..17dc2151 100755 --- a/Scripts/build_aggregate.sh +++ b/Scripts/build_aggregate.sh @@ -14,6 +14,8 @@ UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal # Step 1. Build Device and Simulator versions xcodebuild -scheme "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath "${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}" archive SKIP_INSTALL=false FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR +#copy the framework into the build directory where it is looking for it. +ditto $FRAMEWORKS_DIR/MVMCore.framework "${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/MVMCore.framework xcodebuild -target "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator -arch x86_64 FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR mkdir -p "${UNIVERSAL_OUTPUTFOLDER}" From 143fe459c21b7698179f7014542e4e5771226ab6 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 1 Jul 2021 12:11:12 -0400 Subject: [PATCH 066/113] build and deploy --- Scripts/build_aggregate.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Scripts/build_aggregate.sh b/Scripts/build_aggregate.sh index 17dc2151..762969ca 100755 --- a/Scripts/build_aggregate.sh +++ b/Scripts/build_aggregate.sh @@ -15,8 +15,8 @@ UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal xcodebuild -scheme "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath "${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}" archive SKIP_INSTALL=false FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR #copy the framework into the build directory where it is looking for it. -ditto $FRAMEWORKS_DIR/MVMCore.framework "${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/MVMCore.framework -xcodebuild -target "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator -arch x86_64 FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR +#ditto "$FRAMEWORKS_DIR/MVMCore.framework" "${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/MVMCore.framework +xcodebuild -target "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator -arch x86_64 FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR ALWAYS_SEARCH_USER_PATHS=true mkdir -p "${UNIVERSAL_OUTPUTFOLDER}" From 119399b6745c4ef5cc02e05081702c522f4b5035 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 1 Jul 2021 12:16:01 -0400 Subject: [PATCH 067/113] build and deploy --- Scripts/build_aggregate.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Scripts/build_aggregate.sh b/Scripts/build_aggregate.sh index 762969ca..38da239e 100755 --- a/Scripts/build_aggregate.sh +++ b/Scripts/build_aggregate.sh @@ -11,6 +11,8 @@ echo $FRAMEWORKS_DIR UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal +xcodebuild -project ./MVMCoreUI.xcodeproj -clean + # Step 1. Build Device and Simulator versions xcodebuild -scheme "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath "${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}" archive SKIP_INSTALL=false FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR From 3b0a2b3b32a838373bf3804dc5f7799f2d5b0bcb Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 1 Jul 2021 12:22:11 -0400 Subject: [PATCH 068/113] build and deploy --- Scripts/build_aggregate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/build_aggregate.sh b/Scripts/build_aggregate.sh index 38da239e..f90bf01c 100755 --- a/Scripts/build_aggregate.sh +++ b/Scripts/build_aggregate.sh @@ -11,7 +11,7 @@ echo $FRAMEWORKS_DIR UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal -xcodebuild -project ./MVMCoreUI.xcodeproj -clean +xcodebuild -project ./MVMCoreUI.xcodeproj clean # Step 1. Build Device and Simulator versions xcodebuild -scheme "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath "${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}" archive SKIP_INSTALL=false FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR From 9f7dbbb1bf09a62b3a704e9e3fe4211f0d5868c0 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 1 Jul 2021 12:30:41 -0400 Subject: [PATCH 069/113] build and deploy --- Scripts/build_aggregate.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Scripts/build_aggregate.sh b/Scripts/build_aggregate.sh index f90bf01c..312133e9 100755 --- a/Scripts/build_aggregate.sh +++ b/Scripts/build_aggregate.sh @@ -11,10 +11,8 @@ echo $FRAMEWORKS_DIR UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal -xcodebuild -project ./MVMCoreUI.xcodeproj clean - # Step 1. Build Device and Simulator versions -xcodebuild -scheme "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath "${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}" archive SKIP_INSTALL=false FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR +xcodebuild -scheme "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath "${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}" archive SKIP_INSTALL=false #copy the framework into the build directory where it is looking for it. #ditto "$FRAMEWORKS_DIR/MVMCore.framework" "${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/MVMCore.framework From 10818afbdfcbebb85f2dc596f0b3958d2f419dde Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 1 Jul 2021 12:36:42 -0400 Subject: [PATCH 070/113] build and deploy --- Scripts/build_aggregate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/build_aggregate.sh b/Scripts/build_aggregate.sh index 312133e9..762969ca 100755 --- a/Scripts/build_aggregate.sh +++ b/Scripts/build_aggregate.sh @@ -12,7 +12,7 @@ echo $FRAMEWORKS_DIR UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal # Step 1. Build Device and Simulator versions -xcodebuild -scheme "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath "${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}" archive SKIP_INSTALL=false +xcodebuild -scheme "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath "${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}" archive SKIP_INSTALL=false FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR #copy the framework into the build directory where it is looking for it. #ditto "$FRAMEWORKS_DIR/MVMCore.framework" "${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/MVMCore.framework From 12f8ea8130e7812a25b20cfeeaf02e8199e235c6 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 1 Jul 2021 13:00:54 -0400 Subject: [PATCH 071/113] build and deploy --- Scripts/build_aggregate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/build_aggregate.sh b/Scripts/build_aggregate.sh index 762969ca..8bcb83f0 100755 --- a/Scripts/build_aggregate.sh +++ b/Scripts/build_aggregate.sh @@ -16,7 +16,7 @@ xcodebuild -scheme "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${PHON #copy the framework into the build directory where it is looking for it. #ditto "$FRAMEWORKS_DIR/MVMCore.framework" "${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/MVMCore.framework -xcodebuild -target "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator -arch x86_64 FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR ALWAYS_SEARCH_USER_PATHS=true +xcodebuild -target "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR ALWAYS_SEARCH_USER_PATHS=true mkdir -p "${UNIVERSAL_OUTPUTFOLDER}" From 5732fbc9492b68dea65c423c1c633631c570bc66 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 1 Jul 2021 13:05:21 -0400 Subject: [PATCH 072/113] build and deploy --- Scripts/build_aggregate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/build_aggregate.sh b/Scripts/build_aggregate.sh index 8bcb83f0..a774a1cf 100755 --- a/Scripts/build_aggregate.sh +++ b/Scripts/build_aggregate.sh @@ -16,7 +16,7 @@ xcodebuild -scheme "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${PHON #copy the framework into the build directory where it is looking for it. #ditto "$FRAMEWORKS_DIR/MVMCore.framework" "${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/MVMCore.framework -xcodebuild -target "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR ALWAYS_SEARCH_USER_PATHS=true +xcodebuild -target "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator mkdir -p "${UNIVERSAL_OUTPUTFOLDER}" From d26a8a2a1bf3367d1559a4e59cf8b68906122080 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 1 Jul 2021 13:11:49 -0400 Subject: [PATCH 073/113] build and deploy --- Scripts/build_aggregate.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Scripts/build_aggregate.sh b/Scripts/build_aggregate.sh index a774a1cf..f73cde7d 100755 --- a/Scripts/build_aggregate.sh +++ b/Scripts/build_aggregate.sh @@ -12,19 +12,19 @@ echo $FRAMEWORKS_DIR UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal # Step 1. Build Device and Simulator versions -xcodebuild -scheme "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath "${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}" archive SKIP_INSTALL=false FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR +#xcodebuild -scheme "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath "${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}" archive SKIP_INSTALL=false FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR ALWAYS_SEARCH_USER_PATHS=true #copy the framework into the build directory where it is looking for it. #ditto "$FRAMEWORKS_DIR/MVMCore.framework" "${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/MVMCore.framework -xcodebuild -target "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator +xcodebuild -target "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR ALWAYS_SEARCH_USER_PATHS=true ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=true -mkdir -p "${UNIVERSAL_OUTPUTFOLDER}" - -rm -rf ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework -cp -R ${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/"${C_PROJECT_NAME}".xcarchive/Products/Library/Frameworks/${C_PROJECT_NAME}.framework ${UNIVERSAL_OUTPUTFOLDER} - -# Step 2. Create universal binary file using lipo - -lipo -create -output "${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}" "${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}" "${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}" - -mv ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME} ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME} +#mkdir -p "${UNIVERSAL_OUTPUTFOLDER}" +# +#rm -rf ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework +#cp -R ${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/"${C_PROJECT_NAME}".xcarchive/Products/Library/Frameworks/${C_PROJECT_NAME}.framework ${UNIVERSAL_OUTPUTFOLDER} +# +## Step 2. Create universal binary file using lipo +# +#lipo -create -output "${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}" "${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}" "${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}" +# +#mv ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME} ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME} From 83a6b21ce644e7be0d7481ea0ac41d95ddada3e3 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 1 Jul 2021 13:12:25 -0400 Subject: [PATCH 074/113] build and deploy --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 006d149e..17444e42 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,6 @@ stages: # - test - - download +# - download - build - deploy From 37967a447a4a2e0663bcade766e0579df7189811 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 1 Jul 2021 13:15:09 -0400 Subject: [PATCH 075/113] build and deploy --- .gitlab-ci.yml | 58 +++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 17444e42..1d36ea20 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,7 +2,7 @@ stages: # - test # - download - build - - deploy +# - deploy #test: # stage: test @@ -11,20 +11,20 @@ stages: # tags: # - xcode_12_2 -download_artifacts: - stage: download - script: - - ./Scripts/download_dependencies.sh - only: - - branches - - feature/script_to_upload - tags: - - bash_shell - environment: - name: oneartifactory - url: https://oneartifactoryprod.verizon.com/artifactory - variables: - ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory +#download_artifacts: +# stage: download +# script: +# - ./Scripts/download_dependencies.sh +# only: +# - branches +# - feature/script_to_upload +# tags: +# - bash_shell +# environment: +# name: oneartifactory +# url: https://oneartifactoryprod.verizon.com/artifactory +# variables: +# ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory build_project: stage: build @@ -36,20 +36,20 @@ build_project: tags: - xcode_12_2 -deploy_snapshot: - stage: deploy - script: - - cd Scripts && ./upload_core_ui_frameworks.sh - only: - - branches - - develop - tags: - - bash_shell - environment: - name: oneartifactory - url: https://oneartifactoryprod.verizon.com/artifactory - variables: - ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory +#deploy_snapshot: +# stage: deploy +# script: +# - cd Scripts && ./upload_core_ui_frameworks.sh +# only: +# - branches +# - develop +# tags: +# - bash_shell +# environment: +# name: oneartifactory +# url: https://oneartifactoryprod.verizon.com/artifactory +# variables: +# ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory #promote_snapshot: # stage: go live From f4935da4769ce82f736d8897c272c6b0240e2a50 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 1 Jul 2021 13:47:05 -0400 Subject: [PATCH 076/113] build and deploy --- MVMCoreUI.xcodeproj/project.pbxproj | 66 ----------------------------- 1 file changed, 66 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 9785a981..c9833c3f 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -6,20 +6,6 @@ objectVersion = 48; objects = { -/* Begin PBXAggregateTarget section */ - D23F60FA268CBB5E007914AB /* MVMCoreUIAggregate */ = { - isa = PBXAggregateTarget; - buildConfigurationList = D23F60FD268CBB5E007914AB /* Build configuration list for PBXAggregateTarget "MVMCoreUIAggregate" */; - buildPhases = ( - D23F6100268CBB71007914AB /* ShellScript */, - ); - dependencies = ( - ); - name = MVMCoreUIAggregate; - productName = MVMCoreUIAggregate; - }; -/* End PBXAggregateTarget section */ - /* Begin PBXBuildFile section */ 01004F3022721C3800991ECC /* RadioButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01004F2F22721C3800991ECC /* RadioButton.swift */; }; 0103B84E23D7E33A009C315C /* HeadlineBodyToggleModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0103B84D23D7E33A009C315C /* HeadlineBodyToggleModel.swift */; }; @@ -2480,10 +2466,6 @@ LastUpgradeCheck = 1010; ORGANIZATIONNAME = "Verizon Wireless"; TargetAttributes = { - D23F60FA268CBB5E007914AB = { - CreatedOnToolsVersion = 12.4; - ProvisioningStyle = Automatic; - }; D29DF0CB21E404D4003B2FB9 = { CreatedOnToolsVersion = 10.1; LastSwiftMigration = 1010; @@ -2506,7 +2488,6 @@ projectRoot = ""; targets = ( D29DF0CB21E404D4003B2FB9 /* MVMCoreUI */, - D23F60FA268CBB5E007914AB /* MVMCoreUIAggregate */, ); }; /* End PBXProject section */ @@ -2529,26 +2510,6 @@ }; /* End PBXResourcesBuildPhase section */ -/* Begin PBXShellScriptBuildPhase section */ - D23F6100268CBB71007914AB /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - ); - outputFileListPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "unset TOOLCHAINS #Xcode 7.3 BUG FIX http://stackoverflow.com/questions/36184930/xcodebuild-7-3-cant-enable-bitcode\n\n# define output folder environment variable\nC_PROJECT_NAME=\"MVMCoreUI\"\nPHONE_CONFIGURATION=\"Release\"\nSIMULATOR_CONFIGURATION=\"Debug\"\n\nUNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal\n\n# Step 1. Build Device and Simulator versions\nxcodebuild -scheme \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath \"${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}\" archive SKIP_INSTALL=false\n\nxcodebuild -target \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator -arch x86_64 BUILD_DIR=\"${BUILD_DIR}\"\n\nmkdir -p \"${UNIVERSAL_OUTPUTFOLDER}\"\n\nrm -rf ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework\ncp -R ${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/\"${C_PROJECT_NAME}\".xcarchive/Products/Library/Frameworks/${C_PROJECT_NAME}.framework ${UNIVERSAL_OUTPUTFOLDER}\n\n# Step 2. Create universal binary file using lipo\n\nlipo -create -output \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}\" \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\" \"${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\"\n\nmv ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME} ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\n"; - }; -/* End PBXShellScriptBuildPhase section */ - /* Begin PBXSourcesBuildPhase section */ D29DF0C821E404D4003B2FB9 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -3077,24 +3038,6 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ - D23F60FB268CBB5E007914AB /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = FCMA4QKS77; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Debug; - }; - D23F60FC268CBB5E007914AB /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = FCMA4QKS77; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Release; - }; D29DF0D221E404D4003B2FB9 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -3274,15 +3217,6 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - D23F60FD268CBB5E007914AB /* Build configuration list for PBXAggregateTarget "MVMCoreUIAggregate" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - D23F60FB268CBB5E007914AB /* Debug */, - D23F60FC268CBB5E007914AB /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; D29DF0C621E404D4003B2FB9 /* Build configuration list for PBXProject "MVMCoreUI" */ = { isa = XCConfigurationList; buildConfigurations = ( From bb72b6ecc7c8495ec494500db2cc1e9399d324d6 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 1 Jul 2021 13:48:57 -0400 Subject: [PATCH 077/113] build and deploy --- .gitlab-ci.yml | 30 +++++++++++++++--------------- Scripts/build_aggregate.sh | 2 -- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1d36ea20..7735fb50 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,6 @@ stages: # - test -# - download + - download - build # - deploy @@ -11,20 +11,20 @@ stages: # tags: # - xcode_12_2 -#download_artifacts: -# stage: download -# script: -# - ./Scripts/download_dependencies.sh -# only: -# - branches -# - feature/script_to_upload -# tags: -# - bash_shell -# environment: -# name: oneartifactory -# url: https://oneartifactoryprod.verizon.com/artifactory -# variables: -# ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory +download_artifacts: + stage: download + script: + - ./Scripts/download_dependencies.sh + only: + - branches + - feature/script_to_upload + tags: + - bash_shell + environment: + name: oneartifactory + url: https://oneartifactoryprod.verizon.com/artifactory + variables: + ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory build_project: stage: build diff --git a/Scripts/build_aggregate.sh b/Scripts/build_aggregate.sh index f73cde7d..f9ea8d63 100755 --- a/Scripts/build_aggregate.sh +++ b/Scripts/build_aggregate.sh @@ -14,8 +14,6 @@ UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal # Step 1. Build Device and Simulator versions #xcodebuild -scheme "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath "${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}" archive SKIP_INSTALL=false FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR ALWAYS_SEARCH_USER_PATHS=true -#copy the framework into the build directory where it is looking for it. -#ditto "$FRAMEWORKS_DIR/MVMCore.framework" "${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/MVMCore.framework xcodebuild -target "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR ALWAYS_SEARCH_USER_PATHS=true ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=true #mkdir -p "${UNIVERSAL_OUTPUTFOLDER}" From 48ea1840b15c308c75cf060fca46f285bbc02263 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 1 Jul 2021 14:01:35 -0400 Subject: [PATCH 078/113] build and deploy --- Scripts/build_aggregate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/build_aggregate.sh b/Scripts/build_aggregate.sh index f9ea8d63..01592712 100755 --- a/Scripts/build_aggregate.sh +++ b/Scripts/build_aggregate.sh @@ -14,7 +14,7 @@ UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal # Step 1. Build Device and Simulator versions #xcodebuild -scheme "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath "${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}" archive SKIP_INSTALL=false FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR ALWAYS_SEARCH_USER_PATHS=true -xcodebuild -target "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR ALWAYS_SEARCH_USER_PATHS=true ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=true +xcodebuild -target "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=true -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR ALWAYS_SEARCH_USER_PATHS=true ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=true #mkdir -p "${UNIVERSAL_OUTPUTFOLDER}" # From f4a7f7392be065eee998659f3467f2cb2b6de7b7 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 1 Jul 2021 14:06:04 -0400 Subject: [PATCH 079/113] build and deploy --- Scripts/build_aggregate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/build_aggregate.sh b/Scripts/build_aggregate.sh index 01592712..f9ea8d63 100755 --- a/Scripts/build_aggregate.sh +++ b/Scripts/build_aggregate.sh @@ -14,7 +14,7 @@ UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal # Step 1. Build Device and Simulator versions #xcodebuild -scheme "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath "${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}" archive SKIP_INSTALL=false FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR ALWAYS_SEARCH_USER_PATHS=true -xcodebuild -target "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=true -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR ALWAYS_SEARCH_USER_PATHS=true ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=true +xcodebuild -target "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR ALWAYS_SEARCH_USER_PATHS=true ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=true #mkdir -p "${UNIVERSAL_OUTPUTFOLDER}" # From 125a0b5fd9a0f706968ac443753657770676bc98 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 1 Jul 2021 14:50:44 -0400 Subject: [PATCH 080/113] build and deploy --- Scripts/build_aggregate.sh | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/Scripts/build_aggregate.sh b/Scripts/build_aggregate.sh index f9ea8d63..30e20c5f 100755 --- a/Scripts/build_aggregate.sh +++ b/Scripts/build_aggregate.sh @@ -4,25 +4,28 @@ unset TOOLCHAINS #Xcode 7.3 BUG FIX http://stackoverflow.com/questions/36184930 C_PROJECT_NAME="MVMCoreUI" PHONE_CONFIGURATION="Release" SIMULATOR_CONFIGURATION="Debug" - BUILD_DIR=$(xcodebuild -showBuildSettings -project ./MVMCoreUI.xcodeproj | grep -w -o 'BUILD_DIR = .*' | cut -d\ -f3-) +SIMULATOR_LIBRARY_PATH="${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/${C_PROJECT_NAME}.framework" FRAMEWORKS_DIR=$BUILD_DIR/Frameworks -echo $FRAMEWORKS_DIR - UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal # Step 1. Build Device and Simulator versions -#xcodebuild -scheme "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath "${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}" archive SKIP_INSTALL=false FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR ALWAYS_SEARCH_USER_PATHS=true +xcodebuild -scheme "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath "${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}" archive SKIP_INSTALL=false FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR ALWAYS_SEARCH_USER_PATHS=true xcodebuild -target "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR ALWAYS_SEARCH_USER_PATHS=true ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=true -#mkdir -p "${UNIVERSAL_OUTPUTFOLDER}" -# -#rm -rf ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework -#cp -R ${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/"${C_PROJECT_NAME}".xcarchive/Products/Library/Frameworks/${C_PROJECT_NAME}.framework ${UNIVERSAL_OUTPUTFOLDER} -# -## Step 2. Create universal binary file using lipo -# -#lipo -create -output "${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}" "${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}" "${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}" -# -#mv ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME} ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME} +mkdir -p "${UNIVERSAL_OUTPUTFOLDER}" + +rm -rf ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework +cp -R "${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}.xcarchive/Products/Library/Frameworks/${C_PROJECT_NAME}.framework" ${UNIVERSAL_OUTPUTFOLDER} + +# Step 2. Create universal binary file using lipo + +lipo -create -output "${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}" "${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}" "${SIMULATOR_LIBRARY_PATH}/${C_PROJECT_NAME}" + +mv ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME} ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME} + +# For Swift framework, Swiftmodule needs to be copied in the universal framework +if [ -d "${SIMULATOR_LIBRARY_PATH}/Modules/${C_PROJECT_NAME}.swiftmodule/" ]; then +cp -a "${SIMULATOR_LIBRARY_PATH}/Modules/${C_PROJECT_NAME}.swiftmodule/" "${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/Modules/${C_PROJECT_NAME}.swiftmodule/" +fi From 5e7de1baf017f797ede8e8c82613e0cf62655ce4 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 1 Jul 2021 15:00:20 -0400 Subject: [PATCH 081/113] build and deploy --- Scripts/build_aggregate.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Scripts/build_aggregate.sh b/Scripts/build_aggregate.sh index 30e20c5f..c0099cce 100755 --- a/Scripts/build_aggregate.sh +++ b/Scripts/build_aggregate.sh @@ -10,9 +10,9 @@ FRAMEWORKS_DIR=$BUILD_DIR/Frameworks UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal # Step 1. Build Device and Simulator versions -xcodebuild -scheme "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath "${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}" archive SKIP_INSTALL=false FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR ALWAYS_SEARCH_USER_PATHS=true +#xcodebuild -scheme "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath "${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}" archive SKIP_INSTALL=false FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR ALWAYS_SEARCH_USER_PATHS=true -xcodebuild -target "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR ALWAYS_SEARCH_USER_PATHS=true ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=true +xcodebuild -target "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator BUILD_DIR=$BUILD_DIR FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR ALWAYS_SEARCH_USER_PATHS=true ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=true mkdir -p "${UNIVERSAL_OUTPUTFOLDER}" From db592425c7d0880e6d02f8410393b29fffb45825 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 1 Jul 2021 15:05:10 -0400 Subject: [PATCH 082/113] build and deploy --- .gitlab-ci.yml | 30 +++++++++++++++--------------- Scripts/build_aggregate.sh | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7735fb50..006d149e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,7 +2,7 @@ stages: # - test - download - build -# - deploy + - deploy #test: # stage: test @@ -36,20 +36,20 @@ build_project: tags: - xcode_12_2 -#deploy_snapshot: -# stage: deploy -# script: -# - cd Scripts && ./upload_core_ui_frameworks.sh -# only: -# - branches -# - develop -# tags: -# - bash_shell -# environment: -# name: oneartifactory -# url: https://oneartifactoryprod.verizon.com/artifactory -# variables: -# ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory +deploy_snapshot: + stage: deploy + script: + - cd Scripts && ./upload_core_ui_frameworks.sh + only: + - branches + - develop + tags: + - bash_shell + environment: + name: oneartifactory + url: https://oneartifactoryprod.verizon.com/artifactory + variables: + ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory #promote_snapshot: # stage: go live diff --git a/Scripts/build_aggregate.sh b/Scripts/build_aggregate.sh index c0099cce..d3049bff 100755 --- a/Scripts/build_aggregate.sh +++ b/Scripts/build_aggregate.sh @@ -10,7 +10,7 @@ FRAMEWORKS_DIR=$BUILD_DIR/Frameworks UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal # Step 1. Build Device and Simulator versions -#xcodebuild -scheme "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath "${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}" archive SKIP_INSTALL=false FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR ALWAYS_SEARCH_USER_PATHS=true +xcodebuild -scheme "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath "${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}" archive SKIP_INSTALL=false FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR ALWAYS_SEARCH_USER_PATHS=true xcodebuild -target "${C_PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator BUILD_DIR=$BUILD_DIR FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR ALWAYS_SEARCH_USER_PATHS=true ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=true From f51511bd1375e374b7e74e0c4e5ae9465c1e8881 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 1 Jul 2021 15:13:24 -0400 Subject: [PATCH 083/113] build and deploy --- Scripts/download_framework.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Scripts/download_framework.sh b/Scripts/download_framework.sh index a9660d7f..7cc48bc2 100755 --- a/Scripts/download_framework.sh +++ b/Scripts/download_framework.sh @@ -47,7 +47,7 @@ fi #get local and remote checksums for comparison echo -e "Getting checksums..." echo -e "URL: ${URL}/api/storage/${REMOTEPATH}" -JSON=$(curl --header "X-JFrog-Art-Api: ${APITOKEN}" -X GET "${URL}/api/storage/${REMOTEPATH}") +JSON=$(curl --header "X-JFrog-Art-Api: ${ARTIFACTORY_APIKEY}" -X GET "${URL}/api/storage/${REMOTEPATH}") CHECKSUM=$(echo "$JSON" | python -c 'import sys, json; print json.load(sys.stdin)["checksums"]["sha1"]') if [[ -z "$CHECKSUM" ]]; then exit_with_error "No Checksum found in json: ${JSON}" @@ -65,7 +65,7 @@ echo "Local checksum ${OLDCHECKSUM}" if [ ! -e "${LOCALPATH}" ] || [ -z "$OLDCHECKSUM" ] || [ "$CHECKSUM" != "$OLDCHECKSUM" ]; then echo "Downloading..." echo -e "URL: ${URL}/${REMOTEPATH}" -curl --header "X-JFrog-Art-Api: ${APITOKEN}" -f -X GET "$URL/$REMOTEPATH" --output "${NEWFILEPATH}" +curl --header "X-JFrog-Art-Api: ${ARTIFACTORY_APIKEY}" -f -X GET "$URL/$REMOTEPATH" --output "${NEWFILEPATH}" if [ $? -eq 0 ] && [ -e "${NEWFILEPATH}" ]; then echo "Finished Downloading, begin unzip" unzip -q -o "${NEWFILEPATH}" -d "${LOCALDIR}" From 3ddaf3907df3ffd7c8aacdbeca1647dcb4a56502 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 1 Jul 2021 15:22:48 -0400 Subject: [PATCH 084/113] build and deploy --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 006d149e..d475e062 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,7 +17,7 @@ download_artifacts: - ./Scripts/download_dependencies.sh only: - branches - - feature/script_to_upload + - develop tags: - bash_shell environment: From f30d689e14851cf3c673fbe41c2c2d5ffcf09226 Mon Sep 17 00:00:00 2001 From: rajampetS Date: Fri, 2 Jul 2021 16:12:18 +0530 Subject: [PATCH 085/113] Registering ImageButton in CoreUi --- MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift index f45d3aac..d4eb516e 100644 --- a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift @@ -86,6 +86,7 @@ open class CoreUIModelMapping: ModelMapping { ModelRegistry.register(handler: HeadlineBodyButton.self, for: HeadlineBodyButtonModel.self) ModelRegistry.register(handler: BGImageHeadlineBodyButton.self, for: BGImageHeadlineBodyButtonModel.self) ModelRegistry.register(handler: ThreeHeadlineBodyLink.self, for: ThreeHeadlineBodyLinkModel.self) + ModelRegistry.register(handler: ImageButton.self, for: ImageButtonModel.self) // MARK:- Left Right Molecules ModelRegistry.register(handler: CornerLabels.self, for: CornerLabelsModel.self) From d65a4b905a3bb08cf185ef3558d9e67ab9c02729 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 2 Jul 2021 09:25:10 -0400 Subject: [PATCH 086/113] spacing --- Scripts/build_aggregate.sh | 2 +- Scripts/download_dependencies.sh | 2 +- Scripts/download_framework.sh | 52 ++++++++++++++++---------------- Scripts/upload_framework.sh | 23 +++++++------- 4 files changed, 39 insertions(+), 40 deletions(-) diff --git a/Scripts/build_aggregate.sh b/Scripts/build_aggregate.sh index d3049bff..514d0075 100755 --- a/Scripts/build_aggregate.sh +++ b/Scripts/build_aggregate.sh @@ -27,5 +27,5 @@ mv ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME} ${UNIVERSAL_OUTPUTFOLDER}/${C_PRO # For Swift framework, Swiftmodule needs to be copied in the universal framework if [ -d "${SIMULATOR_LIBRARY_PATH}/Modules/${C_PROJECT_NAME}.swiftmodule/" ]; then -cp -a "${SIMULATOR_LIBRARY_PATH}/Modules/${C_PROJECT_NAME}.swiftmodule/" "${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/Modules/${C_PROJECT_NAME}.swiftmodule/" + cp -a "${SIMULATOR_LIBRARY_PATH}/Modules/${C_PROJECT_NAME}.swiftmodule/" "${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/Modules/${C_PROJECT_NAME}.swiftmodule/" fi diff --git a/Scripts/download_dependencies.sh b/Scripts/download_dependencies.sh index 66742216..f03a25e8 100755 --- a/Scripts/download_dependencies.sh +++ b/Scripts/download_dependencies.sh @@ -15,7 +15,7 @@ BUILD_DIR=$(xcodebuild -showBuildSettings -project ./MVMCoreUI.xcodeproj | grep FRAMEWORKS_DIR=$BUILD_DIR/Frameworks if [ ! -d $FRAMEWORKS_DIR ]; then -mkdir $FRAMEWORKS_DIR + mkdir $FRAMEWORKS_DIR fi ./Scripts/download_framework.sh $ARTIFACTORY_URL "$FRAMEWORKS_DIR/MVMCore.framework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMCore/1.0/MVMCore-1.0-Debug-SNAPSHOT.zip diff --git a/Scripts/download_framework.sh b/Scripts/download_framework.sh index 7cc48bc2..9e9e2bb5 100755 --- a/Scripts/download_framework.sh +++ b/Scripts/download_framework.sh @@ -25,7 +25,7 @@ fi exit_with_error () { echo "Error: $1" if [ -f "${NEWFILEPATH}" ]; then -rm -rf "${NEWFILEPATH}" 2 + rm -rf "${NEWFILEPATH}" 2 fi exit 1 } @@ -37,11 +37,11 @@ echo -e "Local Target: ${LOCALPATH}" echo -e "Remote Source: ${REMOTEPATH}" if [ -z "$LOCALPATH" ]; then -exit_with_error "Missing local path argument" + exit_with_error "Missing local path argument" fi if [ -z "$REMOTEPATH" ]; then -exit_with_error "Missing filename path argument" + exit_with_error "Missing filename path argument" fi #get local and remote checksums for comparison @@ -50,37 +50,37 @@ echo -e "URL: ${URL}/api/storage/${REMOTEPATH}" JSON=$(curl --header "X-JFrog-Art-Api: ${ARTIFACTORY_APIKEY}" -X GET "${URL}/api/storage/${REMOTEPATH}") CHECKSUM=$(echo "$JSON" | python -c 'import sys, json; print json.load(sys.stdin)["checksums"]["sha1"]') if [[ -z "$CHECKSUM" ]]; then -exit_with_error "No Checksum found in json: ${JSON}" + exit_with_error "No Checksum found in json: ${JSON}" fi echo "Remote checksum ${CHECKSUM}" if [[ -f "${VERSIONFILE}" ]]; then -OLDCHECKSUM=$(cat "${VERSIONFILE}") + OLDCHECKSUM=$(cat "${VERSIONFILE}") else -OLDCHECKSUM="none" -mkdir -p $(dirname ${VERSIONFILE}) && touch "$VERSIONFILE" + OLDCHECKSUM="none" + mkdir -p $(dirname ${VERSIONFILE}) && touch "$VERSIONFILE" fi echo "Local checksum ${OLDCHECKSUM}" #get new framework if no original framework, no local checksum, or remote checksum is different from local. if [ ! -e "${LOCALPATH}" ] || [ -z "$OLDCHECKSUM" ] || [ "$CHECKSUM" != "$OLDCHECKSUM" ]; then -echo "Downloading..." -echo -e "URL: ${URL}/${REMOTEPATH}" -curl --header "X-JFrog-Art-Api: ${ARTIFACTORY_APIKEY}" -f -X GET "$URL/$REMOTEPATH" --output "${NEWFILEPATH}" -if [ $? -eq 0 ] && [ -e "${NEWFILEPATH}" ]; then -echo "Finished Downloading, begin unzip" -unzip -q -o "${NEWFILEPATH}" -d "${LOCALDIR}" -if [ $? -eq 0 ]; then -echo "Finished unzipping, remove zip" -rm -rf "${NEWFILEPATH}" -echo "Writing new checksum to file" -echo "${CHECKSUM}" > "${VERSIONFILE}" -echo "Successfully downloaded and unzipped archive." + echo "Downloading..." + echo -e "URL: ${URL}/${REMOTEPATH}" + curl --header "X-JFrog-Art-Api: ${ARTIFACTORY_APIKEY}" -f -X GET "$URL/$REMOTEPATH" --output "${NEWFILEPATH}" + if [ $? -eq 0 ] && [ -e "${NEWFILEPATH}" ]; then + echo "Finished Downloading, begin unzip" + unzip -q -o "${NEWFILEPATH}" -d "${LOCALDIR}" + if [ $? -eq 0 ]; then + echo "Finished unzipping, remove zip" + rm -rf "${NEWFILEPATH}" + echo "Writing new checksum to file" + echo "${CHECKSUM}" > "${VERSIONFILE}" + echo "Successfully downloaded and unzipped archive." + else + exit_with_error "Error unzipping" + fi + else + exit_with_error "Failed to download" + fi else -exit_with_error "Error unzipping" -fi -else -exit_with_error "Failed to download" -fi -else -echo "Successful, No New Version" + echo "Successful, No New Version" fi diff --git a/Scripts/upload_framework.sh b/Scripts/upload_framework.sh index 94a6007b..305a6585 100755 --- a/Scripts/upload_framework.sh +++ b/Scripts/upload_framework.sh @@ -59,16 +59,16 @@ zip -r -X "${LOCALBASE}.zip" $LOCALBASE CHECKSUM=$(shasum -a 1 "${LOCALBASE}.zip" | cut -d " " -f 1) echo -e "SHA-1 Checksum: \t${CHECKSUM}" if [ -e ${LOCALBASE}.dSYM ]; then -echo -e "---------\nZipping: \t\t${LOCALBASE}.dSYM.zip" -zip -r -X "${LOCALBASE}.dSYM.zip" $LOCALBASE.dSYM -# Generate its SHA-1 checksum for dsym. -DSYM_CHECKSUM=$(shasum -a 1 "${LOCALBASE}.dSYM.zip" | cut -d " " -f 1) -echo -e "SHA-1 Checksum: \t${DSYM_CHECKSUM}" + echo -e "---------\nZipping: \t\t${LOCALBASE}.dSYM.zip" + zip -r -X "${LOCALBASE}.dSYM.zip" $LOCALBASE.dSYM + # Generate its SHA-1 checksum for dsym. + DSYM_CHECKSUM=$(shasum -a 1 "${LOCALBASE}.dSYM.zip" | cut -d " " -f 1) + echo -e "SHA-1 Checksum: \t${DSYM_CHECKSUM}" fi popd mv ${LOCALPATH}.zip . if [ -e ${LOCALPATH}.dSYM.zip ]; then -mv ${LOCALPATH}.dSYM.zip . + mv ${LOCALPATH}.dSYM.zip . fi # Upload framework to Artifactory. @@ -79,12 +79,11 @@ curl --header "X-JFrog-Art-Api: ${APIKEY}" --header "X-Checksum-Sha1: ${CHECKSUM rm "${LOCALBASE}.zip" if [ -e ${LOCALBASE}.dSYM.zip ]; then -# Upload dsym Artifactory. -echo -e "---------\nUploading to: \t\t${URL}/${REMOTEPATH}.dSYM.zip" -curl --header "X-JFrog-Art-Api: ${APIKEY}" --header "X-Checksum-Sha1: ${DSYM_CHECKSUM}" -X PUT "${URL}/${REMOTEPATH}.dSYM.zip" -T "${LOCALBASE}.dSYM.zip" -# Cleanup dsym. -rm ${LOCALBASE}.dSYM.zip + # Upload dsym Artifactory. + echo -e "---------\nUploading to: \t\t${URL}/${REMOTEPATH}.dSYM.zip" + curl --header "X-JFrog-Art-Api: ${APIKEY}" --header "X-Checksum-Sha1: ${DSYM_CHECKSUM}" -X PUT "${URL}/${REMOTEPATH}.dSYM.zip" -T "${LOCALBASE}.dSYM.zip" + # Cleanup dsym. + rm ${LOCALBASE}.dSYM.zip fi - echo -e "\n\n<<< UPLOAD COMPLETE >>>\n\n" From 47b6115ffdba98fd8b893b6a567b358c8a7a2c8c Mon Sep 17 00:00:00 2001 From: rajampetS Date: Mon, 5 Jul 2021 13:56:53 +0530 Subject: [PATCH 087/113] Generalised delegate method --- MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift index 79a3e6e0..c0f001e7 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift @@ -9,7 +9,7 @@ import Foundation public protocol RadioBoxSelectionDelegate: class { - func selectedRadioBox(text: String) + func selected(radioBox: RadioBoxModel) } open class RadioBoxes: View { @@ -167,7 +167,7 @@ extension RadioBoxes: UICollectionViewDelegate { _ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate) cell.updateAccessibility() guard let radioBox = boxes?[indexPath.row] else { return } - radioDelegate?.selectedRadioBox(text: radioBox.text) + radioDelegate?.selected(radioBox: radioBox) } open func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) { From 56fa3f71c05ce08ad141a4e8928e350f0f8118c9 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 6 Jul 2021 14:16:48 -0400 Subject: [PATCH 088/113] updates made. --- MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift index 5cf71a75..00c58668 100644 --- a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift @@ -222,6 +222,7 @@ open class CoreUIModelMapping: ModelMapping { open class func registerBehaviors() { ModelRegistry.register(handler: ScreenBrightnessModifierBehavior.self, for: ScreenBrightnessModifierBehaviorModel.self) ModelRegistry.register(handler: PageGetContactBehavior.self, for: PageGetContactBehaviorModel.self) + ModelRegistry.register(handler: SelectAllBoxesBehavior.self, for: SelectAllBoxesBehaviorModel.self) } open override class func registerActions() { From 24481d9345d597b41c15dc38cff35c4300d7395e Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 7 Jul 2021 21:34:37 -0400 Subject: [PATCH 089/113] open --- MVMCoreUI/Containers/Views/Container.swift | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/MVMCoreUI/Containers/Views/Container.swift b/MVMCoreUI/Containers/Views/Container.swift index e3512bab..5b2e83eb 100644 --- a/MVMCoreUI/Containers/Views/Container.swift +++ b/MVMCoreUI/Containers/Views/Container.swift @@ -53,31 +53,28 @@ open class Container: View, ContainerProtocol { open func constrainView(_ view: UIView) { containerHelper.constrainView(view) } -} -// MARK: - MVMCoreViewProtocol -public extension Container { - - override func updateView(_ size: CGFloat) { + // MARK: - MVMCoreViewProtocol + open override func updateView(_ size: CGFloat) { super.updateView(size) (view as? MVMCoreViewProtocol)?.updateView(size) containerHelper.updateViewMargins(self, model: containerModel, size: size) } - + /// Will be called only once. - override func setupView() { + open override func setupView() { super.setupView() isAccessibilityElement = false backgroundColor = .clear } - - func addAndContain(_ view: UIView) { + + open func addAndContain(_ view: UIView) { view.translatesAutoresizingMaskIntoConstraints = false addSubview(view) containerHelper.constrainView(view) self.view = view } - + convenience init(andContain view: UIView) { self.init() addAndContain(view) From 1b8f13117db9e2093505e1a9506c5be9e4748f3a Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Thu, 8 Jul 2021 13:36:09 +0530 Subject: [PATCH 090/113] Changes to read contacts using Contact behavior --- MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift | 2 +- .../ListLeftVariableIconWithRightCaretBodyTextModel.swift | 6 +++++- .../ListRightVariableRightCaretAlltextAndLinksModel.swift | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift index 5cc07fed..2eec132f 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift @@ -81,7 +81,7 @@ numberOfLines = try typeContainer.decodeIfPresent(Int.self, forKey: .numberOfLines) } - public func encode(to encoder: Encoder) throws { + open func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeIfPresent(moleculeName, forKey: .moleculeName) try container.encode(text, forKey: .text) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift index 9e93b01d..6a84fee0 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift @@ -7,7 +7,7 @@ // -open class ListLeftVariableIconWithRightCaretBodyTextModel: ListItemModel, MoleculeModelProtocol { +open class ListLeftVariableIconWithRightCaretBodyTextModel: ListItemModel, ParentMoleculeModelProtocol { //----------------------------------------------------- // MARK: - Properties //----------------------------------------------------- @@ -17,6 +17,10 @@ open class ListLeftVariableIconWithRightCaretBodyTextModel: ListItemModel, Molec public var headlineBody: HeadlineBodyModel public var rightLabel: LabelModel + public var children: [MoleculeModelProtocol] { + return [image, headlineBody,rightLabel] + } + //----------------------------------------------------- // MARK: - Methods //----------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinksModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinksModel.swift index f16daf2b..54bf3162 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinksModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinksModel.swift @@ -7,7 +7,7 @@ // -public class ListRightVariableRightCaretAllTextAndLinksModel: ListItemModel, MoleculeModelProtocol { +public class ListRightVariableRightCaretAllTextAndLinksModel: ListItemModel, ParentMoleculeModelProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -16,6 +16,10 @@ public class ListRightVariableRightCaretAllTextAndLinksModel: ListItemModel, Mol public var rightLabel: LabelModel public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel + public var children: [MoleculeModelProtocol] { + return [rightLabel, eyebrowHeadlineBodyLink] + } + //----------------------------------------------------- // MARK: - Methods //----------------------------------------------------- From bb10fdf818dc699741649e842e4ace21b4cf058a Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Mon, 12 Jul 2021 11:50:38 +0530 Subject: [PATCH 091/113] Changes are per review comments --- .../ListLeftVariableIconWithRightCaretBodyTextModel.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift index 6a84fee0..88eec8ea 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift @@ -7,18 +7,18 @@ // -open class ListLeftVariableIconWithRightCaretBodyTextModel: ListItemModel, ParentMoleculeModelProtocol { +public class ListLeftVariableIconWithRightCaretBodyTextModel: ListItemModel, MoleculeModelProtocol { //----------------------------------------------------- // MARK: - Properties //----------------------------------------------------- - open class var identifier: String { return "listLVImgBdy" } + public static var identifier: String = "listLVImgBdy" public var image: ImageViewModel public var headlineBody: HeadlineBodyModel public var rightLabel: LabelModel public var children: [MoleculeModelProtocol] { - return [image, headlineBody,rightLabel] + return [image, headlineBody, rightLabel] } //----------------------------------------------------- From f74372c56ed124926d9f338231f06165b4dc63f0 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Mon, 12 Jul 2021 20:07:50 +0530 Subject: [PATCH 092/113] Changes are per review comments --- .../ListLeftVariableIconWithRightCaretBodyTextModel.swift | 2 +- MVMCoreUI/Behaviors/PlayAudioBehavior.swift | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift index 88eec8ea..33e00982 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift @@ -7,7 +7,7 @@ // -public class ListLeftVariableIconWithRightCaretBodyTextModel: ListItemModel, MoleculeModelProtocol { +public class ListLeftVariableIconWithRightCaretBodyTextModel: ListItemModel, ParentMoleculeModelProtocol { //----------------------------------------------------- // MARK: - Properties //----------------------------------------------------- diff --git a/MVMCoreUI/Behaviors/PlayAudioBehavior.swift b/MVMCoreUI/Behaviors/PlayAudioBehavior.swift index 4775d131..12a98022 100644 --- a/MVMCoreUI/Behaviors/PlayAudioBehavior.swift +++ b/MVMCoreUI/Behaviors/PlayAudioBehavior.swift @@ -29,13 +29,13 @@ public class PagePlayAudioBehavior: PageCustomActionHandlerBehavior { // MARK: - Active Model //-------------------------------------------------- - public static var activeAudioPlayerDelegate: PagePlayAudioBehaviorConsumerProtocol? + public static var activeAudioPlayerDelegate: PagePlayAudioBehaviorConsumerProtocol? //-------------------------------------------------- // MARK: - Delegate //-------------------------------------------------- - var delegate: MVMCoreUIDelegateObject? + weak var delegate: MVMCoreUIDelegateObject? //-------------------------------------------------- // MARK: - Init @@ -57,7 +57,6 @@ public class PagePlayAudioBehavior: PageCustomActionHandlerBehavior { // Update the model. play -> pause OR pause -> play if Self.activeAudioPlayerDelegate?.isPlaying ?? false { Self.activeAudioPlayerDelegate?.pause() - } else { Self.activeAudioPlayerDelegate?.play() } @@ -65,6 +64,7 @@ public class PagePlayAudioBehavior: PageCustomActionHandlerBehavior { } public func onPageHidden(_ delegateObject: MVMCoreUIDelegateObject?) { - // TODO: Stop player + //Stop player + Self.activeAudioPlayerDelegate?.pause() } } From 4d46d56f8e89717441735421df4553efdb3ab93e Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 12 Jul 2021 14:44:26 -0400 Subject: [PATCH 093/113] updates --- MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift | 10 +--------- .../Behaviors/Protocols/PageBehaviorProtocol.swift | 5 +++++ MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift | 10 ++-------- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift index 31f19bae..12330ada 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift @@ -79,15 +79,7 @@ self.selected = isChecked baseValue = isChecked } - - //-------------------------------------------------- - // MARK: - Behavior - //-------------------------------------------------- - - public func getRequiredBehaviors() -> [PageBehaviorModelProtocol] { - [SelectAllBoxesBehaviorModel()] - } - + //-------------------------------------------------- // MARK: - Codec //-------------------------------------------------- diff --git a/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift b/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift index e7db54bc..3f14f3cc 100644 --- a/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift +++ b/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift @@ -41,6 +41,11 @@ public protocol PageLocalDataShareBehavior: PageBehaviorProtocol { public protocol PageCustomActionHandlerBehavior: PageBehaviorProtocol { + /// - Parameters: + /// - actionType: The action type of the passed action model. + /// - information: information of the passed action model. + /// - additionalData: Additional information of the + /// - Returns: Boolean determines if the action has been handled. func handleAction(type actionType: String?, information: [AnyHashable : Any]?, additionalData: [AnyHashable : Any]?) -> Bool } diff --git a/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift b/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift index 3837eaa9..3877bfd1 100644 --- a/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift +++ b/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift @@ -41,7 +41,7 @@ public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior, PageMolecu // MARK: - Delegate //-------------------------------------------------- - var delegate: MVMCoreUIDelegateObject? + weak var delegate: MVMCoreUIDelegateObject? //-------------------------------------------------- // MARK: - Init @@ -69,13 +69,7 @@ public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior, PageMolecu // MARK: - Custom Action //-------------------------------------------------- - /// To select or deselect all controls adhereing to `SelectableMoleculeModel` - /// - /// - Parameters: - /// - actionType: The action type of the passed action model. - /// - information: information of the passed action model. - /// - additionalData: Additional information of the - /// - Returns: Boolean determines if the action has been handled. + // To select or deselect all controls adhereing to `SelectableMoleculeModel` public func handleAction(type actionType: String?, information: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) -> Bool { // Verify we have the correct action type and necessary values. From f434ba3e8d764fec676add585e654d6a8e21b081 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Tue, 13 Jul 2021 00:20:02 +0530 Subject: [PATCH 094/113] Confirming to Visibility behavior --- MVMCoreUI/Behaviors/PlayAudioBehavior.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Behaviors/PlayAudioBehavior.swift b/MVMCoreUI/Behaviors/PlayAudioBehavior.swift index 12a98022..ebb9f46c 100644 --- a/MVMCoreUI/Behaviors/PlayAudioBehavior.swift +++ b/MVMCoreUI/Behaviors/PlayAudioBehavior.swift @@ -24,7 +24,8 @@ public class PagePlayAudioBehaviorModel: PageBehaviorModelProtocol { public init() { } } -public class PagePlayAudioBehavior: PageCustomActionHandlerBehavior { +public class PagePlayAudioBehavior: PageCustomActionHandlerBehavior, PageVisibilityBehavior { + //-------------------------------------------------- // MARK: - Active Model //-------------------------------------------------- @@ -63,6 +64,12 @@ public class PagePlayAudioBehavior: PageCustomActionHandlerBehavior { return true } + //-------------------------------------------------- + // MARK: - PageVisibilityBehavior + //-------------------------------------------------- + + public func onPageShown(_ delegateObject: MVMCoreUIDelegateObject?) { } + public func onPageHidden(_ delegateObject: MVMCoreUIDelegateObject?) { //Stop player Self.activeAudioPlayerDelegate?.pause() From aaef3ea224f00d9285552207103df3458f70c04a Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 12 Jul 2021 16:06:24 -0400 Subject: [PATCH 095/113] move files --- MVMCoreUI.xcodeproj/project.pbxproj | 8 - .../Atoms/Selectors/CheckboxModel.swift | 8 +- .../Atomic/Atoms/Selectors/ToggleModel.swift | 2 +- .../SelectAllNavigationLabelButton.swift | 82 -------- .../Behaviors/SelectAllBoxesBehavior.swift | 178 ------------------ .../OtherHandlers/CoreUIModelMapping.swift | 2 - 6 files changed, 8 insertions(+), 272 deletions(-) delete mode 100644 MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/SelectAllNavigationLabelButton.swift delete mode 100644 MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index ef9b278f..9d145d5a 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -74,7 +74,6 @@ 0A25209824645B76000FA9F6 /* TextViewEntryFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A25209724645B76000FA9F6 /* TextViewEntryFieldModel.swift */; }; 0A41BA6E2344FCD400D4C0BC /* CATransaction+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */; }; 0A41BA7F23453A6400D4C0BC /* TextEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A41BA7E23453A6400D4C0BC /* TextEntryField.swift */; }; - 0A423A202684E7A0008EC258 /* SelectAllNavigationLabelButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A423A1F2684E7A0008EC258 /* SelectAllNavigationLabelButton.swift */; }; 0A51F3E22475CB73002E08B6 /* LoadingSpinnerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A51F3E02475CB73002E08B6 /* LoadingSpinnerModel.swift */; }; 0A51F3E32475CB73002E08B6 /* LoadingSpinner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A51F3E12475CB73002E08B6 /* LoadingSpinner.swift */; }; 0A5D59C223AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */; }; @@ -109,7 +108,6 @@ 0A9D09222433796500D2E6C0 /* CarouselIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A9D091C2433796500D2E6C0 /* CarouselIndicator.swift */; }; 0AA33B3A2398524F0067DD0F /* Toggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B392398524F0067DD0F /* Toggle.swift */; }; 0AA4D2E125CAEC72008DB32D /* AccessibilityModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA4D2E025CAEC72008DB32D /* AccessibilityModelProtocol.swift */; }; - 0AAB7855267B86F900DD6437 /* SelectAllBoxesBehavior.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AAB7854267B86F900DD6437 /* SelectAllBoxesBehavior.swift */; }; 0AB000BA24BF63490090C5E7 /* ModalListPageTemplateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AB000B924BF63490090C5E7 /* ModalListPageTemplateModel.swift */; }; 0AB000BC24BF64A50090C5E7 /* ModalStackPageTemplateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AB000BB24BF64A50090C5E7 /* ModalStackPageTemplateModel.swift */; }; 0AB764D124460F6300E7FE72 /* UIDatePicker+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AB764D024460F6300E7FE72 /* UIDatePicker+Extension.swift */; }; @@ -639,7 +637,6 @@ 0A25209724645B76000FA9F6 /* TextViewEntryFieldModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextViewEntryFieldModel.swift; sourceTree = ""; }; 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CATransaction+Extension.swift"; sourceTree = ""; }; 0A41BA7E23453A6400D4C0BC /* TextEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextEntryField.swift; sourceTree = ""; }; - 0A423A1F2684E7A0008EC258 /* SelectAllNavigationLabelButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectAllNavigationLabelButton.swift; sourceTree = ""; }; 0A51F3E02475CB73002E08B6 /* LoadingSpinnerModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoadingSpinnerModel.swift; sourceTree = ""; }; 0A51F3E12475CB73002E08B6 /* LoadingSpinner.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoadingSpinner.swift; sourceTree = ""; }; 0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppleGuidelinesProtocol.swift; sourceTree = ""; }; @@ -678,7 +675,6 @@ 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Extension.swift"; sourceTree = ""; }; 0AA33B392398524F0067DD0F /* Toggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Toggle.swift; sourceTree = ""; }; 0AA4D2E025CAEC72008DB32D /* AccessibilityModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccessibilityModelProtocol.swift; sourceTree = ""; }; - 0AAB7854267B86F900DD6437 /* SelectAllBoxesBehavior.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectAllBoxesBehavior.swift; sourceTree = ""; }; 0AB000B924BF63490090C5E7 /* ModalListPageTemplateModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalListPageTemplateModel.swift; sourceTree = ""; }; 0AB000BB24BF64A50090C5E7 /* ModalStackPageTemplateModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalStackPageTemplateModel.swift; sourceTree = ""; }; 0AB764D024460F6300E7FE72 /* UIDatePicker+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIDatePicker+Extension.swift"; sourceTree = ""; }; @@ -1324,7 +1320,6 @@ 27F97369246750BE00CAB5C5 /* ScreenBrightnessModifierBehavior.swift */, D23A900826125FFB007E14CE /* GetContactBehavior.swift */, 0A01DE262626236300C2CAAC /* PlayAudioBehavior.swift */, - 0AAB7854267B86F900DD6437 /* SelectAllBoxesBehavior.swift */, ); path = Behaviors; sourceTree = ""; @@ -1763,7 +1758,6 @@ D23EA801247EBED400D60C34 /* ImageBarButtonItem.swift */, D23EA7FD247EBBB700D60C34 /* NavigationLabelButtonModel.swift */, D23EA7FF247EBD6C00D60C34 /* LabelBarButtonItem.swift */, - 0A423A1F2684E7A0008EC258 /* SelectAllNavigationLabelButton.swift */, ); path = Buttons; sourceTree = ""; @@ -2727,7 +2721,6 @@ 011D959B240451E3000E3791 /* RuleRequiredModel.swift in Sources */, 526A265C240D1FF700B0D828 /* ListTwoColumnCompareChangesModel.swift in Sources */, D2A92886241ACD99004E01C6 /* ProgrammaticTableViewController.swift in Sources */, - 0AAB7855267B86F900DD6437 /* SelectAllBoxesBehavior.swift in Sources */, BBAA4F05243D8E3B005AAD5F /* RadioBoxesModel.swift in Sources */, 01509D952327ED1900EF99AA /* HeadlineBodyLinkToggle.swift in Sources */, AA104ADA244734DB004D2810 /* HeadersH1LandingPageHeader.swift in Sources */, @@ -2739,7 +2732,6 @@ D264FA8E243BCD9A00D98315 /* CollectionTemplate.swift in Sources */, 0A7EF85B23D8A52800B2AAD1 /* EntryFieldModel.swift in Sources */, AA633B3124989EC000731E80 /* HeadersH2PricingTwoRowsModel.swift in Sources */, - 0A423A202684E7A0008EC258 /* SelectAllNavigationLabelButton.swift in Sources */, 8DEFA95C243DAC20000D27E5 /* ListThreeColumnDataUsageDividerModel.swift in Sources */, D2092357244FA1EF0044AD09 /* ThreeLayerModelBase.swift in Sources */, D2FD4A4925199BD9000C28A9 /* AccessibilityProtocol.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift index 12330ada..c4f69f27 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift @@ -6,6 +6,12 @@ // Copyright © 2020 Verizon Wireless. All rights reserved. // +/// Protocol to apply to any model of a UI Control with a binary on/off nature. +/// +/// Example classes: Checkbox or Toggle. +@objc public protocol SelectableMoleculeModelProtocol { + var selected: Bool { get set } +} @objcMembers public class CheckboxModel: MoleculeModelProtocol, SelectableMoleculeModelProtocol, FormFieldProtocol { //-------------------------------------------------- @@ -79,7 +85,7 @@ self.selected = isChecked baseValue = isChecked } - + //-------------------------------------------------- // MARK: - Codec //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift index 056035b4..5be014fb 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift @@ -7,7 +7,7 @@ // -public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableModelProtocol, SelectableMoleculeModelProtocol { +public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableModelProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/SelectAllNavigationLabelButton.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/SelectAllNavigationLabelButton.swift deleted file mode 100644 index 59bf6136..00000000 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/SelectAllNavigationLabelButton.swift +++ /dev/null @@ -1,82 +0,0 @@ -// -// SelectAllNavigationLabelButton.swift -// MVMCoreUI -// -// Created by Kevin Christiano on 6/24/21. -// Copyright © 2021 Verizon Wireless. All rights reserved. -// - - -public class SelectAllNavigationLabelButton: NavigationButtonModelProtocol, MoleculeModelProtocol { - //-------------------------------------------------- - // MARK: - Properties - //-------------------------------------------------- - - public var backgroundColor: Color? - public static var identifier: String = "selectAllNavigationLabelButton" - public var accessibilityIdentifier: String? - public var willSelect: Bool = true - public var selectAllTitle: String = "Select All" - public var deselectAllTitle: String = "Deselect All" - public var action: ActionModelProtocol - - public var selectionTitle: String { - willSelect ? selectAllTitle : deselectAllTitle - } - - //-------------------------------------------------- - // MARK: - Initializer - //-------------------------------------------------- - - public init(willSelect: Bool, selectAllTitle: String, deselectAllTitle: String, action: ActionModelProtocol) { - self.willSelect = willSelect - self.action = action - self.selectAllTitle = selectAllTitle - self.deselectAllTitle = deselectAllTitle - } - - //-------------------------------------------------- - // MARK: - Keys - //-------------------------------------------------- - - private enum CodingKeys: String, CodingKey { - case moleculeName - case accessibilityIdentifier - case willSelect - case selectAllTitle - case deSelectAllTitle - case action - } - - //-------------------------------------------------- - // MARK: - Codec - //-------------------------------------------------- - - required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier) - selectAllTitle = try typeContainer.decode(String.self, forKey: .selectAllTitle) - deselectAllTitle = try typeContainer.decode(String.self, forKey: .deSelectAllTitle) - willSelect = try typeContainer.decode(Bool.self, forKey: .willSelect) - action = try typeContainer.decodeModel(codingKey: .action) - } - - open func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(moleculeName, forKey: .moleculeName) - try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) - try container.encode(selectAllTitle, forKey: .selectAllTitle) - try container.encode(deselectAllTitle, forKey: .deSelectAllTitle) - try container.encode(willSelect, forKey: .willSelect) - try container.encodeModel(action, forKey: .action) - } - - //-------------------------------------------------- - // MARK: - Methods - //-------------------------------------------------- - - /// Convenience function that creates a BarButtonItem for the model. - public func createNavigationItemButton(delegateObject: MVMCoreUIDelegateObject? = nil, additionalData: [AnyHashable: Any]? = nil) -> UIBarButtonItem { - LabelBarButtonItem.create(with: selectionTitle, actionModel: action, delegateObject: delegateObject, additionalData: additionalData) - } -} diff --git a/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift b/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift deleted file mode 100644 index 3877bfd1..00000000 --- a/MVMCoreUI/Behaviors/SelectAllBoxesBehavior.swift +++ /dev/null @@ -1,178 +0,0 @@ -// -// SelectAllBoxesBehavior.swift -// MVMCoreUI -// -// Created by Kevin Christiano on 6/17/21. -// Copyright © 2021 Verizon Wireless. All rights reserved. -// - -/// Protocol to apply to any model of a UI Control with a binary on/off nature. -/// -/// Example classes: Checkbox or Toggle. -@objc public protocol SelectableMoleculeModelProtocol { - var selected: Bool { get set } -} - -public class SelectAllBoxesBehaviorModel: PageBehaviorModelProtocol { - public class var identifier: String { "pageSelectAllBoxesBehavior" } - public var shouldAllowMultipleInstances: Bool { false } - public init() { } -} - -/// Selects all the control models presented on a page. -public class SelectAllBoxesBehavior: PageCustomActionHandlerBehavior, PageMoleculeTransformationBehavior { - //-------------------------------------------------- - // MARK: - Properties - //-------------------------------------------------- - - /// Status of the select all behavior. Initially false as the action has not been enaged. - var willSelectAllState: Bool { - get { getSelectAllNavbutton()?.willSelect ?? false } - set { getSelectAllNavbutton()?.willSelect = newValue } - } - - /// Reference to the general PageBehaviorModel. - var model: PageBehaviorModelProtocol - - /// A store representing the values of the `SelectableMoleculeModel`. - private var valuesMirror = [String: Bool]() - - //-------------------------------------------------- - // MARK: - Delegate - //-------------------------------------------------- - - weak var delegate: MVMCoreUIDelegateObject? - - //-------------------------------------------------- - // MARK: - Init - //-------------------------------------------------- - - required public init(model: PageBehaviorModelProtocol, delegateObject: MVMCoreUIDelegateObject?) { - self.model = model - self.delegate = delegateObject - } - - public func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject) { - - let selectableModels: [SelectableMoleculeModelProtocol] = rootMolecules.allMoleculesOfType() - - guard !selectableModels.isEmpty else { return } - - for model in selectableModels { - if let key = (model as? FormFieldProtocol)?.fieldKey { - valuesMirror[key] = model.selected - } - } - } - - //-------------------------------------------------- - // MARK: - Custom Action - //-------------------------------------------------- - - // To select or deselect all controls adhereing to `SelectableMoleculeModel` - public func handleAction(type actionType: String?, information: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) -> Bool { - - // Verify we have the correct action type and necessary values. - if actionType == "selectAllBoxes" { - guard let selectableModels: [SelectableMoleculeModelProtocol] = delegate?.moleculeDelegate?.getRootMolecules().allMoleculesOfType(), - !selectableModels.isEmpty - else { return false } - - // Hold value dues to asynch behavior of page refreshing. - let newSelectedState = willSelectAllState - - // Iterate through selectable molecules. - for selectableModel in selectableModels { - if toSelect(model: selectableModel) || toDeselect(model: selectableModel) { - selectableModel.selected = newSelectedState - } - } - - willSelectAllState.toggle() - updatePageNavigationUI() - return true - - } else if actionType == "boxSelected" { - guard let checkboxModel = (additionalData?["sourceModel"] as? CheckboxModel), - let fieldKey = checkboxModel.fieldKey - else { return false } - - self.valuesMirror[fieldKey] = checkboxModel.selected - - // If all are models are in the opposite state of the behavior, then realign. - if self.selectAllIsMisaligned() { - self.realignPageBehaviorAs(willSelectAll: false) - - } else if self.deselectAllIsMisaligned() { - self.realignPageBehaviorAs(willSelectAll: true) - } - - return true - - } else { - return false - } - } - - //-------------------------------------------------- - // MARK: - Methods - //-------------------------------------------------- - - func getSelectAllNavbutton() -> SelectAllNavigationLabelButton? { - guard let controller = self.delegate?.moleculeDelegate as? PageProtocol, - let rightNavButtonModels = controller.pageModel?.navigationBar?.additionalRightButtons - else { return nil } - - var navButton: SelectAllNavigationLabelButton? = nil - - for navModel in rightNavButtonModels { - if let model = navModel as? SelectAllNavigationLabelButton { - navButton = model - } - } - - return navButton - } - - /// In the event that the user manually selects or deselects all `SelectableMoleculeModel` - /// the behavior will need to reflect the inverse of its previously expected action. - /// Initiates the navigation and page behavior realignment - /// - Parameter asSelectAll: The actual value willSelectAllState ought to be. - func realignPageBehaviorAs(willSelectAll: Bool) { - willSelectAllState = willSelectAll - updatePageNavigationUI() - } - - /// Updates the navigation UI to correctly reflect the behavior's state. - func updatePageNavigationUI() { - MVMCoreDispatchUtility.performBlock(onMainThread: { [weak self] in - (self?.delegate?.moleculeDelegate as? ViewController)?.handleNewDataAndUpdateUI() - }) - } - - /// Convenience function for readability to confirmt he state of the behavior. - /// - Returns: Boolean indicating that the behavior's `willSelectAllState` is false while all model values are true (selected). - func selectAllIsMisaligned() -> Bool { - willSelectAllState && valuesMirror.values.allSatisfy { $0 == true } - } - - /// Convenience function for readability to confirmt he state of the behavior. - /// - Returns: Boolean indicating that the behavior's `willSelectAllState` is true while all model values are false (deselected). - func deselectAllIsMisaligned() -> Bool { - !willSelectAllState && valuesMirror.values.allSatisfy { $0 == false } - } - - /// Convenience function making it easier to read if a current selectable model should be acted on. - /// - Parameter model: A model object assined to the SelectableModel protocol - /// - Returns: Boolean determining if the passed model should be selected. - func toSelect(model: SelectableMoleculeModelProtocol) -> Bool { - willSelectAllState && !model.selected - } - - /// Convenience function making it easier to read if a current selectable model should be acted on. - /// - Parameter model: A model object assined to the SelectableModel protocol - /// - Returns: Boolean determining if the passed model should be deselected. - func toDeselect(model: SelectableMoleculeModelProtocol) -> Bool { - !willSelectAllState && model.selected - } -} diff --git a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift index 3fc511f3..c95964b2 100644 --- a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift @@ -127,7 +127,6 @@ open class CoreUIModelMapping: ModelMapping { ModelRegistry.register(NavigationItemModel.self) ModelRegistry.register(NavigationImageButtonModel.self) ModelRegistry.register(NavigationLabelButtonModel.self) - ModelRegistry.register(SelectAllNavigationLabelButton.self) // MARK:- Other Organisms ModelRegistry.register(handler: Carousel.self, for: CarouselModel.self) @@ -224,7 +223,6 @@ open class CoreUIModelMapping: ModelMapping { ModelRegistry.register(handler: ScreenBrightnessModifierBehavior.self, for: ScreenBrightnessModifierBehaviorModel.self) ModelRegistry.register(handler: PageGetContactBehavior.self, for: PageGetContactBehaviorModel.self) ModelRegistry.register(handler: PagePlayAudioBehavior.self, for: PagePlayAudioBehaviorModel.self) - ModelRegistry.register(handler: SelectAllBoxesBehavior.self, for: SelectAllBoxesBehaviorModel.self) } open override class func registerActions() { From edbe68429b0d791dde49f365ce7dc4710b0a1a77 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Wed, 14 Jul 2021 00:19:00 +0530 Subject: [PATCH 096/113] Moving PlayAudioBehavior to MobileFirst --- MVMCoreUI.xcodeproj/project.pbxproj | 4 - MVMCoreUI/Behaviors/PlayAudioBehavior.swift | 77 ------------------- .../OtherHandlers/CoreUIModelMapping.swift | 1 - 3 files changed, 82 deletions(-) delete mode 100644 MVMCoreUI/Behaviors/PlayAudioBehavior.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 9d145d5a..15f22974 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -61,7 +61,6 @@ 01EB369323609801006832FA /* HeaderModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368C23609801006832FA /* HeaderModel.swift */; }; 01EB369423609801006832FA /* HeadlineBodyModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368D23609801006832FA /* HeadlineBodyModel.swift */; }; 01F2A03223A4498200D954D8 /* CaretLinkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A03123A4498200D954D8 /* CaretLinkModel.swift */; }; - 0A01DE272626236300C2CAAC /* PlayAudioBehavior.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A01DE262626236300C2CAAC /* PlayAudioBehavior.swift */; }; 0A0FEC7425D42A5E00AF2548 /* BaseItemPickerEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A0FEC7325D42A5E00AF2548 /* BaseItemPickerEntryField.swift */; }; 0A0FEC7825D42A8500AF2548 /* BaseItemPickerEntryFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A0FEC7725D42A8500AF2548 /* BaseItemPickerEntryFieldModel.swift */; }; 0A1214A022C11A18007C7030 /* ActionDetailWithImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */; }; @@ -625,7 +624,6 @@ 01EB368C23609801006832FA /* HeaderModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeaderModel.swift; sourceTree = ""; }; 01EB368D23609801006832FA /* HeadlineBodyModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeadlineBodyModel.swift; sourceTree = ""; }; 01F2A03123A4498200D954D8 /* CaretLinkModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CaretLinkModel.swift; sourceTree = ""; }; - 0A01DE262626236300C2CAAC /* PlayAudioBehavior.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayAudioBehavior.swift; sourceTree = ""; }; 0A0FEC7325D42A5E00AF2548 /* BaseItemPickerEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseItemPickerEntryField.swift; sourceTree = ""; }; 0A0FEC7725D42A8500AF2548 /* BaseItemPickerEntryFieldModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseItemPickerEntryFieldModel.swift; sourceTree = ""; }; 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionDetailWithImage.swift; sourceTree = ""; }; @@ -1319,7 +1317,6 @@ 0A1C30972620F61A00B47F3B /* Protocols */, 27F97369246750BE00CAB5C5 /* ScreenBrightnessModifierBehavior.swift */, D23A900826125FFB007E14CE /* GetContactBehavior.swift */, - 0A01DE262626236300C2CAAC /* PlayAudioBehavior.swift */, ); path = Behaviors; sourceTree = ""; @@ -2886,7 +2883,6 @@ D2092355244FA0FD0044AD09 /* ThreeLayerTemplateModelProtocol.swift in Sources */, 0AE14F64238315D2005417F8 /* TextField.swift in Sources */, 0A51F3E22475CB73002E08B6 /* LoadingSpinnerModel.swift in Sources */, - 0A01DE272626236300C2CAAC /* PlayAudioBehavior.swift in Sources */, D2169303251E53D9002A6324 /* SectionListTemplateModel.swift in Sources */, 0AB764D124460F6300E7FE72 /* UIDatePicker+Extension.swift in Sources */, BB105859248DEFF70069D008 /* UICollectionViewLeftAlignedLayout.swift in Sources */, diff --git a/MVMCoreUI/Behaviors/PlayAudioBehavior.swift b/MVMCoreUI/Behaviors/PlayAudioBehavior.swift deleted file mode 100644 index ebb9f46c..00000000 --- a/MVMCoreUI/Behaviors/PlayAudioBehavior.swift +++ /dev/null @@ -1,77 +0,0 @@ -// -// PlayAudioBehavior.swift -// MVMCoreUI -// -// Created by Kevin Christiano on 4/9/21. -// Copyright © 2021 Verizon Wireless. All rights reserved. -// - - -public protocol PagePlayAudioBehaviorConsumerProtocol { - func togglePlayPause() - func play() - func pause() - func stop() - var isPlaying: Bool { get } - var messageID: String? { get } - var audioFileURL: URL? { get set } -} - -public class PagePlayAudioBehaviorModel: PageBehaviorModelProtocol { - public class var identifier: String { "pagePlayAudioBehavior" } - public var shouldAllowMultipleInstances: Bool { false } - - public init() { } -} - -public class PagePlayAudioBehavior: PageCustomActionHandlerBehavior, PageVisibilityBehavior { - - //-------------------------------------------------- - // MARK: - Active Model - //-------------------------------------------------- - - public static var activeAudioPlayerDelegate: PagePlayAudioBehaviorConsumerProtocol? - - //-------------------------------------------------- - // MARK: - Delegate - //-------------------------------------------------- - - weak var delegate: MVMCoreUIDelegateObject? - - //-------------------------------------------------- - // MARK: - Init - //-------------------------------------------------- - - public required init(model: PageBehaviorModelProtocol, delegateObject: MVMCoreUIDelegateObject?) { - self.delegate = delegateObject - } - - //-------------------------------------------------- - // MARK: - Custom Action - //-------------------------------------------------- - - // Either play or pause - public func handleAction(type actionType: String?, information: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) -> Bool { - - guard actionType == "playAudio" else { return false } - - // Update the model. play -> pause OR pause -> play - if Self.activeAudioPlayerDelegate?.isPlaying ?? false { - Self.activeAudioPlayerDelegate?.pause() - } else { - Self.activeAudioPlayerDelegate?.play() - } - return true - } - - //-------------------------------------------------- - // MARK: - PageVisibilityBehavior - //-------------------------------------------------- - - public func onPageShown(_ delegateObject: MVMCoreUIDelegateObject?) { } - - public func onPageHidden(_ delegateObject: MVMCoreUIDelegateObject?) { - //Stop player - Self.activeAudioPlayerDelegate?.pause() - } -} diff --git a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift index c95964b2..1edea27b 100644 --- a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift @@ -222,7 +222,6 @@ open class CoreUIModelMapping: ModelMapping { open class func registerBehaviors() { ModelRegistry.register(handler: ScreenBrightnessModifierBehavior.self, for: ScreenBrightnessModifierBehaviorModel.self) ModelRegistry.register(handler: PageGetContactBehavior.self, for: PageGetContactBehaviorModel.self) - ModelRegistry.register(handler: PagePlayAudioBehavior.self, for: PagePlayAudioBehaviorModel.self) } open override class func registerActions() { From 882d818c0678f771a72994f9cca0cb9d2335f250 Mon Sep 17 00:00:00 2001 From: "Tondapu, Alekhya" Date: Thu, 15 Jul 2021 15:43:24 +0000 Subject: [PATCH 097/113] Bugfix/carousel issues --- .../CarouselIndicator/BarsIndicatorView.swift | 1 + .../CarouselIndicator/CarouselIndicator.swift | 6 ++++++ .../Atomic/Organisms/Carousel/Carousel.swift | 15 ++++++++++++++- .../Atomic/Organisms/Carousel/CarouselModel.swift | 4 ++-- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift index 975c7ebb..8a1f960b 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift @@ -234,6 +234,7 @@ open class BarsIndicatorView: CarouselIndicator { super.reset() barReferences.forEach { $0.removeFromSuperview() } barReferences = [] + currentIndex = 0 } public override func updateUI(previousIndex: Int, newIndex: Int, totalCount: Int, isAnimated: Bool) { diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift index 6a82ef80..5b04d065 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift @@ -248,4 +248,10 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol { bottomConstraint?.constant = constant topConstraint?.constant = constant } + + open override func reset() { + super.reset() + currentIndex = 0 + previousIndex = 0 + } } diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift index 67e024ca..24ae0c06 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift @@ -41,7 +41,7 @@ open class Carousel: View { open var numberOfPages = 0 /// The models for the molecules. - public var molecules: [MoleculeModelProtocol & CarouselItemModelProtocol]? + public var molecules: [MoleculeModelProtocol & CarouselItemModelProtocol & CollectionItemModelProtocol]? /// The horizontal alignment of the cell in the collection view. Only noticeable if the itemWidthPercent is less than 100%. public var itemAlignment = UICollectionView.ScrollPosition.left @@ -177,6 +177,7 @@ open class Carousel: View { if let selectedIndex = carouselModel.selectedIndex { let adjustedIndex = loop ? selectedIndex + 2 : selectedIndex collectionView.selectItem(at: IndexPath(row: adjustedIndex, section: 0), animated: false, scrollPosition: []) + goTo(adjustedIndex, animated: false) } } @@ -207,6 +208,13 @@ open class Carousel: View { pageIndex = 0 } + open override func reset() { + super.reset() + currentIndex = 0 + pageIndex = 0 + pagingView?.reset() + } + var pagingMoleculeName: String? /// Sets up the paging molecule @@ -216,6 +224,7 @@ open class Carousel: View { molecule.moleculeName == pagingMoleculeName { pagingView?.set(with: molecule, delegateObject, nil) pagingView?.numberOfPages = numberOfPages + pagingView?.currentIndex = currentIndex return } @@ -423,6 +432,10 @@ extension Carousel: UICollectionViewDelegate { adjustedIndex = adjustedIndex + numberOfPages } model.selectedIndex = adjustedIndex + currentIndex = adjustedIndex + pageIndex = currentIndex + pagingView?.currentIndex = adjustedIndex + updateModelIndex() } if let cell = collectionView.cellForItem(at: indexPath) as? CollectionTemplateItemProtocol { cell.didSelectCell(at: indexPath, delegateObject: delegateObject, additionalData: nil) diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift index 8721db72..df258324 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift @@ -20,7 +20,7 @@ import UIKit } public var backgroundColor: Color? - public var molecules: [MoleculeModelProtocol & CarouselItemModelProtocol] + public var molecules: [MoleculeModelProtocol & CarouselItemModelProtocol & CollectionItemModelProtocol] public var index: Int = 0 public var spacing: CGFloat? public var border: Bool? @@ -41,7 +41,7 @@ import UIKit public var selectable = false public var selectedIndex: Int? - public init(molecules: [MoleculeModelProtocol & CarouselItemModelProtocol]) { + public init(molecules: [MoleculeModelProtocol & CarouselItemModelProtocol & CollectionItemModelProtocol]) { self.molecules = molecules } From 3af89dfdc64ce5102fb401cbe739fae0e1cdc62a Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Fri, 16 Jul 2021 02:14:56 +0530 Subject: [PATCH 098/113] Changes in CornerLabelModel to dynamically pick molecule's model --- .../LeftRightViews/CornerLabelsModel.swift | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/LeftRightViews/CornerLabelsModel.swift b/MVMCoreUI/Atomic/Molecules/LeftRightViews/CornerLabelsModel.swift index 76a56178..58b661c6 100644 --- a/MVMCoreUI/Atomic/Molecules/LeftRightViews/CornerLabelsModel.swift +++ b/MVMCoreUI/Atomic/Molecules/LeftRightViews/CornerLabelsModel.swift @@ -8,7 +8,7 @@ import UIKit -public class CornerLabelsModel: MoleculeModelProtocol { +public class CornerLabelsModel: ParentMoleculeModelProtocol { public static var identifier: String = "cornerLabels" public var backgroundColor: Color? public var topLeftLabel: LabelModel? @@ -16,7 +16,10 @@ public class CornerLabelsModel: MoleculeModelProtocol { public var bottomLeftLabel: LabelModel? public var bottomRightLabel: LabelModel? public var molecule: MoleculeModelProtocol? - + public var children: [MoleculeModelProtocol] { + return [topLeftLabel, topRightLabel, bottomLeftLabel, bottomRightLabel].compactMap { (molecule: MoleculeModelProtocol?) in molecule } + } + init(with molecule: MoleculeModelProtocol?) { self.molecule = molecule } @@ -35,20 +38,20 @@ public class CornerLabelsModel: MoleculeModelProtocol { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) molecule = try typeContainer.decodeModelIfPresent(codingKey: .molecule) - topLeftLabel = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .topLeftLabel) - topRightLabel = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .topRightLabel) - bottomLeftLabel = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .bottomLeftLabel) - bottomRightLabel = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .bottomRightLabel) + topLeftLabel = try typeContainer.decodeMoleculeIfPresent(codingKey: .topLeftLabel) + topRightLabel = try typeContainer.decodeMoleculeIfPresent(codingKey: .topRightLabel) + bottomLeftLabel = try typeContainer.decodeMoleculeIfPresent(codingKey: .bottomLeftLabel) + bottomRightLabel = try typeContainer.decodeMoleculeIfPresent(codingKey: .bottomRightLabel) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeModelIfPresent(molecule, forKey: .molecule) - try container.encodeIfPresent(topLeftLabel, forKey: .topLeftLabel) - try container.encodeIfPresent(topRightLabel, forKey: .topRightLabel) - try container.encodeIfPresent(bottomLeftLabel, forKey: .bottomLeftLabel) - try container.encodeIfPresent(bottomRightLabel, forKey: .bottomRightLabel) + try container.encodeModelIfPresent(topLeftLabel, forKey: .topLeftLabel) + try container.encodeModelIfPresent(topRightLabel, forKey: .topRightLabel) + try container.encodeModelIfPresent(bottomLeftLabel, forKey: .bottomLeftLabel) + try container.encodeModelIfPresent(bottomRightLabel, forKey: .bottomRightLabel) try container.encode(moleculeName, forKey: .moleculeName) } } From 0c7a4bf62ce428eaa3477d95ad2986a8ae512985 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Fri, 16 Jul 2021 03:05:06 +0530 Subject: [PATCH 099/113] Fixing moleculeLayoutUpdate for tableView --- MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift index 34f81bc4..32c4f1f2 100644 --- a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift @@ -185,7 +185,8 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol open override func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) { guard let tableView = tableView else { return } - let point = molecule.convert(molecule.bounds.origin, to: tableView) + var point = molecule.convert(molecule.bounds.origin, to: tableView) + point = CGPoint(x: ceil(point.x), y: ceil(point.y)) if let indexPath = tableView.indexPathForRow(at: point), tableView.indexPathsForVisibleRows?.contains(indexPath) ?? false { performTableViewUpdates() } From 52a872f95dedf7806b43b2ecf15fc9cd59c5f156 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 16 Jul 2021 17:37:55 -0400 Subject: [PATCH 100/113] child molecule fixes --- ...iableIconWithRightCaretBodyTextModel.swift | 2 +- .../NavigationBar/NavigationItemModel.swift | 22 +++++++++++++++++++ .../Templates/StackPageTemplateModel.swift | 2 +- .../Templates/ThreeLayerModelBase.swift | 2 +- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift index 33e00982..633989d5 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift @@ -18,7 +18,7 @@ public class ListLeftVariableIconWithRightCaretBodyTextModel: ListItemModel, Par public var rightLabel: LabelModel public var children: [MoleculeModelProtocol] { - return [image, headlineBody, rightLabel] + [image, headlineBody, rightLabel] } //----------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift index 5fab61f9..5f3db6be 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift @@ -91,3 +91,25 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc try container.encodeModelIfPresent(titleView, forKey: .titleView) } } + +extension NavigationItemModel: ParentMoleculeModelProtocol { + public var children: [MoleculeModelProtocol] { + var children: [MoleculeModelProtocol] = [] + if let line = line { + children.append(line) + } + if let titleView = titleView { + children.append(titleView) + } + if let backButton = backButton { + children.append(backButton) + } + if let leftButtons = additionalLeftButtons { + children.append(contentsOf: leftButtons) + } + if let rightButtons = additionalRightButtons { + children.append(contentsOf: rightButtons) + } + return children + } +} diff --git a/MVMCoreUI/Atomic/Templates/StackPageTemplateModel.swift b/MVMCoreUI/Atomic/Templates/StackPageTemplateModel.swift index 27769b20..1ed663c2 100644 --- a/MVMCoreUI/Atomic/Templates/StackPageTemplateModel.swift +++ b/MVMCoreUI/Atomic/Templates/StackPageTemplateModel.swift @@ -16,7 +16,7 @@ public var moleculeStack: StackModel public override var rootMolecules: [MoleculeModelProtocol] { - return [header, moleculeStack, footer].compactMap { $0 } + [navigationBar, header, moleculeStack, footer].compactMap { $0 } } //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Templates/ThreeLayerModelBase.swift b/MVMCoreUI/Atomic/Templates/ThreeLayerModelBase.swift index 6a1bb244..06d813ef 100644 --- a/MVMCoreUI/Atomic/Templates/ThreeLayerModelBase.swift +++ b/MVMCoreUI/Atomic/Templates/ThreeLayerModelBase.swift @@ -18,7 +18,7 @@ public var footer: MoleculeModelProtocol? public override var rootMolecules: [MoleculeModelProtocol] { - return [header, footer].compactMap { $0 } + [navigationBar, header, footer].compactMap { $0 } } //-------------------------------------------------- From b75f25764f866607decfb608ecd23fa5049bac77 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 16 Jul 2021 17:59:19 -0400 Subject: [PATCH 101/113] cleanup --- .../Molecules/LeftRightViews/CornerLabelsModel.swift | 2 +- .../Molecules/NavigationBar/NavigationItemModel.swift | 11 +---------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/LeftRightViews/CornerLabelsModel.swift b/MVMCoreUI/Atomic/Molecules/LeftRightViews/CornerLabelsModel.swift index 58b661c6..5c910298 100644 --- a/MVMCoreUI/Atomic/Molecules/LeftRightViews/CornerLabelsModel.swift +++ b/MVMCoreUI/Atomic/Molecules/LeftRightViews/CornerLabelsModel.swift @@ -17,7 +17,7 @@ public class CornerLabelsModel: ParentMoleculeModelProtocol { public var bottomRightLabel: LabelModel? public var molecule: MoleculeModelProtocol? public var children: [MoleculeModelProtocol] { - return [topLeftLabel, topRightLabel, bottomLeftLabel, bottomRightLabel].compactMap { (molecule: MoleculeModelProtocol?) in molecule } + [molecule, topLeftLabel, topRightLabel, bottomLeftLabel, bottomRightLabel].compactMap { $0 } } init(with molecule: MoleculeModelProtocol?) { diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift index 5f3db6be..6a75718b 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift @@ -94,16 +94,7 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc extension NavigationItemModel: ParentMoleculeModelProtocol { public var children: [MoleculeModelProtocol] { - var children: [MoleculeModelProtocol] = [] - if let line = line { - children.append(line) - } - if let titleView = titleView { - children.append(titleView) - } - if let backButton = backButton { - children.append(backButton) - } + var children: [MoleculeModelProtocol] = [line, titleView, backButton].compactMap { $0 } if let leftButtons = additionalLeftButtons { children.append(contentsOf: leftButtons) } From ccf583615e2c22094997cbd36788ad6f654a66b0 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 16 Jul 2021 18:00:44 -0400 Subject: [PATCH 102/113] cleanup --- .../ListRightVariableRightCaretAlltextAndLinksModel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinksModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinksModel.swift index 54bf3162..e2bc1691 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinksModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinksModel.swift @@ -17,7 +17,7 @@ public class ListRightVariableRightCaretAllTextAndLinksModel: ListItemModel, Par public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel public var children: [MoleculeModelProtocol] { - return [rightLabel, eyebrowHeadlineBodyLink] + [rightLabel, eyebrowHeadlineBodyLink] } //----------------------------------------------------- From bcf810d5cb6e4b3dc3e73858206bc62892da3435 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 16 Jul 2021 18:12:04 -0400 Subject: [PATCH 103/113] chang to just use a different point --- MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift index 32c4f1f2..a1c2d3b6 100644 --- a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift @@ -185,8 +185,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol open override func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) { guard let tableView = tableView else { return } - var point = molecule.convert(molecule.bounds.origin, to: tableView) - point = CGPoint(x: ceil(point.x), y: ceil(point.y)) + let point = molecule.convert(molecule.center, to: tableView) if let indexPath = tableView.indexPathForRow(at: point), tableView.indexPathsForVisibleRows?.contains(indexPath) ?? false { performTableViewUpdates() } From d00897cf75246de769d36fa6ca4d68446c307843 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 16 Jul 2021 20:54:33 -0400 Subject: [PATCH 104/113] navigation bar changes --- .../Buttons/ImageBarButtonItem.swift | 11 ++--------- .../Buttons/LabelBarButtonItem.swift | 11 ++--------- .../Buttons/NavigationImageButtonModel.swift | 2 +- .../Buttons/NavigationLabelButtonModel.swift | 16 ++++++++-------- MVMCoreUI/BaseClasses/BarButtonItem.swift | 16 +++++----------- 5 files changed, 18 insertions(+), 38 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/ImageBarButtonItem.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/ImageBarButtonItem.swift index 33ed39b8..50676cbc 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/ImageBarButtonItem.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/ImageBarButtonItem.swift @@ -20,16 +20,9 @@ } /// Creates the item with the passed in action. - public static func create(with image: UIImage?, actionModel: ActionModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Self { + public static func create(with image: UIImage?, model: MoleculeModelProtocol & NavigationButtonModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Self { let button = create(with: image) - button.set(with: actionModel, delegateObject: delegateObject, additionalData: additionalData) - return button - } - - /// Creates the item with the passed in action map. - public static func create(with image: UIImage?, actionMap: [AnyHashable: Any], delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Self { - let button = create(with: image) - button.set(with: actionMap, delegateObject: delegateObject, additionalData: additionalData) + button.set(with: model, delegateObject: delegateObject, additionalData: additionalData) return button } diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/LabelBarButtonItem.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/LabelBarButtonItem.swift index 5175defe..1eb4c8a1 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/LabelBarButtonItem.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/LabelBarButtonItem.swift @@ -21,16 +21,9 @@ } /// Creates the item with the passed in action. - public static func create(with title: String?, actionModel: ActionModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Self { + public static func create(with title: String?, model: NavigationLabelButtonModel, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Self { let button = create(with: title) - button.set(with: actionModel, delegateObject: delegateObject, additionalData: additionalData) - return button - } - - /// Creates the item with the passed in action map. - public static func create(with title: String?, actionMap: [AnyHashable : Any], delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Self { - let button = create(with: title) - button.set(with: actionMap, delegateObject: delegateObject, additionalData: additionalData) + button.set(with: model, delegateObject: delegateObject, additionalData: additionalData) return button } diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift index f18c9fa1..8ba75d1a 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift @@ -67,7 +67,7 @@ public class NavigationImageButtonModel: NavigationButtonModelProtocol, Molecule /// Convenience function that creates a BarButtonItem for the model. public func createNavigationItemButton(delegateObject: MVMCoreUIDelegateObject? = nil, additionalData: [AnyHashable: Any]? = nil) -> UIBarButtonItem { let uiImage = MVMCoreCache.shared()?.getImageFromRegisteredBundles(image) - let buttonItem = ImageBarButtonItem.create(with: uiImage, actionModel: action, delegateObject: delegateObject, additionalData: additionalData) + let buttonItem = ImageBarButtonItem.create(with: uiImage, model: self, delegateObject: delegateObject, additionalData: additionalData) buttonItem.accessibilityIdentifier = accessibilityIdentifier ?? image if let accessibilityString = accessibilityText { buttonItem.accessibilityLabel = accessibilityString diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationLabelButtonModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationLabelButtonModel.swift index e52ea0d5..d72c6ae0 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationLabelButtonModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationLabelButtonModel.swift @@ -7,16 +7,16 @@ // -public class NavigationLabelButtonModel: NavigationButtonModelProtocol, MoleculeModelProtocol { +open class NavigationLabelButtonModel: NavigationButtonModelProtocol, MoleculeModelProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - public var backgroundColor: Color? - public static var identifier: String = "navigationLabelButton" - public var accessibilityIdentifier: String? - public var title: String - public var action: ActionModelProtocol + open var backgroundColor: Color? + open class var identifier: String { "navigationLabelButton" } + open var accessibilityIdentifier: String? + open var title: String + open var action: ActionModelProtocol //-------------------------------------------------- // MARK: - Initializer @@ -62,7 +62,7 @@ public class NavigationLabelButtonModel: NavigationButtonModelProtocol, Molecule //-------------------------------------------------- /// Convenience function that creates a BarButtonItem for the model. - public func createNavigationItemButton(delegateObject: MVMCoreUIDelegateObject? = nil, additionalData: [AnyHashable: Any]? = nil) -> UIBarButtonItem { - return LabelBarButtonItem.create(with: title, actionModel: action, delegateObject: delegateObject, additionalData: additionalData) + open func createNavigationItemButton(delegateObject: MVMCoreUIDelegateObject? = nil, additionalData: [AnyHashable: Any]? = nil) -> UIBarButtonItem { + return LabelBarButtonItem.create(with: title, model: self, delegateObject: delegateObject, additionalData: additionalData) } } diff --git a/MVMCoreUI/BaseClasses/BarButtonItem.swift b/MVMCoreUI/BaseClasses/BarButtonItem.swift index d41fd57f..b46647f2 100644 --- a/MVMCoreUI/BaseClasses/BarButtonItem.swift +++ b/MVMCoreUI/BaseClasses/BarButtonItem.swift @@ -20,7 +20,7 @@ public typealias BarButtonAction = (BarButtonItem) -> () //-------------------------------------------------- // MARK: - Delegate //-------------------------------------------------- - + open var model: (MoleculeModelProtocol & NavigationButtonModelProtocol)? open weak var buttonDelegate: ButtonDelegateProtocol? var actionDelegate: ActionDelegate? @@ -28,18 +28,12 @@ public typealias BarButtonAction = (BarButtonItem) -> () // MARK: - Methods //-------------------------------------------------- - open func set(with actionModel: ActionModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + open func set(with model: MoleculeModelProtocol & NavigationButtonModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + self.model = model buttonDelegate = delegateObject?.buttonDelegate actionDelegate?.buttonAction = { sender in - Button.performButtonAction(with: actionModel, button: sender, delegateObject: delegateObject, additionalData: additionalData) - } - } - - open func set(with actionMap: [AnyHashable : Any], delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - buttonDelegate = delegateObject?.buttonDelegate - actionDelegate?.buttonAction = { sender in - guard delegateObject?.buttonDelegate?.button?(sender, shouldPerformActionWithMap: actionMap, additionalData: additionalData) ?? true else { return } - MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) + let additionalDataWithSource = additionalData.dictionaryAdding(key: KeySourceModel, value: model) + Button.performButtonAction(with: model.action, button: sender, delegateObject: delegateObject, additionalData: additionalDataWithSource) } } } From 350edf147c62c5b7f188649c12832774d69b115a Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Tue, 20 Jul 2021 07:56:23 +0530 Subject: [PATCH 105/113] update view for given molecule --- .../Templates/MoleculeListTemplate.swift | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift index a1c2d3b6..dc86aa4d 100644 --- a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift @@ -222,6 +222,33 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } } + open func newData(for molecule: MoleculeModelProtocol) { + //TODO: expand for header, navigation, etc + let json = molecule.toJSON() + guard let index = moleculesInfo?.firstIndex(where: { (moleculeInfo) -> Bool in + //TODO: check for molecule protocol eqaulity + if json == moleculeInfo.molecule.toJSON() { + return true + } else if let parent = moleculeInfo.molecule as? ParentMoleculeModelProtocol { + // Get all molecules of the same type for faster check. + let molecules: [MoleculeModelProtocol] = parent.reduceDepthFirstTraverse(options: .childFirst, depth: 0, initialResult: []) { (accumulator, currentMolecule, depth) in + if currentMolecule.moleculeName == molecule.moleculeName { + return accumulator + [currentMolecule] + } + return accumulator + } + for molecule in molecules { + if json == molecule.toJSON() { + return true + } + } + } + return false + }) else { return } + let indexPath = IndexPath(row: index, section: 0) + tableView.reloadRows(at: [indexPath], with: .none) + } + open override func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], animation: UITableView.RowAnimation) { var indexPaths: [IndexPath] = [] //TODO: check for molecule protocol equality From f0c567d6d47821d9710d214b7cd1e5b21c41cddb Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 20 Jul 2021 00:57:34 -0400 Subject: [PATCH 106/113] fixes --- .../Templates/MoleculeListTemplate.swift | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift index dc86aa4d..c12b74fa 100644 --- a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift @@ -183,10 +183,8 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol //-------------------------------------------------- open override func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) { - guard let tableView = tableView else { return } - - let point = molecule.convert(molecule.center, to: tableView) - if let indexPath = tableView.indexPathForRow(at: point), tableView.indexPathsForVisibleRows?.contains(indexPath) ?? false { + guard let tableView = tableView else { return } + if let indexPath = tableView.indexPathForRow(at: molecule.center), tableView.indexPathsForVisibleRows?.contains(indexPath) ?? false { performTableViewUpdates() } } @@ -226,25 +224,27 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol //TODO: expand for header, navigation, etc let json = molecule.toJSON() guard let index = moleculesInfo?.firstIndex(where: { (moleculeInfo) -> Bool in - //TODO: check for molecule protocol eqaulity - if json == moleculeInfo.molecule.toJSON() { - return true - } else if let parent = moleculeInfo.molecule as? ParentMoleculeModelProtocol { - // Get all molecules of the same type for faster check. - let molecules: [MoleculeModelProtocol] = parent.reduceDepthFirstTraverse(options: .childFirst, depth: 0, initialResult: []) { (accumulator, currentMolecule, depth) in - if currentMolecule.moleculeName == molecule.moleculeName { - return accumulator + [currentMolecule] - } - return accumulator - } - for molecule in molecules { - if json == molecule.toJSON() { + //TODO: check for molecule protocol eqaulity + if json == moleculeInfo.molecule.toJSON() { return true - } + } else if let parent = moleculeInfo.molecule as? ParentMoleculeModelProtocol { + // Get all molecules of the same type for faster check. + let molecules: [MoleculeModelProtocol] = parent.reduceDepthFirstTraverse(options: .childFirst, depth: 0, initialResult: []) { (accumulator, currentMolecule, depth) in + if currentMolecule.moleculeName == molecule.moleculeName { + return accumulator + [currentMolecule] + } + return accumulator + } + for molecule in molecules { + if json == molecule.toJSON() { + return true + } + } } - } - return false + return false }) else { return } + + // Refresh the cell. let indexPath = IndexPath(row: index, section: 0) tableView.reloadRows(at: [indexPath], with: .none) } From 9a477a11a06cb02363df778bb41d5441c284c397 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 20 Jul 2021 01:13:35 -0400 Subject: [PATCH 107/113] teemporary fix for unselect issues --- MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift index c12b74fa..baab7479 100644 --- a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift @@ -246,8 +246,9 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol // Refresh the cell. let indexPath = IndexPath(row: index, section: 0) - tableView.reloadRows(at: [indexPath], with: .none) - } + _ = tableView(tableView, cellForRowAt: indexPath) + performTableViewUpdates() + } open override func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], animation: UITableView.RowAnimation) { var indexPaths: [IndexPath] = [] From f56bc4b894f74fe9d07e738d96afd298909dba45 Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Tue, 20 Jul 2021 06:10:17 +0000 Subject: [PATCH 108/113] Audio player behavior --- .../Atomic/Atoms/Selectors/Checkbox.swift | 6 ++-- .../Atoms/Selectors/CheckboxModel.swift | 26 ++++++++------ MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift | 4 +-- .../Atomic/Atoms/Selectors/ToggleModel.swift | 14 ++++---- .../Atomic/Atoms/Views/Label/LabelModel.swift | 2 +- ...iableIconWithRightCaretBodyTextModel.swift | 6 +++- ...riableRightCaretAlltextAndLinksModel.swift | 6 +++- .../LeftRightViews/CornerLabelsModel.swift | 23 ++++++------ .../Buttons/ImageBarButtonItem.swift | 11 ++---- .../Buttons/LabelBarButtonItem.swift | 11 ++---- .../Buttons/NavigationImageButtonModel.swift | 2 +- .../Buttons/NavigationLabelButtonModel.swift | 16 ++++----- .../NavigationBar/NavigationItemModel.swift | 13 +++++++ .../Protocols/MoleculeDelegateProtocol.swift | 22 +++++++----- .../MoleculeTreeTraversalProtocol.swift | 1 - .../Templates/MoleculeListTemplate.swift | 36 ++++++++++++++++--- .../Templates/StackPageTemplateModel.swift | 2 +- .../Templates/ThreeLayerModelBase.swift | 2 +- MVMCoreUI/BaseClasses/BarButtonItem.swift | 16 +++------ .../BaseControllers/ViewController.swift | 14 +++++--- MVMCoreUI/Behaviors/GetContactBehavior.swift | 3 +- .../Protocols/PageBehaviorProtocol.swift | 5 +++ .../OtherHandlers/CoreUIModelMapping.swift | 2 +- 23 files changed, 146 insertions(+), 97 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift index f1fd5fed..a5657dd4 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift @@ -124,7 +124,7 @@ import MVMCore didSet { if !updateSelectionOnly { layoutIfNeeded() - (model as? CheckboxModel)?.checked = isSelected + (model as? CheckboxModel)?.selected = isSelected shapeLayer?.removeAllAnimations() updateCheckboxUI(isSelected: isSelected, isAnimated: isAnimated) _ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate) @@ -419,8 +419,8 @@ import MVMCore isAnimated = model.animated isRound = model.round - if model.checked { - checkAndBypassAnimations(selected: model.checked) + if model.selected { + checkAndBypassAnimations(selected: model.selected) } isEnabled = model.enabled diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift index c2d9f14e..c4f69f27 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift @@ -6,10 +6,14 @@ // Copyright © 2020 Verizon Wireless. All rights reserved. // -import Foundation +/// Protocol to apply to any model of a UI Control with a binary on/off nature. +/// +/// Example classes: Checkbox or Toggle. +@objc public protocol SelectableMoleculeModelProtocol { + var selected: Bool { get set } +} - -@objcMembers public class CheckboxModel: MoleculeModelProtocol, FormFieldProtocol { +@objcMembers public class CheckboxModel: MoleculeModelProtocol, SelectableMoleculeModelProtocol, FormFieldProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -17,7 +21,7 @@ import Foundation public static var identifier: String = "checkbox" public var backgroundColor: Color? public var accessibilityIdentifier: String? - public var checked: Bool = false + public var selected: Bool = false public var enabled: Bool = true public var animated: Bool = true public var inverted: Bool = false @@ -66,19 +70,19 @@ import Foundation case groupName case offAction } - + //-------------------------------------------------- - // MARK: - Methods + // MARK: - Form Validation //-------------------------------------------------- - public func formFieldValue() -> AnyHashable? { checked } + public func formFieldValue() -> AnyHashable? { selected } //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- public init(isChecked: Bool = false) { - self.checked = isChecked + self.selected = isChecked baseValue = isChecked } @@ -132,10 +136,10 @@ import Foundation } if let checked = try typeContainer.decodeIfPresent(Bool.self, forKey: .checked) { - self.checked = checked + self.selected = checked } - baseValue = checked + baseValue = selected if let animated = try typeContainer.decodeIfPresent(Bool.self, forKey: .animated) { self.animated = animated @@ -169,7 +173,7 @@ import Foundation try container.encodeIfPresent(fieldKey, forKey: .fieldKey) try container.encodeIfPresent(borderColor, forKey: .borderColor) try container.encode(borderWidth, forKey: .borderWidth) - try container.encode(checked, forKey: .checked) + try container.encode(selected, forKey: .checked) try container.encode(inverted, forKey: .inverted) try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encodeIfPresent(checkColor, forKey: .checkColor) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift index 304b23c4..3513a03b 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift @@ -98,7 +98,7 @@ public typealias ActionBlockConfirmation = () -> (Bool) self.constrainKnob() } - toggleModel?.state = isOn + toggleModel?.selected = isOn _ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate) accessibilityValue = isOn ? MVMCoreUIUtility.hardcodedString(withKey: "AccOn") : MVMCoreUIUtility.hardcodedString(withKey: "AccOff") setNeedsLayout() @@ -381,7 +381,7 @@ public typealias ActionBlockConfirmation = () -> (Bool) containerTintColor.off = model.offTintColor.uiColor knobTintColor.on = model.onKnobTintColor.uiColor knobTintColor.off = model.offKnobTintColor.uiColor - isOn = model.state + isOn = model.selected changeStateNoAnimation(isOn) isAnimated = model.animated isEnabled = model.enabled diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift index 4990df73..5be014fb 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift @@ -15,7 +15,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableMo public static var identifier: String = "toggle" public var accessibilityIdentifier: String? public var backgroundColor: Color? - public var state: Bool = false + public var selected: Bool = false public var animated: Bool = true public var enabled: Bool = true public var action: ActionModelProtocol? @@ -53,17 +53,17 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableMo } //-------------------------------------------------- - // MARK: - Methods + // MARK: - Form Valdiation //-------------------------------------------------- - public func formFieldValue() -> AnyHashable? { state } + public func formFieldValue() -> AnyHashable? { selected } //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- public init(_ state: Bool) { - self.state = state + self.selected = state baseValue = state } @@ -75,7 +75,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableMo let typeContainer = try decoder.container(keyedBy: CodingKeys.self) if let state = try typeContainer.decodeIfPresent(Bool.self, forKey: .state) { - self.state = state + self.selected = state } if let enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) { @@ -109,7 +109,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableMo accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) - baseValue = state + baseValue = selected fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { self.groupName = groupName @@ -123,7 +123,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableMo try container.encodeModelIfPresent(action, forKey: .action) try container.encodeModelIfPresent(alternateAction, forKey: .alternateAction) try container.encode(moleculeName, forKey: .moleculeName) - try container.encode(state, forKey: .state) + try container.encode(selected, forKey: .state) try container.encode(animated, forKey: .animated) try container.encode(enabled, forKey: .enabled) try container.encode(onTintColor, forKey: .onTintColor) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift index 5cc07fed..2eec132f 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift @@ -81,7 +81,7 @@ numberOfLines = try typeContainer.decodeIfPresent(Int.self, forKey: .numberOfLines) } - public func encode(to encoder: Encoder) throws { + open func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeIfPresent(moleculeName, forKey: .moleculeName) try container.encode(text, forKey: .text) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift index 5076eb9e..633989d5 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift @@ -7,7 +7,7 @@ // -public class ListLeftVariableIconWithRightCaretBodyTextModel: ListItemModel, MoleculeModelProtocol { +public class ListLeftVariableIconWithRightCaretBodyTextModel: ListItemModel, ParentMoleculeModelProtocol { //----------------------------------------------------- // MARK: - Properties //----------------------------------------------------- @@ -17,6 +17,10 @@ public class ListLeftVariableIconWithRightCaretBodyTextModel: ListItemModel, Mol public var headlineBody: HeadlineBodyModel public var rightLabel: LabelModel + public var children: [MoleculeModelProtocol] { + [image, headlineBody, rightLabel] + } + //----------------------------------------------------- // MARK: - Methods //----------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinksModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinksModel.swift index f16daf2b..e2bc1691 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinksModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinksModel.swift @@ -7,7 +7,7 @@ // -public class ListRightVariableRightCaretAllTextAndLinksModel: ListItemModel, MoleculeModelProtocol { +public class ListRightVariableRightCaretAllTextAndLinksModel: ListItemModel, ParentMoleculeModelProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -16,6 +16,10 @@ public class ListRightVariableRightCaretAllTextAndLinksModel: ListItemModel, Mol public var rightLabel: LabelModel public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel + public var children: [MoleculeModelProtocol] { + [rightLabel, eyebrowHeadlineBodyLink] + } + //----------------------------------------------------- // MARK: - Methods //----------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/LeftRightViews/CornerLabelsModel.swift b/MVMCoreUI/Atomic/Molecules/LeftRightViews/CornerLabelsModel.swift index 76a56178..5c910298 100644 --- a/MVMCoreUI/Atomic/Molecules/LeftRightViews/CornerLabelsModel.swift +++ b/MVMCoreUI/Atomic/Molecules/LeftRightViews/CornerLabelsModel.swift @@ -8,7 +8,7 @@ import UIKit -public class CornerLabelsModel: MoleculeModelProtocol { +public class CornerLabelsModel: ParentMoleculeModelProtocol { public static var identifier: String = "cornerLabels" public var backgroundColor: Color? public var topLeftLabel: LabelModel? @@ -16,7 +16,10 @@ public class CornerLabelsModel: MoleculeModelProtocol { public var bottomLeftLabel: LabelModel? public var bottomRightLabel: LabelModel? public var molecule: MoleculeModelProtocol? - + public var children: [MoleculeModelProtocol] { + [molecule, topLeftLabel, topRightLabel, bottomLeftLabel, bottomRightLabel].compactMap { $0 } + } + init(with molecule: MoleculeModelProtocol?) { self.molecule = molecule } @@ -35,20 +38,20 @@ public class CornerLabelsModel: MoleculeModelProtocol { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) molecule = try typeContainer.decodeModelIfPresent(codingKey: .molecule) - topLeftLabel = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .topLeftLabel) - topRightLabel = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .topRightLabel) - bottomLeftLabel = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .bottomLeftLabel) - bottomRightLabel = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .bottomRightLabel) + topLeftLabel = try typeContainer.decodeMoleculeIfPresent(codingKey: .topLeftLabel) + topRightLabel = try typeContainer.decodeMoleculeIfPresent(codingKey: .topRightLabel) + bottomLeftLabel = try typeContainer.decodeMoleculeIfPresent(codingKey: .bottomLeftLabel) + bottomRightLabel = try typeContainer.decodeMoleculeIfPresent(codingKey: .bottomRightLabel) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeModelIfPresent(molecule, forKey: .molecule) - try container.encodeIfPresent(topLeftLabel, forKey: .topLeftLabel) - try container.encodeIfPresent(topRightLabel, forKey: .topRightLabel) - try container.encodeIfPresent(bottomLeftLabel, forKey: .bottomLeftLabel) - try container.encodeIfPresent(bottomRightLabel, forKey: .bottomRightLabel) + try container.encodeModelIfPresent(topLeftLabel, forKey: .topLeftLabel) + try container.encodeModelIfPresent(topRightLabel, forKey: .topRightLabel) + try container.encodeModelIfPresent(bottomLeftLabel, forKey: .bottomLeftLabel) + try container.encodeModelIfPresent(bottomRightLabel, forKey: .bottomRightLabel) try container.encode(moleculeName, forKey: .moleculeName) } } diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/ImageBarButtonItem.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/ImageBarButtonItem.swift index 33ed39b8..50676cbc 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/ImageBarButtonItem.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/ImageBarButtonItem.swift @@ -20,16 +20,9 @@ } /// Creates the item with the passed in action. - public static func create(with image: UIImage?, actionModel: ActionModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Self { + public static func create(with image: UIImage?, model: MoleculeModelProtocol & NavigationButtonModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Self { let button = create(with: image) - button.set(with: actionModel, delegateObject: delegateObject, additionalData: additionalData) - return button - } - - /// Creates the item with the passed in action map. - public static func create(with image: UIImage?, actionMap: [AnyHashable: Any], delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Self { - let button = create(with: image) - button.set(with: actionMap, delegateObject: delegateObject, additionalData: additionalData) + button.set(with: model, delegateObject: delegateObject, additionalData: additionalData) return button } diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/LabelBarButtonItem.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/LabelBarButtonItem.swift index 5175defe..1eb4c8a1 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/LabelBarButtonItem.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/LabelBarButtonItem.swift @@ -21,16 +21,9 @@ } /// Creates the item with the passed in action. - public static func create(with title: String?, actionModel: ActionModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Self { + public static func create(with title: String?, model: NavigationLabelButtonModel, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Self { let button = create(with: title) - button.set(with: actionModel, delegateObject: delegateObject, additionalData: additionalData) - return button - } - - /// Creates the item with the passed in action map. - public static func create(with title: String?, actionMap: [AnyHashable : Any], delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Self { - let button = create(with: title) - button.set(with: actionMap, delegateObject: delegateObject, additionalData: additionalData) + button.set(with: model, delegateObject: delegateObject, additionalData: additionalData) return button } diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift index f18c9fa1..8ba75d1a 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift @@ -67,7 +67,7 @@ public class NavigationImageButtonModel: NavigationButtonModelProtocol, Molecule /// Convenience function that creates a BarButtonItem for the model. public func createNavigationItemButton(delegateObject: MVMCoreUIDelegateObject? = nil, additionalData: [AnyHashable: Any]? = nil) -> UIBarButtonItem { let uiImage = MVMCoreCache.shared()?.getImageFromRegisteredBundles(image) - let buttonItem = ImageBarButtonItem.create(with: uiImage, actionModel: action, delegateObject: delegateObject, additionalData: additionalData) + let buttonItem = ImageBarButtonItem.create(with: uiImage, model: self, delegateObject: delegateObject, additionalData: additionalData) buttonItem.accessibilityIdentifier = accessibilityIdentifier ?? image if let accessibilityString = accessibilityText { buttonItem.accessibilityLabel = accessibilityString diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationLabelButtonModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationLabelButtonModel.swift index e52ea0d5..d72c6ae0 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationLabelButtonModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationLabelButtonModel.swift @@ -7,16 +7,16 @@ // -public class NavigationLabelButtonModel: NavigationButtonModelProtocol, MoleculeModelProtocol { +open class NavigationLabelButtonModel: NavigationButtonModelProtocol, MoleculeModelProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - public var backgroundColor: Color? - public static var identifier: String = "navigationLabelButton" - public var accessibilityIdentifier: String? - public var title: String - public var action: ActionModelProtocol + open var backgroundColor: Color? + open class var identifier: String { "navigationLabelButton" } + open var accessibilityIdentifier: String? + open var title: String + open var action: ActionModelProtocol //-------------------------------------------------- // MARK: - Initializer @@ -62,7 +62,7 @@ public class NavigationLabelButtonModel: NavigationButtonModelProtocol, Molecule //-------------------------------------------------- /// Convenience function that creates a BarButtonItem for the model. - public func createNavigationItemButton(delegateObject: MVMCoreUIDelegateObject? = nil, additionalData: [AnyHashable: Any]? = nil) -> UIBarButtonItem { - return LabelBarButtonItem.create(with: title, actionModel: action, delegateObject: delegateObject, additionalData: additionalData) + open func createNavigationItemButton(delegateObject: MVMCoreUIDelegateObject? = nil, additionalData: [AnyHashable: Any]? = nil) -> UIBarButtonItem { + return LabelBarButtonItem.create(with: title, model: self, delegateObject: delegateObject, additionalData: additionalData) } } diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift index 5fab61f9..6a75718b 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift @@ -91,3 +91,16 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc try container.encodeModelIfPresent(titleView, forKey: .titleView) } } + +extension NavigationItemModel: ParentMoleculeModelProtocol { + public var children: [MoleculeModelProtocol] { + var children: [MoleculeModelProtocol] = [line, titleView, backButton].compactMap { $0 } + if let leftButtons = additionalLeftButtons { + children.append(contentsOf: leftButtons) + } + if let rightButtons = additionalRightButtons { + children.append(contentsOf: rightButtons) + } + return children + } +} diff --git a/MVMCoreUI/Atomic/Protocols/MoleculeDelegateProtocol.swift b/MVMCoreUI/Atomic/Protocols/MoleculeDelegateProtocol.swift index e61ea662..0435cf66 100644 --- a/MVMCoreUI/Atomic/Protocols/MoleculeDelegateProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/MoleculeDelegateProtocol.swift @@ -6,30 +6,34 @@ // Copyright © 2019 Verizon Wireless. All rights reserved. // -import Foundation public protocol MoleculeDelegateProtocol: AnyObject { - + func getRootMolecules() -> [MoleculeModelProtocol] /// returns a module for the corresponding module name. - func getModuleWithName(_ name: String?) -> [AnyHashable : Any]? + func getModuleWithName(_ name: String?) -> [AnyHashable: Any]? + func getModuleWithName(_ moleculeName: String) -> MoleculeModelProtocol? - + /// Notifies the delegate that the molecule layout update. Should be called when the layout may change due to an async method. Mainly used for list or collections. func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) //optional - + /// Asks the delegate to add or remove molecules. Mainly used for list or collections. func getIndexPath(for molecule: ListItemModelProtocol & MoleculeModelProtocol) -> IndexPath? + func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], indexPath: IndexPath, animation: UITableView.RowAnimation) + func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], animation: UITableView.RowAnimation) } extension MoleculeDelegateProtocol { - public func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) {} + public func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) { } - public func getIndexPath(for molecule: ListItemModelProtocol & MoleculeModelProtocol) -> IndexPath? { return nil } - public func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], indexPath: IndexPath, animation: UITableView.RowAnimation) {} - public func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], animation: UITableView.RowAnimation) {} + public func getIndexPath(for molecule: ListItemModelProtocol & MoleculeModelProtocol) -> IndexPath? { nil } + + public func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], indexPath: IndexPath, animation: UITableView.RowAnimation) { } + + public func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], animation: UITableView.RowAnimation) { } } diff --git a/MVMCoreUI/Atomic/Protocols/MoleculeTreeTraversalProtocol.swift b/MVMCoreUI/Atomic/Protocols/MoleculeTreeTraversalProtocol.swift index 4e7efabb..abe4cdd7 100644 --- a/MVMCoreUI/Atomic/Protocols/MoleculeTreeTraversalProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/MoleculeTreeTraversalProtocol.swift @@ -50,5 +50,4 @@ extension MoleculeTreeTraversalProtocol { return accumulator } } - } diff --git a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift index 34f81bc4..baab7479 100644 --- a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift @@ -183,10 +183,8 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol //-------------------------------------------------- open override func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) { - guard let tableView = tableView else { return } - - let point = molecule.convert(molecule.bounds.origin, to: tableView) - if let indexPath = tableView.indexPathForRow(at: point), tableView.indexPathsForVisibleRows?.contains(indexPath) ?? false { + guard let tableView = tableView else { return } + if let indexPath = tableView.indexPathForRow(at: molecule.center), tableView.indexPathsForVisibleRows?.contains(indexPath) ?? false { performTableViewUpdates() } } @@ -222,6 +220,36 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } } + open func newData(for molecule: MoleculeModelProtocol) { + //TODO: expand for header, navigation, etc + let json = molecule.toJSON() + guard let index = moleculesInfo?.firstIndex(where: { (moleculeInfo) -> Bool in + //TODO: check for molecule protocol eqaulity + if json == moleculeInfo.molecule.toJSON() { + return true + } else if let parent = moleculeInfo.molecule as? ParentMoleculeModelProtocol { + // Get all molecules of the same type for faster check. + let molecules: [MoleculeModelProtocol] = parent.reduceDepthFirstTraverse(options: .childFirst, depth: 0, initialResult: []) { (accumulator, currentMolecule, depth) in + if currentMolecule.moleculeName == molecule.moleculeName { + return accumulator + [currentMolecule] + } + return accumulator + } + for molecule in molecules { + if json == molecule.toJSON() { + return true + } + } + } + return false + }) else { return } + + // Refresh the cell. + let indexPath = IndexPath(row: index, section: 0) + _ = tableView(tableView, cellForRowAt: indexPath) + performTableViewUpdates() + } + open override func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], animation: UITableView.RowAnimation) { var indexPaths: [IndexPath] = [] //TODO: check for molecule protocol equality diff --git a/MVMCoreUI/Atomic/Templates/StackPageTemplateModel.swift b/MVMCoreUI/Atomic/Templates/StackPageTemplateModel.swift index 27769b20..1ed663c2 100644 --- a/MVMCoreUI/Atomic/Templates/StackPageTemplateModel.swift +++ b/MVMCoreUI/Atomic/Templates/StackPageTemplateModel.swift @@ -16,7 +16,7 @@ public var moleculeStack: StackModel public override var rootMolecules: [MoleculeModelProtocol] { - return [header, moleculeStack, footer].compactMap { $0 } + [navigationBar, header, moleculeStack, footer].compactMap { $0 } } //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Templates/ThreeLayerModelBase.swift b/MVMCoreUI/Atomic/Templates/ThreeLayerModelBase.swift index 6a1bb244..06d813ef 100644 --- a/MVMCoreUI/Atomic/Templates/ThreeLayerModelBase.swift +++ b/MVMCoreUI/Atomic/Templates/ThreeLayerModelBase.swift @@ -18,7 +18,7 @@ public var footer: MoleculeModelProtocol? public override var rootMolecules: [MoleculeModelProtocol] { - return [header, footer].compactMap { $0 } + [navigationBar, header, footer].compactMap { $0 } } //-------------------------------------------------- diff --git a/MVMCoreUI/BaseClasses/BarButtonItem.swift b/MVMCoreUI/BaseClasses/BarButtonItem.swift index d41fd57f..b46647f2 100644 --- a/MVMCoreUI/BaseClasses/BarButtonItem.swift +++ b/MVMCoreUI/BaseClasses/BarButtonItem.swift @@ -20,7 +20,7 @@ public typealias BarButtonAction = (BarButtonItem) -> () //-------------------------------------------------- // MARK: - Delegate //-------------------------------------------------- - + open var model: (MoleculeModelProtocol & NavigationButtonModelProtocol)? open weak var buttonDelegate: ButtonDelegateProtocol? var actionDelegate: ActionDelegate? @@ -28,18 +28,12 @@ public typealias BarButtonAction = (BarButtonItem) -> () // MARK: - Methods //-------------------------------------------------- - open func set(with actionModel: ActionModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + open func set(with model: MoleculeModelProtocol & NavigationButtonModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + self.model = model buttonDelegate = delegateObject?.buttonDelegate actionDelegate?.buttonAction = { sender in - Button.performButtonAction(with: actionModel, button: sender, delegateObject: delegateObject, additionalData: additionalData) - } - } - - open func set(with actionMap: [AnyHashable : Any], delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - buttonDelegate = delegateObject?.buttonDelegate - actionDelegate?.buttonAction = { sender in - guard delegateObject?.buttonDelegate?.button?(sender, shouldPerformActionWithMap: actionMap, additionalData: additionalData) ?? true else { return } - MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) + let additionalDataWithSource = additionalData.dictionaryAdding(key: KeySourceModel, value: model) + Button.performButtonAction(with: model.action, button: sender, delegateObject: delegateObject, additionalData: additionalDataWithSource) } } } diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index f86061e5..5cd811de 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -450,10 +450,12 @@ import UIKit addFormParams(requestParameters: requestParameters, actionInformation: actionInformation, additionalData: additionalData) requestParameters.parentPageType = loadObject?.pageJSON?.optionalStringForKey("parentPageType") var pageForwardedData = additionalData ?? [:] + executeBehaviors { (behavior: PageLocalDataShareBehavior) in let dataMap = behavior.compileLocalPageDataForTransfer(delegateObjectIVar) - pageForwardedData.merge(dataMap) { (current, _) in current } + pageForwardedData.merge(dataMap) { current, _ in current } } + MVMCoreActionHandler.defaultHandleOpenPage(for: requestParameters, actionInformation: actionInformation, additionalData: pageForwardedData, delegateObject: delegateObject()) } @@ -461,14 +463,16 @@ import UIKit MVMCoreUILoggingHandler.shared()?.defaultLogAction(forController: self, actionInformation: actionInformation, additionalData: additionalData) } - open func handleUnknownActionType(_ actionType: String?, actionInformation: [AnyHashable : Any]?, additionalData: [AnyHashable : Any]?) { + open func handleUnknownActionType(_ actionType: String?, actionInformation: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) { var handled = false + executeBehaviors { (behavior: PageCustomActionHandlerBehavior) in - if (!handled) { + if !handled { handled = behavior.handleAction(type: actionType, information: actionInformation, additionalData: additionalData) } } - if (!handled) { + + if !handled { MVMCoreUIActionHandler.defaultHandleUnknownActionType(actionType, actionInformation: actionInformation, additionalData: additionalData, delegateObject: delegateObjectIVar) } } @@ -478,7 +482,7 @@ import UIKit //-------------------------------------------------- open func getRootMolecules() -> [MoleculeModelProtocol] { - return model?.rootMolecules ?? [] + model?.rootMolecules ?? [] } open func getModuleWithName(_ name: String?) -> [AnyHashable: Any]? { diff --git a/MVMCoreUI/Behaviors/GetContactBehavior.swift b/MVMCoreUI/Behaviors/GetContactBehavior.swift index c69bdbce..77c0d7f4 100644 --- a/MVMCoreUI/Behaviors/GetContactBehavior.swift +++ b/MVMCoreUI/Behaviors/GetContactBehavior.swift @@ -9,6 +9,7 @@ import Foundation import Contacts + public protocol PageGetContactBehaviorConsumerProtocol { func getMatchParameters() -> (NSPredicate, [CNKeyDescriptor])? func consume(contacts: [CNContact]) @@ -18,7 +19,7 @@ public class PageGetContactBehaviorModel: PageBehaviorModelProtocol { public class var identifier: String { "pageGetContactBehavior" } public var shouldAllowMultipleInstances: Bool { false } - public init() {} + public init() { } } public class PageGetContactBehavior: PageVisibilityBehavior { diff --git a/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift b/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift index e7db54bc..3f14f3cc 100644 --- a/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift +++ b/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift @@ -41,6 +41,11 @@ public protocol PageLocalDataShareBehavior: PageBehaviorProtocol { public protocol PageCustomActionHandlerBehavior: PageBehaviorProtocol { + /// - Parameters: + /// - actionType: The action type of the passed action model. + /// - information: information of the passed action model. + /// - additionalData: Additional information of the + /// - Returns: Boolean determines if the action has been handled. func handleAction(type actionType: String?, information: [AnyHashable : Any]?, additionalData: [AnyHashable : Any]?) -> Bool } diff --git a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift index d4eb516e..1edea27b 100644 --- a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift @@ -127,7 +127,7 @@ open class CoreUIModelMapping: ModelMapping { ModelRegistry.register(NavigationItemModel.self) ModelRegistry.register(NavigationImageButtonModel.self) ModelRegistry.register(NavigationLabelButtonModel.self) - + // MARK:- Other Organisms ModelRegistry.register(handler: Carousel.self, for: CarouselModel.self) ModelRegistry.register(handler: BarsIndicatorView.self, for: BarsCarouselIndicatorModel.self) From d244c38921020e7262e97471ae4d3f646e67fb18 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 20 Jul 2021 13:38:04 -0400 Subject: [PATCH 109/113] revert for ui --- MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift index baab7479..d5c7de98 100644 --- a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift @@ -246,8 +246,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol // Refresh the cell. let indexPath = IndexPath(row: index, section: 0) - _ = tableView(tableView, cellForRowAt: indexPath) - performTableViewUpdates() + tableView.reloadRows(at: [indexPath], with: .automatic) } open override func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], animation: UITableView.RowAnimation) { From cfad9aae27f11d1f4432b5a2ed8fa8c89ca7aa2f Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 20 Jul 2021 13:47:08 -0400 Subject: [PATCH 110/113] selection update --- MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift index d5c7de98..de79cec3 100644 --- a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift @@ -244,9 +244,13 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol return false }) else { return } - // Refresh the cell. + // Refresh the cell. (reload loses cell selection) + let selectedIndex = tableView.indexPathForSelectedRow let indexPath = IndexPath(row: index, section: 0) tableView.reloadRows(at: [indexPath], with: .automatic) + if let selectedIndex = selectedIndex { + tableView.selectRow(at: selectedIndex, animated: false, scrollPosition: .none) + } } open override func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], animation: UITableView.RowAnimation) { From 8f2a4b2469ba592d61af6f845502c04d1b816891 Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Thu, 22 Jul 2021 11:42:04 -0400 Subject: [PATCH 111/113] Revert "Merge branch 'bugfix/carousel_issues' into 'develop'" This reverts merge request !734 --- .../CarouselIndicator/BarsIndicatorView.swift | 1 - .../CarouselIndicator/CarouselIndicator.swift | 6 ------ .../Atomic/Organisms/Carousel/Carousel.swift | 15 +-------------- .../Atomic/Organisms/Carousel/CarouselModel.swift | 4 ++-- 4 files changed, 3 insertions(+), 23 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift index 8a1f960b..975c7ebb 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift @@ -234,7 +234,6 @@ open class BarsIndicatorView: CarouselIndicator { super.reset() barReferences.forEach { $0.removeFromSuperview() } barReferences = [] - currentIndex = 0 } public override func updateUI(previousIndex: Int, newIndex: Int, totalCount: Int, isAnimated: Bool) { diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift index 5b04d065..6a82ef80 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift @@ -248,10 +248,4 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol { bottomConstraint?.constant = constant topConstraint?.constant = constant } - - open override func reset() { - super.reset() - currentIndex = 0 - previousIndex = 0 - } } diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift index 24ae0c06..67e024ca 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift @@ -41,7 +41,7 @@ open class Carousel: View { open var numberOfPages = 0 /// The models for the molecules. - public var molecules: [MoleculeModelProtocol & CarouselItemModelProtocol & CollectionItemModelProtocol]? + public var molecules: [MoleculeModelProtocol & CarouselItemModelProtocol]? /// The horizontal alignment of the cell in the collection view. Only noticeable if the itemWidthPercent is less than 100%. public var itemAlignment = UICollectionView.ScrollPosition.left @@ -177,7 +177,6 @@ open class Carousel: View { if let selectedIndex = carouselModel.selectedIndex { let adjustedIndex = loop ? selectedIndex + 2 : selectedIndex collectionView.selectItem(at: IndexPath(row: adjustedIndex, section: 0), animated: false, scrollPosition: []) - goTo(adjustedIndex, animated: false) } } @@ -208,13 +207,6 @@ open class Carousel: View { pageIndex = 0 } - open override func reset() { - super.reset() - currentIndex = 0 - pageIndex = 0 - pagingView?.reset() - } - var pagingMoleculeName: String? /// Sets up the paging molecule @@ -224,7 +216,6 @@ open class Carousel: View { molecule.moleculeName == pagingMoleculeName { pagingView?.set(with: molecule, delegateObject, nil) pagingView?.numberOfPages = numberOfPages - pagingView?.currentIndex = currentIndex return } @@ -432,10 +423,6 @@ extension Carousel: UICollectionViewDelegate { adjustedIndex = adjustedIndex + numberOfPages } model.selectedIndex = adjustedIndex - currentIndex = adjustedIndex - pageIndex = currentIndex - pagingView?.currentIndex = adjustedIndex - updateModelIndex() } if let cell = collectionView.cellForItem(at: indexPath) as? CollectionTemplateItemProtocol { cell.didSelectCell(at: indexPath, delegateObject: delegateObject, additionalData: nil) diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift index df258324..8721db72 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift @@ -20,7 +20,7 @@ import UIKit } public var backgroundColor: Color? - public var molecules: [MoleculeModelProtocol & CarouselItemModelProtocol & CollectionItemModelProtocol] + public var molecules: [MoleculeModelProtocol & CarouselItemModelProtocol] public var index: Int = 0 public var spacing: CGFloat? public var border: Bool? @@ -41,7 +41,7 @@ import UIKit public var selectable = false public var selectedIndex: Int? - public init(molecules: [MoleculeModelProtocol & CarouselItemModelProtocol & CollectionItemModelProtocol]) { + public init(molecules: [MoleculeModelProtocol & CarouselItemModelProtocol]) { self.molecules = molecules } From 69499bf0495b57eaa3e9787abf6bd0ac49ef99b5 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 22 Jul 2021 15:10:11 -0400 Subject: [PATCH 112/113] threading fix --- .../SplitViewController/MVMCoreUISplitViewController.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index 20f0d227..d8639b56 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -1053,7 +1053,11 @@ CGFloat const PanelAnimationDuration = 0.2; } + (CGFloat)getApplicationViewWidth { - return CGRectGetWidth([self getBounds:[MVMCoreUISession sharedGlobal].splitViewController.view.superview]); + __block CGFloat width; + [MVMCoreDispatchUtility performSyncBlockOnMainThread:^{ + width = CGRectGetWidth([self getBounds:[MVMCoreUISession sharedGlobal].splitViewController.view.superview]); + }]; + return width; } + (CGFloat)getApplicationViewMaxSize { From 54b510f98a9b81cec223e36a1cf05ea9d9f28397 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 22 Jul 2021 15:49:34 -0400 Subject: [PATCH 113/113] nullability change --- .../Atomic/Protocols/MoleculeTreeTraversalProtocol.swift | 2 +- MVMCoreUI/Atomic/Templates/CollectionTemplate.swift | 2 +- MVMCoreUI/BaseControllers/ViewController.swift | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atomic/Protocols/MoleculeTreeTraversalProtocol.swift b/MVMCoreUI/Atomic/Protocols/MoleculeTreeTraversalProtocol.swift index abe4cdd7..d10a2d19 100644 --- a/MVMCoreUI/Atomic/Protocols/MoleculeTreeTraversalProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/MoleculeTreeTraversalProtocol.swift @@ -28,7 +28,7 @@ public protocol MoleculeTreeTraversalProtocol { // Helper Extensions // -extension MoleculeTreeTraversalProtocol { +public extension MoleculeTreeTraversalProtocol { func countMolecules(options: TreeTraversalOptions = .parentFirst) -> Int { return reduceDepthFirstTraverse(options: options, depth: 0, initialResult: 0) { (accumulator, molecule, depth) in diff --git a/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift b/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift index 0d33d57f..f3bd5d83 100644 --- a/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift @@ -66,7 +66,7 @@ return molecule } - open override func shouldFinishProcessingLoad(_ loadObject: MVMCoreLoadObject, error: AutoreleasingUnsafeMutablePointer) -> Bool { + open override func shouldFinishProcessingLoad(_ loadObject: MVMCoreLoadObject, error: AutoreleasingUnsafeMutablePointer) -> Bool { guard super.shouldFinishProcessingLoad(loadObject, error: error) else { return false } // This template requires atleast one of the three layers. diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 5cd811de..52d63f84 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -122,7 +122,7 @@ import UIKit } } - open func shouldFinishProcessingLoad(_ loadObject: MVMCoreLoadObject, error: AutoreleasingUnsafeMutablePointer) -> Bool { + open func shouldFinishProcessingLoad(_ loadObject: MVMCoreLoadObject, error: AutoreleasingUnsafeMutablePointer) -> Bool { pageType = loadObject.pageType self.loadObject = loadObject @@ -186,7 +186,7 @@ import UIKit open func parsePageJSON() throws { } - open class func verifyRequiredModulesLoaded(for loadObject: MVMCoreLoadObject?, error: AutoreleasingUnsafeMutablePointer) -> Bool { + open class func verifyRequiredModulesLoaded(for loadObject: MVMCoreLoadObject?, error: AutoreleasingUnsafeMutablePointer) -> Bool { guard let pageType = loadObject?.pageType, var modulesRequired = MVMCoreUIViewControllerMappingObject.shared()?.modulesRequired(forPageType: pageType), !modulesRequired.isEmpty