updated emojitableview to:

use a custom tableviewcell
supports ios 15
need to fix random order when scrolling fast
This commit is contained in:
neon443 committed 2026-04-11 00:14:39 +01:00
1 parent 39c8457c3e
commit 6bcef5c8dd
3 files changed
+76 -33

No files matched your search

+6
View File
@@ -119,6 +119,8 @@
A9C52F752F89A93D00078588 /* URL.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C52F742F89A93D00078588 /* URL.swift */; };
A9C52F762F89A93D00078588 /* URL.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C52F742F89A93D00078588 /* URL.swift */; };
A9C52F772F89A9BF00078588 /* URL.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C52F742F89A93D00078588 /* URL.swift */; };
A9C52F792F89BB0800078588 /* EmojiCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C52F782F89BB0800078588 /* EmojiCell.swift */; };
A9C52F7A2F89BB0800078588 /* EmojiCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C52F782F89BB0800078588 /* EmojiCell.swift */; };
A9CD6C352EDDE22800B7F421 /* EmojiPackDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9CD6C342EDDE22800B7F421 /* EmojiPackDetailView.swift */; };
A9CD6C362EDDE22800B7F421 /* EmojiPackDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9CD6C342EDDE22800B7F421 /* EmojiPackDetailView.swift */; };
A9CD6C382EDDE37500B7F421 /* EmojiPackManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9CD6C372EDDE37500B7F421 /* EmojiPackManager.swift */; };
@@ -229,6 +231,7 @@
A9C52F6E2F89A22000078588 /* Wiggle.metal */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.metal; path = Wiggle.metal; sourceTree = "<group>"; };
A9C52F712F89A85F00078588 /* ShareSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareSheet.swift; sourceTree = "<group>"; };
A9C52F742F89A93D00078588 /* URL.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URL.swift; sourceTree = "<group>"; };
A9C52F782F89BB0800078588 /* EmojiCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiCell.swift; sourceTree = "<group>"; };
A9CD6C342EDDE22800B7F421 /* EmojiPackDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPackDetailView.swift; sourceTree = "<group>"; };
A9CD6C372EDDE37500B7F421 /* EmojiPackManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPackManager.swift; sourceTree = "<group>"; };
A9D15B892EB1142C00404792 /* EmojiPack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPack.swift; sourceTree = "<group>"; };
@@ -341,6 +344,7 @@
children = (
A9EB72382EB93FDB00658CEB /* EmojiTableView.swift */,
A9C52F712F89A85F00078588 /* ShareSheet.swift */,
A9C52F782F89BB0800078588 /* EmojiCell.swift */,
);
path = UIKit;
sourceTree = "<group>";
@@ -694,6 +698,7 @@
A9A7A4482F68361200BB84C6 /* Meta.swift in Sources */,
A995D95C2F6EBBDD0043E5F5 /* TestStructures.swift in Sources */,
A9BE30FE2F5FA47100A57668 /* Hoarder.swift in Sources */,
A9C52F792F89BB0800078588 /* EmojiCell.swift in Sources */,
A9C52F722F89A85F00078588 /* ShareSheet.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -763,6 +768,7 @@
A9EC46AD2F6D9E4600E066E6 /* Hoarder.swift in Sources */,
A9A7A4682F6AA17C00BB84C6 /* Int.swift in Sources */,
A9C172DC2EB8C9AC008A7885 /* Trie.swift in Sources */,
A9C52F7A2F89BB0800078588 /* EmojiCell.swift in Sources */,
A957C1752ECCE2CE00EA3EE9 /* SettingsView.swift in Sources */,
A9CD6C362EDDE22800B7F421 /* EmojiPackDetailView.swift in Sources */,
A9EB72472EB948C400658CEB /* StickerRow.swift in Sources */,
+61
View File
@@ -0,0 +1,61 @@
//
// EmojiCell.swift
// StickerSlack
//
// Created by neon443 on 11/04/2026.
//
import Foundation
import UIKit
import SwiftUI
class EmojiCell: UITableViewCell {
private var spinner: UIActivityIndicatorView = UIActivityIndicatorView(style: .large)
private var hostingController: UIHostingController<StickerRow<EmojiHoarder>>?
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
spinner.startAnimating()
spinner.frame = frame
addSubview(spinner)
spinner.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)
])
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func configure(with hoarder: EmojiHoarder, emoji: Emoji) {
let swiftUIView = StickerRow(hoarder: hoarder, sticker: emoji)
spinner.removeFromSuperview()
if let hostingController {
hostingController.rootView = swiftUIView
} else {
let controller = UIHostingController(rootView: swiftUIView)
hostingController = controller
contentView.addSubview(controller.view)
controller.view.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
controller.view.topAnchor.constraint(equalTo: contentView.topAnchor),
controller.view.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),
controller.view.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
controller.view.trailingAnchor.constraint(equalTo: contentView.trailingAnchor)
])
}
}
override func prepareForReuse() {
spinner.removeFromSuperview()
super.prepareForReuse()
}
}
+9 -33
View File
@@ -16,7 +16,7 @@ struct EmojiTableView: UIViewRepresentable {
func makeUIView(context: Context) -> UITableView {
let tableView = context.coordinator as UITableViewController
tableView.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
tableView.tableView.register(EmojiCell.self, forCellReuseIdentifier: "cell")
tableView.tableView.dataSource = context.coordinator
tableView.tableView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 50, right: 0)
tableView.tableView.separatorStyle = .none
@@ -52,29 +52,17 @@ struct EmojiTableView: UIViewRepresentable {
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard !hoarder.trie.dict.isEmpty else {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
let spinner = UIActivityIndicatorView()
spinner.startAnimating()
spinner.style = .large
spinner.frame = cell.frame
spinner.autoresizingMask = .flexibleWidth
cell.addSubview(spinner)
return cell
}
let emojiName = items[indexPath.row]
let emoji = hoarder.trie.dict[emojiName]!
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
cell.selectedBackgroundView = nil
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! EmojiCell
cell.selectionStyle = .none
let swiftUIView = StickerRow(hoarder: hoarder, sticker: emoji).id(emoji)
let hostingController = UIHostingController(rootView: swiftUIView)
hostingController.view.frame = cell.frame
hostingController.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
cell.addSubview(hostingController.view)
guard !hoarder.trie.dict.isEmpty else {
return cell
}
let emojiName = items[indexPath.row]
let emoji = hoarder.trie.dict[emojiName]!
cell.configure(with: hoarder, emoji: emoji)
return cell
}
@@ -91,15 +79,3 @@ struct EmojiTableView: UIViewRepresentable {
}
}
}
//
//class EmojiCell: UITableViewCell {
// override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
// let l = UILabel()
// l.text = "ifosa"
// self.view = l
// }
//
// required init?(coder: NSCoder) {
// fatalError("init(coder:) has not been implemented")
// }
//}
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.