updating specific model class change for Modal template
This commit is contained in:
parent
0ee938cf57
commit
66b0370574
@ -23,24 +23,24 @@ import Foundation
|
|||||||
// MARK: - Keys
|
// MARK: - Keys
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
// private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
// case closeAction
|
case closeAction
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// //--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// // MARK: - Codec
|
// MARK: - Codec
|
||||||
// //--------------------------------------------------
|
//--------------------------------------------------
|
||||||
//
|
|
||||||
// required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
// let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
// closeAction = try typeContainer.decodeModelIfPresent(codingKey: .closeAction)
|
closeAction = try typeContainer.decodeModelIfPresent(codingKey: .closeAction)
|
||||||
// try super.init(from: decoder)
|
try super.init(from: decoder)
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// open override func encode(to encoder: Encoder) throws {
|
open override func encode(to encoder: Encoder) throws {
|
||||||
// try super.encode(to: encoder)
|
try super.encode(to: encoder)
|
||||||
// var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
// try container.encodeModelIfPresent(closeAction, forKey: .closeAction)
|
try container.encodeModelIfPresent(closeAction, forKey: .closeAction)
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,6 +20,11 @@ open class ModalMoleculeListTemplate: MoleculeListTemplate {
|
|||||||
// MARK: - Lifecycle
|
// MARK: - Lifecycle
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
// For subclassing the model.
|
||||||
|
open override func decodeTemplate(using decoder: JSONDecoder, from data: Data) throws -> ModalListPageTemplateModel {
|
||||||
|
return try decoder.decode(ModalListPageTemplateModel.self, from: data)
|
||||||
|
}
|
||||||
|
|
||||||
override open func handleNewData() {
|
override open func handleNewData() {
|
||||||
super.handleNewData()
|
super.handleNewData()
|
||||||
|
|
||||||
|
|||||||
@ -10,17 +10,23 @@ import UIKit
|
|||||||
|
|
||||||
open class ModalMoleculeStackTemplate: MoleculeStackTemplate {
|
open class ModalMoleculeStackTemplate: MoleculeStackTemplate {
|
||||||
|
|
||||||
|
// For subclassing the model.
|
||||||
|
open override func decodeTemplate(using decoder: JSONDecoder, from data: Data) throws -> ModalStackPageTemplateModel {
|
||||||
|
return try decoder.decode(ModalStackPageTemplateModel.self, from: data)
|
||||||
|
}
|
||||||
|
|
||||||
override open func handleNewData() {
|
override open func handleNewData() {
|
||||||
super.handleNewData()
|
super.handleNewData()
|
||||||
_ = MVMCoreUICommonViewsUtility.addCloseButton(to: view, action: {[weak self] _ in
|
_ = MVMCoreUICommonViewsUtility.addCloseButton(to: view, action: {[weak self] _ in
|
||||||
guard let self = self else {
|
guard let self = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// guard let actionMap = self.templateModel?.closeAction else {
|
|
||||||
// MVMCoreActionHandler.shared()?.handleAction(with: ActionBackModel().toJSON(), additionalData: nil, delegateObject: self.delegateObjectIVar)
|
guard let model = self.templateModel as? ModalStackPageTemplateModel, let actionMap = model.closeAction else {
|
||||||
// return
|
MVMCoreActionHandler.shared()?.handleAction(with: ActionBackModel().toJSON(), additionalData: nil, delegateObject: self.delegateObjectIVar)
|
||||||
// }
|
return
|
||||||
// MVMCoreActionHandler.shared()?.handleAction(with: actionMap.toJSON(), additionalData: nil, delegateObject: self.delegateObjectIVar)
|
}
|
||||||
|
MVMCoreActionHandler.shared()?.handleAction(with: actionMap.toJSON(), additionalData: nil, delegateObject: self.delegateObjectIVar)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,26 +8,18 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
@objcMembers public class ModalStackPageTemplateModel: ThreeLayerModelBase {
|
@objcMembers public class ModalStackPageTemplateModel: StackPageTemplateModel {
|
||||||
public override class var identifier: String {
|
public override class var identifier: String {
|
||||||
return "modalStack"
|
return "modalStack"
|
||||||
}
|
}
|
||||||
public var moleculeStack: StackModel
|
|
||||||
public var closeAction: ActionModelProtocol?
|
public var closeAction: ActionModelProtocol?
|
||||||
|
|
||||||
public init(pageType: String, moleculeStack: StackModel) {
|
|
||||||
self.moleculeStack = moleculeStack
|
|
||||||
super.init(pageType: pageType)
|
|
||||||
}
|
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
case stack
|
|
||||||
case closeAction
|
case closeAction
|
||||||
}
|
}
|
||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
moleculeStack = try typeContainer.decode(StackModel.self, forKey: .stack)
|
|
||||||
closeAction = try typeContainer.decodeModelIfPresent(codingKey: .closeAction)
|
closeAction = try typeContainer.decodeModelIfPresent(codingKey: .closeAction)
|
||||||
try super.init(from: decoder)
|
try super.init(from: decoder)
|
||||||
}
|
}
|
||||||
@ -35,7 +27,6 @@ import Foundation
|
|||||||
public override func encode(to encoder: Encoder) throws {
|
public override func encode(to encoder: Encoder) throws {
|
||||||
try super.encode(to: encoder)
|
try super.encode(to: encoder)
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encode(moleculeStack, forKey: .stack)
|
|
||||||
try container.encodeModelIfPresent(closeAction, forKey: .closeAction)
|
try container.encodeModelIfPresent(closeAction, forKey: .closeAction)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,6 +17,11 @@ open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol {
|
|||||||
bottomViewOutsideOfScroll = templateModel?.anchorFooter ?? false
|
bottomViewOutsideOfScroll = templateModel?.anchorFooter ?? false
|
||||||
super.handleNewData()
|
super.handleNewData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For subclassing the model.
|
||||||
|
open func decodeTemplate(using decoder: JSONDecoder, from data: Data) throws -> StackPageTemplateModel {
|
||||||
|
return try decoder.decode(StackPageTemplateModel.self, from: data)
|
||||||
|
}
|
||||||
|
|
||||||
open override func parsePageJSON() throws {
|
open override func parsePageJSON() throws {
|
||||||
try parseTemplate(json: loadObject?.pageJSON)
|
try parseTemplate(json: loadObject?.pageJSON)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user