diff --git a/StickerSlack/UIKit/CollectionView/EmojiCollectionView.swift b/StickerSlack/UIKit/CollectionView/EmojiCollectionView.swift index 876fd45..b072066 100644 --- a/StickerSlack/UIKit/CollectionView/EmojiCollectionView.swift +++ b/StickerSlack/UIKit/CollectionView/EmojiCollectionView.swift @@ -21,7 +21,7 @@ struct EmojiCollectionView: UIViewRepresentable { func makeUIView(context: Context) -> UICollectionView { let collectionView = context.coordinator as UICollectionViewController collectionView.collectionView.register(PlainEmojiCollectionViewCell.self, forCellWithReuseIdentifier: "plain") - collectionView.collectionView.register(EmojiCollectionViewCell.self, forCellWithReuseIdentifier: "full") + collectionView.collectionView.register(EmojiCollectionViewCell.self, forCellWithReuseIdentifier: "full") collectionView.collectionView.dataSource = context.coordinator collectionView.collectionView.delegate = context.coordinator return collectionView.collectionView diff --git a/StickerSlack/UIKit/CollectionView/EmojiCollectionViewCell.swift b/StickerSlack/UIKit/CollectionView/EmojiCollectionViewCell.swift index 7bee37b..ee4f692 100644 --- a/StickerSlack/UIKit/CollectionView/EmojiCollectionViewCell.swift +++ b/StickerSlack/UIKit/CollectionView/EmojiCollectionViewCell.swift @@ -7,6 +7,7 @@ import Foundation import UIKit +import SwiftUI class EmojiCollectionViewCell: PlainEmojiCollectionViewCell { let label = UILabel() @@ -38,7 +39,8 @@ class EmojiCollectionViewCell: PlainEmojiCollectionViewCell { override func configure(with: EmojiHoarder, emoji: Emoji) { super.configure(with: with, emoji: emoji) label.text = emoji.UIName - setNeedsLayout() + stackView.addArrangedSubview(label) +// setNeedsLayout() } override func prepareForReuse() { diff --git a/StickerSlack/UIKit/CollectionView/PlainEmojiCollectionViewCell.swift b/StickerSlack/UIKit/CollectionView/PlainEmojiCollectionViewCell.swift index 671ad62..9d94c7b 100644 --- a/StickerSlack/UIKit/CollectionView/PlainEmojiCollectionViewCell.swift +++ b/StickerSlack/UIKit/CollectionView/PlainEmojiCollectionViewCell.swift @@ -10,6 +10,7 @@ import UIKit import SwiftUI class PlainEmojiCollectionViewCell: UICollectionViewCell { + let stackView = UIStackView() let spinner = UIActivityIndicatorView() var hostingController: UIHostingController? @@ -24,14 +25,15 @@ class PlainEmojiCollectionViewCell: UICollectionViewCell { func configureSkeleton() { spinner.frame = frame spinner.startAnimating() - self.contentView.addSubview(spinner) + self.contentView.addSubview(stackView) + stackView.addArrangedSubview(spinner) - spinner.translatesAutoresizingMaskIntoConstraints = false + stackView.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ - spinner.topAnchor.constraint(equalTo: contentView.topAnchor), - spinner.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), - spinner.leadingAnchor.constraint(equalTo: contentView.leadingAnchor), - spinner.trailingAnchor.constraint(equalTo: contentView.trailingAnchor) + stackView.topAnchor.constraint(equalTo: contentView.topAnchor), + stackView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), + stackView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor), + stackView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor) ]) } @@ -44,14 +46,14 @@ class PlainEmojiCollectionViewCell: UICollectionViewCell { } else { let hostingController = UIHostingController(rootView: swiftUIView) self.hostingController = hostingController - self.contentView.addSubview(hostingController.view) + self.stackView.addArrangedSubview(hostingController.view) hostingController.view.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate( [ - hostingController.view.topAnchor.constraint(equalTo: contentView.topAnchor), - hostingController.view.leadingAnchor.constraint(equalTo: contentView.leadingAnchor), - hostingController.view.trailingAnchor.constraint(equalTo: contentView.trailingAnchor), + hostingController.view.topAnchor.constraint(equalTo: stackView.topAnchor), + hostingController.view.leadingAnchor.constraint(equalTo: stackView.leadingAnchor), + hostingController.view.trailingAnchor.constraint(equalTo: stackView.trailingAnchor), hostingController.view.heightAnchor.constraint(equalTo: hostingController.view.widthAnchor) ] )