story:ONEAPP-3275 Review comments addressed
This commit is contained in:
parent
6dfbea79dd
commit
7ae015ee5f
@ -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 {
|
||||
|
||||
@ -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?) {
|
||||
|
||||
@ -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() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user