fix crash from divide by zero error

This commit is contained in:
Nihaal Sharma committed 2026-07-04 00:40:02 +01:00
1 parent d5b6394e9e
commit 678839c886
2 files changed
+5 -6

No files matched your search

@@ -73,12 +73,13 @@ class PlainEmojiCollectionViewCell: UICollectionViewCell {
let totalWidth = collectionView.bounds.width let totalWidth = collectionView.bounds.width
let availWidth = totalWidth-collectionView.contentInset.left-collectionView.contentInset.right let availWidth = totalWidth-collectionView.contentInset.left-collectionView.contentInset.right
let cols: CGFloat var cols: CGFloat
if style == .jumboMoji { if style == .jumboMoji {
cols = width cols = width
} else { } else {
cols = max(1, floor(availWidth/width)) cols = max(1, floor(availWidth/width))
} }
if cols == 0 || cols == .infinity { cols = 4 }
let totalSpacing = ((collectionView.collectionViewLayout as? UICollectionViewFlowLayout)?.minimumInteritemSpacing ?? 0) * (cols-1) let totalSpacing = ((collectionView.collectionViewLayout as? UICollectionViewFlowLayout)?.minimumInteritemSpacing ?? 0) * (cols-1)
let itemWidth = ((availWidth-totalSpacing)/cols).rounded(.down) let itemWidth = ((availWidth-totalSpacing)/cols).rounded(.down)
layoutAttributes.size = CGSize(width: itemWidth, height: itemWidth) layoutAttributes.size = CGSize(width: itemWidth, height: itemWidth)
@@ -10,18 +10,16 @@ import UIKit
import SwiftUI import SwiftUI
struct EmojiPackDetailViewRepresentable: UIViewControllerRepresentable { struct EmojiPackDetailViewRepresentable: UIViewControllerRepresentable {
typealias UIViewControllerType = UINavigationController
var hoarder: EmojiHoarder var hoarder: EmojiHoarder
var pack: EmojiPack var pack: EmojiPack
func makeUIViewController(context: Context) -> UINavigationController { func makeUIViewController(context: Context) -> UIViewController {
let view = EmojiPackDetailViewController(with: hoarder, andPack: pack) let view = EmojiPackDetailViewController(with: hoarder, andPack: pack)
view.isToolbarHidden = false view.navigationController?.isToolbarHidden = false
return view return view
} }
func updateUIViewController(_ uiViewController: UINavigationController, context: Context) { func updateUIViewController(_ uiViewController: UIViewController, context: Context) {
} }
} }
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.