added notification posting for uikit ui reactiveness

added dowloadedviewcontroller to recieve updates when data changes
fixed crash due to unregistered reusable cell identifiers
working delete button for multiselect
cleaned up downloadedview
extracted packs logic into an extension file
extracted letterstats into an extension file
This commit is contained in:
Nihaal Sharma committed 2026-07-03 00:27:44 +01:00
1 parent 78b55c2c90
commit 78cca9a052
11 files changed
+286 -176

No files matched your search

+31 -1
View File
@@ -150,6 +150,14 @@
A9CD6C3B2EDDE6B500B7F421 /* EmojiPack.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D15B892EB1142C00404792 /* EmojiPack.swift */; };
A9D15B8B2EB1142C00404792 /* EmojiPack.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D15B892EB1142C00404792 /* EmojiPack.swift */; };
A9D6A8212F7014AE00F198FB /* TestStructures.swift in Sources */ = {isa = PBXBuildFile; fileRef = A995D95A2F6EBBDD0043E5F5 /* TestStructures.swift */; };
A9E8C78F2FF71D8C009A38B5 /* DownloadedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9E8C78E2FF71D8C009A38B5 /* DownloadedViewController.swift */; };
A9E8C7902FF71D8C009A38B5 /* DownloadedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9E8C78E2FF71D8C009A38B5 /* DownloadedViewController.swift */; };
A9E8C79A2FF7256B009A38B5 /* EmojiHoarder.Packs.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9E8C7992FF7256B009A38B5 /* EmojiHoarder.Packs.swift */; };
A9E8C79B2FF7256B009A38B5 /* EmojiHoarder.Packs.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9E8C7992FF7256B009A38B5 /* EmojiHoarder.Packs.swift */; };
A9E8C79C2FF7256B009A38B5 /* EmojiHoarder.Packs.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9E8C7992FF7256B009A38B5 /* EmojiHoarder.Packs.swift */; };
A9E8C79E2FF726DA009A38B5 /* EmojiHoarder.LetterStats.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9E8C79D2FF726D4009A38B5 /* EmojiHoarder.LetterStats.swift */; };
A9E8C79F2FF726DA009A38B5 /* EmojiHoarder.LetterStats.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9E8C79D2FF726D4009A38B5 /* EmojiHoarder.LetterStats.swift */; };
A9E8C7A02FF726DA009A38B5 /* EmojiHoarder.LetterStats.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9E8C79D2FF726D4009A38B5 /* EmojiHoarder.LetterStats.swift */; };
A9EB72392EB93FDB00658CEB /* EmojiTableViewRepresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9EB72382EB93FDB00658CEB /* EmojiTableViewRepresentable.swift */; };
A9EB72472EB948C400658CEB /* StickerRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9EB72462EB948C400658CEB /* StickerRow.swift */; };
A9EB72492EB948C400658CEB /* StickerRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9EB72462EB948C400658CEB /* StickerRow.swift */; };
@@ -269,6 +277,9 @@
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>"; };
A9E2ECD72EB74CE00038B2D6 /* Config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; };
A9E8C78E2FF71D8C009A38B5 /* DownloadedViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DownloadedViewController.swift; sourceTree = "<group>"; };
A9E8C7992FF7256B009A38B5 /* EmojiHoarder.Packs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiHoarder.Packs.swift; sourceTree = "<group>"; };
A9E8C79D2FF726D4009A38B5 /* EmojiHoarder.LetterStats.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiHoarder.LetterStats.swift; sourceTree = "<group>"; };
A9EB72382EB93FDB00658CEB /* EmojiTableViewRepresentable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiTableViewRepresentable.swift; sourceTree = "<group>"; };
A9EB72462EB948C400658CEB /* StickerRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StickerRow.swift; sourceTree = "<group>"; };
A9EB724C2EB94A6B00658CEB /* TrieTestingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrieTestingView.swift; sourceTree = "<group>"; };
@@ -385,6 +396,7 @@
A94F3E642F9E385300FA6995 /* CollectionView */,
A9C52F712F89A85F00078588 /* ShareSheet.swift */,
A9FB3EE22FA7AB3A00030E2A /* UIKitGifView.swift */,
A9E8C78E2FF71D8C009A38B5 /* DownloadedViewController.swift */,
);
path = UIKit;
sourceTree = "<group>";
@@ -422,6 +434,7 @@
A9BE30EB2F5AFE1E00A57668 /* StickerType.swift */,
A9BE30F42F5B011400A57668 /* Stickers */,
A9BE30ED2F5B003A00A57668 /* Gifs */,
A9E8C7942FF72550009A38B5 /* EmojiHoarder */,
A949B1F92EA0517800215164 /* Emoji */,
A91C09892EBBD75A00210C34 /* Trie */,
A9104C812EB4022E00D160EA /* Extensions */,
@@ -437,7 +450,6 @@
isa = PBXGroup;
children = (
A924C3712EA9127200F20781 /* Emoji.swift */,
A949B1F72EA04F2300215164 /* EmojiHoarder.swift */,
A91C098B2EBBD78700210C34 /* Categorisation */,
A957C1792ECE542D00EA3EE9 /* GifManager.swift */,
A957C17D2ECFAA1100EA3EE9 /* GifView.swift */,
@@ -544,6 +556,16 @@
path = Stickers;
sourceTree = "<group>";
};
A9E8C7942FF72550009A38B5 /* EmojiHoarder */ = {
isa = PBXGroup;
children = (
A949B1F72EA04F2300215164 /* EmojiHoarder.swift */,
A9E8C7992FF7256B009A38B5 /* EmojiHoarder.Packs.swift */,
A9E8C79D2FF726D4009A38B5 /* EmojiHoarder.LetterStats.swift */,
);
path = EmojiHoarder;
sourceTree = "<group>";
};
A9F423C32F87229100C0BE3B /* Shared */ = {
isa = PBXGroup;
children = (
@@ -718,12 +740,14 @@
A949B1F42EA04E8200215164 /* ContentView.swift in Sources */,
A9CD6C382EDDE37500B7F421 /* EmojiPackManager.swift in Sources */,
A9FB3EE42FA7AB3A00030E2A /* UIKitGifView.swift in Sources */,
A9E8C79E2FF726DA009A38B5 /* EmojiHoarder.LetterStats.swift in Sources */,
A949B1F52EA04E8200215164 /* StickerSlackApp.swift in Sources */,
A9A7A4452F68360900BB84C6 /* Pagination.swift in Sources */,
A9104C802EB4022500D160EA /* MSSticker.swift in Sources */,
A98FA65C2FF3B29700D50212 /* EmojiTableView.swift in Sources */,
A9A7A43F2F6835F800BB84C6 /* Trending.swift in Sources */,
A9A7A4422F68360200BB84C6 /* GifObject.swift in Sources */,
A9E8C79A2FF7256B009A38B5 /* EmojiHoarder.Packs.swift in Sources */,
A97322A62FA8CA2B004B657D /* JumboMojiTestView.swift in Sources */,
A975F9192FA38C8D00A5C62E /* EmojiPackGridView.swift in Sources */,
A957C1772ECD008E00EA3EE9 /* Bundle.swift in Sources */,
@@ -764,6 +788,7 @@
A9BE30F22F5B004E00A57668 /* Gif.swift in Sources */,
A917BACF2F9B787B008DB31E /* EmojiCollectionViewRepresentable.swift in Sources */,
A98FA6612FF3BD5400D50212 /* EmojiCollectionView.swift in Sources */,
A9E8C78F2FF71D8C009A38B5 /* DownloadedViewController.swift in Sources */,
A9BE30EC2F5AFE1E00A57668 /* StickerType.swift in Sources */,
A9A7A4482F68361200BB84C6 /* Meta.swift in Sources */,
A995D95C2F6EBBDD0043E5F5 /* TestStructures.swift in Sources */,
@@ -787,6 +812,7 @@
A9EB724B2EB94A5700658CEB /* Trie.swift in Sources */,
A9BDEAE02F82BCB4002798DF /* NoStickersView.swift in Sources */,
A9BE30FA2F5B03F400A57668 /* Sticker.swift in Sources */,
A9E8C79B2FF7256B009A38B5 /* EmojiHoarder.Packs.swift in Sources */,
A986A6CD2EB659E000B6E0FA /* MessagesViewController.swift in Sources */,
A9A7A4572F69568700BB84C6 /* GifHoarder.swift in Sources */,
A9BE30FF2F5FA78E00A57668 /* Hoarder.swift in Sources */,
@@ -805,6 +831,7 @@
A9D6A8212F7014AE00F198FB /* TestStructures.swift in Sources */,
A9BBC5192EB8FA4500FFE82F /* ViewModifiers.swift in Sources */,
A986A6C42EB6598500B6E0FA /* SlackResponse.swift in Sources */,
A9E8C79F2FF726DA009A38B5 /* EmojiHoarder.LetterStats.swift in Sources */,
A986A6C22EB6597600B6E0FA /* Emoji.swift in Sources */,
A986A6C12EB6595F00B6E0FA /* EmojiHoarder.swift in Sources */,
);
@@ -821,6 +848,7 @@
A9C52F762F89A93D00078588 /* URL.swift in Sources */,
A9B9A8302EB2CD0B004C9245 /* Emoji.swift in Sources */,
A9C52F702F89A22000078588 /* Wiggle.metal in Sources */,
A9E8C79C2FF7256B009A38B5 /* EmojiHoarder.Packs.swift in Sources */,
A955B3F12EC22E9700E1732D /* BrowseView.swift in Sources */,
A9A7A4402F6835F800BB84C6 /* Trending.swift in Sources */,
A975F9212FA52B3600A5C62E /* AddToPackMenuView.swift in Sources */,
@@ -839,6 +867,7 @@
A98BD15C2FF5242700ADC264 /* EmojiPackPreview.swift in Sources */,
A9BBC51A2EB8FA4500FFE82F /* ViewModifiers.swift in Sources */,
A995D95B2F6EBBDD0043E5F5 /* TestStructures.swift in Sources */,
A9E8C7A02FF726DA009A38B5 /* EmojiHoarder.LetterStats.swift in Sources */,
A955B3ED2EC22C4A00E1732D /* DownloadedView.swift in Sources */,
A9EC46AD2F6D9E4600E066E6 /* Hoarder.swift in Sources */,
A9A7A4682F6AA17C00BB84C6 /* Int.swift in Sources */,
@@ -851,6 +880,7 @@
A9CD6C362EDDE22800B7F421 /* EmojiPackDetailView.swift in Sources */,
A9EB72472EB948C400658CEB /* StickerRow.swift in Sources */,
A9CD6C392EDDE37500B7F421 /* EmojiPackManager.swift in Sources */,
A9E8C7902FF71D8C009A38B5 /* DownloadedViewController.swift in Sources */,
A955B3F62EC22EE900E1732D /* SearchView.swift in Sources */,
A97322A52FA8CA2B004B657D /* JumboMojiTestView.swift in Sources */,
A98FA6622FF3BD5400D50212 /* EmojiCollectionView.swift in Sources */,
@@ -0,0 +1,57 @@
//
// EmojiHoarder.LetterStats.swift
// StickerSlack
//
// Created by neon443 on 03/07/2026.
//
import Foundation
extension EmojiHoarder {
func generateLetterStats() {
var result: [EmojiHoarder.LetterStat] = []
for child in trie.root.children {
let count = trie.collectWords(startingWith: child.key, from: child.value).count
let stat = LetterStat(char: child.key, count: count)
result.append(stat)
}
self.letterStats = result
sortLetterStats(by: self.letterStatsSorting)
}
func sortLetterStats(by: EmojiHoarder.LetterStatSorting) {
self.letterStatsSorting = by
let sortByLetter = letterStatsSorting.by == .letter
switch by.ascending {
case true:
letterStats.sort {
if sortByLetter {
$0.char > $1.char
} else {
$0.count > $1.count
}
}
case false:
letterStats.sort {
if sortByLetter {
$0.char > $1.char
} else {
$0.count < $1.count
}
}
}
}
struct LetterStat: Hashable {
var char: String
var count: Int
}
enum SortLetterStatsBy: String, CaseIterable {
case letter = "Letter"
case count = "Count"
}
struct LetterStatSorting: Hashable, Equatable {
var by: EmojiHoarder.SortLetterStatsBy = .count
var ascending: Bool = true
}
}
@@ -0,0 +1,71 @@
//
// EmojiHoarder.Packs.swift
// StickerSlack
//
// Created by neon443 on 03/07/2026.
//
import Foundation
import SwiftUI
extension EmojiHoarder {
func loadEmojiPacks() {
guard let data = try? Data(contentsOf: Self.packStore),
let decoded = try? decoder.decode([URL].self, from: data) else { return }
self.emojiPacks = decoded.map {
EmojiPack(fromShareLink: $0) ?? .new()
}
sendChangeNotif(for: .emojiPacks)
}
func saveEmojiPacks() {
var toStore: [URL] = []
for pack in emojiPacks {
toStore.append(pack.shareLink())
}
guard let encoded = try? encoder.encode(toStore) else { return }
try? encoded.write(to: Self.packStore)
}
func newEmojiPack(withItems items: [String] = []) {
addEmojiPack(.new(withItems: items))
sendChangeNotif(for: .emojiPacks)
}
func addEmojiPack(_ packToAdd: EmojiPack) {
var packToAdd = packToAdd
if emojiPacks.contains(where: { $0.id == packToAdd.id }) {
packToAdd.id = UUID()
}
withAnimation {
emojiPacks.append(packToAdd)
}
sendChangeNotif(for: .emojiPacks)
saveEmojiPacks()
}
func removeEmojiPack(_ packToRemove: EmojiPack) {
withAnimation {
emojiPacks.removeAll { $0.id == packToRemove.id }
}
sendChangeNotif(for: .emojiPack(packToRemove))
sendChangeNotif(for: .emojiPacks)
saveEmojiPacks()
}
func removeEmojiPack(atOffsets offset: IndexSet) {
withAnimation {
emojiPacks.remove(atOffsets: offset)
}
sendChangeNotif(for: .emojiPacks)
saveEmojiPacks()
}
func moveEmojiPacks(fromOffsets: IndexSet, toOffset: Int) {
withAnimation {
emojiPacks.move(fromOffsets: fromOffsets, toOffset: toOffset)
}
sendChangeNotif(for: .emojiPacks)
saveEmojiPacks()
}
}
@@ -41,6 +41,7 @@ import Haptics
loadEmojiPacks()
self.emojis = loadLocalDB()
sendChangeNotif(for: .emojis)
self.trie.dict = loadTrieDict()
startLoading(localOnly: localOnly, skipIndex: skipIndex)
@@ -64,48 +65,6 @@ import Haptics
}
}
func downloadAllStickers() async {
let start: Date = .now
// let dict = trie.dict
// let allStickers = Set(emojis.map { $0.name })
// let downloadedStickers = downloadedStickers
// let toDownload = allStickers.filter { !downloadedStickers.contains($0) }
//
// await withTaskGroup { group in
// for name in toDownload {
// group.addTask {
// await self.download(emoji: dict[name], skipStoreIndex: true)
// }
// }
// }
// await buildDownloadedStickers()
let cores = ProcessInfo.processInfo.processorCount-1
var ranges: [Range<Int>] = []
for i in 0..<cores {
let onething = emojis.count/cores
ranges.append(onething*i..<onething + (onething*i))
if i == (0..<cores).last {
let last = ranges.last!
ranges.removeLast()
ranges.append(onething*i..<(onething + (onething*i)+emojis.count-last.upperBound))
}
}
await withTaskGroup { group in
for range in ranges {
group.addTask {
for i in range {
await self.download(emoji: self.emojis[i], skipStoreIndex: true)
}
}
}
}
print(Date.now.timeIntervalSince(start))
}
func deleteAllStickers() async {
await withTaskGroup { group in
for i in emojis.indices {
@@ -118,6 +77,7 @@ import Haptics
await MainActor.run {
downloadedStickers = []
downloadedStickersArr = []
sendChangeNotif(for: .downloadedEmojis)
}
}
@@ -133,6 +93,7 @@ import Haptics
try? FileManager.default.removeItem(at: EmojiHoarder.localTrieDict)
downloadedStickers = []
sendChangeNotif(for: .downloadedEmojis)
letterStats = []
}
@@ -172,6 +133,7 @@ import Haptics
nonisolated override func buildDownloadedStickers(for stickerType: String = "Emojis") async {
await super.buildDownloadedStickers(for: stickerType)
downloadedStickersArr = await Array(downloadedStickers).sorted()
sendChangeNotif(for: .downloadedEmojis)
}
private func loadLocalDB() -> [Emoji] {
@@ -192,6 +154,7 @@ import Haptics
await fetched != self.emojis {
await MainActor.run {
withAnimation(.snappy) { self.emojis = fetched }
sendChangeNotif(for: .emojis)
}
}
}
@@ -208,6 +171,35 @@ import Haptics
}
}
//MARK: emojis
func downloadAllStickers() async {
let start: Date = .now
let cores = ProcessInfo.processInfo.processorCount-1
var ranges: [Range<Int>] = []
for i in 0..<cores {
let onething = emojis.count/cores
ranges.append(onething*i..<onething + (onething*i))
if i == (0..<cores).last {
let last = ranges.last!
ranges.removeLast()
ranges.append(onething*i..<(onething + (onething*i)+emojis.count-last.upperBound))
}
}
await withTaskGroup { group in
for range in ranges {
group.addTask {
for i in range {
await self.download(emoji: self.emojis[i], skipStoreIndex: true)
}
}
}
}
print(Date.now.timeIntervalSince(start))
}
nonisolated func batchDownload(emojis emojisToDownload: [any StickerProtocol]) async {
await withTaskGroup { group in
for emoji in emojisToDownload {
@@ -229,6 +221,7 @@ import Haptics
let _ = withAnimation(.snappy) {
self.downloadedStickers.insert(emoji.name)
self.downloadedStickersArr.append(emoji.name)
sendChangeNotif(for: .downloadedEmojis)
}
}
}
@@ -242,9 +235,6 @@ import Haptics
}
}
}
// for emoji in emojisToDelete {
// await delete(emoji: emoji, skipStoreIndex: true)
// }
await buildDownloadedStickers()
}
@@ -257,6 +247,7 @@ import Haptics
let _ = withAnimation(.snappy) {
downloadedStickers.remove(emoji.name)
downloadedStickersArr.removeAll(where: { $0 == emoji.name })
sendChangeNotif(for: .downloadedEmojis)
}
}
}
@@ -267,103 +258,38 @@ import Haptics
self.showWelcome = newValue
}
func loadEmojiPacks() {
guard let data = try? Data(contentsOf: Self.packStore),
let decoded = try? decoder.decode([URL].self, from: data) else { return }
self.emojiPacks = decoded.map {
EmojiPack(fromShareLink: $0) ?? .new()
//MARK: notifications
func sendChangeNotif(for notifFor: NotifCategory) {
let nc = NotificationCenter.default
switch notifFor {
case .emojis:
nc.post(name: notifFor.name, object: nil)
case .downloadedEmojis:
nc.post(name: notifFor.name, object: nil)
case .emojiPacks:
nc.post(name: notifFor.name, object: nil)
case .emojiPack(let emojiPack):
nc.post(name: notifFor.name, object: nil)
}
}
func saveEmojiPacks() {
var toStore: [URL] = []
for pack in emojiPacks {
toStore.append(pack.shareLink())
}
guard let encoded = try? encoder.encode(toStore) else { return }
try? encoded.write(to: Self.packStore)
}
func newEmojiPack(withItems items: [String] = []) {
addEmojiPack(.new(withItems: items))
}
func addEmojiPack(_ packToAdd: EmojiPack) {
var packToAdd = packToAdd
if emojiPacks.contains(where: { $0.id == packToAdd.id }) {
packToAdd.id = UUID()
}
withAnimation {
emojiPacks.append(packToAdd)
}
saveEmojiPacks()
}
func removeEmojiPack(_ packToRemove: EmojiPack) {
withAnimation {
emojiPacks.removeAll { $0.id == packToRemove.id }
}
saveEmojiPacks()
}
func removeEmojiPack(atOffsets offset: IndexSet) {
withAnimation {
emojiPacks.remove(atOffsets: offset)
}
saveEmojiPacks()
}
func moveEmojiPacks(fromOffsets: IndexSet, toOffset: Int) {
withAnimation {
emojiPacks.move(fromOffsets: fromOffsets, toOffset: toOffset)
}
saveEmojiPacks()
}
func generateLetterStats() {
var result: [EmojiHoarder.LetterStat] = []
for child in trie.root.children {
let count = trie.collectWords(startingWith: child.key, from: child.value).count
let stat = LetterStat(char: child.key, count: count)
result.append(stat)
}
self.letterStats = result
sortLetterStats(by: self.letterStatsSorting)
}
func sortLetterStats(by: EmojiHoarder.LetterStatSorting) {
self.letterStatsSorting = by
let sortByLetter = letterStatsSorting.by == .letter
switch by.ascending {
case true:
letterStats.sort {
if sortByLetter {
$0.char > $1.char
} else {
$0.count > $1.count
}
}
case false:
letterStats.sort {
if sortByLetter {
$0.char > $1.char
} else {
$0.count < $1.count
}
enum NotifCategory {
case emojis
case downloadedEmojis
case emojiPacks
case emojiPack(EmojiPack)
var name: Notification.Name {
switch self {
case .emojis:
Notification.Name("EmojiHoarder.notif.emojis")
case .downloadedEmojis:
Notification.Name("EmojiHoarder.notif.downloadedEmojis")
case .emojiPacks:
Notification.Name("EmojiHoarder.notif.emojiPacks")
case .emojiPack(let emojiPack):
Notification.Name("EmojiHoarder.notif.emojiPack.\(emojiPack.id)")
}
}
}
struct LetterStat: Hashable {
var char: String
var count: Int
}
enum SortLetterStatsBy: String, CaseIterable {
case letter = "Letter"
case count = "Count"
}
struct LetterStatSorting: Hashable, Equatable {
var by: EmojiHoarder.SortLetterStatsBy = .count
var ascending: Bool = true
}
}
-1
View File
@@ -22,7 +22,6 @@ protocol Hoarder: ObservableObject {
}
@Observable class BaseHoarder: Hoarder {
static let library: URL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.com.neon443.StickerSlack")!.appendingPathComponent("Library", conformingTo: .directory)
var downloadedStickers: Set<String> = []
+13 -13
View File
@@ -11,21 +11,21 @@ struct DownloadedView: View {
@ObservedObject var emojiHoarder: EmojiHoarder
@ObservedObject var gifHoarder: GifHoarder
@Environment(\.colorScheme) var colorScheme
var isDark: Bool { colorScheme == .dark }
@State var browseWhat: StickerType = .slackEmoji
// @Environment(\.colorScheme) var colorScheme
// var isDark: Bool { colorScheme == .dark }
@State private var browseWhat: StickerType = .slackEmoji
@State var showShare: Bool = false
// @State var showShare: Bool = false
var minColWidth: CGFloat { 75 }
var spacing: CGFloat { 5 }
var col: GridItem {
GridItem(
.flexible(minimum: minColWidth, maximum: 100),
spacing: spacing,
alignment: .center
)
}
// var minColWidth: CGFloat { 75 }
// var spacing: CGFloat { 5 }
// var col: GridItem {
// GridItem(
// .flexible(minimum: minColWidth, maximum: 100),
// spacing: spacing,
// alignment: .center
// )
// }
var body: some View {
Picker("", selection: $browseWhat) {
@@ -67,24 +67,20 @@ struct EmojiPackManager: View {
EditButton()
}
#if compiler(>=6.2)
if #available(iOS 19, *) {
ToolbarSpacer()
}
#endif
ToolbarItem(placement: .topBarLeading) {
Button("", systemImage: "trash") {
showDeleteAlert.toggle()
for pack in selection {
hoarder.removeEmojiPack(pack)
}
selection = []
}
.disabled(selection.isEmpty)
// .confirmationDialog("These items will be deleted immediately", isPresented: $showDeleteAlert) {
// Button("Delete \(selection.count) pack\(selection.count.plural)", role: .destructive) {
// for pack in selection {
// hoarder.removeEmojiPack(pack)
// }
// }
// } message: {
// Text("This action cannot be undone")
// }
}
}
}
@@ -40,6 +40,10 @@ final class EmojiCollectionView: UICollectionViewController, UICollectionViewDel
super.init(collectionViewLayout: layout)
collectionView.register(PlainEmojiCollectionViewCell.self, forCellWithReuseIdentifier: "plain")
collectionView.register(EmojiCollectionViewCell.self, forCellWithReuseIdentifier: "full")
collectionView.delegate = self
self.dataSource = UICollectionViewDiffableDataSource<Int, String>(collectionView: collectionView) { (collectionView: UICollectionView, indexPath: IndexPath, itemIdentifier: String) -> UICollectionViewCell? in
self.collectionView(collectionView, cellForItemAt: indexPath)
}
@@ -74,7 +78,7 @@ final class EmojiCollectionView: UICollectionViewController, UICollectionViewDel
self.refreshUI(edit: edit, with: items)
}
func refreshUI(edit: Bool?, with items: [String]) {
func refreshUI(edit: Bool? = false, with items: [String]) {
self.edit = edit
if edit ?? false {
self.startAnimating()
@@ -21,9 +21,6 @@ struct EmojiCollectionViewRepresentable: UIViewRepresentable {
func makeUIView(context: Context) -> UICollectionView {
let collectionView = context.coordinator as UICollectionViewController
collectionView.collectionView.register(PlainEmojiCollectionViewCell.self, forCellWithReuseIdentifier: "plain")
collectionView.collectionView.register(EmojiCollectionViewCell.self, forCellWithReuseIdentifier: "full")
collectionView.collectionView.delegate = context.coordinator
return collectionView.collectionView
}
@@ -0,0 +1,37 @@
//
// DownloadedViewController.swift
// StickerSlack
//
// Created by neon443 on 02/07/2026.
//
import Foundation
import UIKit
class DownloadedViewController: UINavigationController, UINavigationControllerDelegate {
let downloadedView: EmojiCollectionView
var emojiHoarder: EmojiHoarder
init(emojiHoarder: EmojiHoarder) {
self.emojiHoarder = emojiHoarder
downloadedView = EmojiCollectionView(
hoarder: emojiHoarder,
items: emojiHoarder.downloadedStickersArr,
width: 75,
style: .plainWithMenu
)
downloadedView.navigationItem.title = "Saved"
super.init(rootViewController: downloadedView)
NotificationCenter.default.addObserver(self, selector: #selector(downloadedEmojisChanged), name: EmojiHoarder.NotifCategory.downloadedEmojis.name, object: nil)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
@objc
func downloadedEmojisChanged(_ notification: Notification) {
downloadedView.refreshUI(with: emojiHoarder.downloadedStickersArr)
}
}
+2 -9
View File
@@ -41,15 +41,8 @@ final class TabbedContentView: UITabBarController {
packs.tabBarItem = UITabBarItem(title: "Packs", image: UIImage(systemName: "square.stack.3d.up.fill"), tag: 1)
let downloadedView = EmojiCollectionView(
hoarder: emojiHoarder,
items: emojiHoarder.downloadedStickersArr,
width: 75,
style: .plainWithMenu
)
let downloaded = UINavigationController(rootViewController: downloadedView)
downloadedView.navigationItem.title = "Downloaded"
downloaded.tabBarItem = UITabBarItem(title: "Downloaded", image: UIImage(systemName: "arrow.down.circle.fill"), tag: 2)
let downloaded = DownloadedViewController(emojiHoarder: emojiHoarder)
downloaded.tabBarItem = UITabBarItem(title: "Saved", image: UIImage(systemName: "arrow.down.circle.fill"), tag: 2)
let settingsView = SettingsView(hoarder: emojiHoarder)
let settings = UIHostingController(rootView: settingsView)
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.