From 678839c886b6d0506ab553c2de5c75a3d533421b Mon Sep 17 00:00:00 2001 From: Nihaal Sharma <69979447+neon443@users.noreply.github.com> Date: Sat, 4 Jul 2026 00:40:02 +0100 Subject: [PATCH] fix crash from divide by zero error --- .../CollectionView/PlainEmojiCollectionViewCell.swift | 3 ++- StickerSlack/UIKit/EmojiPackDetailViewRepresentable.swift | 8 +++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/StickerSlack/UIKit/CollectionView/PlainEmojiCollectionViewCell.swift b/StickerSlack/UIKit/CollectionView/PlainEmojiCollectionViewCell.swift index 01b186b..80e7aae 100644 --- a/StickerSlack/UIKit/CollectionView/PlainEmojiCollectionViewCell.swift +++ b/StickerSlack/UIKit/CollectionView/PlainEmojiCollectionViewCell.swift @@ -73,12 +73,13 @@ class PlainEmojiCollectionViewCell: UICollectionViewCell { let totalWidth = collectionView.bounds.width let availWidth = totalWidth-collectionView.contentInset.left-collectionView.contentInset.right - let cols: CGFloat + var cols: CGFloat if style == .jumboMoji { cols = width } else { cols = max(1, floor(availWidth/width)) } + if cols == 0 || cols == .infinity { cols = 4 } let totalSpacing = ((collectionView.collectionViewLayout as? UICollectionViewFlowLayout)?.minimumInteritemSpacing ?? 0) * (cols-1) let itemWidth = ((availWidth-totalSpacing)/cols).rounded(.down) layoutAttributes.size = CGSize(width: itemWidth, height: itemWidth) diff --git a/StickerSlack/UIKit/EmojiPackDetailViewRepresentable.swift b/StickerSlack/UIKit/EmojiPackDetailViewRepresentable.swift index f1a1419..3b98254 100644 --- a/StickerSlack/UIKit/EmojiPackDetailViewRepresentable.swift +++ b/StickerSlack/UIKit/EmojiPackDetailViewRepresentable.swift @@ -10,18 +10,16 @@ import UIKit import SwiftUI struct EmojiPackDetailViewRepresentable: UIViewControllerRepresentable { - typealias UIViewControllerType = UINavigationController - var hoarder: EmojiHoarder var pack: EmojiPack - func makeUIViewController(context: Context) -> UINavigationController { + func makeUIViewController(context: Context) -> UIViewController { let view = EmojiPackDetailViewController(with: hoarder, andPack: pack) - view.isToolbarHidden = false + view.navigationController?.isToolbarHidden = false return view } - func updateUIViewController(_ uiViewController: UINavigationController, context: Context) { + func updateUIViewController(_ uiViewController: UIViewController, context: Context) { } }