From c5dd5ed4e7d7b4ee619809d2b0239fb25dabe5a8 Mon Sep 17 00:00:00 2001 From: "Hedden, Kyle Matthew" Date: Thu, 25 Apr 2024 19:34:36 -0400 Subject: [PATCH] Digital PCT265 story ONEAPP-7249 - Prevent forcing immediate layouts on cell changes which causes scroll stagger and carousel width double layouts. --- MVMCoreUI/Atomic/Templates/CollectionTemplate.swift | 2 +- MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift | 8 ++++---- MVMCoreUI/Atomic/Templates/SectionListTemplate.swift | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift b/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift index b242c64a..100b1b17 100644 --- a/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift @@ -134,7 +134,7 @@ } update(cell: cell, size: view.frame.width) // Neded to fix an apple defect where the cell is not the correct size on certain devices for certain cells - cell.layoutIfNeeded() + cell.setNeedsLayout() return cell } diff --git a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift index b825dc68..0c65d403 100644 --- a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift @@ -169,7 +169,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } (cell as? MVMCoreViewProtocol)?.updateView(tableView.bounds.width) // Neded to fix an apple defect where the cell is not the correct size on certain devices for certain cells - cell.layoutIfNeeded() + cell.setNeedsLayout() return cell } @@ -353,7 +353,7 @@ extension MoleculeListTemplate: MoleculeListProtocol { indexPaths.count > 0 else { return } tableView?.deleteRows(at: indexPaths, with: animation) updateViewConstraints() - view.layoutIfNeeded() + view.setNeedsLayout() } public func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], indexPath: IndexPath, animation: UITableView.RowAnimation?) { @@ -372,7 +372,7 @@ extension MoleculeListTemplate: MoleculeListProtocol { indexPaths.count > 0 else { return } self.tableView?.insertRows(at: indexPaths, with: animation) self.updateViewConstraints() - self.view.layoutIfNeeded() + self.view.setNeedsLayout() } public func swapMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], with replacements: [ListItemModelProtocol & MoleculeModelProtocol], at indexPath: IndexPath, animation: UITableView.RowAnimation?) { @@ -420,7 +420,7 @@ extension MoleculeListTemplate: MoleculeListProtocol { tableView.endUpdates() self.updateViewConstraints() - self.view.layoutIfNeeded() + self.view.setNeedsLayout() } public func getIndexPath(for molecule: ListItemModelProtocol & MoleculeModelProtocol) -> IndexPath? { diff --git a/MVMCoreUI/Atomic/Templates/SectionListTemplate.swift b/MVMCoreUI/Atomic/Templates/SectionListTemplate.swift index 08a7d020..0feeadb8 100644 --- a/MVMCoreUI/Atomic/Templates/SectionListTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/SectionListTemplate.swift @@ -112,7 +112,7 @@ open class SectionListTemplate: MoleculeListTemplate { (header as? MoleculeViewProtocol)?.set(with: headerInfo.molecule, delegateObjectIVar, nil) (header as? MVMCoreViewProtocol)?.updateView(tableView.bounds.width) // Neded to fix an apple defect where the cell is not the correct size on certain devices for certain cells - header?.layoutIfNeeded() + header?.setNeedsLayout() return header } @@ -126,7 +126,7 @@ open class SectionListTemplate: MoleculeListTemplate { (footer as? MoleculeViewProtocol)?.set(with: footerInfo.molecule, delegateObjectIVar, nil) (footer as? MVMCoreViewProtocol)?.updateView(tableView.bounds.width) // Neded to fix an apple defect where the cell is not the correct size on certain devices for certain cells - footer?.layoutIfNeeded() + footer?.setNeedsLayout() return footer }