From 90f277282e847bd67f0dd4694afe72a19cf247d4 Mon Sep 17 00:00:00 2001 From: Nihaal Sharma <69979447+neon443@users.noreply.github.com> Date: Fri, 8 May 2026 14:41:58 +0100 Subject: [PATCH] collectionview cell sizes are now not calculated upfront :sob: need to fix why theyre not expanding horizontally and that theyre too big --- .../UIKit/CollectionView/EmojiCollectionViewCell.swift | 7 ++++--- .../CollectionView/PlainEmojiCollectionViewCell.swift | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/StickerSlack/UIKit/CollectionView/EmojiCollectionViewCell.swift b/StickerSlack/UIKit/CollectionView/EmojiCollectionViewCell.swift index 1fdb6eb..a1ebe17 100644 --- a/StickerSlack/UIKit/CollectionView/EmojiCollectionViewCell.swift +++ b/StickerSlack/UIKit/CollectionView/EmojiCollectionViewCell.swift @@ -104,10 +104,11 @@ class EmojiCollectionViewCell: PlainEmojiCollectionViewCell { } override func preferredLayoutAttributesFitting(_ layoutAttributes: UICollectionViewLayoutAttributes) -> UICollectionViewLayoutAttributes { - super.preferredLayoutAttributesFitting(layoutAttributes) + let layoutAttributes = super.preferredLayoutAttributesFitting(layoutAttributes) guard label.text != nil else { return layoutAttributes } - let labelHeight = label.sizeThatFits(CGSize(width: self.contentView.frame.width, height: .infinity)).height - layoutAttributes.size = CGSize(width: self.contentView.frame.width, height: labelHeight+4+view.frame.height) + let labelHeight = label.sizeThatFits(CGSize(width: layoutAttributes.size.width, height: .infinity)).height + layoutAttributes.size = CGSize(width: layoutAttributes.size.width, height: labelHeight+4+view.frame.height) + print(label.text!, layoutAttributes.size) return layoutAttributes } diff --git a/StickerSlack/UIKit/CollectionView/PlainEmojiCollectionViewCell.swift b/StickerSlack/UIKit/CollectionView/PlainEmojiCollectionViewCell.swift index fc036a2..ec29e42 100644 --- a/StickerSlack/UIKit/CollectionView/PlainEmojiCollectionViewCell.swift +++ b/StickerSlack/UIKit/CollectionView/PlainEmojiCollectionViewCell.swift @@ -81,7 +81,8 @@ class PlainEmojiCollectionViewCell: UICollectionViewCell { } let totalSpacing = (collectionView.collectionViewLayout as? UICollectionViewFlowLayout)?.minimumInteritemSpacing ?? 0 * (cols-1) let itemWidth = (availWidth-totalSpacing)/cols - layoutAttributes.size = CGSize(width: itemWidth, height: layoutAttributes.size.height) + layoutAttributes.size = CGSize(width: itemWidth, height: itemWidth) + print(layoutAttributes.size) return layoutAttributes }