diff --git a/StickerSlack.xcodeproj/project.pbxproj b/StickerSlack.xcodeproj/project.pbxproj index 57171c8..df48fbd 100644 --- a/StickerSlack.xcodeproj/project.pbxproj +++ b/StickerSlack.xcodeproj/project.pbxproj @@ -58,6 +58,18 @@ A99589AF2F5E0D83003A4A8C /* image.png in Resources */ = {isa = PBXBuildFile; fileRef = A99589AE2F5E0D83003A4A8C /* image.png */; }; A99589B02F5E0D83003A4A8C /* image.png in Resources */ = {isa = PBXBuildFile; fileRef = A99589AE2F5E0D83003A4A8C /* image.png */; }; A99589B12F5E0D83003A4A8C /* image.png in Resources */ = {isa = PBXBuildFile; fileRef = A99589AE2F5E0D83003A4A8C /* image.png */; }; + A9A7A43F2F6835F800BB84C6 /* Trending.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9A7A43E2F6835F800BB84C6 /* Trending.swift */; }; + A9A7A4402F6835F800BB84C6 /* Trending.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9A7A43E2F6835F800BB84C6 /* Trending.swift */; }; + A9A7A4422F68360200BB84C6 /* GifObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9A7A4412F68360200BB84C6 /* GifObject.swift */; }; + A9A7A4432F68360200BB84C6 /* GifObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9A7A4412F68360200BB84C6 /* GifObject.swift */; }; + A9A7A4452F68360900BB84C6 /* Pagination.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9A7A4442F68360900BB84C6 /* Pagination.swift */; }; + A9A7A4462F68360900BB84C6 /* Pagination.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9A7A4442F68360900BB84C6 /* Pagination.swift */; }; + A9A7A4482F68361200BB84C6 /* Meta.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9A7A4472F68361200BB84C6 /* Meta.swift */; }; + A9A7A4492F68361200BB84C6 /* Meta.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9A7A4472F68361200BB84C6 /* Meta.swift */; }; + A9A7A44B2F6837A800BB84C6 /* GiphyUser.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9A7A44A2F6837A800BB84C6 /* GiphyUser.swift */; }; + A9A7A44C2F6837A800BB84C6 /* GiphyUser.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9A7A44A2F6837A800BB84C6 /* GiphyUser.swift */; }; + A9A7A44E2F68383900BB84C6 /* GiphyImages.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9A7A44D2F68383900BB84C6 /* GiphyImages.swift */; }; + A9A7A44F2F68383900BB84C6 /* GiphyImages.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9A7A44D2F68383900BB84C6 /* GiphyImages.swift */; }; A9B9A82E2EB2CCBE004C9245 /* StickerSlackTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9B9A82C2EB2CCBE004C9245 /* StickerSlackTests.swift */; }; A9B9A82F2EB2CCED004C9245 /* EmojiHoarder.swift in Sources */ = {isa = PBXBuildFile; fileRef = A949B1F72EA04F2300215164 /* EmojiHoarder.swift */; }; A9B9A8302EB2CD0B004C9245 /* Emoji.swift in Sources */ = {isa = PBXBuildFile; fileRef = A924C3712EA9127200F20781 /* Emoji.swift */; }; @@ -162,6 +174,12 @@ A986A6CA2EB659E000B6E0FA /* MessagesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessagesViewController.swift; sourceTree = ""; }; A986A6CB2EB659E000B6E0FA /* StickerBrowserDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StickerBrowserDataSource.swift; sourceTree = ""; }; A99589AE2F5E0D83003A4A8C /* image.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = image.png; sourceTree = ""; }; + A9A7A43E2F6835F800BB84C6 /* Trending.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Trending.swift; sourceTree = ""; }; + A9A7A4412F68360200BB84C6 /* GifObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GifObject.swift; sourceTree = ""; }; + A9A7A4442F68360900BB84C6 /* Pagination.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Pagination.swift; sourceTree = ""; }; + A9A7A4472F68361200BB84C6 /* Meta.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Meta.swift; sourceTree = ""; }; + A9A7A44A2F6837A800BB84C6 /* GiphyUser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GiphyUser.swift; sourceTree = ""; }; + A9A7A44D2F68383900BB84C6 /* GiphyImages.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GiphyImages.swift; sourceTree = ""; }; 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 = ""; }; A9BBC5172EB8FA4500FFE82F /* ViewModifiers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewModifiers.swift; sourceTree = ""; }; @@ -239,14 +257,6 @@ path = Trie; sourceTree = ""; }; - A91C098A2EBBD77B00210C34 /* API */ = { - isa = PBXGroup; - children = ( - A949B1FA2EA0518800215164 /* SlackResponse.swift */, - ); - path = API; - sourceTree = ""; - }; A91C098B2EBBD78700210C34 /* Categorisation */ = { isa = PBXGroup; children = ( @@ -317,6 +327,7 @@ A949B1F22EA04E8200215164 /* StickerSlack */ = { isa = PBXGroup; children = ( + A9A7A4502F68447F00BB84C6 /* Models */, A924C3742EA9134C00F20781 /* StickerSlack.entitlements */, A949B1F12EA04E8200215164 /* StickerSlackApp.swift */, A9BE30EB2F5AFE1E00A57668 /* StickerType.swift */, @@ -338,7 +349,6 @@ A924C3712EA9127200F20781 /* Emoji.swift */, A949B1F72EA04F2300215164 /* EmojiHoarder.swift */, A91C098B2EBBD78700210C34 /* Categorisation */, - A91C098A2EBBD77B00210C34 /* API */, A957C1792ECE542D00EA3EE9 /* GifManager.swift */, A957C17D2ECFAA1100EA3EE9 /* GifView.swift */, ); @@ -366,6 +376,36 @@ path = StickerSlackiMessageApp; sourceTree = ""; }; + A9A7A4502F68447F00BB84C6 /* Models */ = { + isa = PBXGroup; + children = ( + A9A7A4522F68448A00BB84C6 /* Cachet */, + A9A7A4512F68448500BB84C6 /* Giphy */, + ); + path = Models; + sourceTree = ""; + }; + A9A7A4512F68448500BB84C6 /* Giphy */ = { + isa = PBXGroup; + children = ( + A9A7A43E2F6835F800BB84C6 /* Trending.swift */, + A9A7A4412F68360200BB84C6 /* GifObject.swift */, + A9A7A4442F68360900BB84C6 /* Pagination.swift */, + A9A7A4472F68361200BB84C6 /* Meta.swift */, + A9A7A44A2F6837A800BB84C6 /* GiphyUser.swift */, + A9A7A44D2F68383900BB84C6 /* GiphyImages.swift */, + ); + path = Giphy; + sourceTree = ""; + }; + A9A7A4522F68448A00BB84C6 /* Cachet */ = { + isa = PBXGroup; + children = ( + A949B1FA2EA0518800215164 /* SlackResponse.swift */, + ); + path = Cachet; + sourceTree = ""; + }; A9B9A82D2EB2CCBE004C9245 /* StickerSlackTests */ = { isa = PBXGroup; children = ( @@ -548,10 +588,14 @@ A949B1F42EA04E8200215164 /* ContentView.swift in Sources */, A9CD6C382EDDE37500B7F421 /* EmojiPackManager.swift in Sources */, A949B1F52EA04E8200215164 /* StickerSlackApp.swift in Sources */, + A9A7A4452F68360900BB84C6 /* Pagination.swift in Sources */, A9104C802EB4022500D160EA /* MSSticker.swift in Sources */, + A9A7A43F2F6835F800BB84C6 /* Trending.swift in Sources */, + A9A7A4422F68360200BB84C6 /* GifObject.swift in Sources */, A957C1772ECD008E00EA3EE9 /* Bundle.swift in Sources */, A957C17F2ECFAA1100EA3EE9 /* GifView.swift in Sources */, A957C1742ECCE2CE00EA3EE9 /* SettingsView.swift in Sources */, + A9A7A44B2F6837A800BB84C6 /* GiphyUser.swift in Sources */, A9EB72392EB93FDB00658CEB /* EmojiCollectionView.swift in Sources */, A955B3EE2EC22C4A00E1732D /* DownloadedView.swift in Sources */, A949B1FB2EA0518800215164 /* SlackResponse.swift in Sources */, @@ -559,6 +603,7 @@ A955B3F52EC22EE900E1732D /* SearchView.swift in Sources */, A935437B2EB2A3C800BB80A4 /* FilterCategory.swift in Sources */, A9CD6C352EDDE22800B7F421 /* EmojiPackView.swift in Sources */, + A9A7A44E2F68383900BB84C6 /* GiphyImages.swift in Sources */, A9C172DD2EB8C9AC008A7885 /* Trie.swift in Sources */, A955B3F22EC22E9700E1732D /* BrowseView.swift in Sources */, A9EB724F2EB94A6B00658CEB /* TrieTestingView.swift in Sources */, @@ -575,6 +620,7 @@ A9BE30F02F5B004800A57668 /* GifHoarder.swift in Sources */, A9BE30F22F5B004E00A57668 /* Gif.swift in Sources */, A9BE30EC2F5AFE1E00A57668 /* StickerType.swift in Sources */, + A9A7A4482F68361200BB84C6 /* Meta.swift in Sources */, A9BE30FE2F5FA47100A57668 /* Hoarder.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -604,16 +650,19 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + A9A7A4462F68360900BB84C6 /* Pagination.swift in Sources */, A957C17C2ECE542D00EA3EE9 /* GifManager.swift in Sources */, A9104C7F2EB4022500D160EA /* MSSticker.swift in Sources */, A9B9A8302EB2CD0B004C9245 /* Emoji.swift in Sources */, A955B3F12EC22E9700E1732D /* BrowseView.swift in Sources */, + A9A7A4402F6835F800BB84C6 /* Trending.swift in Sources */, A9BE30F72F5B011A00A57668 /* StickerProtocol.swift in Sources */, A9BE30FC2F5B03F400A57668 /* Sticker.swift in Sources */, A9B9A82F2EB2CCED004C9245 /* EmojiHoarder.swift in Sources */, A9CD6C3B2EDDE6B500B7F421 /* EmojiPack.swift in Sources */, A921C2E32ED071C900E57B1A /* ListRow.swift in Sources */, A9BE30EF2F5B004800A57668 /* GifHoarder.swift in Sources */, + A9A7A4492F68361200BB84C6 /* Meta.swift in Sources */, A9EB724A2EB948E000658CEB /* EmojiCollectionView.swift in Sources */, A9EB724D2EB94A6B00658CEB /* TrieTestingView.swift in Sources */, A9BBC51A2EB8FA4500FFE82F /* ViewModifiers.swift in Sources */, @@ -628,10 +677,13 @@ A957C1782ECD008E00EA3EE9 /* Bundle.swift in Sources */, A921C2E02ED067BB00E57B1A /* WelcomeView.swift in Sources */, A9B9A82E2EB2CCBE004C9245 /* StickerSlackTests.swift in Sources */, + A9A7A44F2F68383900BB84C6 /* GiphyImages.swift in Sources */, A9BE30F32F5B004E00A57668 /* Gif.swift in Sources */, + A9A7A44C2F6837A800BB84C6 /* GiphyUser.swift in Sources */, A9B9A8312EB2CD14004C9245 /* FilterCategory.swift in Sources */, A957C1802ECFAA1100EA3EE9 /* GifView.swift in Sources */, A9EB72502EB94FAD00658CEB /* EmojiPreview.swift in Sources */, + A9A7A4432F68360200BB84C6 /* GifObject.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/StickerSlack/Gifs/GifHoarder.swift b/StickerSlack/Gifs/GifHoarder.swift index 68752bc..f93d85f 100644 --- a/StickerSlack/Gifs/GifHoarder.swift +++ b/StickerSlack/Gifs/GifHoarder.swift @@ -38,8 +38,8 @@ class GifHoarder: Hoarder, ObservableObject { Task { do { async let (data, _) = try URLSession.shared.data(from: components!.url!) - dump(try await data) - print(try await data.base64EncodedString()) + let object = + print(try JSONDecoder().decode(Trending.self, from: await data)) } catch { print(error.localizedDescription) } diff --git a/StickerSlack/Emoji/API/SlackResponse.swift b/StickerSlack/Models/Cachet/SlackResponse.swift similarity index 100% rename from StickerSlack/Emoji/API/SlackResponse.swift rename to StickerSlack/Models/Cachet/SlackResponse.swift diff --git a/StickerSlack/Models/Giphy/GifObject.swift b/StickerSlack/Models/Giphy/GifObject.swift new file mode 100644 index 0000000..6f9e30b --- /dev/null +++ b/StickerSlack/Models/Giphy/GifObject.swift @@ -0,0 +1,32 @@ +// +// GifObject.swift +// StickerSlack +// +// Created by neon443 on 16/03/2026. +// + +import Foundation + +struct GifObject: Codable, Identifiable { + var type: String + var id: String + var slug: String + var url: String + var bitly_url: String + var embed_url: String + var username: String + var source: String + var rating: String + var content_url: String? + var user: GiphyUser + var source_tld: String + var source_post_url: String + var update_datetime: Date + var create_datetime: Date + var import_datetime: Date + var trending_datetime: Date + var images: GiphyImages + var title: String + var alt_text: String + var is_low_contrast: Bool +} diff --git a/StickerSlack/Models/Giphy/GiphyImages.swift b/StickerSlack/Models/Giphy/GiphyImages.swift new file mode 100644 index 0000000..d94ab38 --- /dev/null +++ b/StickerSlack/Models/Giphy/GiphyImages.swift @@ -0,0 +1,95 @@ +// +// GiphyImages.swift +// StickerSlack +// +// Created by neon443 on 16/03/2026. +// + +import Foundation + +struct GiphyImages: Codable { + //fixed height of 200px + var fixed_height: motion + //fixed height of 200px still + var fixed_height_still: still + //fixed height 200px with 6 frames + var fixed_height_downsampled: downsampled + + //fixed height of 100px + var fixed_height_small: motion + //fixed height of 100px still + var fixed_height_small_still: still + + //fixed width of 200px + var fixed_width: motion + //fixed width of 200px + var fixed_width_still: still + //fixed width 200px with 6 frames + var fixed_width_downsampled: downsampled + + //fixed width of 100px + var fixed_width_small: motion + //fixed width of 100px still + var fixed_width_small_still: still + + //under 2mb + var downsized: downsized + //downsized still + var downsized_still: still + //under 8mb + var downsized_large: downsized + //under 5mb + var downsized_medium: downsized + //under 200kb + var downsized_small: video + + var original: motion + var original_still: still + + //15s looping version + var looping: looping + //mp4 format 50kb, first 1-2s of the gif + var preview: video + //50kb first 1-2s of the gif + var preview_gif: still + + + struct motion: Codable { + var url: String + var width: String + var height: String + var size: String + var mp4: String + var mp4_size: String + var webp: String + var webp_size: String + } + struct still: Codable { + var url: String + var width: String + var height: String + } + struct downsampled: Codable { + var url: String + var width: String + var height: String + var size: String + var webp: String + var webp_size: String + } + struct downsized: Codable { + var url: String + var width: String + var height: String + var size: String + } + struct looping: Codable { + var mp4: String + } + struct video: Codable { + var mp4: String + var mp4_size: String + var width: String + var height: String + } +} diff --git a/StickerSlack/Models/Giphy/GiphyUser.swift b/StickerSlack/Models/Giphy/GiphyUser.swift new file mode 100644 index 0000000..82a3bb1 --- /dev/null +++ b/StickerSlack/Models/Giphy/GiphyUser.swift @@ -0,0 +1,16 @@ +// +// GiphyUser.swift +// StickerSlack +// +// Created by neon443 on 16/03/2026. +// + +import Foundation + +struct GiphyUser: Codable { + var avatar_url: String + var banner_url: String + var profile_url: String + var username: String + var display_name: String +} diff --git a/StickerSlack/Models/Giphy/Meta.swift b/StickerSlack/Models/Giphy/Meta.swift new file mode 100644 index 0000000..ada7983 --- /dev/null +++ b/StickerSlack/Models/Giphy/Meta.swift @@ -0,0 +1,19 @@ +// +// Meta.swift +// StickerSlack +// +// Created by neon443 on 16/03/2026. +// + +import Foundation + +struct Meta: Codable, Identifiable { + var msg: String + var status: Int + var response_id: String + var id: String { response_id } + + static var example: Meta { + Meta(msg: "OK", status: 200, response_id: "57eea03c72381f86e05c35d2") + } +} diff --git a/StickerSlack/Models/Giphy/Pagination.swift b/StickerSlack/Models/Giphy/Pagination.swift new file mode 100644 index 0000000..4b44ec9 --- /dev/null +++ b/StickerSlack/Models/Giphy/Pagination.swift @@ -0,0 +1,18 @@ +// +// Pagination.swift +// StickerSlack +// +// Created by neon443 on 16/03/2026. +// + +import Foundation + +struct Pagination: Codable { + var offset: Int + var total_count: Int? + var count: Int + + static var example: Pagination { + Pagination(offset: 2591, total_count: 250, count: 25) + } +} diff --git a/StickerSlack/Models/Giphy/Trending.swift b/StickerSlack/Models/Giphy/Trending.swift new file mode 100644 index 0000000..da0f078 --- /dev/null +++ b/StickerSlack/Models/Giphy/Trending.swift @@ -0,0 +1,14 @@ +// +// Trending.swift +// StickerSlack +// +// Created by neon443 on 16/03/2026. +// + +import Foundation + +struct Trending: Codable { + var data: [GifObject] + var pagination: Pagination + var meta: Meta +}