From 208039ea3a1d7e041fdf9daa6305f5333ca55caf Mon Sep 17 00:00:00 2001 From: Eugene Kazaev Date: Tue, 30 Apr 2024 20:44:57 +0100 Subject: [PATCH] Minor fix for sections --- ChatLayout.podspec | 2 +- ChatLayout/Classes/Core/Model/StateController.swift | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ChatLayout.podspec b/ChatLayout.podspec index 6e4943fd..dd0802ed 100644 --- a/ChatLayout.podspec +++ b/ChatLayout.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'ChatLayout' - s.version = '2.0.5' + s.version = '2.0.6' s.summary = 'Chat UI Library. It uses custom UICollectionViewLayout to provide you full control over the presentation.' s.swift_version = '5.8' diff --git a/ChatLayout/Classes/Core/Model/StateController.swift b/ChatLayout/Classes/Core/Model/StateController.swift index 670ae45c..8858f817 100644 --- a/ChatLayout/Classes/Core/Model/StateController.swift +++ b/ChatLayout/Classes/Core/Model/StateController.swift @@ -529,10 +529,10 @@ final class StateController { var itemToRestore: ItemToRestore? if layoutRepresentation.keepContentOffsetAtBottomOnBatchUpdates, let lastVisibleAttribute = allAttributes(at: .beforeUpdate, visibleRect: layoutRepresentation.visibleBounds).last, - let item = item(for: lastVisibleAttribute.indexPath.itemPath, kind: lastVisibleAttribute.kind, at: .beforeUpdate) { + let itemFrame = itemFrame(for: lastVisibleAttribute.indexPath.itemPath, kind: lastVisibleAttribute.kind, at: .beforeUpdate) { itemToRestore = ItemToRestore(globalIndex: globalIndexFor(lastVisibleAttribute.indexPath.itemPath, kind: lastVisibleAttribute.kind, state: .beforeUpdate), kind: lastVisibleAttribute.kind, - offset: (item.frame.maxY - layoutRepresentation.visibleBounds.maxY).rounded()) + offset: (itemFrame.maxY - layoutRepresentation.visibleBounds.maxY).rounded()) } batchUpdateCompensatingOffset = 0 proposedCompensatingOffset = 0 @@ -811,9 +811,9 @@ final class StateController { if layoutRepresentation.keepContentOffsetAtBottomOnBatchUpdates, let itemToRestore, let itemPath = itemPathFor(itemToRestore.globalIndex, kind: itemToRestore.kind, state: .model(afterUpdateModel)), - let item = item(for: itemPath, kind: itemToRestore.kind, at: .afterUpdate), + let itemFrame = itemFrame(for: itemPath, kind: itemToRestore.kind, at: .afterUpdate), isLayoutBiggerThanVisibleBounds(at: .afterUpdate, visibleBounds: layoutRepresentation.visibleBounds) { - let newProposedCompensationOffset = (item.frame.maxY - itemToRestore.offset) - layoutRepresentation.visibleBounds.maxY + let newProposedCompensationOffset = (itemFrame.maxY - itemToRestore.offset) - layoutRepresentation.visibleBounds.maxY proposedCompensatingOffset = newProposedCompensationOffset } totalProposedCompensatingOffset = proposedCompensatingOffset @@ -1179,7 +1179,7 @@ final class StateController { func numberOfItemsBeforeSection(_ sectionIndex: Int, state: GlobalIndexModel) -> Int { let layout = state.layout ?? layout(at: .beforeUpdate) var total = 0 - for index in 0..