fucked collection view ...

This commit is contained in:
Nihaal Sharma committed 2026-04-28 22:11:23 +01:00
1 parent 3348e971eb
commit 2ca8569258
3 files changed
+16 -12

No files matched your search

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