Skip to content

Commit b84bdd8

Browse files
committed
Added initial support for sticky headers and footers.
1 parent 450ea08 commit b84bdd8

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

ChatLayout.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'ChatLayout'
3-
s.version = '2.0.11'
3+
s.version = '2.0.12'
44
s.summary = 'Chat UI Library. It uses custom UICollectionViewLayout to provide you full control over the presentation.'
55
s.swift_version = '5.10'
66

ChatLayout/Classes/Core/CollectionViewChatLayout.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,6 @@ open class CollectionViewChatLayout: UICollectionViewLayout {
722722
open override func prepare(forCollectionViewUpdates updateItems: [UICollectionViewUpdateItem]) {
723723
var changeItems = updateItems.compactMap { ChangeItem(with: $0) }
724724
changeItems.append(contentsOf: reconfigureItemsIndexPaths.map { .itemReconfigure(itemIndexPath: $0) })
725-
print("\(#function) \(changeItems)")
726725
controller.process(changeItems: changeItems)
727726
state = .afterUpdate
728727
dontReturnAttributes = false

ChatLayout/Classes/Core/Model/StateController.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ final class StateController<Layout: ChatLayoutRepresentation> {
193193
let cachedAttributesState,
194194
cachedAttributesState.rect.contains(rect) {
195195
return hasPinnedHeaderOrFooter
196-
? cachedAttributesState.attributes.filter { $0.frame.intersects(rect) }
197-
: cachedAttributesState.attributes.withUnsafeBufferPointer { $0.binarySearchRange(predicate: predicate) }
196+
? cachedAttributesState.attributes.filter { $0.frame.intersects(rect) }
197+
: cachedAttributesState.attributes.withUnsafeBufferPointer { $0.binarySearchRange(predicate: predicate) }
198198
} else {
199199
let totalRect: CGRect
200200
switch state {
@@ -379,13 +379,13 @@ final class StateController<Layout: ChatLayoutRepresentation> {
379379

380380
itemFrame.offsettingBy(dx: dx, dy: section.offsetY)
381381

382-
if kind == .header && section.shouldPinHeaderToVisibleBounds == true {
382+
if kind == .header, section.shouldPinHeaderToVisibleBounds == true {
383383
layoutRepresentation.hasPinnedHeaderOrFooter = true
384384
let offsetY = max(min(visibleBounds.minY - section.offsetY, section.height - (section.footer?.size.height ?? 0) - item.size.height), 0)
385385
itemFrame.offsettingBy(dx: 0, dy: offsetY)
386386
}
387387

388-
if kind == .footer && section.shouldPinFooterToVisibleBounds == true {
388+
if kind == .footer, section.shouldPinFooterToVisibleBounds == true {
389389
layoutRepresentation.hasPinnedHeaderOrFooter = true
390390
let offsetY = max(min(0, visibleBounds.maxY - item.size.height - itemFrame.minY), section.offsetY + (section.header?.size.height ?? 0) - itemFrame.minY)
391391
itemFrame.offsettingBy(dx: 0, dy: offsetY)

0 commit comments

Comments
 (0)