From 5257c03f496d1928cbd067259d48b7abbaa2a77f Mon Sep 17 00:00:00 2001 From: neon443 <69979447+neon443@users.noreply.github.com> Date: Sun, 5 Apr 2026 00:38:45 +0100 Subject: [PATCH] migrated datasource to tableviewcontroller, disabled selecting cells, set insetgrouped stype ts lowk mostly works yay --- StickerSlack/Emoji/EmojiHoarder.swift | 6 ++-- StickerSlack/SwiftUI/SearchView.swift | 1 + StickerSlack/UIKit/EmojiCollectionView.swift | 35 ++++++++++++++++---- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/StickerSlack/Emoji/EmojiHoarder.swift b/StickerSlack/Emoji/EmojiHoarder.swift index 6896de6..af15dae 100644 --- a/StickerSlack/Emoji/EmojiHoarder.swift +++ b/StickerSlack/Emoji/EmojiHoarder.swift @@ -13,9 +13,9 @@ import Haptics class EmojiHoarder: Hoarder, ObservableObject { static let container: URL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.com.neon443.StickerSlack")!.appendingPathComponent("Library", conformingTo: .directory) - nonisolated static let localEmojiDB: URL = EmojiHoarder.container.appendingPathComponent("_localEmojiDB.json", conformingTo: .fileURL) - nonisolated static let localTrie: URL = EmojiHoarder.container.appendingPathComponent("_localTrie.json", conformingTo: .fileURL) - nonisolated static let localTrieDict: URL = EmojiHoarder.container.appendingPathComponent("_localTrieDict.json", conformingTo: .fileURL) + nonisolated static let localEmojiDB: URL = EmojiHoarder.container.appendingPathComponent("_____localEmojiDB.json", conformingTo: .fileURL) + nonisolated static let localTrie: URL = EmojiHoarder.container.appendingPathComponent("_____localTrie.json", conformingTo: .fileURL) + nonisolated static let localTrieDict: URL = EmojiHoarder.container.appendingPathComponent("_____localTrieDict.json", conformingTo: .fileURL) let endpoint: URL = URL(string: "https://cachet.dunkirk.sh/emojis")! @Published var emojis: [Emoji] = [] diff --git a/StickerSlack/SwiftUI/SearchView.swift b/StickerSlack/SwiftUI/SearchView.swift index 7ab61b7..8d9e222 100644 --- a/StickerSlack/SwiftUI/SearchView.swift +++ b/StickerSlack/SwiftUI/SearchView.swift @@ -29,6 +29,7 @@ struct SearchView: View { case .slackEmoji: EmojiCollectionView(hoarder: hoarder, items: searchResult) .id(searchResult) + .ignoresSafeArea(edges: .bottom) case .giphyGifs: Text("uhh") } diff --git a/StickerSlack/UIKit/EmojiCollectionView.swift b/StickerSlack/UIKit/EmojiCollectionView.swift index 83f0d91..9c6423d 100644 --- a/StickerSlack/UIKit/EmojiCollectionView.swift +++ b/StickerSlack/UIKit/EmojiCollectionView.swift @@ -15,10 +15,12 @@ struct EmojiCollectionView: UIViewRepresentable { let items: [String] func makeUIView(context: Context) -> UITableView { - let tableView = UITableView() - tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell") - tableView.dataSource = context.coordinator - return tableView + let tableView = context.coordinator as UITableViewController + tableView.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell") + tableView.tableView.dataSource = context.coordinator + tableView.tableView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 5, right: 0) + tableView.tableView.separatorStyle = .none + return tableView.tableView } func updateUIView(_ uiView: UITableView, context: Context) { @@ -31,30 +33,49 @@ struct EmojiCollectionView: UIViewRepresentable { Coordinator(hoarder: hoarder, items: items) } - final class Coordinator: NSObject, UITableViewDataSource { + final class Coordinator: UITableViewController { var hoarder: EmojiHoarder var items: [String] init(hoarder: EmojiHoarder, items: [String]) { self.hoarder = hoarder self.items = items + super.init(style: .insetGrouped) } - func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return items.count } - func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let emojiName = items[indexPath.row] let emoji = hoarder.trie.dict[emojiName]! let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) + cell.selectedBackgroundView = nil + cell.selectionStyle = .none cell.contentConfiguration = UIHostingConfiguration { StickerRow(hoarder: hoarder, sticker: emoji) .id(emoji) } return cell } + + override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { +// <#code#> + } + + override func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) { +// <#code#> + } + + override func tableView(_ tableView: UITableView, shouldBeginMultipleSelectionInteractionAt indexPath: IndexPath) -> Bool { + return true + } } } //