List template behavior fix.

This commit is contained in:
Hedden, Kyle Matthew 2023-09-18 15:04:57 -04:00
parent f6640cc60b
commit 33a05b79a6
3 changed files with 31 additions and 16 deletions

View File

@ -80,11 +80,15 @@
}
open override func handleNewData() {
setup()
registerCells()
super.handleNewData()
}
open override func updateUI() {
topViewOutsideOfScrollArea = templateModel?.anchorHeader ?? false
bottomViewOutsideOfScrollArea = templateModel?.anchorFooter ?? false
setup()
registerCells()
super.updateUI()
}

View File

@ -81,11 +81,15 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
return molecule
}
open override func handleNewData() {
setup()
registerWithTable()
super.handleNewData() // Currently stuck as MoleculeListProtocol being called from AddRemoveMoleculesBehaviorModel.
}
open override func updateUI() {
topViewOutsideOfScrollArea = templateModel?.anchorHeader ?? false
bottomViewOutsideOfScrollArea = templateModel?.anchorFooter ?? false
setup()
registerWithTable()
super.updateUI()
}

View File

@ -232,16 +232,6 @@ import MVMCore
return true
}
@MainActor
open func updateUI() {
if let backgroundColor = model?.backgroundColor {
view.backgroundColor = backgroundColor.uiColor
}
needsUpdateUI = true
view.setNeedsLayout()
}
/// Creates a legacy navigation model.
open func createDefaultLegacyNavigationModel() -> NavigationItemModel {
let navigationModel = NavigationItemModel()
@ -249,7 +239,7 @@ import MVMCore
return navigationModel
}
/// Processes any new data. Called after the page is loaded the first time and on response updates for this page,
/// Processes any new data. Called after the page is loaded the first time and on response updates for this page, Triggers a render refresh.
@MainActor
open func handleNewData() {
if model?.navigationBar == nil {
@ -269,7 +259,24 @@ import MVMCore
// Notify the manager of new data
manager?.newDataReceived?(in: self)
updateUI()
Task { @MainActor in
updateUI()
}
}
/// Applies the latest model to the UI.
@MainActor
open func updateUI() {
executeBehaviors { (behavior: PageMoleculeTransformationBehavior) in
behavior.willRender(rootMolecules: getRootMolecules(), delegateObjectIVar)
}
if let backgroundColor = model?.backgroundColor {
view.backgroundColor = backgroundColor.uiColor
}
needsUpdateUI = true
view.setNeedsLayout()
}
public func generateMoleculeView(from model: MoleculeModelProtocol) -> MoleculeViewProtocol? {