fix for button model
review comment updated
This commit is contained in:
parent
b6623b34c6
commit
db7e59191a
@ -8,7 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
open class ImageButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWatcherFieldProtocol {
|
||||
open class ImageButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWatcherFieldProtocol, ParentMoleculeModelProtocol {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Properties
|
||||
//--------------------------------------------------
|
||||
@ -29,6 +29,14 @@ open class ImageButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGro
|
||||
|
||||
public var updateUI: ActionBlock?
|
||||
|
||||
public var children: [MoleculeModelProtocol] {
|
||||
[image].compactMap({$0})
|
||||
}
|
||||
|
||||
public func replaceChildMolecule(with molecule: MoleculeModelProtocol) throws -> Bool {
|
||||
return try replaceChildMolecule(at: &image, with: molecule)
|
||||
}
|
||||
|
||||
public init(image: ImageViewModel?, action: ActionModelProtocol) {
|
||||
self.image = image
|
||||
self.action = action
|
||||
|
||||
@ -203,16 +203,13 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
|
||||
|
||||
open func newData(for molecule: MoleculeModelProtocol) {
|
||||
|
||||
if let headerMolecule = molecule as? MoleculeHeaderModel {
|
||||
//If complete header replaced then it makes sense to add this
|
||||
/*createViewForTableHeader()
|
||||
let width = view.bounds.width
|
||||
if let topView = topView as? MVMCoreViewProtocol {
|
||||
topView.updateView(width)
|
||||
showHeader(width)
|
||||
}*/
|
||||
//Just update is happening only on the existing molecules. ex. changing the title, action etc..
|
||||
(topView as? MoleculeViewProtocol)?.set(with: headerMolecule, delegateObject() as? MVMCoreUIDelegateObject, nil)
|
||||
//Update the header
|
||||
if updateHeaderFooter(modelView: topView, molecule: molecule) {
|
||||
return
|
||||
}
|
||||
|
||||
//Update the footer
|
||||
if updateHeaderFooter(modelView: bottomView, molecule: molecule) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -235,6 +232,16 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
|
||||
tableView.selectRow(at: selectedIndex, animated: false, scrollPosition: .none)
|
||||
}
|
||||
}
|
||||
|
||||
///Helper functions to update the header/footer view
|
||||
private func updateHeaderFooter(modelView: UIView?, molecule: MoleculeModelProtocol) -> Bool {
|
||||
if let updateView = modelView,
|
||||
let moleculeView = MVMCoreUIUtility.findViews(by: MoleculeViewProtocol.self, views: [updateView]).first(where: { $0.model?.moleculeName == molecule.moleculeName && $0.model?.id == molecule.id }) {
|
||||
updateMoleculeView(moleculeView, from: molecule)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Convenience
|
||||
|
||||
Loading…
Reference in New Issue
Block a user