migrated datasource to tableviewcontroller, disabled selecting cells, set insetgrouped stype

ts lowk mostly works yay
This commit is contained in:
neon443 committed 2026-04-05 00:38:45 +01:00
1 parent 1f937db771
commit 5257c03f49
3 files changed
+32 -10

No files matched your search

+3 -3
View File
@@ -13,9 +13,9 @@ import Haptics
class EmojiHoarder: Hoarder, ObservableObject { class EmojiHoarder: Hoarder, ObservableObject {
static let container: URL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.com.neon443.StickerSlack")!.appendingPathComponent("Library", conformingTo: .directory) 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 localEmojiDB: URL = EmojiHoarder.container.appendingPathComponent("_____localEmojiDB.json", conformingTo: .fileURL)
nonisolated static let localTrie: URL = EmojiHoarder.container.appendingPathComponent("_localTrie.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 localTrieDict: URL = EmojiHoarder.container.appendingPathComponent("_____localTrieDict.json", conformingTo: .fileURL)
let endpoint: URL = URL(string: "https://cachet.dunkirk.sh/emojis")! let endpoint: URL = URL(string: "https://cachet.dunkirk.sh/emojis")!
@Published var emojis: [Emoji] = [] @Published var emojis: [Emoji] = []
+1
View File
@@ -29,6 +29,7 @@ struct SearchView: View {
case .slackEmoji: case .slackEmoji:
EmojiCollectionView(hoarder: hoarder, items: searchResult) EmojiCollectionView(hoarder: hoarder, items: searchResult)
.id(searchResult) .id(searchResult)
.ignoresSafeArea(edges: .bottom)
case .giphyGifs: case .giphyGifs:
Text("uhh") Text("uhh")
} }
+28 -7
View File
@@ -15,10 +15,12 @@ struct EmojiCollectionView: UIViewRepresentable {
let items: [String] let items: [String]
func makeUIView(context: Context) -> UITableView { func makeUIView(context: Context) -> UITableView {
let tableView = UITableView() let tableView = context.coordinator as UITableViewController
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell") tableView.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
tableView.dataSource = context.coordinator tableView.tableView.dataSource = context.coordinator
return tableView 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) { func updateUIView(_ uiView: UITableView, context: Context) {
@@ -31,30 +33,49 @@ struct EmojiCollectionView: UIViewRepresentable {
Coordinator(hoarder: hoarder, items: items) Coordinator(hoarder: hoarder, items: items)
} }
final class Coordinator: NSObject, UITableViewDataSource { final class Coordinator: UITableViewController {
var hoarder: EmojiHoarder var hoarder: EmojiHoarder
var items: [String] var items: [String]
init(hoarder: EmojiHoarder, items: [String]) { init(hoarder: EmojiHoarder, items: [String]) {
self.hoarder = hoarder self.hoarder = hoarder
self.items = items 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 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 emojiName = items[indexPath.row]
let emoji = hoarder.trie.dict[emojiName]! let emoji = hoarder.trie.dict[emojiName]!
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
cell.selectedBackgroundView = nil
cell.selectionStyle = .none
cell.contentConfiguration = UIHostingConfiguration { cell.contentConfiguration = UIHostingConfiguration {
StickerRow(hoarder: hoarder, sticker: emoji) StickerRow(hoarder: hoarder, sticker: emoji)
.id(emoji) .id(emoji)
} }
return cell 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
}
} }
} }
// //
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.