mirror of
https://github.com/neon443/StickerSlack.git
synced 2026-11-30 20:54:51 +00:00
masssive changes sob
MUCH faster emojihoarder init, async stuff yaya faster trie building and downloaded sticker building loading spinners if trie.dict is empty put slack emojis in library/slack and giphy in /giphy added a lil info thingy to stickerpicker and a button to open stickerslack if no stickers downloaded update file.contains to have a . when searching for fule name extensions more logging for nil stuff in sticker data source moved picker on browseview out of the overlay fixed the contentinsets for uikit emoji list haptic when u click the confetti thingy for having all the emojis lol consolidated the continue button, added stickerslack icon to welcome view
This commit is contained in:
17 files changed
+252
-95
No files matched your search
@@ -44,7 +44,7 @@
|
||||
A957C17E2ECFAA1100EA3EE9 /* GifView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A957C17D2ECFAA1100EA3EE9 /* GifView.swift */; };
|
||||
A957C17F2ECFAA1100EA3EE9 /* GifView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A957C17D2ECFAA1100EA3EE9 /* GifView.swift */; };
|
||||
A957C1802ECFAA1100EA3EE9 /* GifView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A957C17D2ECFAA1100EA3EE9 /* GifView.swift */; };
|
||||
A9773C2F2EA54AF000F3B753 /* EmojiPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9773C2E2EA54AF000F3B753 /* EmojiPreview.swift */; };
|
||||
A9773C2F2EA54AF000F3B753 /* StickerPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9773C2E2EA54AF000F3B753 /* StickerPreview.swift */; };
|
||||
A986A6AE2EB658DF00B6E0FA /* Messages.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A969D6932EA3E86500399C05 /* Messages.framework */; };
|
||||
A986A6BA2EB658E100B6E0FA /* StickerSlackiMessageApp.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = A986A6AD2EB658DF00B6E0FA /* StickerSlackiMessageApp.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
A986A6C12EB6595F00B6E0FA /* EmojiHoarder.swift in Sources */ = {isa = PBXBuildFile; fileRef = A949B1F72EA04F2300215164 /* EmojiHoarder.swift */; };
|
||||
@@ -91,6 +91,9 @@
|
||||
A9BBC5182EB8FA4500FFE82F /* ViewModifiers.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9BBC5172EB8FA4500FFE82F /* ViewModifiers.swift */; };
|
||||
A9BBC5192EB8FA4500FFE82F /* ViewModifiers.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9BBC5172EB8FA4500FFE82F /* ViewModifiers.swift */; };
|
||||
A9BBC51A2EB8FA4500FFE82F /* ViewModifiers.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9BBC5172EB8FA4500FFE82F /* ViewModifiers.swift */; };
|
||||
A9BDEADE2F82BC93002798DF /* NoStickersView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9BDEADD2F82BC93002798DF /* NoStickersView.swift */; };
|
||||
A9BDEADF2F82BC93002798DF /* NoStickersView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9BDEADD2F82BC93002798DF /* NoStickersView.swift */; };
|
||||
A9BDEAE02F82BCB4002798DF /* NoStickersView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9BDEADD2F82BC93002798DF /* NoStickersView.swift */; };
|
||||
A9BE30EC2F5AFE1E00A57668 /* StickerType.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9BE30EB2F5AFE1E00A57668 /* StickerType.swift */; };
|
||||
A9BE30EF2F5B004800A57668 /* GifHoarder.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9BE30EE2F5B004800A57668 /* GifHoarder.swift */; };
|
||||
A9BE30F02F5B004800A57668 /* GifHoarder.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9BE30EE2F5B004800A57668 /* GifHoarder.swift */; };
|
||||
@@ -121,7 +124,7 @@
|
||||
A9EB724B2EB94A5700658CEB /* Trie.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C172DB2EB8C9AC008A7885 /* Trie.swift */; };
|
||||
A9EB724D2EB94A6B00658CEB /* TrieTestingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9EB724C2EB94A6B00658CEB /* TrieTestingView.swift */; };
|
||||
A9EB724F2EB94A6B00658CEB /* TrieTestingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9EB724C2EB94A6B00658CEB /* TrieTestingView.swift */; };
|
||||
A9EB72502EB94FAD00658CEB /* EmojiPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9773C2E2EA54AF000F3B753 /* EmojiPreview.swift */; };
|
||||
A9EB72502EB94FAD00658CEB /* StickerPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9773C2E2EA54AF000F3B753 /* StickerPreview.swift */; };
|
||||
A9EC46AD2F6D9E4600E066E6 /* Hoarder.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9BE30FD2F5FA47100A57668 /* Hoarder.swift */; };
|
||||
A9EC46AE2F6D9E5800E066E6 /* StickerType.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9BE30EB2F5AFE1E00A57668 /* StickerType.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
@@ -182,7 +185,7 @@
|
||||
A957C1792ECE542D00EA3EE9 /* GifManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GifManager.swift; sourceTree = "<group>"; };
|
||||
A957C17D2ECFAA1100EA3EE9 /* GifView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GifView.swift; sourceTree = "<group>"; };
|
||||
A969D6932EA3E86500399C05 /* Messages.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Messages.framework; path = Library/Frameworks/Messages.framework; sourceTree = DEVELOPER_DIR; };
|
||||
A9773C2E2EA54AF000F3B753 /* EmojiPreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPreview.swift; sourceTree = "<group>"; };
|
||||
A9773C2E2EA54AF000F3B753 /* StickerPreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StickerPreview.swift; sourceTree = "<group>"; };
|
||||
A986A6AD2EB658DF00B6E0FA /* StickerSlackiMessageApp.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = StickerSlackiMessageApp.appex; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
A986A6C62EB659E000B6E0FA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
A986A6C72EB659E000B6E0FA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
@@ -201,6 +204,8 @@
|
||||
A9B9A8232EB2CCB5004C9245 /* StickerSlackTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = StickerSlackTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
A9B9A82C2EB2CCBE004C9245 /* StickerSlackTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StickerSlackTests.swift; sourceTree = "<group>"; };
|
||||
A9BBC5172EB8FA4500FFE82F /* ViewModifiers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewModifiers.swift; sourceTree = "<group>"; };
|
||||
A9BDEADD2F82BC93002798DF /* NoStickersView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoStickersView.swift; sourceTree = "<group>"; };
|
||||
A9BDEAE12F82BFF8002798DF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
|
||||
A9BE30EB2F5AFE1E00A57668 /* StickerType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StickerType.swift; sourceTree = "<group>"; };
|
||||
A9BE30EE2F5B004800A57668 /* GifHoarder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GifHoarder.swift; sourceTree = "<group>"; };
|
||||
A9BE30F12F5B004E00A57668 /* Gif.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Gif.swift; sourceTree = "<group>"; };
|
||||
@@ -290,8 +295,6 @@
|
||||
A91C098C2EBBD7AB00210C34 /* Emoji */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A9773C2E2EA54AF000F3B753 /* EmojiPreview.swift */,
|
||||
A9EB72462EB948C400658CEB /* StickerRow.swift */,
|
||||
A9CD6C342EDDE22800B7F421 /* EmojiPackView.swift */,
|
||||
);
|
||||
path = Emoji;
|
||||
@@ -304,12 +307,15 @@
|
||||
A949B1F02EA04E8200215164 /* ContentView.swift */,
|
||||
A9BBC5172EB8FA4500FFE82F /* ViewModifiers.swift */,
|
||||
A91C098C2EBBD7AB00210C34 /* Emoji */,
|
||||
A955B3EC2EC22C4A00E1732D /* DownloadedView.swift */,
|
||||
A955B3F02EC22E9700E1732D /* BrowseView.swift */,
|
||||
A955B3F42EC22EE900E1732D /* SearchView.swift */,
|
||||
A957C1732ECCE2CE00EA3EE9 /* SettingsView.swift */,
|
||||
A921C2DE2ED067BB00E57B1A /* WelcomeView.swift */,
|
||||
A921C2E12ED071C900E57B1A /* ListRow.swift */,
|
||||
A921C2DE2ED067BB00E57B1A /* WelcomeView.swift */,
|
||||
A9EB72462EB948C400658CEB /* StickerRow.swift */,
|
||||
A957C1732ECCE2CE00EA3EE9 /* SettingsView.swift */,
|
||||
A955B3F42EC22EE900E1732D /* SearchView.swift */,
|
||||
A955B3F02EC22E9700E1732D /* BrowseView.swift */,
|
||||
A9BDEADD2F82BC93002798DF /* NoStickersView.swift */,
|
||||
A955B3EC2EC22C4A00E1732D /* DownloadedView.swift */,
|
||||
A9773C2E2EA54AF000F3B753 /* StickerPreview.swift */,
|
||||
);
|
||||
path = SwiftUI;
|
||||
sourceTree = "<group>";
|
||||
@@ -348,6 +354,7 @@
|
||||
A949B1F22EA04E8200215164 /* StickerSlack */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A9BDEAE12F82BFF8002798DF /* Info.plist */,
|
||||
A9A7A4502F68447F00BB84C6 /* Models */,
|
||||
A924C3742EA9134C00F20781 /* StickerSlack.entitlements */,
|
||||
A949B1F12EA04E8200215164 /* StickerSlackApp.swift */,
|
||||
@@ -628,6 +635,7 @@
|
||||
A955B3EE2EC22C4A00E1732D /* DownloadedView.swift in Sources */,
|
||||
A949B1FB2EA0518800215164 /* SlackResponse.swift in Sources */,
|
||||
A957C17A2ECE542D00EA3EE9 /* GifManager.swift in Sources */,
|
||||
A9BDEADE2F82BC93002798DF /* NoStickersView.swift in Sources */,
|
||||
A955B3F52EC22EE900E1732D /* SearchView.swift in Sources */,
|
||||
A935437B2EB2A3C800BB80A4 /* FilterCategory.swift in Sources */,
|
||||
A9CD6C352EDDE22800B7F421 /* EmojiPackView.swift in Sources */,
|
||||
@@ -645,7 +653,7 @@
|
||||
A9BBC5182EB8FA4500FFE82F /* ViewModifiers.swift in Sources */,
|
||||
A9EB72492EB948C400658CEB /* StickerRow.swift in Sources */,
|
||||
A921C2E22ED071C900E57B1A /* ListRow.swift in Sources */,
|
||||
A9773C2F2EA54AF000F3B753 /* EmojiPreview.swift in Sources */,
|
||||
A9773C2F2EA54AF000F3B753 /* StickerPreview.swift in Sources */,
|
||||
A9BE30F02F5B004800A57668 /* GifHoarder.swift in Sources */,
|
||||
A9BE30F22F5B004E00A57668 /* Gif.swift in Sources */,
|
||||
A9BE30EC2F5AFE1E00A57668 /* StickerType.swift in Sources */,
|
||||
@@ -664,6 +672,7 @@
|
||||
A986A6C32EB6598100B6E0FA /* FilterCategory.swift in Sources */,
|
||||
A9CD6C3A2EDDE6B500B7F421 /* EmojiPack.swift in Sources */,
|
||||
A9EB724B2EB94A5700658CEB /* Trie.swift in Sources */,
|
||||
A9BDEAE02F82BCB4002798DF /* NoStickersView.swift in Sources */,
|
||||
A9BE30FA2F5B03F400A57668 /* Sticker.swift in Sources */,
|
||||
A986A6CD2EB659E000B6E0FA /* MessagesViewController.swift in Sources */,
|
||||
A9A7A4572F69568700BB84C6 /* GifHoarder.swift in Sources */,
|
||||
@@ -717,6 +726,7 @@
|
||||
A9EB72472EB948C400658CEB /* StickerRow.swift in Sources */,
|
||||
A9CD6C392EDDE37500B7F421 /* EmojiPackManager.swift in Sources */,
|
||||
A955B3F62EC22EE900E1732D /* SearchView.swift in Sources */,
|
||||
A9BDEADF2F82BC93002798DF /* NoStickersView.swift in Sources */,
|
||||
A9B9A8322EB2CD29004C9245 /* SlackResponse.swift in Sources */,
|
||||
A957C1782ECD008E00EA3EE9 /* Bundle.swift in Sources */,
|
||||
A921C2E02ED067BB00E57B1A /* WelcomeView.swift in Sources */,
|
||||
@@ -726,7 +736,7 @@
|
||||
A9A7A44C2F6837A800BB84C6 /* GiphyUser.swift in Sources */,
|
||||
A9B9A8312EB2CD14004C9245 /* FilterCategory.swift in Sources */,
|
||||
A957C1802ECFAA1100EA3EE9 /* GifView.swift in Sources */,
|
||||
A9EB72502EB94FAD00658CEB /* EmojiPreview.swift in Sources */,
|
||||
A9EB72502EB94FAD00658CEB /* StickerPreview.swift in Sources */,
|
||||
A9A7A4432F68360200BB84C6 /* GifObject.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -891,6 +901,7 @@
|
||||
ENABLE_PREVIEWS = YES;
|
||||
ENABLE_USER_SELECTED_FILES = readonly;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = StickerSlack/Info.plist;
|
||||
INFOPLIST_KEY_ITSAppUsesNonExemptEncryption = NO;
|
||||
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES;
|
||||
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES;
|
||||
@@ -942,6 +953,7 @@
|
||||
ENABLE_PREVIEWS = YES;
|
||||
ENABLE_USER_SELECTED_FILES = readonly;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = StickerSlack/Info.plist;
|
||||
INFOPLIST_KEY_ITSAppUsesNonExemptEncryption = NO;
|
||||
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES;
|
||||
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES;
|
||||
|
||||
@@ -12,10 +12,10 @@ import UniformTypeIdentifiers
|
||||
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)
|
||||
static let library: URL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.com.neon443.StickerSlack")!.appendingPathComponent("Library", conformingTo: .directory)
|
||||
static let container: URL = library.appendingPathComponent("slack", conformingTo: .directory)
|
||||
nonisolated static let localEmojiDB: URL = EmojiHoarder.library.appendingPathComponent("_____localEmojiDB.json", conformingTo: .fileURL)
|
||||
nonisolated static let localTrieDict: URL = EmojiHoarder.library.appendingPathComponent("_____localTrieDict.json", conformingTo: .fileURL)
|
||||
let endpoint: URL = URL(string: "https://cachet.dunkirk.sh/emojis")!
|
||||
|
||||
@Published var emojis: [Emoji] = []
|
||||
@@ -32,16 +32,26 @@ class EmojiHoarder: Hoarder, ObservableObject {
|
||||
init(localOnly: Bool = false, skipIndex: Bool = false) {
|
||||
self.showWelcome = !UserDefaults.standard.bool(forKey: "showWelcome")
|
||||
|
||||
let localDB = loadLocalDB()
|
||||
withAnimation(.snappy) { self.emojis = localDB }
|
||||
loadTrie()
|
||||
if !skipIndex { buildTrie() }
|
||||
if !FileManager.default.fileExists(atPath: EmojiHoarder.container.path()) {
|
||||
try! FileManager.default.createDirectory(at: EmojiHoarder.container, withIntermediateDirectories: true)
|
||||
}
|
||||
|
||||
guard !localOnly else { return }
|
||||
self.emojis = loadLocalDB()
|
||||
loadTrie()
|
||||
|
||||
startLoading(localOnly: localOnly, skipIndex: skipIndex)
|
||||
}
|
||||
|
||||
func startLoading(localOnly: Bool, skipIndex: Bool) {
|
||||
Task.detached {
|
||||
if !skipIndex { await self.buildTrie() }
|
||||
|
||||
guard !localOnly else { return }
|
||||
|
||||
print("start loading remote db")
|
||||
await self.loadRemoteDB()
|
||||
print("end")
|
||||
|
||||
if !skipIndex {
|
||||
await self.buildTrie()
|
||||
}
|
||||
@@ -51,8 +61,6 @@ class EmojiHoarder: Hoarder, ObservableObject {
|
||||
@MainActor
|
||||
func downloadAllStickers() async {
|
||||
let start: Date = .now
|
||||
|
||||
|
||||
let cores = ProcessInfo.processInfo.processorCount-1
|
||||
var ranges: [Range<Int>] = []
|
||||
for i in 0..<cores {
|
||||
@@ -104,7 +112,6 @@ class EmojiHoarder: Hoarder, ObservableObject {
|
||||
trie.dict = [:]
|
||||
trie.wordlist = []
|
||||
try? FileManager.default.removeItem(at: EmojiHoarder.localEmojiDB)
|
||||
try? FileManager.default.removeItem(at: EmojiHoarder.localTrie)
|
||||
try? FileManager.default.removeItem(at: EmojiHoarder.localTrieDict)
|
||||
|
||||
downloadedStickers = []
|
||||
@@ -128,31 +135,44 @@ class EmojiHoarder: Hoarder, ObservableObject {
|
||||
self.trie.dict = decodedDict
|
||||
}
|
||||
|
||||
func buildTrie() {
|
||||
nonisolated
|
||||
func buildTrie() async {
|
||||
let start = Date().timeIntervalSince1970
|
||||
for emoji in emojis {
|
||||
var wordlist = await trie.wordlist
|
||||
var dict = await trie.dict
|
||||
for emoji in await emojis {
|
||||
// trie.insert(word: emoji.name)
|
||||
trie.wordlist.insert(emoji.name)
|
||||
trie.dict[emoji.name] = emoji
|
||||
wordlist.insert(emoji.name)
|
||||
dict[emoji.name] = emoji
|
||||
}
|
||||
buildDownloadedEmojis()
|
||||
saveTrie()
|
||||
generateLetterStats()
|
||||
await trie.wordlist = wordlist
|
||||
await trie.dict = dict
|
||||
|
||||
await buildDownloadedEmojis()
|
||||
await saveTrie()
|
||||
print("done building trie in", Date().timeIntervalSince1970-start)
|
||||
}
|
||||
|
||||
func buildDownloadedEmojis() {
|
||||
nonisolated
|
||||
func buildDownloadedEmojis() async {
|
||||
if let data = UserDefaults.standard.data(forKey: "downloadedEmojis"),
|
||||
let decoded = try? decoder.decode(Set<String>.self, from: data) {
|
||||
downloadedStickers = decoded
|
||||
let decoded = try? await decoder.decode(Set<String>.self, from: data) {
|
||||
await MainActor.run {
|
||||
downloadedStickers = decoded
|
||||
}
|
||||
} else {
|
||||
downloadedStickers = []
|
||||
if let files = try? FileManager.default.contentsOfDirectory(atPath: EmojiHoarder.container.path) {
|
||||
var newDownloadedStickers: Set<String> = []
|
||||
if let files = try? await FileManager.default.contentsOfDirectory(atPath: EmojiHoarder.container.path) {
|
||||
for file in files {
|
||||
let name = String(file.split(separator: ".")[0])
|
||||
downloadedStickers.insert(name)
|
||||
newDownloadedStickers.insert(name)
|
||||
}
|
||||
}
|
||||
newDownloadedStickers.remove("DS_Store")
|
||||
await MainActor.run {
|
||||
downloadedStickers = []
|
||||
downloadedStickers = newDownloadedStickers
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -198,14 +218,14 @@ class EmojiHoarder: Hoarder, ObservableObject {
|
||||
let local = loadLocalDB()
|
||||
await MainActor.run {
|
||||
emojis = local
|
||||
buildTrie()
|
||||
}
|
||||
await buildTrie()
|
||||
return
|
||||
}
|
||||
await MainActor.run {
|
||||
withAnimation(.snappy) { self.emojis = fetched }
|
||||
buildTrie()
|
||||
}
|
||||
await buildTrie()
|
||||
}
|
||||
|
||||
nonisolated func download(emoji: any StickerProtocol, skipStoreIndex: Bool = false) async {
|
||||
|
||||
@@ -11,7 +11,8 @@ import UniformTypeIdentifiers
|
||||
import Combine
|
||||
|
||||
class GifHoarder: Hoarder, ObservableObject {
|
||||
static let container: URL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.com.neon443.StickerSlack")!.appendingPathComponent("Library", conformingTo: .directory)
|
||||
static let library: URL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.com.neon443.StickerSlack")!.appendingPathComponent("Library", conformingTo: .directory)
|
||||
static let container: URL = library.appendingPathComponent("giphy", conformingTo: .directory)
|
||||
|
||||
static var apiKey: String = "a2mFsDTpX5blodY8ltkG6Q1xy5NgFSbc"
|
||||
var endpoint: URL = URL(string: "https://api.giphy.com/v1/gifs/trending")!
|
||||
@@ -31,6 +32,10 @@ class GifHoarder: Hoarder, ObservableObject {
|
||||
}
|
||||
|
||||
init(localOnly: Bool = false) {
|
||||
if !FileManager.default.fileExists(atPath: GifHoarder.container.path()) {
|
||||
try! FileManager.default.createDirectory(at: GifHoarder.container, withIntermediateDirectories: true)
|
||||
}
|
||||
|
||||
var components = URLComponents(url: endpoint, resolvingAgainstBaseURL: false)
|
||||
components?.queryItems = [
|
||||
URLQueryItem(name: "api_key", value: GifHoarder.apiKey),
|
||||
|
||||
@@ -11,6 +11,7 @@ import Combine
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
protocol Hoarder: ObservableObject {
|
||||
static var library: URL { get }
|
||||
static var container: URL { get }
|
||||
var endpoint: URL { get }
|
||||
var downloadedStickers: Set<String> { get set }
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleURLTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Viewer</string>
|
||||
<key>CFBundleURLName</key>
|
||||
<string>com.neon443.stickerslack</string>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>stickerslack://</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -14,6 +14,13 @@ struct BrowseView: View {
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
Picker("", selection: $browseWhat) {
|
||||
ForEach(StickerType.allCases) { type in
|
||||
Text(type.description).tag(type)
|
||||
}
|
||||
}
|
||||
.pickerStyle(.segmented)
|
||||
.padding(.horizontal)
|
||||
Group {
|
||||
switch browseWhat {
|
||||
case .slackEmoji:
|
||||
@@ -32,15 +39,6 @@ struct BrowseView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
.overlay(alignment: .top) {
|
||||
Picker("", selection: $browseWhat) {
|
||||
ForEach(StickerType.allCases) { type in
|
||||
Text(type.description).tag(type)
|
||||
}
|
||||
}
|
||||
.pickerStyle(.segmented)
|
||||
.padding(.horizontal)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,16 +26,7 @@ struct DownloadedView: View {
|
||||
|
||||
var body: some View {
|
||||
if emojiHoarder.downloadedStickers.isEmpty && gifHoarder.downloadedStickers.isEmpty {
|
||||
VStack(alignment: .center) {
|
||||
Image(systemName: "questionmark.app.dashed")
|
||||
.resizable().scaledToFit()
|
||||
.frame(width: 75, height: 75)
|
||||
Text("No Downloaded Stickers")
|
||||
.font(.title)
|
||||
.bold()
|
||||
Text("Download some Slack Emojis or GIFs to use in iMessage!")
|
||||
.foregroundStyle(.gray)
|
||||
}
|
||||
NoStickersView()
|
||||
}
|
||||
GeometryReader { geo in
|
||||
ScrollView {
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// NoStickersView.swift
|
||||
// StickerSlack
|
||||
//
|
||||
// Created by neon443 on 05/04/2026.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct NoStickersView: View {
|
||||
var body: some View {
|
||||
VStack(alignment: .center) {
|
||||
Image(systemName: "questionmark.app.dashed")
|
||||
.resizable().scaledToFit()
|
||||
.frame(width: 75, height: 75)
|
||||
Text("No Downloaded Stickers")
|
||||
.font(.title)
|
||||
.bold()
|
||||
Text("Download some Slack Emojis or GIFs to use in iMessage!")
|
||||
.foregroundStyle(.gray)
|
||||
.multilineTextAlignment(.center)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
NoStickersView()
|
||||
}
|
||||
@@ -50,7 +50,7 @@ struct SearchView: View {
|
||||
previousResult: Set(searchResult)
|
||||
)
|
||||
await MainActor.run {
|
||||
withAnimation {
|
||||
withAnimation(.interactiveSpring) {
|
||||
searchResult = result
|
||||
previousSearches.append(searchTerm)
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import Haptics
|
||||
|
||||
struct SettingsView: View {
|
||||
@ObservedObject var hoarder: EmojiHoarder
|
||||
@@ -50,6 +51,9 @@ struct SettingsView: View {
|
||||
if hoarder.downloadedStickers.count == hoarder.emojis.count {
|
||||
Text("🎉")
|
||||
.font(.largeTitle)
|
||||
.onTapGesture {
|
||||
Haptic.rigid.trigger()
|
||||
}
|
||||
}
|
||||
// NavigationLink {
|
||||
// List {
|
||||
@@ -122,7 +126,9 @@ struct SettingsView: View {
|
||||
|
||||
Button("Reindex", systemImage: "list.bullet.clipboard", role: .destructive) {
|
||||
hoarder.resetAllIndexes()
|
||||
hoarder.buildTrie()
|
||||
Task {
|
||||
await hoarder.buildTrie()
|
||||
}
|
||||
}
|
||||
.foregroundStyle(.red)
|
||||
}
|
||||
|
||||
File renamed without changes.
File renamed without changes.
@@ -9,14 +9,26 @@ import SwiftUI
|
||||
|
||||
struct WelcomeView: View {
|
||||
@Environment(\.dismiss) var dismiss
|
||||
@Environment(\.colorScheme) var colourScheme
|
||||
var isDark: Bool {
|
||||
return colourScheme == .dark
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
Text("StickerSlack")
|
||||
.bold()
|
||||
.font(.largeTitle)
|
||||
.monospaced()
|
||||
.padding()
|
||||
VStack(spacing: 0) {
|
||||
HStack {
|
||||
Image("icon\(isDark ? "-dark" : "")")
|
||||
.resizable().scaledToFit()
|
||||
.frame(maxWidth: 75)
|
||||
Spacer()
|
||||
Text("StickerSlack")
|
||||
.bold()
|
||||
.font(.largeTitle)
|
||||
.monospaced()
|
||||
Spacer()
|
||||
}
|
||||
.padding(.top, 20)
|
||||
.padding(.leading, 20)
|
||||
List {
|
||||
Section("How to use") {
|
||||
ListRow(number: 1, text: "Browse or search for an emoji")
|
||||
@@ -29,31 +41,37 @@ struct WelcomeView: View {
|
||||
}
|
||||
.scrollContentBackground(.hidden)
|
||||
Spacer()
|
||||
if #available(iOS 19, *) {
|
||||
Button() {
|
||||
dismiss()
|
||||
} label: {
|
||||
Text("Continue")
|
||||
.font(.title)
|
||||
.bold()
|
||||
Group {
|
||||
if #available(iOS 19, *) {
|
||||
Button() {
|
||||
dismiss()
|
||||
} label: {
|
||||
ContinueButtonView()
|
||||
}
|
||||
.buttonStyle(.glassProminent)
|
||||
} else {
|
||||
Button() {
|
||||
dismiss()
|
||||
} label: {
|
||||
ContinueButtonView()
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
}
|
||||
.buttonStyle(.glassProminent)
|
||||
.padding(.bottom)
|
||||
} else {
|
||||
Button() {
|
||||
dismiss()
|
||||
} label: {
|
||||
Text("Continue")
|
||||
.font(.title)
|
||||
.bold()
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
.padding(.bottom)
|
||||
}
|
||||
.padding(.bottom)
|
||||
.tint(.purple)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate struct ContinueButtonView: View {
|
||||
var body: some View {
|
||||
Text("Continue")
|
||||
.font(.title)
|
||||
.bold()
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
Color.gray.opacity(0.5)
|
||||
.ignoresSafeArea(.all)
|
||||
|
||||
@@ -62,7 +62,9 @@ struct TrieTestingView: View {
|
||||
}
|
||||
Spacer()
|
||||
Button("add emojis!") {
|
||||
hoarder.buildTrie()
|
||||
Task {
|
||||
await hoarder.buildTrie()
|
||||
}
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ struct EmojiCollectionView: UIViewRepresentable {
|
||||
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.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 50, right: 0)
|
||||
tableView.tableView.separatorStyle = .none
|
||||
return tableView.tableView
|
||||
}
|
||||
@@ -52,6 +52,16 @@ struct EmojiCollectionView: 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)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
import UIKit
|
||||
import Messages
|
||||
import SwiftUI
|
||||
|
||||
class MessagesViewController: MSMessagesAppViewController {
|
||||
let dataSource: StickerBrowserDataSource = StickerBrowserDataSource()
|
||||
@@ -24,6 +25,37 @@ class MessagesViewController: MSMessagesAppViewController {
|
||||
stickerBrowser.frame = CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height)
|
||||
stickerBrowser.dataSource = dataSource
|
||||
stickerBrowser.autoresizingMask = [.flexibleWidth]
|
||||
|
||||
guard stickerBrowser.dataSource?.numberOfStickers(in: stickerBrowser) != 0 else {
|
||||
let swiftUIView = NoStickersView()
|
||||
let hostingController = UIHostingController(rootView: swiftUIView)
|
||||
addChild(hostingController)
|
||||
hostingController.view.translatesAutoresizingMaskIntoConstraints = false
|
||||
view.addSubview(hostingController.view)
|
||||
hostingController.didMove(toParent: self)
|
||||
|
||||
let link = UIButton()
|
||||
link.setTitle("Open StickerSlack", for: .normal)
|
||||
link.setImage(UIImage(systemName: "arrow.up.right.square"), for: .normal)
|
||||
link.setTitleColor(.systemBlue, for: .normal)
|
||||
link.frame = view.frame
|
||||
link.translatesAutoresizingMaskIntoConstraints = false
|
||||
link.addTarget(self, action: #selector(openStickerSlack), for: .touchUpInside)
|
||||
view.addSubview(link)
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
hostingController.view.centerXAnchor.constraint(equalTo: view.centerXAnchor),
|
||||
hostingController.view.centerYAnchor.constraint(equalTo: view.centerYAnchor),
|
||||
hostingController.view.widthAnchor.constraint(equalTo: view.widthAnchor),
|
||||
hostingController.view.heightAnchor.constraint(equalTo: view.heightAnchor),
|
||||
link.centerXAnchor.constraint(equalTo: view.centerXAnchor),
|
||||
link.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor),
|
||||
link.heightAnchor.constraint(equalToConstant: 50)
|
||||
])
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
view.addSubview(stickerBrowser)
|
||||
stickerBrowser.reloadData()
|
||||
view.bringSubviewToFront(stickerBrowser)
|
||||
@@ -73,4 +105,12 @@ class MessagesViewController: MSMessagesAppViewController {
|
||||
// Use this method to finalize any behaviors associated with the change in presentation style.
|
||||
}
|
||||
|
||||
@objc
|
||||
func openStickerSlack() {
|
||||
if let url = URL(string: "stickerslack://") {
|
||||
self.extensionContext?.open(url) { success in
|
||||
print("open url: \(success)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,20 +20,27 @@ class StickerBrowserDataSource: NSObject, MSStickerBrowserViewDataSource {
|
||||
guard let files = try? FileManager.default.contentsOfDirectory(atPath: EmojiHoarder.container.path()) else { return }
|
||||
|
||||
for file in files {
|
||||
guard file.contains("png") ||
|
||||
file.contains("jpg") ||
|
||||
file.contains("gif") else { continue }
|
||||
guard file.contains(".png") ||
|
||||
file.contains(".jpg") ||
|
||||
file.contains(".gif") else { continue }
|
||||
let name = String(file.split(separator: ".")[0])
|
||||
// if let emoji = hoarder.trie.dict[name],
|
||||
if let msSticker = hoarder.trie.dict[name]!.msSticker {
|
||||
if let emoji = hoarder.trie.dict[name],
|
||||
let msSticker = emoji.msSticker {
|
||||
msStickers.append(msSticker)
|
||||
} else {
|
||||
print(
|
||||
"name, emoji has value, mssticker has value:",
|
||||
name,
|
||||
hoarder.trie.dict[name] != nil,
|
||||
hoarder.trie.dict[name]?.msSticker != nil
|
||||
)
|
||||
}
|
||||
}
|
||||
print(msStickers.count)
|
||||
print(msStickers.count, "init")
|
||||
}
|
||||
|
||||
func numberOfStickers(in stickerBrowserView: MSStickerBrowserView) -> Int {
|
||||
print(msStickers.count)
|
||||
print(msStickers.count, "numberofstickers")
|
||||
return msStickers.count
|
||||
}
|
||||
|
||||
|
||||