fixed again

This commit is contained in:
neon443 committed 2026-04-29 00:03:55 +01:00
1 parent e75e275674
commit be185eb3b3
1 file changed
+16 -17
@@ -11,7 +11,7 @@ import SwiftUI
class PlainEmojiCollectionViewCell: UICollectionViewCell { class PlainEmojiCollectionViewCell: UICollectionViewCell {
let stackView = UIStackView() let stackView = UIStackView()
let spinner = UIActivityIndicatorView() // let spinner = UIActivityIndicatorView()
var hostingController: UIHostingController<StickerPreview>? var hostingController: UIHostingController<StickerPreview>?
override init(frame: CGRect) { override init(frame: CGRect) {
@@ -37,41 +37,40 @@ class PlainEmojiCollectionViewCell: UICollectionViewCell {
} }
func configureSkeleton() { func configureSkeleton() {
spinner.startAnimating() // spinner.startAnimating()
if spinner.superview == nil { // if spinner.superview == nil {
stackView.addArrangedSubview(spinner) // stackView.addArrangedSubview(spinner)
} // }
} }
func configure(with: EmojiHoarder, emoji: Emoji) { func configure(with: EmojiHoarder, emoji: Emoji) {
spinner.stopAnimating() hostingController?.view.removeFromSuperview()
spinner.removeFromSuperview()
let swiftUIView = StickerPreview(sticker: emoji) let swiftUIView = StickerPreview(sticker: emoji)
if let hostingController, // if let hostingController {
hostingController.view.superview != nil { // hostingController.rootView = swiftUIView
hostingController.rootView = swiftUIView // } else {
} else {
let hostingController = UIHostingController(rootView: swiftUIView) let hostingController = UIHostingController(rootView: swiftUIView)
self.hostingController = hostingController self.hostingController = hostingController
self.stackView.addArrangedSubview(hostingController.view) self.stackView.insertArrangedSubview(hostingController.view, at: 0)
hostingController.view.translatesAutoresizingMaskIntoConstraints = false hostingController.view.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([ NSLayoutConstraint.activate([
hostingController.view.heightAnchor.constraint(equalTo: hostingController.view.widthAnchor) hostingController.view.heightAnchor.constraint(equalTo: hostingController.view.widthAnchor)
]) ])
} // }
} }
override func prepareForReuse() { override func prepareForReuse() {
super.prepareForReuse() super.prepareForReuse()
stackView.arrangedSubviews.forEach { // stackView.arrangedSubviews.forEach {
stackView.removeArrangedSubview($0) // stackView.removeArrangedSubview($0)
$0.removeFromSuperview() // $0.removeFromSuperview()
} // }
hostingController?.view.removeFromSuperview() hostingController?.view.removeFromSuperview()
hostingController = nil
configureSkeleton() configureSkeleton()
} }
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.