From 3d351cc83fe88e4dc2d0c7e7049579de2eaa3579 Mon Sep 17 00:00:00 2001 From: teegsh2 Date: Fri, 31 Mar 2023 04:33:36 +0530 Subject: [PATCH 1/5] bill Tabs Shifty red selectionLine issue fixed --- .../Atomic/Molecules/HorizontalCombinationViews/Tabs.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift index de9ef49f..4e340ab6 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift @@ -235,7 +235,9 @@ extension Tabs: UICollectionViewDelegateFlowLayout { public func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) { guard let tabCell = cell as? TabItemCell else { return } if indexPath.row == selectedIndex { - moveSelectionLine(toIndex: indexPath, animated: false, cell: tabCell) + DispatchQueue.main.async { + self.moveSelectionLine(toIndex: indexPath, animated: false, cell: tabCell) + } } } From 81bcbd42de442e97e7b1697a551a112d51b3d71c Mon Sep 17 00:00:00 2001 From: Rebecca Antonelli Date: Fri, 31 Mar 2023 13:48:11 -0500 Subject: [PATCH 2/5] changed formatting for mdn from . to - --- MVMCoreUI/Utility/MVMCoreUIUtility.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Utility/MVMCoreUIUtility.m b/MVMCoreUI/Utility/MVMCoreUIUtility.m index 887d7438..01a8c435 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility.m +++ b/MVMCoreUI/Utility/MVMCoreUIUtility.m @@ -150,8 +150,8 @@ if(mdn.length == LengthContactNumber) { NSMutableString * newmdn = [NSMutableString stringWithCapacity:14]; [newmdn appendString:mdn]; - [newmdn insertString:@"." atIndex:6]; - [newmdn insertString:@"." atIndex:3]; + [newmdn insertString:@"-" atIndex:6]; + [newmdn insertString:@"-" atIndex:3]; return newmdn; } From 252b5529ff0c22ce2bd341c81762f77aabce5e18 Mon Sep 17 00:00:00 2001 From: Nowfal E Salam Date: Fri, 14 Apr 2023 18:16:52 +0530 Subject: [PATCH 3/5] 1. Created a behavior with name "GetNotificationAuthStatusBehavior" to get current notification authorisation status 2. Created molecule with name "list1CTxtConsumeNotificationAuth" molecule by subclassing "list1CTxt" molecule --- MVMCoreUI.xcodeproj/project.pbxproj | 8 +++ ...umnFullWidthTextAllTextAndLinksModel.swift | 69 +++++++++++++++++++ ...umnFullWidthTextAllTextAndLinksModel.swift | 3 +- .../GetNotificationAuthStatusBehavior.swift | 61 ++++++++++++++++ .../OtherHandlers/CoreUIModelMapping.swift | 2 + 5 files changed, 141 insertions(+), 2 deletions(-) create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksModel.swift create mode 100644 MVMCoreUI/Behaviors/GetNotificationAuthStatusBehavior.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index eb5327be..7fa7844c 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -129,6 +129,8 @@ 187FEB2A2844D2A600BF29C2 /* VDSFormControlsTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 187FEB292844D2A600BF29C2 /* VDSFormControlsTokens.xcframework */; }; 1D6D258826899B0C00DEBB08 /* ImageButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D6D258626899B0B00DEBB08 /* ImageButtonModel.swift */; }; 1D6D258926899B0C00DEBB08 /* ImageButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D6D258726899B0B00DEBB08 /* ImageButton.swift */; }; + 22B678F929E7944E00CF4196 /* GetNotificationAuthStatusBehavior.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22B678F829E7944E00CF4196 /* GetNotificationAuthStatusBehavior.swift */; }; + 22B678FD29E82B0300CF4196 /* ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22B678FC29E82B0300CF4196 /* ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksModel.swift */; }; 27559EFC27D691D3000836C1 /* ViewMaskingProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27559EFB27D691D3000836C1 /* ViewMaskingProtocol.swift */; }; 27577DCD286CA959001EC47E /* MoleculeMaskingProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27577DCC286CA959001EC47E /* MoleculeMaskingProtocol.swift */; }; 279B1569242BBC2F00921D6C /* ActionModelAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 279B1568242BBC2F00921D6C /* ActionModelAdapter.swift */; }; @@ -730,6 +732,8 @@ 187FEB292844D2A600BF29C2 /* VDSFormControlsTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSFormControlsTokens.xcframework; path = ../SharedFrameworks/VDSFormControlsTokens.xcframework; sourceTree = ""; }; 1D6D258626899B0B00DEBB08 /* ImageButtonModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ImageButtonModel.swift; path = MVMCoreUI/Atomic/Atoms/Buttons/ImageButtonModel.swift; sourceTree = SOURCE_ROOT; }; 1D6D258726899B0B00DEBB08 /* ImageButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ImageButton.swift; path = MVMCoreUI/Atomic/Atoms/Buttons/ImageButton.swift; sourceTree = SOURCE_ROOT; }; + 22B678F829E7944E00CF4196 /* GetNotificationAuthStatusBehavior.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GetNotificationAuthStatusBehavior.swift; sourceTree = ""; }; + 22B678FC29E82B0300CF4196 /* ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksModel.swift; sourceTree = ""; }; 27559EFB27D691D3000836C1 /* ViewMaskingProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewMaskingProtocol.swift; sourceTree = ""; }; 27577DCC286CA959001EC47E /* MoleculeMaskingProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeMaskingProtocol.swift; sourceTree = ""; }; 279B1568242BBC2F00921D6C /* ActionModelAdapter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionModelAdapter.swift; sourceTree = ""; }; @@ -1417,6 +1421,7 @@ 27F97369246750BE00CAB5C5 /* ScreenBrightnessModifierBehavior.swift */, D23A900826125FFB007E14CE /* GetContactBehavior.swift */, D270E5662642F77300CDBED2 /* AddRemoveMoleculeBehavior.swift */, + 22B678F829E7944E00CF4196 /* GetNotificationAuthStatusBehavior.swift */, ); path = Behaviors; sourceTree = ""; @@ -1437,6 +1442,7 @@ 52267A0623FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift */, 8D084ACF2410BF4800951227 /* ListOneColumnFullWidthTextBodyTextModel.swift */, 8D084AD12410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift */, + 22B678FC29E82B0300CF4196 /* ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksModel.swift */, ); path = OneColumn; sourceTree = ""; @@ -3007,6 +3013,7 @@ 324FB6AC24936717002552C7 /* ListLeftVariableNumberedListBodyText.swift in Sources */, AAA74A172410C04600080241 /* HeadersH2NoButtonsBodyText.swift in Sources */, 522679C223FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift in Sources */, + 22B678FD29E82B0300CF4196 /* ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksModel.swift in Sources */, AA7F32AB246C0F7900C965BA /* ListLeftVariableRadioButtonAllTextAndLinksModel.swift in Sources */, 8D084AD02410BF4800951227 /* ListOneColumnFullWidthTextBodyTextModel.swift in Sources */, AF60A7F82892D34D00919EEB /* ActionDismissNotificationHandler.swift in Sources */, @@ -3081,6 +3088,7 @@ 01F2C20427C81F9700DC3D36 /* SubNavInteractor.swift.swift in Sources */, D28A837D23CCA86A00DFE4FC /* TabsListItemModel.swift in Sources */, 0A51F3E32475CB73002E08B6 /* LoadingSpinner.swift in Sources */, + 22B678F929E7944E00CF4196 /* GetNotificationAuthStatusBehavior.swift in Sources */, BB2FB3BB247E7EBC00DF73CD /* TagCollectionViewCell.swift in Sources */, 012A88C6238DA34000FE3DA1 /* ModuleMoleculeModel.swift in Sources */, 94C2D9A123872BCC0006CF46 /* LabelAttributeUnderlineModel.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksModel.swift new file mode 100644 index 00000000..fe0eaf04 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksModel.swift @@ -0,0 +1,69 @@ +// +// ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksModel.swift +// MVMCoreUI +// +// Created by Edayattu Salam, Nowfal on 13/04/23. +// Copyright © 2023 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksModel: ListOneColumnFullWidthTextAllTextAndLinksModel { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public class override var identifier: String { "list1CTxtConsumeNotificationAuth" } + public var enableStatus: String? + public var disableStatus: String? + public var enableAction: ActionModelProtocol? + public var disableAction: ActionModelProtocol? + + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + private enum CodingKeys: String, CodingKey { + case enableStatus + case disableStatus + case enableAction + case disableAction + } + + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + required public init(from decoder: Decoder) throws { + try super.init(from: decoder) + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + enableStatus = try typeContainer.decodeIfPresent(String.self, forKey: .enableStatus) + disableStatus = try typeContainer.decodeIfPresent(String.self, forKey: .disableStatus) + enableAction = try typeContainer.decodeModelIfPresent(codingKey: .enableAction) + disableAction = try typeContainer.decodeModelIfPresent(codingKey: .disableAction) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeIfPresent(enableStatus, forKey: .enableStatus) + try container.encodeIfPresent(disableStatus, forKey: .disableStatus) + try container.encodeModelIfPresent(enableAction, forKey: .enableAction) + try container.encodeModelIfPresent(disableAction, forKey: .disableAction) + } +} + +extension ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksModel: PageBehaviorProtocolRequirer { + public func getRequiredBehaviors() -> [PageBehaviorModelProtocol] { + [PageGetNotificationAuthStatusBehaviorModel()] + } +} + +extension ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksModel: PageGetNotificationAuthStatusBehaviorConsumerProtocol { + public func consume(notificationStatus: UNAuthorizationStatus) { + if(notificationStatus == .authorized){ + body?.text = enableStatus ?? "" + action = enableAction + } else { + body?.text = disableStatus ?? "" + action = disableAction + } + } +} diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextAllTextAndLinksModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextAllTextAndLinksModel.swift index 34e1d28b..1bdb2b41 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextAllTextAndLinksModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextAllTextAndLinksModel.swift @@ -13,8 +13,7 @@ public class ListOneColumnFullWidthTextAllTextAndLinksModel: ListItemModel, Mole //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - - public static var identifier: String = "list1CTxt" + open class var identifier: String { "list1CTxt" } public var eyebrow: LabelModel? public var headline : LabelModel? public var subHeadline: LabelModel? diff --git a/MVMCoreUI/Behaviors/GetNotificationAuthStatusBehavior.swift b/MVMCoreUI/Behaviors/GetNotificationAuthStatusBehavior.swift new file mode 100644 index 00000000..fea35cf7 --- /dev/null +++ b/MVMCoreUI/Behaviors/GetNotificationAuthStatusBehavior.swift @@ -0,0 +1,61 @@ +// +// GetNotificationAuthStatusBehavior.swift +// MVMCoreUI +// +// Created by Edayattu Salam, Nowfal on 13/04/23. +// Copyright © 2023 Verizon Wireless. All rights reserved. +// + +public protocol PageGetNotificationAuthStatusBehaviorConsumerProtocol { + func consume(notificationStatus: UNAuthorizationStatus) +} + +public class PageGetNotificationAuthStatusBehaviorModel: PageBehaviorModelProtocol { + public class var identifier: String { "pageGetNotificationAuthStatusBehavior" } + public var shouldAllowMultipleInstances: Bool { false } + + public init() { } +} + +public class PageGetNotificationAuthStatusBehavior: PageVisibilityBehavior { + var delegate: MVMCoreUIDelegateObject? + + public required init(model: PageBehaviorModelProtocol, delegateObject: MVMCoreUIDelegateObject?) { + self.delegate = delegateObject + } + + public func onPageShown(_ delegateObject: MVMCoreUIDelegateObject?) { + // Get notification auth status + self.getNotificationStatus() + + NotificationCenter.default.addObserver(self, selector: #selector(onForeground), name: UIApplication.willEnterForegroundNotification, object: nil) + } + + @objc public func onForeground() { + // Get notification authorization status + self.getNotificationStatus() + } + + public func getNotificationStatus() { + guard let rootMolecules = self.delegate?.moleculeDelegate?.getRootMolecules() else { return } + let consumers: [PageGetNotificationAuthStatusBehaviorConsumerProtocol] = rootMolecules.allMoleculesOfType() + + let center = UNUserNotificationCenter.current() + center.getNotificationSettings { (settings) in + for consumer in consumers { + consumer.consume(notificationStatus: settings.authorizationStatus) + } + } + + // Tell template to update + MVMCoreDispatchUtility.performBlock(onMainThread: { + guard let controller = self.delegate?.moleculeDelegate as? ViewController else { return } + controller.handleNewDataAndUpdateUI() + }) + + } + + public func onPageHidden(_ delegateObject: MVMCoreUIDelegateObject?) { + NotificationCenter.default.removeObserver(self, name: UIApplication.willEnterForegroundNotification, object: nil) + } +} diff --git a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift index 3e5357ea..39d100d4 100644 --- a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift @@ -155,6 +155,7 @@ open class CoreUIModelMapping: ModelMapping { ModelRegistry.register(handler: ListRightVariableToggleAllTextAndLinks.self, for: ListRightVariableToggleAllTextAndLinksModel.self) ModelRegistry.register(handler: ListRightVariableRightCaretAllTextAndLinks.self, for: ListRightVariableRightCaretAllTextAndLinksModel.self) ModelRegistry.register(handler: ListOneColumnFullWidthTextAllTextAndLinks.self, for: ListOneColumnFullWidthTextAllTextAndLinksModel.self) + ModelRegistry.register(handler: ListOneColumnFullWidthTextAllTextAndLinks.self, for: ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksModel.self) ModelRegistry.register(handler: ListOneColumnFullWidthTextBodyText.self, for: ListOneColumnFullWidthTextBodyTextModel.self) ModelRegistry.register(handler: ListTwoColumnCompareChanges.self, for: ListTwoColumnCompareChangesModel.self) ModelRegistry.register(handler: ListTwoColumnPriceDetails.self, for: ListTwoColumnPriceDetailsModel.self) @@ -224,6 +225,7 @@ open class CoreUIModelMapping: ModelMapping { ModelRegistry.register(handler: ScreenBrightnessModifierBehavior.self, for: ScreenBrightnessModifierBehaviorModel.self) ModelRegistry.register(handler: PageGetContactBehavior.self, for: PageGetContactBehaviorModel.self) ModelRegistry.register(handler: AddRemoveMoleculesBehavior.self, for: AddRemoveMoleculesBehaviorModel.self) + ModelRegistry.register(handler: PageGetNotificationAuthStatusBehavior.self, for: PageGetNotificationAuthStatusBehaviorModel.self) } open override class func registerActions() { From 8e0000cb8141319728a608ff3912dc51c15b40e1 Mon Sep 17 00:00:00 2001 From: Nowfal E Salam Date: Tue, 18 Apr 2023 17:50:25 +0530 Subject: [PATCH 4/5] Review comments resolved Renamed molecule nam to listNotificationAuth --- MVMCoreUI.xcodeproj/project.pbxproj | 8 +++---- .../ListNotificationAuthModel.swift} | 22 +++++++++---------- .../GetNotificationAuthStatusBehavior.swift | 4 ++-- .../OtherHandlers/CoreUIModelMapping.swift | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) rename MVMCoreUI/Atomic/Molecules/DesignedComponents/List/{OneColumn/ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksModel.swift => Miscellaneous/ListNotificationAuthModel.swift} (72%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index d394d55d..4e3105bf 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -130,7 +130,7 @@ 1D6D258826899B0C00DEBB08 /* ImageButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D6D258626899B0B00DEBB08 /* ImageButtonModel.swift */; }; 1D6D258926899B0C00DEBB08 /* ImageButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D6D258726899B0B00DEBB08 /* ImageButton.swift */; }; 22B678F929E7944E00CF4196 /* GetNotificationAuthStatusBehavior.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22B678F829E7944E00CF4196 /* GetNotificationAuthStatusBehavior.swift */; }; - 22B678FD29E82B0300CF4196 /* ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22B678FC29E82B0300CF4196 /* ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksModel.swift */; }; + 22B678FD29E82B0300CF4196 /* ListNotificationAuthModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22B678FC29E82B0300CF4196 /* ListNotificationAuthModel.swift */; }; 27559EFC27D691D3000836C1 /* ViewMaskingProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27559EFB27D691D3000836C1 /* ViewMaskingProtocol.swift */; }; 27577DCD286CA959001EC47E /* MoleculeMaskingProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27577DCC286CA959001EC47E /* MoleculeMaskingProtocol.swift */; }; 279B1569242BBC2F00921D6C /* ActionModelAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 279B1568242BBC2F00921D6C /* ActionModelAdapter.swift */; }; @@ -742,7 +742,7 @@ 1D6D258626899B0B00DEBB08 /* ImageButtonModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ImageButtonModel.swift; path = MVMCoreUI/Atomic/Atoms/Buttons/ImageButtonModel.swift; sourceTree = SOURCE_ROOT; }; 1D6D258726899B0B00DEBB08 /* ImageButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ImageButton.swift; path = MVMCoreUI/Atomic/Atoms/Buttons/ImageButton.swift; sourceTree = SOURCE_ROOT; }; 22B678F829E7944E00CF4196 /* GetNotificationAuthStatusBehavior.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GetNotificationAuthStatusBehavior.swift; sourceTree = ""; }; - 22B678FC29E82B0300CF4196 /* ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksModel.swift; sourceTree = ""; }; + 22B678FC29E82B0300CF4196 /* ListNotificationAuthModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListNotificationAuthModel.swift; sourceTree = ""; }; 27559EFB27D691D3000836C1 /* ViewMaskingProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewMaskingProtocol.swift; sourceTree = ""; }; 27577DCC286CA959001EC47E /* MoleculeMaskingProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeMaskingProtocol.swift; sourceTree = ""; }; 279B1568242BBC2F00921D6C /* ActionModelAdapter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionModelAdapter.swift; sourceTree = ""; }; @@ -1462,7 +1462,6 @@ 52267A0623FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift */, 8D084ACF2410BF4800951227 /* ListOneColumnFullWidthTextBodyTextModel.swift */, 8D084AD12410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift */, - 22B678FC29E82B0300CF4196 /* ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksModel.swift */, ); path = OneColumn; sourceTree = ""; @@ -1601,6 +1600,7 @@ children = ( AAE96FA125341F6A0037A989 /* ListStoreLocatorModel.swift */, AAE96FA425341F7D0037A989 /* ListStoreLocator.swift */, + 22B678FC29E82B0300CF4196 /* ListNotificationAuthModel.swift */, AA7F47722541AD560015A2C1 /* ListStarRatingModel.swift */, AA7F47752541AD6A0015A2C1 /* ListStarRating.swift */, ); @@ -3047,7 +3047,7 @@ 324FB6AC24936717002552C7 /* ListLeftVariableNumberedListBodyText.swift in Sources */, AAA74A172410C04600080241 /* HeadersH2NoButtonsBodyText.swift in Sources */, 522679C223FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift in Sources */, - 22B678FD29E82B0300CF4196 /* ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksModel.swift in Sources */, + 22B678FD29E82B0300CF4196 /* ListNotificationAuthModel.swift in Sources */, AA7F32AB246C0F7900C965BA /* ListLeftVariableRadioButtonAllTextAndLinksModel.swift in Sources */, 8D084AD02410BF4800951227 /* ListOneColumnFullWidthTextBodyTextModel.swift in Sources */, AF60A7F82892D34D00919EEB /* ActionDismissNotificationHandler.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListNotificationAuthModel.swift similarity index 72% rename from MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksModel.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListNotificationAuthModel.swift index fe0eaf04..9d17b754 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListNotificationAuthModel.swift @@ -8,13 +8,13 @@ import Foundation -public class ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksModel: ListOneColumnFullWidthTextAllTextAndLinksModel { +public class ListNotificationAuthModel: ListOneColumnFullWidthTextAllTextAndLinksModel { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - public class override var identifier: String { "list1CTxtConsumeNotificationAuth" } - public var enableStatus: String? - public var disableStatus: String? + public class override var identifier: String { "listNotificationAuth" } + public var enableStatus: String + public var disableStatus: String public var enableAction: ActionModelProtocol? public var disableAction: ActionModelProtocol? @@ -32,12 +32,12 @@ public class ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksMod // MARK: - Codec //-------------------------------------------------- required public init(from decoder: Decoder) throws { - try super.init(from: decoder) let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - enableStatus = try typeContainer.decodeIfPresent(String.self, forKey: .enableStatus) - disableStatus = try typeContainer.decodeIfPresent(String.self, forKey: .disableStatus) + enableStatus = try typeContainer.decode(String.self, forKey: .enableStatus) + disableStatus = try typeContainer.decode(String.self, forKey: .disableStatus) enableAction = try typeContainer.decodeModelIfPresent(codingKey: .enableAction) disableAction = try typeContainer.decodeModelIfPresent(codingKey: .disableAction) + try super.init(from: decoder) } public override func encode(to encoder: Encoder) throws { @@ -50,19 +50,19 @@ public class ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksMod } } -extension ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksModel: PageBehaviorProtocolRequirer { +extension ListNotificationAuthModel: PageBehaviorProtocolRequirer { public func getRequiredBehaviors() -> [PageBehaviorModelProtocol] { [PageGetNotificationAuthStatusBehaviorModel()] } } -extension ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksModel: PageGetNotificationAuthStatusBehaviorConsumerProtocol { +extension ListNotificationAuthModel: PageGetNotificationAuthStatusBehaviorConsumerProtocol { public func consume(notificationStatus: UNAuthorizationStatus) { if(notificationStatus == .authorized){ - body?.text = enableStatus ?? "" + body?.text = enableStatus action = enableAction } else { - body?.text = disableStatus ?? "" + body?.text = disableStatus action = disableAction } } diff --git a/MVMCoreUI/Behaviors/GetNotificationAuthStatusBehavior.swift b/MVMCoreUI/Behaviors/GetNotificationAuthStatusBehavior.swift index fea35cf7..a3acffdf 100644 --- a/MVMCoreUI/Behaviors/GetNotificationAuthStatusBehavior.swift +++ b/MVMCoreUI/Behaviors/GetNotificationAuthStatusBehavior.swift @@ -26,14 +26,14 @@ public class PageGetNotificationAuthStatusBehavior: PageVisibilityBehavior { public func onPageShown(_ delegateObject: MVMCoreUIDelegateObject?) { // Get notification auth status - self.getNotificationStatus() + getNotificationStatus() NotificationCenter.default.addObserver(self, selector: #selector(onForeground), name: UIApplication.willEnterForegroundNotification, object: nil) } @objc public func onForeground() { // Get notification authorization status - self.getNotificationStatus() + getNotificationStatus() } public func getNotificationStatus() { diff --git a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift index 5632c697..6ee54804 100644 --- a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift @@ -156,7 +156,7 @@ open class CoreUIModelMapping: ModelMapping { ModelRegistry.register(handler: ListRightVariableToggleAllTextAndLinks.self, for: ListRightVariableToggleAllTextAndLinksModel.self) ModelRegistry.register(handler: ListRightVariableRightCaretAllTextAndLinks.self, for: ListRightVariableRightCaretAllTextAndLinksModel.self) ModelRegistry.register(handler: ListOneColumnFullWidthTextAllTextAndLinks.self, for: ListOneColumnFullWidthTextAllTextAndLinksModel.self) - ModelRegistry.register(handler: ListOneColumnFullWidthTextAllTextAndLinks.self, for: ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksModel.self) + ModelRegistry.register(handler: ListOneColumnFullWidthTextAllTextAndLinks.self, for: ListNotificationAuthModel.self) ModelRegistry.register(handler: ListOneColumnFullWidthTextBodyText.self, for: ListOneColumnFullWidthTextBodyTextModel.self) ModelRegistry.register(handler: ListTwoColumnCompareChanges.self, for: ListTwoColumnCompareChangesModel.self) ModelRegistry.register(handler: ListTwoColumnPriceDetails.self, for: ListTwoColumnPriceDetailsModel.self) From 7ae015ee5f8ef698606b1b52812f0f17183bde7c Mon Sep 17 00:00:00 2001 From: Nowfal E Salam Date: Wed, 26 Apr 2023 00:19:53 +0530 Subject: [PATCH 5/5] story:ONEAPP-3275 Review comments addressed --- .../ListNotificationAuthModel.swift | 12 +++++----- .../GetNotificationAuthStatusBehavior.swift | 22 +++++++++---------- .../OtherHandlers/CoreUIModelMapping.swift | 2 +- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListNotificationAuthModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListNotificationAuthModel.swift index 9d17b754..4469d017 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListNotificationAuthModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListNotificationAuthModel.swift @@ -1,5 +1,5 @@ // -// ConsumeNotificationAuthListOneColumnFullWidthTextAllTextAndLinksModel.swift +// ListNotificationAuthModel.swift // MVMCoreUI // // Created by Edayattu Salam, Nowfal on 13/04/23. @@ -43,8 +43,8 @@ public class ListNotificationAuthModel: ListOneColumnFullWidthTextAllTextAndLink public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeIfPresent(enableStatus, forKey: .enableStatus) - try container.encodeIfPresent(disableStatus, forKey: .disableStatus) + try container.encode(enableStatus, forKey: .enableStatus) + try container.encode(disableStatus, forKey: .disableStatus) try container.encodeModelIfPresent(enableAction, forKey: .enableAction) try container.encodeModelIfPresent(disableAction, forKey: .disableAction) } @@ -52,13 +52,13 @@ public class ListNotificationAuthModel: ListOneColumnFullWidthTextAllTextAndLink extension ListNotificationAuthModel: PageBehaviorProtocolRequirer { public func getRequiredBehaviors() -> [PageBehaviorModelProtocol] { - [PageGetNotificationAuthStatusBehaviorModel()] + [GetNotificationAuthStatusBehaviorModel()] } } -extension ListNotificationAuthModel: PageGetNotificationAuthStatusBehaviorConsumerProtocol { +extension ListNotificationAuthModel: GetNotificationAuthStatusBehaviorConsumerProtocol { public func consume(notificationStatus: UNAuthorizationStatus) { - if(notificationStatus == .authorized){ + if notificationStatus == .authorized { body?.text = enableStatus action = enableAction } else { diff --git a/MVMCoreUI/Behaviors/GetNotificationAuthStatusBehavior.swift b/MVMCoreUI/Behaviors/GetNotificationAuthStatusBehavior.swift index a3acffdf..78bb1129 100644 --- a/MVMCoreUI/Behaviors/GetNotificationAuthStatusBehavior.swift +++ b/MVMCoreUI/Behaviors/GetNotificationAuthStatusBehavior.swift @@ -6,18 +6,18 @@ // Copyright © 2023 Verizon Wireless. All rights reserved. // -public protocol PageGetNotificationAuthStatusBehaviorConsumerProtocol { +public protocol GetNotificationAuthStatusBehaviorConsumerProtocol { func consume(notificationStatus: UNAuthorizationStatus) } -public class PageGetNotificationAuthStatusBehaviorModel: PageBehaviorModelProtocol { - public class var identifier: String { "pageGetNotificationAuthStatusBehavior" } +public class GetNotificationAuthStatusBehaviorModel: PageBehaviorModelProtocol { + public class var identifier: String { "notificationAuthStatus" } public var shouldAllowMultipleInstances: Bool { false } public init() { } } -public class PageGetNotificationAuthStatusBehavior: PageVisibilityBehavior { +public class GetNotificationAuthStatusBehavior: PageVisibilityBehavior { var delegate: MVMCoreUIDelegateObject? public required init(model: PageBehaviorModelProtocol, delegateObject: MVMCoreUIDelegateObject?) { @@ -38,21 +38,19 @@ public class PageGetNotificationAuthStatusBehavior: PageVisibilityBehavior { public func getNotificationStatus() { guard let rootMolecules = self.delegate?.moleculeDelegate?.getRootMolecules() else { return } - let consumers: [PageGetNotificationAuthStatusBehaviorConsumerProtocol] = rootMolecules.allMoleculesOfType() + let consumers: [GetNotificationAuthStatusBehaviorConsumerProtocol] = rootMolecules.allMoleculesOfType() let center = UNUserNotificationCenter.current() center.getNotificationSettings { (settings) in for consumer in consumers { consumer.consume(notificationStatus: settings.authorizationStatus) } + // Tell template to update + MVMCoreDispatchUtility.performBlock(onMainThread: { + guard let controller = self.delegate?.moleculeDelegate as? ViewController else { return } + controller.handleNewDataAndUpdateUI() + }) } - - // Tell template to update - MVMCoreDispatchUtility.performBlock(onMainThread: { - guard let controller = self.delegate?.moleculeDelegate as? ViewController else { return } - controller.handleNewDataAndUpdateUI() - }) - } public func onPageHidden(_ delegateObject: MVMCoreUIDelegateObject?) { diff --git a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift index 5f98b64d..11108eeb 100644 --- a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift @@ -226,7 +226,7 @@ open class CoreUIModelMapping: ModelMapping { ModelRegistry.register(handler: ScreenBrightnessModifierBehavior.self, for: ScreenBrightnessModifierBehaviorModel.self) ModelRegistry.register(handler: PageGetContactBehavior.self, for: PageGetContactBehaviorModel.self) ModelRegistry.register(handler: AddRemoveMoleculesBehavior.self, for: AddRemoveMoleculesBehaviorModel.self) - ModelRegistry.register(handler: PageGetNotificationAuthStatusBehavior.self, for: PageGetNotificationAuthStatusBehaviorModel.self) + ModelRegistry.register(handler: GetNotificationAuthStatusBehavior.self, for: GetNotificationAuthStatusBehaviorModel.self) } open override class func registerActions() {