mirror of
https://github.com/neon443/StickerSlack.git
synced 2026-11-30 12:44:51 +00:00
50 lines
1.2 KiB
Swift
50 lines
1.2 KiB
Swift
//
|
|
// EmojiCollectionView.swift
|
|
// StickerSlack
|
|
//
|
|
// Created by neon443 on 24/04/2026.
|
|
//
|
|
|
|
import Foundation
|
|
import UIKit
|
|
import SwiftUI
|
|
|
|
struct EmojiCollectionView: UIViewRepresentable {
|
|
let hoarder: EmojiHoarder
|
|
let items: [String]
|
|
|
|
func makeUIView(context: Context) -> UICollectionView {
|
|
let collectionView = context.coordinator as UICollectionViewController
|
|
collectionView.collectionView.register(EmojiCollectionViewCell.self, forCellWithReuseIdentifier: "cell")
|
|
collectionView.collectionView.dataSource = context.coordinator
|
|
return collectionView.collectionView
|
|
}
|
|
|
|
func updateUIView(_ uiView: UICollectionView, context: Context) {
|
|
context.coordinator.hoarder = hoarder
|
|
context.coordinator.items = items
|
|
uiView.reloadData()
|
|
}
|
|
|
|
func makeCoordinator() -> Coordinator {
|
|
Coordinator(hoarder: hoarder, items: items)
|
|
}
|
|
|
|
final class Coordinator: UICollectionViewController {
|
|
var hoarder: EmojiHoarder
|
|
var items: [String]
|
|
|
|
init(hoarder: EmojiHoarder, items: [String]) {
|
|
self.hoarder = hoarder
|
|
self.items = items
|
|
|
|
super.init(collectionViewLayout: UICollectionViewFlowLayout())
|
|
}
|
|
|
|
required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
}
|
|
}
|
|
|