mirror of
https://github.com/neon443/StickerSlack.git
synced 2026-11-30 12:44: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 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)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
}
|
||||
}
|
||||