Files
StickerSlack/StickerSlackiMessageApp/MessagesPackListView.swift
T
Nihaal Sharma 8b87febd30 YAYAYYAAY FIXED THE STUPID STATE ISSUES AND SWITCHING PACKS
updated rootviewcontroller to remove previous trailingvc and add new one
added proper reload function that rebuilds the sticker array
updated the subtitle for packs, slightly smaller and gray font
2026-07-31 00:57:13 +05:30

57 lines
1.5 KiB
Swift

//
// MessagesPackListView.swift
// StickerSlackiMessageApp
//
// Created by neon443 on 24/07/2026.
//
import Foundation
import UIKit
class MessagesPackListView: UITableViewController {
var emojiHoarder: EmojiHoarder!
var onSelect: ((EmojiPack) -> Void)?
init(hoarder: EmojiHoarder) {
self.emojiHoarder = hoarder
super.init(style: .plain)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func packFor(indexPath: IndexPath) -> EmojiPack? {
guard emojiHoarder.emojiPacks.indices.contains(indexPath.row) else { return nil }
return emojiHoarder.emojiPacks[indexPath.row]
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return emojiHoarder.emojiPacks.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell()
var config = cell.defaultContentConfiguration()
if let pack = packFor(indexPath: indexPath) {
config.text = pack.name
config.textProperties.font = UIFont.systemFont(ofSize: 14)
config.secondaryText = pack.description
config.secondaryTextProperties.font = UIFont.systemFont(ofSize: 12)
config.secondaryTextProperties.color = .systemGray
}
cell.contentConfiguration = config
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
onSelect?(emojiHoarder.emojiPacks[indexPath.row])
}
}