diff --git a/Tusker/Screens/Compose/EmojiPickerCollectionViewController.swift b/Tusker/Screens/Compose/EmojiPickerCollectionViewController.swift index 0757189f20..216b9dfd10 100644 --- a/Tusker/Screens/Compose/EmojiPickerCollectionViewController.swift +++ b/Tusker/Screens/Compose/EmojiPickerCollectionViewController.swift @@ -37,18 +37,21 @@ class EmojiPickerCollectionViewController: UICollectionViewController { init(mastodonController: MastodonController) { self.mastodonController = mastodonController - let itemWidth = NSCollectionLayoutDimension.fractionalWidth(1.0 / 10) - let itemSize = NSCollectionLayoutSize(widthDimension: itemWidth, heightDimension: itemWidth) - let item = NSCollectionLayoutItem(layoutSize: itemSize) - - let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), heightDimension: itemWidth) - let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [item]) - group.interItemSpacing = .fixed(4) - - let section = NSCollectionLayoutSection(group: group) - section.interGroupSpacing = 4 - - let layout = UICollectionViewCompositionalLayout(section: section) + let layout = UICollectionViewCompositionalLayout { sectionIndex, environment in + let hSizeClass = environment.traitCollection.horizontalSizeClass + + let itemWidth = NSCollectionLayoutDimension.fractionalWidth(1.0 / (hSizeClass == .compact ? 10 : 20)) + let itemSize = NSCollectionLayoutSize(widthDimension: itemWidth, heightDimension: itemWidth) + let item = NSCollectionLayoutItem(layoutSize: itemSize) + + let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), heightDimension: itemWidth) + let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [item]) + group.interItemSpacing = .fixed(4) + + let section = NSCollectionLayoutSection(group: group) + section.interGroupSpacing = 4 + return section + } super.init(collectionViewLayout: layout) }