mirror of
https://github.com/neon443/StickerSlack.git
synced 2026-11-30 12:44:51 +00:00
fucked collection view ...
This commit is contained in:
3 files changed
+16
-12
No files matched your search
@@ -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
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -10,6 +10,7 @@ import UIKit
|
||||
import SwiftUI
|
||||
|
||||
class PlainEmojiCollectionViewCell: UICollectionViewCell {
|
||||
let stackView = UIStackView()
|
||||
let spinner = UIActivityIndicatorView()
|
||||
var hostingController: UIHostingController<StickerPreview>?
|
||||
|
||||
@@ -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)
|
||||
]
|
||||
)
|
||||
|
||||