From c8f6e699885e9c81c4a28e23037e2c51b47ca53f Mon Sep 17 00:00:00 2001 From: Nihaal Sharma <69979447+neon443@users.noreply.github.com> Date: Fri, 8 May 2026 21:56:15 +0100 Subject: [PATCH] gifs!!! also swipe share in thingy --- StickerSlack.xcodeproj/project.pbxproj | 12 +++++++ StickerSlack/Emoji/GifManager.swift | 26 ++++++++++++++ .../SwiftUI/EmojiPacks/EmojiPackManager.swift | 13 +++++++ StickerSlack/UIKit/UIKitGifView.swift | 34 ++++++++++--------- 4 files changed, 69 insertions(+), 16 deletions(-) diff --git a/StickerSlack.xcodeproj/project.pbxproj b/StickerSlack.xcodeproj/project.pbxproj index 67b3fa4..f45f5be 100644 --- a/StickerSlack.xcodeproj/project.pbxproj +++ b/StickerSlack.xcodeproj/project.pbxproj @@ -146,6 +146,10 @@ 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 */; }; + A9E61EC42FAE60370057220B /* iPad.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9E61EC32FAE60370057220B /* iPad.swift */; }; + A9E61EC52FAE60370057220B /* iPad.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9E61EC32FAE60370057220B /* iPad.swift */; }; + A9E61EC72FAE60430057220B /* iPhone.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9E61EC62FAE60430057220B /* iPhone.swift */; }; + A9E61EC82FAE60430057220B /* iPhone.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9E61EC62FAE60430057220B /* iPhone.swift */; }; A9EB72392EB93FDB00658CEB /* EmojiTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9EB72382EB93FDB00658CEB /* EmojiTableView.swift */; }; A9EB72472EB948C400658CEB /* StickerRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9EB72462EB948C400658CEB /* StickerRow.swift */; }; A9EB72492EB948C400658CEB /* StickerRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9EB72462EB948C400658CEB /* StickerRow.swift */; }; @@ -263,6 +267,8 @@ A9CD6C372EDDE37500B7F421 /* EmojiPackManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPackManager.swift; sourceTree = ""; }; A9D15B892EB1142C00404792 /* EmojiPack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPack.swift; sourceTree = ""; }; A9E2ECD72EB74CE00038B2D6 /* Config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = ""; }; + A9E61EC32FAE60370057220B /* iPad.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iPad.swift; sourceTree = ""; }; + A9E61EC62FAE60430057220B /* iPhone.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iPhone.swift; sourceTree = ""; }; A9EB72382EB93FDB00658CEB /* EmojiTableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiTableView.swift; sourceTree = ""; }; A9EB72462EB948C400658CEB /* StickerRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StickerRow.swift; sourceTree = ""; }; A9EB724C2EB94A6B00658CEB /* TrieTestingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrieTestingView.swift; sourceTree = ""; }; @@ -357,6 +363,8 @@ isa = PBXGroup; children = ( A949B1F02EA04E8200215164 /* ContentView.swift */, + A9E61EC62FAE60430057220B /* iPhone.swift */, + A9E61EC32FAE60370057220B /* iPad.swift */, A91C098C2EBBD7AB00210C34 /* EmojiPacks */, A9F423C32F87229100C0BE3B /* Shared */, A9F423C42F8722AA00C0BE3B /* Misc */, @@ -726,6 +734,7 @@ A955B3EE2EC22C4A00E1732D /* DownloadedView.swift in Sources */, A949B1FB2EA0518800215164 /* SlackResponse.swift in Sources */, A957C17A2ECE542D00EA3EE9 /* GifManager.swift in Sources */, + A9E61EC42FAE60370057220B /* iPad.swift in Sources */, A9C52F6F2F89A22000078588 /* Wiggle.metal in Sources */, A9BDEADE2F82BC93002798DF /* NoStickersView.swift in Sources */, A955B3F52EC22EE900E1732D /* SearchView.swift in Sources */, @@ -749,6 +758,7 @@ A949B1F82EA04F2300215164 /* EmojiHoarder.swift in Sources */, A9BBC5182EB8FA4500FFE82F /* ViewModifiers.swift in Sources */, A9EB72492EB948C400658CEB /* StickerRow.swift in Sources */, + A9E61EC72FAE60430057220B /* iPhone.swift in Sources */, A921C2E22ED071C900E57B1A /* ListRow.swift in Sources */, A9773C2F2EA54AF000F3B753 /* StickerPreview.swift in Sources */, A9BE30F02F5B004800A57668 /* GifHoarder.swift in Sources */, @@ -810,6 +820,7 @@ A9C52F762F89A93D00078588 /* URL.swift in Sources */, A9B9A8302EB2CD0B004C9245 /* Emoji.swift in Sources */, A9C52F702F89A22000078588 /* Wiggle.metal in Sources */, + A9E61EC52FAE60370057220B /* iPad.swift in Sources */, A955B3F12EC22E9700E1732D /* BrowseView.swift in Sources */, A9A7A4402F6835F800BB84C6 /* Trending.swift in Sources */, A975F9212FA52B3600A5C62E /* AddToPackMenuView.swift in Sources */, @@ -837,6 +848,7 @@ A9C52F7A2F89BB0800078588 /* EmojiTableViewCell.swift in Sources */, A957C1752ECCE2CE00EA3EE9 /* SettingsView.swift in Sources */, A9CD6C362EDDE22800B7F421 /* EmojiPackDetailView.swift in Sources */, + A9E61EC82FAE60430057220B /* iPhone.swift in Sources */, A9EB72472EB948C400658CEB /* StickerRow.swift in Sources */, A9CD6C392EDDE37500B7F421 /* EmojiPackManager.swift in Sources */, A97BFFBD2F9E6092000441E5 /* EmptyEmojiPackView.swift in Sources */, diff --git a/StickerSlack/Emoji/GifManager.swift b/StickerSlack/Emoji/GifManager.swift index a742501..80d3084 100644 --- a/StickerSlack/Emoji/GifManager.swift +++ b/StickerSlack/Emoji/GifManager.swift @@ -38,4 +38,30 @@ class GifManager { } return result } + + nonisolated static func uiImageFrom(data: Data) -> UIImage? { + guard let source = CGImageSourceCreateWithData(data as NSData, nil) else { fatalError("couldnt create source") } + let frameCount = CGImageSourceGetCount(source) + guard frameCount > 1 else { return UIImage(data: data) } + + var result: [UIImage] = [] + var frameDuration: Double = 0.0833333333 + + for i in 0.. UIImage? { - let raw: UIImage? + let raw: Data? switch sticker.type { case .slackEmoji: - raw = await sticker.image() + raw = await sticker.data() case .giphyGifs: if sticker.isLocal { - raw = await sticker.image() + raw = await sticker.data() } else { let gif = sticker as! Gif - raw = await gif.getPreviewImage() + raw = await gif.getPreviewData() } } guard let raw else { return nil } - return await render(image: raw) + return await render(data: raw) } - nonisolated func render(image: UIImage) async -> UIImage { + nonisolated func render(data: Data) async -> UIImage { return await Task.detached(priority: .userInitiated) { - let size = image.size - guard size.width > 0 && size.height > 0 else { return image } + return GifManager.uiImageFrom(data: data) ?? UIImage(systemName: "xmark")! - let format = UIGraphicsImageRendererFormat() - format.scale = image.scale - format.opaque = false - - let renderer = UIGraphicsImageRenderer(size: size, format: format) - return renderer.image { _ in - image.draw(at: .zero) - } +// let size = image.size +// guard size.width > 0 && size.height > 0 else { return image } +// +// let format = UIGraphicsImageRendererFormat() +// format.scale = image.scale +// format.opaque = false +// +// let renderer = UIGraphicsImageRenderer(size: size, format: format) +// return renderer.image { _ in +// image.draw(at: .zero) +// } }.value } }