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() {