Digital PCT265 story VZWYZDG-1866 - Updating format per code review.
This commit is contained in:
parent
a691f8d713
commit
4921d7d8db
@ -308,8 +308,8 @@
|
||||
AFA4933F29E874F0001A9663 /* MVMCoreUILoggingDelegateProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFA4933E29E874F0001A9663 /* MVMCoreUILoggingDelegateProtocol.swift */; };
|
||||
AFA4935729EE3DCC001A9663 /* AlertDelegateProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFA4935629EE3DCC001A9663 /* AlertDelegateProtocol.swift */; };
|
||||
AFB6336E2C65166E00791221 /* GoneableProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFB6336D2C65166E00791221 /* GoneableProtocol.swift */; };
|
||||
AFB633702C65175800791221 /* ActionNegateGone.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFB6336F2C65175800791221 /* ActionNegateGone.swift */; };
|
||||
AFB633722C653C0900791221 /* ActionNegateGoneModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFB633712C653C0900791221 /* ActionNegateGoneModel.swift */; };
|
||||
AFB633702C65175800791221 /* ActionUpdateVisibility.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFB6336F2C65175800791221 /* ActionUpdateVisibility.swift */; };
|
||||
AFB633722C653C0900791221 /* ActionUpdateVisibilityModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFB633712C653C0900791221 /* ActionUpdateVisibilityModel.swift */; };
|
||||
AFE4A1D627DFBB6F00C458D0 /* UINavigationController+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFE4A1D527DFBB6F00C458D0 /* UINavigationController+Extension.swift */; };
|
||||
B4CC8FBD29DF34680005D28B /* Badge.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4CC8FBC29DF34680005D28B /* Badge.swift */; };
|
||||
B4CC8FBF29DF34730005D28B /* BadgeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4CC8FBE29DF34730005D28B /* BadgeModel.swift */; };
|
||||
@ -935,8 +935,8 @@
|
||||
AFA4933E29E874F0001A9663 /* MVMCoreUILoggingDelegateProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMCoreUILoggingDelegateProtocol.swift; sourceTree = "<group>"; };
|
||||
AFA4935629EE3DCC001A9663 /* AlertDelegateProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertDelegateProtocol.swift; sourceTree = "<group>"; };
|
||||
AFB6336D2C65166E00791221 /* GoneableProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GoneableProtocol.swift; sourceTree = "<group>"; };
|
||||
AFB6336F2C65175800791221 /* ActionNegateGone.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionNegateGone.swift; sourceTree = "<group>"; };
|
||||
AFB633712C653C0900791221 /* ActionNegateGoneModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionNegateGoneModel.swift; sourceTree = "<group>"; };
|
||||
AFB6336F2C65175800791221 /* ActionUpdateVisibility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionUpdateVisibility.swift; sourceTree = "<group>"; };
|
||||
AFB633712C653C0900791221 /* ActionUpdateVisibilityModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionUpdateVisibilityModel.swift; sourceTree = "<group>"; };
|
||||
AFE4A1D527DFBB6F00C458D0 /* UINavigationController+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UINavigationController+Extension.swift"; sourceTree = "<group>"; };
|
||||
B4CC8FBC29DF34680005D28B /* Badge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Badge.swift; sourceTree = "<group>"; };
|
||||
B4CC8FBE29DF34730005D28B /* BadgeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BadgeModel.swift; sourceTree = "<group>"; };
|
||||
@ -1605,8 +1605,8 @@
|
||||
AF1C33722885D481006B1001 /* MVMCoreUIActionOpenPageHandler.swift */,
|
||||
AF60A7F52892D2E300919EEB /* ActionDismissNotificationModel.swift */,
|
||||
AF60A7F72892D34D00919EEB /* ActionDismissNotificationHandler.swift */,
|
||||
AFB633712C653C0900791221 /* ActionNegateGoneModel.swift */,
|
||||
AFB6336F2C65175800791221 /* ActionNegateGone.swift */,
|
||||
AFB633712C653C0900791221 /* ActionUpdateVisibilityModel.swift */,
|
||||
AFB6336F2C65175800791221 /* ActionUpdateVisibility.swift */,
|
||||
);
|
||||
path = Actions;
|
||||
sourceTree = "<group>";
|
||||
@ -2853,7 +2853,7 @@
|
||||
D2E2A99423D8CCBC000B42E6 /* HeadlineBodyLinkModel.swift in Sources */,
|
||||
01004F3022721C3800991ECC /* RadioButton.swift in Sources */,
|
||||
D268C70E238C22D7007F2C1C /* DropDownFilterTableViewCell.swift in Sources */,
|
||||
AFB633702C65175800791221 /* ActionNegateGone.swift in Sources */,
|
||||
AFB633702C65175800791221 /* ActionUpdateVisibility.swift in Sources */,
|
||||
D236E5B7242007C500C38625 /* MVMControllerModelProtocol.swift in Sources */,
|
||||
AA71AD4024A32FE700ACA76F /* HeadersH2Link.swift in Sources */,
|
||||
D29DF11721E6805F003B2FB9 /* UIColor+MFConvenience.m in Sources */,
|
||||
@ -2903,7 +2903,7 @@
|
||||
D2E2A99D23DA3217000B42E6 /* UIStackViewAlignment+Extension.swift in Sources */,
|
||||
01EB369423609801006832FA /* HeadlineBodyModel.swift in Sources */,
|
||||
D2A92884241ACB25004E01C6 /* ProgrammaticScrollViewController.swift in Sources */,
|
||||
AFB633722C653C0900791221 /* ActionNegateGoneModel.swift in Sources */,
|
||||
AFB633722C653C0900791221 /* ActionUpdateVisibilityModel.swift in Sources */,
|
||||
EA985C3E2970938F00F2FF2E /* Tilelet.swift in Sources */,
|
||||
D23A90002612347A007E14CE /* PageBehaviorContainerModelProtocol.swift in Sources */,
|
||||
EAA78020290081320057DFDF /* VDSMoleculeViewProtocol.swift in Sources */,
|
||||
|
||||
@ -1,38 +0,0 @@
|
||||
//
|
||||
// ActionToggleGone.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Scott Pfeil on 8/8/24.
|
||||
// Copyright © 2024 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import MVMCore
|
||||
|
||||
public struct ActionNegateGone: MVMCoreActionHandlerProtocol {
|
||||
|
||||
public enum ActionNegateGoneError: MVMError {
|
||||
case moleculeNotFound(id: String)
|
||||
}
|
||||
|
||||
public init() {}
|
||||
|
||||
public func execute(with model: any MVMCore.ActionModelProtocol, delegateObject: MVMCore.DelegateObject?, additionalData: [AnyHashable : Any]?) async throws {
|
||||
guard let model = model as? ActionNegateGoneModel else { return }
|
||||
guard let goneableModels: [GoneableProtocol & MoleculeModelProtocol] = (delegateObject as? MVMCoreUIDelegateObject)?.moleculeDelegate?.getRootMolecules().allMoleculesOfType(),
|
||||
var goneableModel = goneableModels.first(where: { goneableModel in
|
||||
goneableModel.id == model.id
|
||||
}) else { throw ActionNegateGoneError.moleculeNotFound(id: model.id) }
|
||||
goneableModel.gone = !goneableModel.gone
|
||||
await (delegateObject as? MVMCoreUIDelegateObject)?.moleculeDelegate?.updateUI(for: [goneableModel])
|
||||
}
|
||||
}
|
||||
|
||||
extension ActionNegateGone.ActionNegateGoneError: CustomStringConvertible {
|
||||
public var description: String {
|
||||
switch self {
|
||||
case .moleculeNotFound(id: let id):
|
||||
"Unable to negate gone for molecule with id: \(id)"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
//
|
||||
// ActionToggleGoneModel.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Scott Pfeil on 8/8/24.
|
||||
// Copyright © 2024 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import MVMCore
|
||||
|
||||
public struct ActionNegateGoneModel: ActionModelProtocol {
|
||||
public static var identifier: String = "negateGone"
|
||||
public var actionType: String = ActionNegateGoneModel.identifier
|
||||
public var extraParameters: JSONValueDictionary?
|
||||
public var analyticsData: JSONValueDictionary?
|
||||
public var id: String
|
||||
|
||||
public init(id: String, extraParameters: JSONValueDictionary? = nil, analyticsData: JSONValueDictionary? = nil) {
|
||||
self.id = id
|
||||
self.extraParameters = extraParameters
|
||||
self.analyticsData = analyticsData
|
||||
}
|
||||
}
|
||||
47
MVMCoreUI/Atomic/Actions/ActionUpdateVisibility.swift
Normal file
47
MVMCoreUI/Atomic/Actions/ActionUpdateVisibility.swift
Normal file
@ -0,0 +1,47 @@
|
||||
//
|
||||
// ActionToggleGone.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Scott Pfeil on 8/8/24.
|
||||
// Copyright © 2024 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import MVMCore
|
||||
|
||||
public struct ActionUpdateVisibility: MVMCoreActionHandlerProtocol {
|
||||
|
||||
public init() {}
|
||||
|
||||
public func execute(with model: any MVMCore.ActionModelProtocol, delegateObject: MVMCore.DelegateObject?, additionalData: [AnyHashable : Any]?) async throws {
|
||||
guard let model = model as? ActionUpdateVisibilityModel,
|
||||
let delegate = (delegateObject as? MVMCoreUIDelegateObject)?.moleculeDelegate else { return }
|
||||
|
||||
let stateMap = model.targets.reduce(into: [String: ActionUpdateVisibilityModel.VisibilityTarget.VisibilityState]()) {
|
||||
$0[$1.id] = $1.state
|
||||
}
|
||||
|
||||
let updatedModels: [MoleculeModelProtocol] = delegate.getRootMolecules().reduceDepthFirstTraverse(options: .parentFirst, depth: 0, initialResult: [], nextPartialResult: { accumulator, model, depth in
|
||||
guard var model = model as? (GoneableProtocol & MoleculeModelProtocol),
|
||||
let state = stateMap[model.id] else { return accumulator }
|
||||
model.updateVisibility(state)
|
||||
return accumulator + [model]
|
||||
})
|
||||
|
||||
guard updatedModels.count > 0 else { return }
|
||||
await delegate.updateUI(for: updatedModels)
|
||||
}
|
||||
}
|
||||
|
||||
extension GoneableProtocol {
|
||||
mutating func updateVisibility(_ state: ActionUpdateVisibilityModel.VisibilityTarget.VisibilityState) {
|
||||
switch state {
|
||||
case .true:
|
||||
gone = false
|
||||
case .false:
|
||||
gone = true
|
||||
case .inverted:
|
||||
gone = !gone
|
||||
}
|
||||
}
|
||||
}
|
||||
42
MVMCoreUI/Atomic/Actions/ActionUpdateVisibilityModel.swift
Normal file
42
MVMCoreUI/Atomic/Actions/ActionUpdateVisibilityModel.swift
Normal file
@ -0,0 +1,42 @@
|
||||
//
|
||||
// ActionToggleGoneModel.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Scott Pfeil on 8/8/24.
|
||||
// Copyright © 2024 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import MVMCore
|
||||
|
||||
public struct ActionUpdateVisibilityModel: ActionModelProtocol {
|
||||
|
||||
public static var identifier: String = "updateVisibility"
|
||||
public var actionType: String = ActionUpdateVisibilityModel.identifier
|
||||
public var extraParameters: JSONValueDictionary?
|
||||
public var analyticsData: JSONValueDictionary?
|
||||
public var targets: [VisibilityTarget]
|
||||
|
||||
public struct VisibilityTarget: Codable {
|
||||
|
||||
public enum VisibilityState: String, Codable {
|
||||
case `true`
|
||||
case `false`
|
||||
case inverted
|
||||
}
|
||||
|
||||
public var id: String
|
||||
public var state: VisibilityState
|
||||
|
||||
public init(id: String, state: VisibilityState) {
|
||||
self.id = id
|
||||
self.state = state
|
||||
}
|
||||
}
|
||||
|
||||
public init(targets: [VisibilityTarget], extraParameters: JSONValueDictionary? = nil, analyticsData: JSONValueDictionary? = nil) {
|
||||
self.targets = targets
|
||||
self.extraParameters = extraParameters
|
||||
self.analyticsData = analyticsData
|
||||
}
|
||||
}
|
||||
@ -249,7 +249,7 @@ open class CoreUIModelMapping: ModelMapping {
|
||||
ModelRegistry.register(handler: ActionOpenPanelHandler.self, for: ActionOpenPanelModel.self)
|
||||
ModelRegistry.register(handler: ActionTopNotificationHandler.self, for: ActionTopNotificationModel.self)
|
||||
ModelRegistry.register(handler: MVMCoreUIActionOpenPageHandler.self, for: ActionOpenPageModel.self, allowsReplace: true)
|
||||
ModelRegistry.register(handler: ActionNegateGone.self, for: ActionNegateGoneModel.self)
|
||||
ModelRegistry.register(handler: ActionUpdateVisibility.self, for: ActionUpdateVisibilityModel.self)
|
||||
}
|
||||
|
||||
open class func registerRules() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user