minor cleanup

This commit is contained in:
vimal 2024-01-04 11:07:34 +05:30
parent 721de40fe0
commit 03ea6c528c

View File

@ -203,17 +203,10 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
open func newData(for molecule: MoleculeModelProtocol) { open func newData(for molecule: MoleculeModelProtocol) {
//Update the header if updateMoleculeViewByModelId(molecule: molecule) {
if updateHeaderFooter(modelView: topView, molecule: molecule) {
return return
} }
//Update the footer
if updateHeaderFooter(modelView: bottomView, molecule: molecule) {
return
}
//TODO: expand for navigation, etc
guard let moleculesInfo = moleculesInfo else { return } guard let moleculesInfo = moleculesInfo else { return }
let indicies = moleculesInfo.indices.filter({ index -> Bool in let indicies = moleculesInfo.indices.filter({ index -> Bool in
@ -234,11 +227,14 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
} }
///Helper functions to update the header/footer view ///Helper functions to update the header/footer view
private func updateHeaderFooter(modelView: UIView?, molecule: MoleculeModelProtocol) -> Bool { //TODO: expand for navigation, etc
if let updateView = modelView, private func updateMoleculeViewByModelId(molecule: MoleculeModelProtocol) -> Bool {
let moleculeView = MVMCoreUIUtility.findViews(by: MoleculeViewProtocol.self, views: [updateView]).first(where: { $0.model?.moleculeName == molecule.moleculeName && $0.model?.id == molecule.id }) { let headerFooterViews = [topView, bottomView].compactMap({$0 as? MoleculeViewProtocol})
updateMoleculeView(moleculeView, from: molecule) for headerFooterView in headerFooterViews {
return true if let moleculeView = MVMCoreUIUtility.findViews(by: MoleculeViewProtocol.self, views: [headerFooterView]).first(where: { $0.model?.moleculeName == molecule.moleculeName && $0.model?.id == molecule.id }) {
updateMoleculeView(moleculeView, from: molecule)
return true
}
} }
return false return false
} }