mirror of
https://github.com/neon443/StickerSlack.git
synced 2026-11-30 20:54:51 +00:00
fix crash from divide by zero error
This commit is contained in:
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) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||