From 2cb16f489f782029936217a85fcebd4647e4d256 Mon Sep 17 00:00:00 2001 From: "Murugan, Vimal" Date: Wed, 11 Nov 2020 23:14:17 +0530 Subject: [PATCH 01/21] date picker updated --- .../Atomic/Extensions/UIDatePicker+Extension.swift | 10 ++++++++++ MVMCoreUI/Atomic/Templates/ListPageTemplateModel.swift | 2 +- MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m | 10 ++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Extensions/UIDatePicker+Extension.swift b/MVMCoreUI/Atomic/Extensions/UIDatePicker+Extension.swift index 4c1acfcb..1d17b194 100644 --- a/MVMCoreUI/Atomic/Extensions/UIDatePicker+Extension.swift +++ b/MVMCoreUI/Atomic/Extensions/UIDatePicker+Extension.swift @@ -20,6 +20,11 @@ public extension UIDatePicker { let locale = NSLocale.current as NSLocale datePicker.locale = locale as Locale datePicker.calendar = locale.object(forKey: .calendar) as? Calendar + //To support old style wheel + if #available(iOS 13.4, *) { + datePicker.preferredDatePickerStyle = .wheels + datePicker.sizeToFit() + } textField.inputView = datePicker return datePicker @@ -30,6 +35,11 @@ public extension UIDatePicker { let datePicker = UIDatePicker() datePicker.backgroundColor = .mvmWhite datePicker.datePickerMode = .time + //To support old style wheel + if #available(iOS 13.4, *) { + datePicker.preferredDatePickerStyle = .wheels + datePicker.sizeToFit() + } textField.inputView = datePicker return datePicker diff --git a/MVMCoreUI/Atomic/Templates/ListPageTemplateModel.swift b/MVMCoreUI/Atomic/Templates/ListPageTemplateModel.swift index ba464f68..a7c92a08 100644 --- a/MVMCoreUI/Atomic/Templates/ListPageTemplateModel.swift +++ b/MVMCoreUI/Atomic/Templates/ListPageTemplateModel.swift @@ -67,7 +67,7 @@ import Foundation var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeModelsIfPresent(molecules, forKey: .molecules) try container.encode(line, forKey: .line) - try container.encode(scrollToRowIndex, forKey: .scrollToRowIndex) + try container.encodeIfPresent(scrollToRowIndex, forKey: .scrollToRowIndex) } } diff --git a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m index 84ad5f5d..cbfa8193 100644 --- a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m +++ b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m @@ -118,6 +118,11 @@ static const CGFloat VertialShadowOffset = 6; NSLocale *locale = [NSLocale currentLocale]; datePicker.locale = locale; datePicker.calendar = [locale objectForKey:NSLocaleCalendar]; + //To handle new style in ios 13.4 and above + if (@available(iOS 13.4, *)) { + [datePicker setPreferredDatePickerStyle:UIDatePickerStyleWheels]; + [datePicker sizeToFit]; + } datePicker = datePicker; textField.inputView = datePicker; return datePicker; @@ -128,6 +133,11 @@ static const CGFloat VertialShadowOffset = 6; datePicker.backgroundColor = [UIColor whiteColor]; datePicker.datePickerMode = UIDatePickerModeTime; datePicker = datePicker; + //To handle new style in ios 13.4 and above + if (@available(iOS 13.4, *)) { + [datePicker setPreferredDatePickerStyle:UIDatePickerStyleWheels]; + [datePicker sizeToFit]; + } textField.inputView = datePicker; return datePicker; From 29a9d3eeb592fe6da95886aa8df295111628b406 Mon Sep 17 00:00:00 2001 From: "Murugan, Vimal" Date: Wed, 11 Nov 2020 23:24:34 +0530 Subject: [PATCH 02/21] removed sizetofit --- MVMCoreUI/Atomic/Extensions/UIDatePicker+Extension.swift | 2 -- MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m | 2 -- 2 files changed, 4 deletions(-) diff --git a/MVMCoreUI/Atomic/Extensions/UIDatePicker+Extension.swift b/MVMCoreUI/Atomic/Extensions/UIDatePicker+Extension.swift index 1d17b194..839b94f3 100644 --- a/MVMCoreUI/Atomic/Extensions/UIDatePicker+Extension.swift +++ b/MVMCoreUI/Atomic/Extensions/UIDatePicker+Extension.swift @@ -23,7 +23,6 @@ public extension UIDatePicker { //To support old style wheel if #available(iOS 13.4, *) { datePicker.preferredDatePickerStyle = .wheels - datePicker.sizeToFit() } textField.inputView = datePicker @@ -38,7 +37,6 @@ public extension UIDatePicker { //To support old style wheel if #available(iOS 13.4, *) { datePicker.preferredDatePickerStyle = .wheels - datePicker.sizeToFit() } textField.inputView = datePicker diff --git a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m index cbfa8193..8e276b72 100644 --- a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m +++ b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m @@ -121,7 +121,6 @@ static const CGFloat VertialShadowOffset = 6; //To handle new style in ios 13.4 and above if (@available(iOS 13.4, *)) { [datePicker setPreferredDatePickerStyle:UIDatePickerStyleWheels]; - [datePicker sizeToFit]; } datePicker = datePicker; textField.inputView = datePicker; @@ -136,7 +135,6 @@ static const CGFloat VertialShadowOffset = 6; //To handle new style in ios 13.4 and above if (@available(iOS 13.4, *)) { [datePicker setPreferredDatePickerStyle:UIDatePickerStyleWheels]; - [datePicker sizeToFit]; } textField.inputView = datePicker; From e3a339a857feb99a777de22a723501b845aeaaa8 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 11 Nov 2020 16:36:03 -0500 Subject: [PATCH 03/21] error check for label --- MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index efbe3aad..3f485099 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -351,9 +351,13 @@ public typealias ActionBlock = () -> () } else { imageAttachment = Label.getTextAttachmentImage(name: imageName, dimension: fontSize) } - let mutableString = NSMutableAttributedString() - mutableString.append(NSAttributedString(attachment: imageAttachment)) - attributedString.insert(mutableString, at: imageAtt.location) + + // Confirm that the intended image location is within range. + if 0...labelText.count ~= imageAtt.location { + let mutableString = NSMutableAttributedString() + mutableString.append(NSAttributedString(attachment: imageAttachment)) + attributedString.insert(mutableString, at: imageAtt.location) + } case let fontAtt as LabelAttributeFontModel: if let fontStyle = fontAtt.style { From 7cc83f3d3d9491463b28c027345bb6fa80f64855 Mon Sep 17 00:00:00 2001 From: "Sankari, Swathi S" Date: Fri, 13 Nov 2020 16:29:55 +0530 Subject: [PATCH 04/21] native error popup fix --- MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m index 80a932de..14888ed1 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m @@ -119,6 +119,7 @@ - (BOOL)handleOtherActions:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { if ([actionType isEqualToString:KeyActionTypePopup]) { [self popupAction:actionInformation additionalData:additionalData delegate:delegate]; + return YES; } else if ([actionType isEqualToString:KeyActionTypeTopAlert]) { [self topAlertAction:actionInformation additionalData:additionalData delegate:delegate]; return YES; From 0f6f0e849266cd6a95885c91a425c2ac894bea23 Mon Sep 17 00:00:00 2001 From: Krishna Kishore Bandaru Date: Tue, 8 Dec 2020 12:56:07 +0530 Subject: [PATCH 05/21] Added indexColor property for NumberedList & UnOrderedList --- .../Lists/NumberedListModel.swift | 12 +++++++++--- .../StringAndMoleculeModel.swift | 9 +++++++-- .../StringAndMoleculeView.swift | 1 + .../Lists/UnOrderedListModel.swift | 10 ++++++++-- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift index eeacb98d..38ddfd02 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift @@ -17,16 +17,18 @@ import Foundation case moleculeName case backgroundColor case list + case indexColor } // Numbered list model comes in the from of list = [MoleculeModelProtocol] public required init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - + + let indexColor = try typeContainer.decodeIfPresent(Color.self, forKey: .indexColor) let list: [MoleculeModelProtocol] = try typeContainer.decodeModels(codingKey: .list) var models: [MoleculeStackItemModel] = [] for (index, molecule) in list.enumerated() { - models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: "\(index+1).", molecule: molecule))) + models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: "\(index+1).", molecule: molecule, indexColor: indexColor))) } super.init(molecules: models, spacing: 0) } @@ -36,11 +38,15 @@ import Foundation try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encode(moleculeName, forKey: .moleculeName) + var indexColor: Color? var models: [MoleculeModelProtocol] = [] for molecule in molecules { - models.append(((molecule as! MoleculeStackItemModel).molecule as! StringAndMoleculeModel).molecule) + let stringAndMoleculeModel: StringAndMoleculeModel = ((molecule as! MoleculeStackItemModel).molecule as! StringAndMoleculeModel) + indexColor = stringAndMoleculeModel.indexColor + models.append(stringAndMoleculeModel.molecule) } try container.encodeModels(models, forKey: .list) + try container.encodeIfPresent(indexColor, forKey: .indexColor) } } diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift index 3adb0bb3..37d5f580 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift @@ -13,10 +13,12 @@ public class StringAndMoleculeModel: MoleculeModelProtocol { public var backgroundColor: Color? public var string: String public var molecule: MoleculeModelProtocol - - public init(string: String, molecule: MoleculeModelProtocol) { + public var indexColor: Color? + + public init(string: String, molecule: MoleculeModelProtocol, indexColor: Color?) { self.string = string self.molecule = molecule + self.indexColor = indexColor } private enum CodingKeys: String, CodingKey { @@ -24,6 +26,7 @@ public class StringAndMoleculeModel: MoleculeModelProtocol { case backgroundColor case string case molecule + case indexColor } public required init(from decoder: Decoder) throws { @@ -31,6 +34,7 @@ public class StringAndMoleculeModel: MoleculeModelProtocol { backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) string = try typeContainer.decode(String.self, forKey: .string) molecule = try typeContainer.decodeModel(codingKey: .molecule) + indexColor = try typeContainer.decodeIfPresent(Color.self, forKey: .indexColor) } public func encode(to encoder: Encoder) throws { @@ -39,5 +43,6 @@ public class StringAndMoleculeModel: MoleculeModelProtocol { try container.encode(string, forKey: .string) try container.encodeModel(molecule, forKey: .molecule) try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(indexColor, forKey: .indexColor) } } diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift index a2a76f68..b95dd8cd 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift @@ -84,6 +84,7 @@ open class StringAndMoleculeView: View { super.set(with: model, delegateObject, additionalData) guard let model = model as? StringAndMoleculeModel else { return } label.text = model.string + label.textColor = model.indexColor?.uiColor ?? .black molecule.set(with: model.molecule, delegateObject, additionalData) } diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift index 3866e918..c6e34197 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift @@ -19,6 +19,7 @@ import Foundation case backgroundColor case list case bulletChar + case indexColor } // Numbered list model comes in the from of list = [MoleculeModelProtocol] @@ -28,10 +29,11 @@ import Foundation self.bulletChar = bulletChar } + let indexColor = try typeContainer.decodeIfPresent(Color.self, forKey: .indexColor) let list: [MoleculeModelProtocol] = try typeContainer.decodeModels(codingKey: .list) var models: [MoleculeStackItemModel] = [] for molecule in list { - models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: bulletChar, molecule: molecule))) + models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: bulletChar, molecule: molecule, indexColor: indexColor))) } super.init(molecules: models, spacing: 0) } @@ -42,10 +44,14 @@ import Foundation try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encode(moleculeName, forKey: .moleculeName) + var indexColor: Color? var models: [MoleculeModelProtocol] = [] for molecule in molecules { - models.append(((molecule as! MoleculeStackItemModel).molecule as! StringAndMoleculeModel).molecule) + let stringAndMoleculeModel: StringAndMoleculeModel = ((molecule as! MoleculeStackItemModel).molecule as! StringAndMoleculeModel) + indexColor = stringAndMoleculeModel.indexColor + models.append(stringAndMoleculeModel.molecule) } try container.encodeModels(models, forKey: .list) + try container.encodeIfPresent(indexColor, forKey: .indexColor) } } From 7e175ef581b1497f94fdf9aef10536080c500c68 Mon Sep 17 00:00:00 2001 From: Krishna Kishore Bandaru Date: Tue, 8 Dec 2020 15:41:50 +0530 Subject: [PATCH 06/21] Updated indexColor datatype to string --- .../VerticalCombinationViews/Lists/NumberedListModel.swift | 4 ++-- .../StringAndMoleculeStack/StringAndMoleculeModel.swift | 6 +++--- .../StringAndMoleculeStack/StringAndMoleculeView.swift | 4 +++- .../VerticalCombinationViews/Lists/UnOrderedListModel.swift | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift index 38ddfd02..4d00d1b1 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift @@ -24,7 +24,7 @@ import Foundation public required init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - let indexColor = try typeContainer.decodeIfPresent(Color.self, forKey: .indexColor) + let indexColor = try typeContainer.decodeIfPresent(String.self, forKey: .indexColor) let list: [MoleculeModelProtocol] = try typeContainer.decodeModels(codingKey: .list) var models: [MoleculeStackItemModel] = [] for (index, molecule) in list.enumerated() { @@ -38,7 +38,7 @@ import Foundation try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encode(moleculeName, forKey: .moleculeName) - var indexColor: Color? + var indexColor: String? var models: [MoleculeModelProtocol] = [] for molecule in molecules { let stringAndMoleculeModel: StringAndMoleculeModel = ((molecule as! MoleculeStackItemModel).molecule as! StringAndMoleculeModel) diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift index 37d5f580..0bfe9e2b 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift @@ -13,9 +13,9 @@ public class StringAndMoleculeModel: MoleculeModelProtocol { public var backgroundColor: Color? public var string: String public var molecule: MoleculeModelProtocol - public var indexColor: Color? + public var indexColor: String? - public init(string: String, molecule: MoleculeModelProtocol, indexColor: Color?) { + public init(string: String, molecule: MoleculeModelProtocol, indexColor: String?) { self.string = string self.molecule = molecule self.indexColor = indexColor @@ -34,7 +34,7 @@ public class StringAndMoleculeModel: MoleculeModelProtocol { backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) string = try typeContainer.decode(String.self, forKey: .string) molecule = try typeContainer.decodeModel(codingKey: .molecule) - indexColor = try typeContainer.decodeIfPresent(Color.self, forKey: .indexColor) + indexColor = try typeContainer.decodeIfPresent(String.self, forKey: .indexColor) } public func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift index b95dd8cd..d8c228ae 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift @@ -84,7 +84,9 @@ open class StringAndMoleculeView: View { super.set(with: model, delegateObject, additionalData) guard let model = model as? StringAndMoleculeModel else { return } label.text = model.string - label.textColor = model.indexColor?.uiColor ?? .black + if let indexColor = model.indexColor { + label.textColor = try? Color(colorString: indexColor)?.uiColor ?? .black + } molecule.set(with: model.molecule, delegateObject, additionalData) } diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift index c6e34197..178794d1 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift @@ -29,7 +29,7 @@ import Foundation self.bulletChar = bulletChar } - let indexColor = try typeContainer.decodeIfPresent(Color.self, forKey: .indexColor) + let indexColor = try typeContainer.decodeIfPresent(String.self, forKey: .indexColor) let list: [MoleculeModelProtocol] = try typeContainer.decodeModels(codingKey: .list) var models: [MoleculeStackItemModel] = [] for molecule in list { @@ -44,7 +44,7 @@ import Foundation try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encode(moleculeName, forKey: .moleculeName) - var indexColor: Color? + var indexColor: String? var models: [MoleculeModelProtocol] = [] for molecule in molecules { let stringAndMoleculeModel: StringAndMoleculeModel = ((molecule as! MoleculeStackItemModel).molecule as! StringAndMoleculeModel) From b9267f219fec644168319fe3ff4f88b2ef76cf86 Mon Sep 17 00:00:00 2001 From: Krishna Kishore Bandaru Date: Tue, 8 Dec 2020 20:18:40 +0530 Subject: [PATCH 07/21] Updated indexColor key to stringColor & data type to Color --- .../Lists/NumberedListModel.swift | 12 ++++++------ .../StringAndMoleculeModel.swift | 12 ++++++------ .../StringAndMoleculeView.swift | 4 +--- .../Lists/UnOrderedListModel.swift | 12 ++++++------ 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift index 4d00d1b1..f40069a6 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift @@ -17,18 +17,18 @@ import Foundation case moleculeName case backgroundColor case list - case indexColor + case stringColor } // Numbered list model comes in the from of list = [MoleculeModelProtocol] public required init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - let indexColor = try typeContainer.decodeIfPresent(String.self, forKey: .indexColor) + let stringColor = try typeContainer.decodeIfPresent(Color.self, forKey: .stringColor) let list: [MoleculeModelProtocol] = try typeContainer.decodeModels(codingKey: .list) var models: [MoleculeStackItemModel] = [] for (index, molecule) in list.enumerated() { - models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: "\(index+1).", molecule: molecule, indexColor: indexColor))) + models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: "\(index+1).", molecule: molecule, stringColor: stringColor))) } super.init(molecules: models, spacing: 0) } @@ -38,15 +38,15 @@ import Foundation try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encode(moleculeName, forKey: .moleculeName) - var indexColor: String? + var indexColor: Color? var models: [MoleculeModelProtocol] = [] for molecule in molecules { let stringAndMoleculeModel: StringAndMoleculeModel = ((molecule as! MoleculeStackItemModel).molecule as! StringAndMoleculeModel) - indexColor = stringAndMoleculeModel.indexColor + indexColor = stringAndMoleculeModel.stringColor models.append(stringAndMoleculeModel.molecule) } try container.encodeModels(models, forKey: .list) - try container.encodeIfPresent(indexColor, forKey: .indexColor) + try container.encodeIfPresent(indexColor, forKey: .stringColor) } } diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift index 0bfe9e2b..c87007f2 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift @@ -13,12 +13,12 @@ public class StringAndMoleculeModel: MoleculeModelProtocol { public var backgroundColor: Color? public var string: String public var molecule: MoleculeModelProtocol - public var indexColor: String? + public var stringColor: Color? - public init(string: String, molecule: MoleculeModelProtocol, indexColor: String?) { + public init(string: String, molecule: MoleculeModelProtocol, stringColor: Color?) { self.string = string self.molecule = molecule - self.indexColor = indexColor + self.stringColor = stringColor } private enum CodingKeys: String, CodingKey { @@ -26,7 +26,7 @@ public class StringAndMoleculeModel: MoleculeModelProtocol { case backgroundColor case string case molecule - case indexColor + case stringColor } public required init(from decoder: Decoder) throws { @@ -34,7 +34,7 @@ public class StringAndMoleculeModel: MoleculeModelProtocol { backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) string = try typeContainer.decode(String.self, forKey: .string) molecule = try typeContainer.decodeModel(codingKey: .molecule) - indexColor = try typeContainer.decodeIfPresent(String.self, forKey: .indexColor) + stringColor = try typeContainer.decodeIfPresent(Color.self, forKey: .stringColor) } public func encode(to encoder: Encoder) throws { @@ -43,6 +43,6 @@ public class StringAndMoleculeModel: MoleculeModelProtocol { try container.encode(string, forKey: .string) try container.encodeModel(molecule, forKey: .molecule) try container.encode(moleculeName, forKey: .moleculeName) - try container.encodeIfPresent(indexColor, forKey: .indexColor) + try container.encodeIfPresent(stringColor, forKey: .stringColor) } } diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift index d8c228ae..29f6ccf6 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift @@ -84,9 +84,7 @@ open class StringAndMoleculeView: View { super.set(with: model, delegateObject, additionalData) guard let model = model as? StringAndMoleculeModel else { return } label.text = model.string - if let indexColor = model.indexColor { - label.textColor = try? Color(colorString: indexColor)?.uiColor ?? .black - } + label.textColor = model.stringColor?.uiColor molecule.set(with: model.molecule, delegateObject, additionalData) } diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift index 178794d1..067429e3 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift @@ -19,7 +19,7 @@ import Foundation case backgroundColor case list case bulletChar - case indexColor + case stringColor } // Numbered list model comes in the from of list = [MoleculeModelProtocol] @@ -29,11 +29,11 @@ import Foundation self.bulletChar = bulletChar } - let indexColor = try typeContainer.decodeIfPresent(String.self, forKey: .indexColor) + let stringColor = try typeContainer.decodeIfPresent(Color.self, forKey: .stringColor) let list: [MoleculeModelProtocol] = try typeContainer.decodeModels(codingKey: .list) var models: [MoleculeStackItemModel] = [] for molecule in list { - models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: bulletChar, molecule: molecule, indexColor: indexColor))) + models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: bulletChar, molecule: molecule, stringColor: stringColor))) } super.init(molecules: models, spacing: 0) } @@ -44,14 +44,14 @@ import Foundation try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encode(moleculeName, forKey: .moleculeName) - var indexColor: String? + var stringColor: Color? var models: [MoleculeModelProtocol] = [] for molecule in molecules { let stringAndMoleculeModel: StringAndMoleculeModel = ((molecule as! MoleculeStackItemModel).molecule as! StringAndMoleculeModel) - indexColor = stringAndMoleculeModel.indexColor + stringColor = stringAndMoleculeModel.stringColor models.append(stringAndMoleculeModel.molecule) } try container.encodeModels(models, forKey: .list) - try container.encodeIfPresent(indexColor, forKey: .indexColor) + try container.encodeIfPresent(stringColor, forKey: .stringColor) } } From 77b5275a44905b48957a2b932ad6738bd594ea01 Mon Sep 17 00:00:00 2001 From: Krishna Kishore Bandaru Date: Tue, 8 Dec 2020 21:38:44 +0530 Subject: [PATCH 08/21] Added numberColor, bulletColor & addressed review comments --- .../Lists/NumberedListModel.swift | 14 ++++++-------- .../StringAndMoleculeModel.swift | 6 +++--- .../StringAndMoleculeView.swift | 2 +- .../Lists/UnOrderedListModel.swift | 16 +++++++--------- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift index f40069a6..7399a756 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift @@ -12,23 +12,24 @@ import Foundation public override class var identifier: String { return "numberedList" } + public var numberColor: Color? private enum CodingKeys: String, CodingKey { case moleculeName case backgroundColor case list - case stringColor + case numberColor } // Numbered list model comes in the from of list = [MoleculeModelProtocol] public required init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - let stringColor = try typeContainer.decodeIfPresent(Color.self, forKey: .stringColor) + numberColor = try typeContainer.decodeIfPresent(Color.self, forKey: .numberColor) let list: [MoleculeModelProtocol] = try typeContainer.decodeModels(codingKey: .list) var models: [MoleculeStackItemModel] = [] for (index, molecule) in list.enumerated() { - models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: "\(index+1).", molecule: molecule, stringColor: stringColor))) + models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: "\(index+1).", molecule: molecule, stringColor: numberColor ?? Color(uiColor: .mvmBlack)))) } super.init(molecules: models, spacing: 0) } @@ -38,15 +39,12 @@ import Foundation try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encode(moleculeName, forKey: .moleculeName) - var indexColor: Color? var models: [MoleculeModelProtocol] = [] for molecule in molecules { - let stringAndMoleculeModel: StringAndMoleculeModel = ((molecule as! MoleculeStackItemModel).molecule as! StringAndMoleculeModel) - indexColor = stringAndMoleculeModel.stringColor - models.append(stringAndMoleculeModel.molecule) + models.append(((molecule as! MoleculeStackItemModel).molecule as! StringAndMoleculeModel).molecule) } try container.encodeModels(models, forKey: .list) - try container.encodeIfPresent(indexColor, forKey: .stringColor) + try container.encodeIfPresent(numberColor, forKey: .numberColor) } } diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift index c87007f2..c22a1c17 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift @@ -13,9 +13,9 @@ public class StringAndMoleculeModel: MoleculeModelProtocol { public var backgroundColor: Color? public var string: String public var molecule: MoleculeModelProtocol - public var stringColor: Color? + public var stringColor: Color - public init(string: String, molecule: MoleculeModelProtocol, stringColor: Color?) { + public init(string: String, molecule: MoleculeModelProtocol, stringColor: Color) { self.string = string self.molecule = molecule self.stringColor = stringColor @@ -34,7 +34,7 @@ public class StringAndMoleculeModel: MoleculeModelProtocol { backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) string = try typeContainer.decode(String.self, forKey: .string) molecule = try typeContainer.decodeModel(codingKey: .molecule) - stringColor = try typeContainer.decodeIfPresent(Color.self, forKey: .stringColor) + stringColor = try typeContainer.decode(Color.self, forKey: .stringColor) } public func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift index 29f6ccf6..a9fd5da8 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift @@ -84,7 +84,7 @@ open class StringAndMoleculeView: View { super.set(with: model, delegateObject, additionalData) guard let model = model as? StringAndMoleculeModel else { return } label.text = model.string - label.textColor = model.stringColor?.uiColor + label.textColor = model.stringColor.uiColor molecule.set(with: model.molecule, delegateObject, additionalData) } diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift index 067429e3..89cb391f 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift @@ -13,13 +13,14 @@ import Foundation return "unOrderedList" } public var bulletChar = "•" - + public var bulletColor: Color? + private enum CodingKeys: String, CodingKey { case moleculeName case backgroundColor case list case bulletChar - case stringColor + case bulletColor } // Numbered list model comes in the from of list = [MoleculeModelProtocol] @@ -29,11 +30,11 @@ import Foundation self.bulletChar = bulletChar } - let stringColor = try typeContainer.decodeIfPresent(Color.self, forKey: .stringColor) + bulletColor = try typeContainer.decodeIfPresent(Color.self, forKey: .bulletColor) let list: [MoleculeModelProtocol] = try typeContainer.decodeModels(codingKey: .list) var models: [MoleculeStackItemModel] = [] for molecule in list { - models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: bulletChar, molecule: molecule, stringColor: stringColor))) + models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: bulletChar, molecule: molecule, stringColor: bulletColor ?? Color(uiColor: .mvmBlack)))) } super.init(molecules: models, spacing: 0) } @@ -44,14 +45,11 @@ import Foundation try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encode(moleculeName, forKey: .moleculeName) - var stringColor: Color? var models: [MoleculeModelProtocol] = [] for molecule in molecules { - let stringAndMoleculeModel: StringAndMoleculeModel = ((molecule as! MoleculeStackItemModel).molecule as! StringAndMoleculeModel) - stringColor = stringAndMoleculeModel.stringColor - models.append(stringAndMoleculeModel.molecule) + models.append(((molecule as! MoleculeStackItemModel).molecule as! StringAndMoleculeModel).molecule) } try container.encodeModels(models, forKey: .list) - try container.encodeIfPresent(stringColor, forKey: .stringColor) + try container.encodeIfPresent(bulletColor, forKey: .bulletColor) } } From bd4abe3c00399daa5e510d2cbe36d931cf14e98d Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 8 Dec 2020 14:42:08 -0500 Subject: [PATCH 09/21] update to make heart enableaable and optional --- MVMCoreUI/Atomic/Atoms/Selectors/Heart.swift | 8 +++-- .../Atomic/Atoms/Selectors/HeartModel.swift | 8 ++++- .../List/Miscellaneous/ListStoreLocator.swift | 34 ++++++++++++++----- .../Miscellaneous/ListStoreLocatorModel.swift | 8 ++--- 4 files changed, 42 insertions(+), 16 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/Heart.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Heart.swift index 796bf617..1cf80fc3 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/Heart.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/Heart.swift @@ -79,8 +79,6 @@ import UIKit heightConstraint = heightAnchor.constraint(equalTo: widthAnchor, multiplier: 1) heightConstraint?.isActive = true isAccessibilityElement = true - accessibilityTraits = .button - updateAccessibilityLabel() } public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { @@ -89,6 +87,8 @@ import UIKit self.additionalData = additionalData guard let model = model as? HeartModel else { return } isSelected = model.isActive + isEnabled = model.enabled + updateAccessibilityLabel() } //-------------------------------------------------- @@ -96,11 +96,13 @@ import UIKit //-------------------------------------------------- /// Adjust accessibility label based on selection of Heart. func updateAccessibilityLabel() { - accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: isSelected ? "heart_unfavorite_action_hint" : "heart_favorite_action_hint") + accessibilityHint = isEnabled ? MVMCoreUIUtility.hardcodedString(withKey: isSelected ? "heart_unfavorite_action_hint" : "heart_favorite_action_hint") : nil + accessibilityTraits = isEnabled ? .button : .none accessibilityLabel = MVMCoreUIUtility.hardcodedString(withKey: isSelected ? "heart_selected_state" : "heart_not_selected_state") } func tapAction() { + guard isEnabled else { return } isSelected = !isSelected if let heartModel = heartModel { Button.performButtonAction(with: heartModel.action, button: self, delegateObject: delegateObject, additionalData: additionalData, sourceModel: heartModel) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/HeartModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/HeartModel.swift index 8001ddd5..7411899c 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/HeartModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/HeartModel.swift @@ -8,7 +8,7 @@ import Foundation -open class HeartModel: MoleculeModelProtocol { +open class HeartModel: MoleculeModelProtocol, EnableableModelProtocol { //-------------------------------------------------- // MARK: - Properties @@ -19,6 +19,7 @@ open class HeartModel: MoleculeModelProtocol { public var activeColor: Color = Color(uiColor: .mvmRed) public var inActiveColor: Color = Color(uiColor: .clear) public var action: ActionModelProtocol = ActionNoopModel() + public var enabled: Bool = true //-------------------------------------------------- // MARK: - Keys @@ -30,6 +31,7 @@ open class HeartModel: MoleculeModelProtocol { case activeColor case inActiveColor case action + case enabled } //-------------------------------------------------- @@ -51,6 +53,9 @@ open class HeartModel: MoleculeModelProtocol { if let action: ActionModelProtocol = try typeContainer.decodeModelIfPresent(codingKey: .action) { self.action = action } + if let enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) { + self.enabled = enabled + } } public func encode(to encoder: Encoder) throws { @@ -61,5 +66,6 @@ open class HeartModel: MoleculeModelProtocol { try container.encode(activeColor, forKey: .activeColor) try container.encode(inActiveColor, forKey: .inActiveColor) try container.encodeModel(action, forKey: .action) + try container.encode(enabled, forKey: .enabled) } } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift index 6a1f0dc5..d81ab5c8 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift @@ -42,8 +42,6 @@ addMolecule(stack) stack.restack() horizontalStack.restack() - accessibilityHint = heart.accessibilityHint - accessibilityTraits = heart.accessibilityTraits } public override func updateView(_ size: CGFloat) { @@ -123,20 +121,40 @@ } func updateAccessibilityLabel() { - if let accessoryView = accessoryView { - // Both caret and heart. + let hasHeart = !(horizontalStack.stackModel?.molecules[1].gone ?? true) + if let accessoryView = accessoryView, + hasHeart { + // Both accessory and heart actions. isAccessibilityElement = false accessoryView.accessibilityLabel = getAccessibilityMessage() accessibilityElements = [accessoryView, heart] } else { // Make whole cell focusable if no action. isAccessibilityElement = true - if let message = getAccessibilityMessage(), - let heartLabel = heart.accessibilityLabel { - accessibilityLabel = message + ", " + heartLabel + var message = getAccessibilityMessage() + if hasHeart { + accessibilityHint = heart.accessibilityHint + if let heartLabel = heart.accessibilityLabel { + message = (message ?? "") + ", " + heartLabel + } } else { - accessibilityLabel = getAccessibilityMessage() + accessibilityHint = nil } + accessibilityLabel = message } } + + // Ensures voice over does not read "selected" after user triggers action on cell. + override public var accessibilityTraits: UIAccessibilityTraits { + get { + if (accessoryView != nil) { + return .button + } else if (!(horizontalStack.stackModel?.molecules[1].gone ?? true)) { + return heart.accessibilityTraits + } else { + return .none + } + } + set {} + } } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift index 32392b50..10a0cd29 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift @@ -12,7 +12,7 @@ public class ListStoreLocatorModel: ListItemModel, MoleculeModelProtocol { //-------------------------------------------------- public static var identifier = "listStoreLocator" - public var heart: HeartModel + public var heart: HeartModel? public var leftHeadline: LabelModel public var leftBody: LabelModel public var leftSubBody: LabelModel @@ -22,7 +22,7 @@ public class ListStoreLocatorModel: ListItemModel, MoleculeModelProtocol { // MARK: - Initializer //-------------------------------------------------- - public init(heart: HeartModel, leftHeadline: LabelModel, leftBody: LabelModel, leftSubBody: LabelModel, rightLabel: LabelModel) { + public init(heart: HeartModel?, leftHeadline: LabelModel, leftBody: LabelModel, leftSubBody: LabelModel, rightLabel: LabelModel) { self.heart = heart self.leftHeadline = leftHeadline self.leftBody = leftBody @@ -59,7 +59,7 @@ public class ListStoreLocatorModel: ListItemModel, MoleculeModelProtocol { public required init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - heart = try typeContainer.decode(HeartModel.self, forKey:.heart) + heart = try typeContainer.decodeIfPresent(HeartModel.self, forKey:.heart) leftHeadline = try typeContainer.decode(LabelModel.self, forKey: .leftHeadline) leftBody = try typeContainer.decode(LabelModel.self, forKey: .leftBody) leftSubBody = try typeContainer.decode(LabelModel.self, forKey: .leftSubBody) @@ -71,7 +71,7 @@ public class ListStoreLocatorModel: ListItemModel, MoleculeModelProtocol { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) - try container.encode(heart, forKey: .heart) + try container.encodeIfPresent(heart, forKey: .heart) try container.encode(leftHeadline, forKey: .leftHeadline) try container.encode(leftBody, forKey: .leftBody) try container.encode(leftSubBody, forKey: .leftSubBody) From 813eb68aad7555e5d49df50445593b0b365ce457 Mon Sep 17 00:00:00 2001 From: Krishna Kishore Bandaru Date: Wed, 9 Dec 2020 17:25:40 +0530 Subject: [PATCH 10/21] added default color in function param & removed optional properties --- .../Lists/NumberedListModel.swift | 8 ++++---- .../StringAndMoleculeStack/StringAndMoleculeModel.swift | 6 +++--- .../Lists/UnOrderedListModel.swift | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift index 7399a756..874868e5 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift @@ -12,7 +12,7 @@ import Foundation public override class var identifier: String { return "numberedList" } - public var numberColor: Color? + public var numberColor: Color private enum CodingKeys: String, CodingKey { case moleculeName @@ -25,11 +25,11 @@ import Foundation public required init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - numberColor = try typeContainer.decodeIfPresent(Color.self, forKey: .numberColor) + numberColor = try typeContainer.decodeIfPresent(Color.self, forKey: .numberColor) ?? Color(uiColor: .mvmBlack) let list: [MoleculeModelProtocol] = try typeContainer.decodeModels(codingKey: .list) var models: [MoleculeStackItemModel] = [] for (index, molecule) in list.enumerated() { - models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: "\(index+1).", molecule: molecule, stringColor: numberColor ?? Color(uiColor: .mvmBlack)))) + models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: "\(index+1).", molecule: molecule, stringColor: numberColor))) } super.init(molecules: models, spacing: 0) } @@ -44,7 +44,7 @@ import Foundation models.append(((molecule as! MoleculeStackItemModel).molecule as! StringAndMoleculeModel).molecule) } try container.encodeModels(models, forKey: .list) - try container.encodeIfPresent(numberColor, forKey: .numberColor) + try container.encode(numberColor, forKey: .numberColor) } } diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift index c22a1c17..6556796b 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift @@ -15,7 +15,7 @@ public class StringAndMoleculeModel: MoleculeModelProtocol { public var molecule: MoleculeModelProtocol public var stringColor: Color - public init(string: String, molecule: MoleculeModelProtocol, stringColor: Color) { + public init(string: String, molecule: MoleculeModelProtocol, stringColor: Color = Color(uiColor: .mvmBlack)) { self.string = string self.molecule = molecule self.stringColor = stringColor @@ -34,7 +34,7 @@ public class StringAndMoleculeModel: MoleculeModelProtocol { backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) string = try typeContainer.decode(String.self, forKey: .string) molecule = try typeContainer.decodeModel(codingKey: .molecule) - stringColor = try typeContainer.decode(Color.self, forKey: .stringColor) + stringColor = try typeContainer.decodeIfPresent(Color.self, forKey: .stringColor) ?? Color(uiColor: .mvmBlack) } public func encode(to encoder: Encoder) throws { @@ -43,6 +43,6 @@ public class StringAndMoleculeModel: MoleculeModelProtocol { try container.encode(string, forKey: .string) try container.encodeModel(molecule, forKey: .molecule) try container.encode(moleculeName, forKey: .moleculeName) - try container.encodeIfPresent(stringColor, forKey: .stringColor) + try container.encode(stringColor, forKey: .stringColor) } } diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift index 89cb391f..4013f3aa 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift @@ -13,7 +13,7 @@ import Foundation return "unOrderedList" } public var bulletChar = "•" - public var bulletColor: Color? + public var bulletColor: Color private enum CodingKeys: String, CodingKey { case moleculeName @@ -30,11 +30,11 @@ import Foundation self.bulletChar = bulletChar } - bulletColor = try typeContainer.decodeIfPresent(Color.self, forKey: .bulletColor) + bulletColor = try typeContainer.decodeIfPresent(Color.self, forKey: .bulletColor) ?? Color(uiColor: .mvmBlack) let list: [MoleculeModelProtocol] = try typeContainer.decodeModels(codingKey: .list) var models: [MoleculeStackItemModel] = [] for molecule in list { - models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: bulletChar, molecule: molecule, stringColor: bulletColor ?? Color(uiColor: .mvmBlack)))) + models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: bulletChar, molecule: molecule, stringColor: bulletColor))) } super.init(molecules: models, spacing: 0) } @@ -50,6 +50,6 @@ import Foundation models.append(((molecule as! MoleculeStackItemModel).molecule as! StringAndMoleculeModel).molecule) } try container.encodeModels(models, forKey: .list) - try container.encodeIfPresent(bulletColor, forKey: .bulletColor) + try container.encode(bulletColor, forKey: .bulletColor) } } From 09b263fa23571ba78803b0db5b387ccc35d01ce9 Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Mon, 14 Dec 2020 18:16:37 +0530 Subject: [PATCH 11/21] adding aem driven accessibilityText to navigationImageButton --- .../Buttons/NavigationImageButtonModel.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift index 9313f9a4..8d837a5a 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift @@ -13,6 +13,7 @@ public class NavigationImageButtonModel: NavigationButtonModelProtocol, Molecule public var image: String public var action: ActionModelProtocol + public var accessibilityText: String? public init(with image: String, action: ActionModelProtocol) { self.image = image @@ -41,6 +42,11 @@ 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) - return ImageBarButtonItem.create(with: uiImage, actionModel: action, delegateObject: delegateObject, additionalData: additionalData) + let navigationImageButton = ImageBarButtonItem.create(with: uiImage, actionModel: action, delegateObject: delegateObject, additionalData: additionalData) + if let accessibilityString = accessibilityText { + navigationImageButton.accessibilityLabel = accessibilityString + navigationImageButton.isAccessibilityElement = true + } + return navigationImageButton } } From 77993736beaaffcbfc791e45cb2d79d7a5c8f436 Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Tue, 15 Dec 2020 22:52:38 +0530 Subject: [PATCH 12/21] fix after tetsing --- .../NavigationBar/Buttons/NavigationImageButtonModel.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift index 8d837a5a..2cfcfbdc 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift @@ -24,12 +24,14 @@ public class NavigationImageButtonModel: NavigationButtonModelProtocol, Molecule case image case action case moleculeName + case accessibilityText } required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) image = try typeContainer.decode(String.self, forKey: .image) action = try typeContainer.decodeModel(codingKey: .action) + accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) } open func encode(to encoder: Encoder) throws { @@ -37,6 +39,7 @@ public class NavigationImageButtonModel: NavigationButtonModelProtocol, Molecule try container.encode(image, forKey: .image) try container.encode(moleculeName, forKey: .moleculeName) try container.encodeModel(action, forKey: .action) + try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText) } /// Convenience function that creates a BarButtonItem for the model. From 3b75339209bd67515b8b78f255396354a49a46fb Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 17 Dec 2020 09:28:14 -0500 Subject: [PATCH 13/21] bugfix with styler --- MVMCoreUI/Styles/MFStyler.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Styles/MFStyler.m b/MVMCoreUI/Styles/MFStyler.m index 130b4c7a..e8d58a26 100644 --- a/MVMCoreUI/Styles/MFStyler.m +++ b/MVMCoreUI/Styles/MFStyler.m @@ -1104,7 +1104,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nonnull NSAttributedString *)styleGetRegularMicroAttributedString:(nullable NSString *)string { - return [MFStyler styleGetRegularBodySmallAttributedString:string genericScaling:YES]; + return [MFStyler styleGetRegularMicroAttributedString:string genericScaling:YES]; } + (nonnull NSAttributedString *)styleGetRegularMicroAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling { From 7418027b56ffc5fac5c6d8416b01e2371cd87626 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 17 Dec 2020 09:49:28 -0500 Subject: [PATCH 14/21] updated for easier readability --- MVMCoreUI/Styles/Styler.swift | 48 ++++++++++++++--------------------- 1 file changed, 19 insertions(+), 29 deletions(-) diff --git a/MVMCoreUI/Styles/Styler.swift b/MVMCoreUI/Styles/Styler.swift index 1229a146..c0dd6792 100644 --- a/MVMCoreUI/Styles/Styler.swift +++ b/MVMCoreUI/Styles/Styler.swift @@ -28,13 +28,13 @@ open class Styler { // Legacy Fonts case H1 - case H2 - case H3 case H32 + case H2 + case B20 + case H3 case B1 case B2 case B3 - case B20 /// Returns the font size of the current enum case. public func pointSize() -> CGFloat { @@ -45,8 +45,7 @@ open class Styler { case .Title2XLarge: return 36 - case .TitleXLarge, - .H32: + case .TitleXLarge, .H32: return 32 case .H2: @@ -57,8 +56,7 @@ open class Styler { return 24 case .BoldTitleMedium, - .RegularTitleMedium, - .B20: + .RegularTitleMedium, .B20: return 20 case .H3: @@ -68,15 +66,12 @@ open class Styler { .RegularBodyLarge: return 16 - case .BoldBodySmall, - .RegularBodySmall, - .B1, - .B2: + case .BoldBodySmall, .B1, + .RegularBodySmall, .B2: return 13 case .BoldMicro, - .RegularMicro, - .B3: + .RegularMicro, .B3: return 11 } } @@ -96,27 +91,22 @@ open class Styler { switch self { case .RegularTitleLarge, - .RegularTitleMedium, + .RegularTitleMedium, .B20, .RegularBodyLarge, - .RegularBodySmall, - .RegularMicro, - .B2, - .B3, - .B20: + .RegularBodySmall, .B2, + .RegularMicro, .B3: return false - case .Title2XLarge, - .TitleXLarge, + case .H1, + .Title2XLarge, + .TitleXLarge, .H32, + .H2, .BoldTitleLarge, .BoldTitleMedium, - .BoldBodyLarge, - .BoldBodySmall, - .BoldMicro, - .H1, - .H2, .H3, - .H32, - .B1: + .BoldBodyLarge, + .BoldBodySmall, .B1, + .BoldMicro: return true } } @@ -140,9 +130,9 @@ open class Styler { return false case .H1, + .H32, .H2, .H3, - .H32, .B1, .B2, .B3, From 8a2d2c9233a44261e3b8ce76d6f445cd3e565aea Mon Sep 17 00:00:00 2001 From: Damodaram Date: Mon, 21 Dec 2020 17:28:40 +0530 Subject: [PATCH 15/21] changes in access specifier --- MVMCoreUI/BaseClasses/UICollectionViewLeftAlignedLayout.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/BaseClasses/UICollectionViewLeftAlignedLayout.swift b/MVMCoreUI/BaseClasses/UICollectionViewLeftAlignedLayout.swift index 717bbc55..080b4e88 100644 --- a/MVMCoreUI/BaseClasses/UICollectionViewLeftAlignedLayout.swift +++ b/MVMCoreUI/BaseClasses/UICollectionViewLeftAlignedLayout.swift @@ -9,8 +9,8 @@ import Foundation -class UICollectionViewLeftAlignedLayout: UICollectionViewFlowLayout { - override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? { +public class UICollectionViewLeftAlignedLayout: UICollectionViewFlowLayout { + public override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? { guard let attributes = super.layoutAttributesForElements(in: rect) else { return nil } var newAttributesForElementsInRect = [UICollectionViewLayoutAttributes]() for attribute in attributes { From 291b0ee9fe2b19d74103ab7192b2ed0cf079e134 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 21 Dec 2020 13:01:03 -0500 Subject: [PATCH 16/21] change to public/open --- MVMCoreUI/Containers/Views/Container.swift | 4 +-- .../Containers/Views/ContainerHelper.swift | 28 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/MVMCoreUI/Containers/Views/Container.swift b/MVMCoreUI/Containers/Views/Container.swift index 7ad02f9d..159535d7 100644 --- a/MVMCoreUI/Containers/Views/Container.swift +++ b/MVMCoreUI/Containers/Views/Container.swift @@ -15,9 +15,9 @@ open class Container: View, ContainerProtocol { //-------------------------------------------------- public var view: UIView? - let containerHelper = ContainerHelper() + public let containerHelper = ContainerHelper() - var containerModel: ContainerModelProtocol? { + public var containerModel: ContainerModelProtocol? { get { return model as? ContainerModelProtocol } } diff --git a/MVMCoreUI/Containers/Views/ContainerHelper.swift b/MVMCoreUI/Containers/Views/ContainerHelper.swift index f60d1ee6..b60bcc1e 100644 --- a/MVMCoreUI/Containers/Views/ContainerHelper.swift +++ b/MVMCoreUI/Containers/Views/ContainerHelper.swift @@ -15,23 +15,23 @@ open class ContainerHelper: NSObject { // MARK: - Constraints //-------------------------------------------------- - var leftConstraint: NSLayoutConstraint? - var topConstraint: NSLayoutConstraint? - var bottomConstraint: NSLayoutConstraint? - var rightConstraint: NSLayoutConstraint? + open var leftConstraint: NSLayoutConstraint? + open var topConstraint: NSLayoutConstraint? + open var bottomConstraint: NSLayoutConstraint? + open var rightConstraint: NSLayoutConstraint? - var alignCenterHorizontalConstraint: NSLayoutConstraint? - var alignCenterLeftConstraint: NSLayoutConstraint? - var alignCenterRightConstraint: NSLayoutConstraint? + open var alignCenterHorizontalConstraint: NSLayoutConstraint? + open var alignCenterLeftConstraint: NSLayoutConstraint? + open var alignCenterRightConstraint: NSLayoutConstraint? - var alignCenterVerticalConstraint: NSLayoutConstraint? - var alignCenterTopConstraint: NSLayoutConstraint? - var alignCenterBottomConstraint: NSLayoutConstraint? + open var alignCenterVerticalConstraint: NSLayoutConstraint? + open var alignCenterTopConstraint: NSLayoutConstraint? + open var alignCenterBottomConstraint: NSLayoutConstraint? - var leftLowConstraint: NSLayoutConstraint? - var topLowConstraint: NSLayoutConstraint? - var bottomLowConstraint: NSLayoutConstraint? - var rightLowConstraint: NSLayoutConstraint? + open var leftLowConstraint: NSLayoutConstraint? + open var topLowConstraint: NSLayoutConstraint? + open var bottomLowConstraint: NSLayoutConstraint? + open var rightLowConstraint: NSLayoutConstraint? //-------------------------------------------------- // MARK: - Methods From 5e7533a95cc24b984678782840ccde8035987145 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 28 Dec 2020 11:39:01 -0500 Subject: [PATCH 17/21] molecular top notification action --- .../Atomic/Actions/ActionTopAlertModel.swift | 9 ++- .../OtherHandlers/MVMCoreUIActionHandler.m | 58 +++++++++++++------ .../MVMCoreUITopAlertView+Extension.swift | 6 ++ 3 files changed, 53 insertions(+), 20 deletions(-) diff --git a/MVMCoreUI/Atomic/Actions/ActionTopAlertModel.swift b/MVMCoreUI/Atomic/Actions/ActionTopAlertModel.swift index 62e496c2..1e93d98f 100644 --- a/MVMCoreUI/Atomic/Actions/ActionTopAlertModel.swift +++ b/MVMCoreUI/Atomic/Actions/ActionTopAlertModel.swift @@ -12,7 +12,8 @@ import Foundation public static var identifier: String = "topAlert" public var actionType: String = ActionTopAlertModel.identifier - public var pageType: String + public var pageType: String? + public var topNotification: TopNotificationModel? public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? @@ -21,4 +22,10 @@ import Foundation self.extraParameters = extraParameters self.analyticsData = analyticsData } + + public init(topNotification: TopNotificationModel, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) { + self.topNotification = topNotification + self.extraParameters = extraParameters + self.analyticsData = analyticsData + } } diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m index 14888ed1..5ca372cd 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m @@ -81,18 +81,28 @@ - (void)topAlertAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { // Perform a top alert. - NSString *pageTypeForTopAlert = [actionInformation stringForKey:KeyPageType]; - [[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForTopAlert queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) { - - NSDictionary *responseInfo = [jsonDictionary dict:KeyResponseInfo]; - if (responseInfo) { - MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectForPageType:pageTypeForTopAlert responseInfo:responseInfo additionalData:additionalData delegateObject:delegateObject]; - if ([delegateObject.actionDelegate respondsToSelector:@selector(willShowTopAlertWithAlertObject:alertJson:)]) { - [((id )delegateObject.actionDelegate) willShowTopAlertWithAlertObject:alertObject alertJson:actionInformation]; + NSString *pageTypeForTopAlert = [actionInformation string:KeyPageType]; + if (pageTypeForTopAlert) { + [[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForTopAlert queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) { + + NSDictionary *responseInfo = [jsonDictionary dict:KeyResponseInfo]; + if (responseInfo) { + MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectForPageType:pageTypeForTopAlert responseInfo:responseInfo additionalData:additionalData delegateObject:delegateObject]; + if ([delegateObject.actionDelegate respondsToSelector:@selector(willShowTopAlertWithAlertObject:alertJson:)]) { + [((id )delegateObject.actionDelegate) willShowTopAlertWithAlertObject:alertObject alertJson:actionInformation]; + } + [alertObject showAlert]; } - [alertObject showAlert]; + }]; + } else { + NSDictionary *topNotification = [actionInformation dict:@"topNotification"]; + if (topNotification) { + [[MVMCoreUITopAlertView sharedGlobal] showTopAlertWith:topNotification]; + } else { + MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeParsingJSON domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_%@",NSStringFromClass([delegateObject.actionDelegate class]),KeyActionTypeTopAlert]]; + [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]; } - }]; + } } - (void)collapseNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { @@ -152,17 +162,27 @@ - (void)topAlertAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { // Perform a top alert. NSString *pageTypeForTopAlert = [actionInformation stringForKey:KeyPageType]; - [[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForTopAlert queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) { - - NSDictionary *responseInfo = [jsonDictionary dict:KeyResponseInfo]; - if (responseInfo) { - MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectForPageType:pageTypeForTopAlert responseInfo:responseInfo additionalData:additionalData actionDelegate:delegate]; - if ([delegate respondsToSelector:@selector(willShowTopAlertWithAlertObject:alertJson:)]) { - alertObject = [((id )delegate) willShowTopAlertWithAlertObject:alertObject alertJson:jsonDictionary]; + if (pageTypeForTopAlert) { + [[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForTopAlert queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) { + + NSDictionary *responseInfo = [jsonDictionary dict:KeyResponseInfo]; + if (responseInfo) { + MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectForPageType:pageTypeForTopAlert responseInfo:responseInfo additionalData:additionalData actionDelegate:delegate]; + if ([delegate respondsToSelector:@selector(willShowTopAlertWithAlertObject:alertJson:)]) { + alertObject = [((id )delegate) willShowTopAlertWithAlertObject:alertObject alertJson:jsonDictionary]; + } + [alertObject showAlert]; } - [alertObject showAlert]; + }]; + } else { + NSDictionary *topNotification = [actionInformation dict:@"topNotification"]; + if (topNotification) { + [[MVMCoreUITopAlertView sharedGlobal] showTopAlertWith:topNotification]; + } else { + MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeParsingJSON domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_%@",NSStringFromClass([delegate class]),KeyActionTypeTopAlert]]; + [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegate:delegate]; } - }]; + } } - (void)collapseNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift index f179fb11..107a3596 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift @@ -61,6 +61,12 @@ public extension MVMCoreUITopAlertView { MVMCoreAlertHandler.shared()?.add(operation) } + /// Shows the top alert with the json. + @objc func showTopAlert(with json: [AnyHashable: Any]) { + guard let model = decodeTopNotification(with: json, delegateObject: getDelegateObject()) else { return } + showTopAlert(with: model) + } + /// Checks for existing top alert object of same type and updates it. Only happens for molecular top alerts. Returns true if we updated. private func checkAndUpdateExisting(with topAlertObject: MVMCoreTopAlertObject) -> Bool { guard let queue = MVMCoreAlertHandler.shared()?.topAlertQueue.operations else { return false } From b520866bf48dc5216692140140171366e842d97e Mon Sep 17 00:00:00 2001 From: Damodaram Date: Tue, 29 Dec 2020 20:03:37 +0530 Subject: [PATCH 18/21] updated access specifier --- MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift | 6 +++--- .../Molecules/Items/MoleculeCollectionItemModel.swift | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift index 1b9ce0dc..be67bfca 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift @@ -9,12 +9,12 @@ import Foundation -@objcMembers public class CarouselItemModel: MoleculeCollectionItemModel, CarouselItemModelProtocol { +@objcMembers open class CarouselItemModel: MoleculeCollectionItemModel, CarouselItemModelProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - public override class var identifier: String { + open override class var identifier: String { return "carouselItem" } @@ -44,7 +44,7 @@ import Foundation try super.init(from: decoder) } - public override func encode(to encoder: Encoder) throws { + open override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeIfPresent(peakingUI, forKey: .peakingUI) diff --git a/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionItemModel.swift index 645d16b1..f9df766f 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionItemModel.swift @@ -9,7 +9,7 @@ import Foundation /// A model for a collection item that is a container for any molecule. -@objcMembers public class MoleculeCollectionItemModel: MoleculeContainerModel, CollectionItemModelProtocol { +@objcMembers open class MoleculeCollectionItemModel: MoleculeContainerModel, CollectionItemModelProtocol { open override class var identifier: String { return "collectionItem" } From 87e02c37b75999a7ffd7a6fd306f0400b3d95979 Mon Sep 17 00:00:00 2001 From: "Murugan, Vimal" Date: Thu, 31 Dec 2020 14:44:01 +0530 Subject: [PATCH 19/21] top notification action implementation --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++++ .../Atomic/Actions/ActionTopAlertModel.swift | 7 ------ .../Actions/ActionTopNotificationModel.swift | 24 +++++++++++++++++++ MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 1 + .../OtherHandlers/MVMCoreUIActionHandler.h | 3 +++ .../OtherHandlers/MVMCoreUIActionHandler.m | 11 +++++++++ MVMCoreUI/Utility/MVMCoreUIConstants.h | 1 + MVMCoreUI/Utility/MVMCoreUIConstants.m | 1 + 8 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 MVMCoreUI/Atomic/Actions/ActionTopNotificationModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 3fce1455..2dc86525 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -290,6 +290,7 @@ BBC0C4FF24811DCA0087C44F /* TagModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBC0C4FE24811DCA0087C44F /* TagModel.swift */; }; C003506123AA94CD00B6AC29 /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003506023AA94CD00B6AC29 /* Button.swift */; }; C07065C42395677300FBF997 /* Link.swift in Sources */ = {isa = PBXBuildFile; fileRef = C07065C32395677300FBF997 /* Link.swift */; }; + C6687441259D92D400F32D13 /* ActionTopNotificationModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6687440259D92D400F32D13 /* ActionTopNotificationModel.swift */; }; C695A67F23C9830600BFB94E /* UnOrderedListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */; }; C695A68123C9830D00BFB94E /* NumberedListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A68023C9830D00BFB94E /* NumberedListModel.swift */; }; C695A69423C9909000BFB94E /* DoughnutChartModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A69323C9909000BFB94E /* DoughnutChartModel.swift */; }; @@ -833,6 +834,7 @@ BBC0C4FE24811DCA0087C44F /* TagModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TagModel.swift; sourceTree = ""; }; C003506023AA94CD00B6AC29 /* Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Button.swift; sourceTree = ""; }; C07065C32395677300FBF997 /* Link.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Link.swift; sourceTree = ""; }; + C6687440259D92D400F32D13 /* ActionTopNotificationModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionTopNotificationModel.swift; sourceTree = ""; }; C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnOrderedListModel.swift; sourceTree = ""; }; C695A68023C9830D00BFB94E /* NumberedListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NumberedListModel.swift; sourceTree = ""; }; C695A69323C9909000BFB94E /* DoughnutChartModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoughnutChartModel.swift; sourceTree = ""; }; @@ -1308,6 +1310,7 @@ D2ED27E9254B0CE600A1C293 /* ActionAlertModel.swift */, D2ED27EA254B0CE700A1C293 /* AlertModel.swift */, D2ED27E8254B0CE600A1C293 /* ActionPopupModel.swift */, + C6687440259D92D400F32D13 /* ActionTopNotificationModel.swift */, ); path = Actions; sourceTree = ""; @@ -2432,6 +2435,7 @@ 32F8804824765C8400C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinks.swift in Sources */, D2CAC7CF2511052300C75681 /* CollapsableNotificationModel.swift in Sources */, DBC4391822442197001AB423 /* CaretView.swift in Sources */, + C6687441259D92D400F32D13 /* ActionTopNotificationModel.swift in Sources */, C07065C42395677300FBF997 /* Link.swift in Sources */, 0A69F611241BDEA700F7231B /* RuleAnyRequiredModel.swift in Sources */, D29B771022C281F400D6ACE0 /* ModuleMolecule.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Actions/ActionTopAlertModel.swift b/MVMCoreUI/Atomic/Actions/ActionTopAlertModel.swift index 1e93d98f..0fb9d00d 100644 --- a/MVMCoreUI/Atomic/Actions/ActionTopAlertModel.swift +++ b/MVMCoreUI/Atomic/Actions/ActionTopAlertModel.swift @@ -13,7 +13,6 @@ import Foundation public static var identifier: String = "topAlert" public var actionType: String = ActionTopAlertModel.identifier public var pageType: String? - public var topNotification: TopNotificationModel? public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? @@ -22,10 +21,4 @@ import Foundation self.extraParameters = extraParameters self.analyticsData = analyticsData } - - public init(topNotification: TopNotificationModel, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) { - self.topNotification = topNotification - self.extraParameters = extraParameters - self.analyticsData = analyticsData - } } diff --git a/MVMCoreUI/Atomic/Actions/ActionTopNotificationModel.swift b/MVMCoreUI/Atomic/Actions/ActionTopNotificationModel.swift new file mode 100644 index 00000000..c1c362c5 --- /dev/null +++ b/MVMCoreUI/Atomic/Actions/ActionTopNotificationModel.swift @@ -0,0 +1,24 @@ +// +// ActionTopNotificationModel.swift +// MVMCoreUI +// +// Created by Murugan, Vimal on 31/12/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import UIKit + +@objcMembers public class ActionTopNotificationModel: ActionModelProtocol { + + public static var identifier: String = "topNotification" + public var actionType: String = ActionTopNotificationModel.identifier + public var topNotification: TopNotificationModel? + public var extraParameters: JSONValueDictionary? + public var analyticsData: JSONValueDictionary? + + public init(topNotification: TopNotificationModel, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) { + self.topNotification = topNotification + self.extraParameters = extraParameters + self.analyticsData = analyticsData + } +} diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index ff262876..559b611b 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -259,6 +259,7 @@ import Foundation try? ModelRegistry.register(ActionTopAlertModel.self) try? ModelRegistry.register(ActionCollapseNotificationModel.self) try? ModelRegistry.register(ActionOpenPanelModel.self) + try? ModelRegistry.register(ActionTopNotificationModel.self) // MARK:- Behaviors try? ModelRegistry.register(ScreenBrightnessModifierBehavior.self) diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h index 3835207b..b18a2249 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h @@ -24,6 +24,9 @@ NS_ASSUME_NONNULL_BEGIN // Collapses the current top notification - (void)collapseNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; +// Shows a topnotification new molecular +- (void)topNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; + #pragma mark - Deprecated // Shows a popup diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m index 5ca372cd..bafdd418 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m @@ -31,6 +31,9 @@ } else if ([actionType isEqualToString:KeyActionTypeAlert]) { [self showAlert:actionInformation additionalData:additionalData delegateObject:delegateObject]; return YES; + } else if ([actionType isEqualToString:KeyActionTypeTopNotification]) { + [self topNotificationAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; + return YES; } return NO; } @@ -112,6 +115,14 @@ } } +- (void)topNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { + //Handle molecular topnotification + NSDictionary *topNotification = [actionInformation dict:@"topNotification"]; + if (topNotification) { + [[MVMCoreUITopAlertView sharedGlobal] showTopAlertWith:topNotification]; + } +} + - (void)defaultHandleActionError:(nonnull MVMCoreErrorObject *)error additionalData:(nullable NSDictionary *)additionalData { [super defaultHandleActionError:error additionalData:additionalData]; if (!error.silentError) { diff --git a/MVMCoreUI/Utility/MVMCoreUIConstants.h b/MVMCoreUI/Utility/MVMCoreUIConstants.h index b96d50ed..ab77986b 100644 --- a/MVMCoreUI/Utility/MVMCoreUIConstants.h +++ b/MVMCoreUI/Utility/MVMCoreUIConstants.h @@ -48,6 +48,7 @@ extern NSString * const KeyActionTypePopup; extern NSString * const KeyActionTypeAlert; extern NSString * const KeyActionTypeTopAlert; extern NSString * const KeyActionTypeCollapseNotification; +extern NSString * const KeyActionTypeTopNotification; /// Key for molecular top notification architecture. extern NSString * const KeyTopAlert; diff --git a/MVMCoreUI/Utility/MVMCoreUIConstants.m b/MVMCoreUI/Utility/MVMCoreUIConstants.m index 092851cd..2483826f 100644 --- a/MVMCoreUI/Utility/MVMCoreUIConstants.m +++ b/MVMCoreUI/Utility/MVMCoreUIConstants.m @@ -47,6 +47,7 @@ NSString * const KeyActionTypeAlert = @"alert"; NSString * const KeyActionTypeTopAlert = @"topAlert"; NSString * const KeyActionTypeCollapseNotification = @"collapseNotification"; +NSString * const KeyActionTypeTopNotification = @"topNotification"; NSString * const KeyTopAlert = @"TopNotification"; #pragma mark - Values From 8a84d42c951d749ad6fc19bf5d2b963af2870197 Mon Sep 17 00:00:00 2001 From: "Murugan, Vimal" Date: Mon, 4 Jan 2021 22:19:14 +0530 Subject: [PATCH 20/21] review comments updated --- .../Actions/ActionTopNotificationModel.swift | 2 +- .../OtherHandlers/MVMCoreUIActionHandler.h | 3 ++ .../OtherHandlers/MVMCoreUIActionHandler.m | 33 +++++++++---------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/MVMCoreUI/Atomic/Actions/ActionTopNotificationModel.swift b/MVMCoreUI/Atomic/Actions/ActionTopNotificationModel.swift index c1c362c5..7ca1d6aa 100644 --- a/MVMCoreUI/Atomic/Actions/ActionTopNotificationModel.swift +++ b/MVMCoreUI/Atomic/Actions/ActionTopNotificationModel.swift @@ -12,7 +12,7 @@ import UIKit public static var identifier: String = "topNotification" public var actionType: String = ActionTopNotificationModel.identifier - public var topNotification: TopNotificationModel? + public var topNotification: TopNotificationModel public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h index b18a2249..f6b89806 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h @@ -35,6 +35,9 @@ NS_ASSUME_NONNULL_BEGIN // Shows a top alert - (void)topAlertAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; +// Shows a molecular top alert +- (void)topNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; + // Collapses the current top notification - (void)collapseNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m index bafdd418..dee4c547 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m @@ -98,13 +98,8 @@ } }]; } else { - NSDictionary *topNotification = [actionInformation dict:@"topNotification"]; - if (topNotification) { - [[MVMCoreUITopAlertView sharedGlobal] showTopAlertWith:topNotification]; - } else { - MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeParsingJSON domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_%@",NSStringFromClass([delegateObject.actionDelegate class]),KeyActionTypeTopAlert]]; - [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]; - } + MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeParsingJSON domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_%@",NSStringFromClass([delegateObject.actionDelegate class]),KeyActionTypeTopAlert]]; + [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]; } } @@ -117,9 +112,8 @@ - (void)topNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { //Handle molecular topnotification - NSDictionary *topNotification = [actionInformation dict:@"topNotification"]; - if (topNotification) { - [[MVMCoreUITopAlertView sharedGlobal] showTopAlertWith:topNotification]; + if (actionInformation) { + [[MVMCoreUITopAlertView sharedGlobal] showTopAlertWith:[actionInformation dictionaryForKey:@"topNotification"]]; } } @@ -147,6 +141,9 @@ } else if ([actionType isEqualToString:KeyActionTypeCollapseNotification]) { [self collapseNotificationAction:actionInformation additionalData:additionalData delegate:delegate]; return YES; + } else if ([actionType isEqualToString:KeyActionTypeTopNotification]) { + [self topNotificationAction:actionInformation additionalData:additionalData delegate:delegate]; + return YES; } return NO; } @@ -186,13 +183,8 @@ } }]; } else { - NSDictionary *topNotification = [actionInformation dict:@"topNotification"]; - if (topNotification) { - [[MVMCoreUITopAlertView sharedGlobal] showTopAlertWith:topNotification]; - } else { - MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeParsingJSON domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_%@",NSStringFromClass([delegate class]),KeyActionTypeTopAlert]]; - [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegate:delegate]; - } + MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeParsingJSON domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_%@",NSStringFromClass([delegate class]),KeyActionTypeTopAlert]]; + [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegate:delegate]; } } @@ -203,4 +195,11 @@ } } +- (void)topNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { + //Handle molecular topnotification + if (actionInformation) { + [[MVMCoreUITopAlertView sharedGlobal] showTopAlertWith:[actionInformation dictionaryForKey:@"topNotification"]]; + } +} + @end From edc6296ff7666b00ec84a9c4d446efa1a9805203 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 4 Jan 2021 13:55:44 -0500 Subject: [PATCH 21/21] proper revert --- .../Atomic/Actions/ActionTopAlertModel.swift | 2 +- .../OtherHandlers/MVMCoreUIActionHandler.m | 60 +++++++------------ 2 files changed, 24 insertions(+), 38 deletions(-) diff --git a/MVMCoreUI/Atomic/Actions/ActionTopAlertModel.swift b/MVMCoreUI/Atomic/Actions/ActionTopAlertModel.swift index 0fb9d00d..62e496c2 100644 --- a/MVMCoreUI/Atomic/Actions/ActionTopAlertModel.swift +++ b/MVMCoreUI/Atomic/Actions/ActionTopAlertModel.swift @@ -12,7 +12,7 @@ import Foundation public static var identifier: String = "topAlert" public var actionType: String = ActionTopAlertModel.identifier - public var pageType: String? + public var pageType: String public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m index dee4c547..79f92990 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m @@ -84,23 +84,18 @@ - (void)topAlertAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { // Perform a top alert. - NSString *pageTypeForTopAlert = [actionInformation string:KeyPageType]; - if (pageTypeForTopAlert) { - [[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForTopAlert queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) { - - NSDictionary *responseInfo = [jsonDictionary dict:KeyResponseInfo]; - if (responseInfo) { - MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectForPageType:pageTypeForTopAlert responseInfo:responseInfo additionalData:additionalData delegateObject:delegateObject]; - if ([delegateObject.actionDelegate respondsToSelector:@selector(willShowTopAlertWithAlertObject:alertJson:)]) { - [((id )delegateObject.actionDelegate) willShowTopAlertWithAlertObject:alertObject alertJson:actionInformation]; - } - [alertObject showAlert]; + NSString *pageTypeForTopAlert = [actionInformation stringForKey:KeyPageType]; + [[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForTopAlert queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) { + + NSDictionary *responseInfo = [jsonDictionary dict:KeyResponseInfo]; + if (responseInfo) { + MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectForPageType:pageTypeForTopAlert responseInfo:responseInfo additionalData:additionalData delegateObject:delegateObject]; + if ([delegateObject.actionDelegate respondsToSelector:@selector(willShowTopAlertWithAlertObject:alertJson:)]) { + [((id )delegateObject.actionDelegate) willShowTopAlertWithAlertObject:alertObject alertJson:actionInformation]; } - }]; - } else { - MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeParsingJSON domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_%@",NSStringFromClass([delegateObject.actionDelegate class]),KeyActionTypeTopAlert]]; - [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]; - } + [alertObject showAlert]; + } + }]; } - (void)collapseNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { @@ -112,9 +107,7 @@ - (void)topNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { //Handle molecular topnotification - if (actionInformation) { - [[MVMCoreUITopAlertView sharedGlobal] showTopAlertWith:[actionInformation dictionaryForKey:@"topNotification"]]; - } + [[MVMCoreUITopAlertView sharedGlobal] showTopAlertWith:[actionInformation dict:@"topNotification"] ?: @{}]; } - (void)defaultHandleActionError:(nonnull MVMCoreErrorObject *)error additionalData:(nullable NSDictionary *)additionalData { @@ -170,22 +163,17 @@ - (void)topAlertAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { // Perform a top alert. NSString *pageTypeForTopAlert = [actionInformation stringForKey:KeyPageType]; - if (pageTypeForTopAlert) { - [[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForTopAlert queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) { - - NSDictionary *responseInfo = [jsonDictionary dict:KeyResponseInfo]; - if (responseInfo) { - MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectForPageType:pageTypeForTopAlert responseInfo:responseInfo additionalData:additionalData actionDelegate:delegate]; - if ([delegate respondsToSelector:@selector(willShowTopAlertWithAlertObject:alertJson:)]) { - alertObject = [((id )delegate) willShowTopAlertWithAlertObject:alertObject alertJson:jsonDictionary]; - } - [alertObject showAlert]; + [[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForTopAlert queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) { + + NSDictionary *responseInfo = [jsonDictionary dict:KeyResponseInfo]; + if (responseInfo) { + MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectForPageType:pageTypeForTopAlert responseInfo:responseInfo additionalData:additionalData actionDelegate:delegate]; + if ([delegate respondsToSelector:@selector(willShowTopAlertWithAlertObject:alertJson:)]) { + alertObject = [((id )delegate) willShowTopAlertWithAlertObject:alertObject alertJson:jsonDictionary]; } - }]; - } else { - MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeParsingJSON domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_%@",NSStringFromClass([delegate class]),KeyActionTypeTopAlert]]; - [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegate:delegate]; - } + [alertObject showAlert]; + } + }]; } - (void)collapseNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { @@ -197,9 +185,7 @@ - (void)topNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { //Handle molecular topnotification - if (actionInformation) { - [[MVMCoreUITopAlertView sharedGlobal] showTopAlertWith:[actionInformation dictionaryForKey:@"topNotification"]]; - } + [[MVMCoreUITopAlertView sharedGlobal] showTopAlertWith:[actionInformation dict:@"topNotification"] ?: @{}]; } @end