Merge branch 'feature/molecule_replacement_header_fix' into 'feature/molecule_replacement_behavior'
Feature/molecule replacement header fix ### Summary (a brief description of the change) ### JIRA Ticket (ticket URL here or remove the section) Co-authored-by: vimal <vimal.murugan@verizon.com> See merge request https://gitlab.verizon.com/BPHV_MIPS/mvm_core_ui/-/merge_requests/1042
This commit is contained in:
commit
721de40fe0
@ -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
|
||||
|
||||
@ -202,7 +202,18 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
|
||||
}
|
||||
|
||||
open func newData(for molecule: MoleculeModelProtocol) {
|
||||
//TODO: expand for header, navigation, etc
|
||||
|
||||
//Update the header
|
||||
if updateHeaderFooter(modelView: topView, molecule: molecule) {
|
||||
return
|
||||
}
|
||||
|
||||
//Update the footer
|
||||
if updateHeaderFooter(modelView: bottomView, molecule: molecule) {
|
||||
return
|
||||
}
|
||||
|
||||
//TODO: expand for navigation, etc
|
||||
guard let moleculesInfo = moleculesInfo else { return }
|
||||
|
||||
let indicies = moleculesInfo.indices.filter({ index -> Bool in
|
||||
@ -221,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