From a79bdd3e40eb74a3f3cd636c652373e2b339b411 Mon Sep 17 00:00:00 2001 From: neon443 <69979447+neon443@users.noreply.github.com> Date: Thu, 19 Mar 2026 20:11:35 +0000 Subject: [PATCH] new test gif made some things optional in gifobject --- StickerSlack/Gifs/Gif.swift | 112 ++++++++++++++++++-- StickerSlack/Models/Giphy/GiphyImages.swift | 26 ++--- StickerSlack/SwiftUI/Emoji/StickerRow.swift | 12 ++- 3 files changed, 124 insertions(+), 26 deletions(-) diff --git a/StickerSlack/Gifs/Gif.swift b/StickerSlack/Gifs/Gif.swift index 0287190..8f6cf07 100644 --- a/StickerSlack/Gifs/Gif.swift +++ b/StickerSlack/Gifs/Gif.swift @@ -16,14 +16,14 @@ struct Gif: StickerProtocol { let urlString = remoteImageURL.absoluteString let split = urlString.split(separator: ".") let fileExtension = ".\(split.last ?? "png")" - + return GifHoarder.container.absoluteString+id+fileExtension } var remoteImageURL: URL -// enum CodingKeys: String, CodingKey { -// -// } + // enum CodingKeys: String, CodingKey { + // + // } init( name: String, @@ -45,7 +45,7 @@ struct Gif: StickerProtocol { if let uiImage = UIImage(data: data), let cgImage = uiImage.cgImage, - !self.localImageURLString.contains(".gif"), + !self.localImageURLString.contains(".gif"), cgImage.width < 300 || cgImage.height < 300 { data = resize(image: uiImage, to: CGSize(width: 300, height: 300)).pngData()! } @@ -54,8 +54,102 @@ struct Gif: StickerProtocol { return } - static var test: Gif = Gif( - name: "doesheknow", - url: URL(string: "https://media1.tenor.com/m/FN9udnZmQU8AAAAd/does-he-know-batman.gif")! - ) + static var test: Gif = GifObject( + type: "gif", + id: "XAeEGyCbp8UehBPkSA", + slug: "know-does-he-XAeEGyCbp8UehBPkSA", + url: "https://giphy.com/gifs/know-does-he-XAeEGyCbp8UehBPkSA", + bitly_url: "https://gph.is/g/4AKMQlV", + embed_url: "https://giphy.com/embed/XAeEGyCbp8UehBPkSA", + username: "Ommarbisafool", + source: "", + rating: "g", + source_tld: "", + source_post_url: "", + import_datetime: "2025-11-06 15:48:02", + images: GiphyImages( + fixed_height: .init( + url: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/200.gif?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=200.gif&ct=g", + width: "270", + height: "200", + size: "74672", + mp4: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/200.mp4?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=200.mp4&ct=g", + mp4_size: "11433", + webp: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/200.webp?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=200.webp&ct=g", + webp_size: "10962" + ), + fixed_height_still: nil, + fixed_height_downsampled: .init( + url: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/200_d.gif?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=200_d.gif&ct=g", + width: "270", + height: "200", + size: "51332", + webp: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/200_d.webp?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=200_d.webp&ct=g", + webp_size: "44850" + ), + fixed_height_small: .init( + url: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/100.gif?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=100.gif&ct=g", + width: "134", + height: "100", + size: "16461", + mp4: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/100.mp4?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=100.mp4&ct=g", + mp4_size: "5340", + webp: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/100.webp?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=100.webp&ct=g", + webp_size: "3142" + ), + fixed_height_small_still: nil, + fixed_width: .init( + url: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/200w.gif?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=200w.gif&ct=g", + width: "200", + height: "148", + size: "42579", + mp4: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/200w.mp4?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=200w.mp4&ct=g", + mp4_size: "8158", + webp: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/200w.webp?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=200w.webp&ct=g", + webp_size: "4458" + ), + fixed_width_still: nil, + fixed_width_downsampled: .init( + url: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/200w_d.gif?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=200w_d.gif&ct=g", + width: "200", + height: "148", + size: "23483", + webp: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/200w_d.webp?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=200w_d.webp&ct=g", + webp_size: "22586" + ), + fixed_width_small: .init( + url: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/100w.gif?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=100w.gif&ct=g", + width: "100", + height: "74", + size: "8150", + mp4: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/100w.mp4?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=100w.mp4&ct=g", + mp4_size: "4103", + webp: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/100w.webp?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=100w.webp&ct=g", + webp_size: "1814" + ), + fixed_width_small_still: nil, + downsized: nil, + downsized_still: nil, + downsized_large: nil, + downsized_medium: nil, + downsized_small: nil, + original: .init( + url: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/giphy.gif?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=giphy.gif&ct=g", + width: "480", + height: "356", + size: "245829", + mp4: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/giphy.mp4?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=giphy.mp4&ct=g", + mp4_size: "23259", + webp: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/giphy.webp?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=giphy.webp&ct=g", + webp_size: "26984" + ), + original_still: nil, + looping: nil, + preview: nil, + preview_gif: nil + ), + title: "Know GIF", + alt_text: "", + is_low_contrast: false + ).toGif } diff --git a/StickerSlack/Models/Giphy/GiphyImages.swift b/StickerSlack/Models/Giphy/GiphyImages.swift index 54b6273..a400877 100644 --- a/StickerSlack/Models/Giphy/GiphyImages.swift +++ b/StickerSlack/Models/Giphy/GiphyImages.swift @@ -11,47 +11,47 @@ struct GiphyImages: Codable { //fixed height of 200px var fixed_height: motion //fixed height of 200px still - var fixed_height_still: 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 + var fixed_height_small_still: still? //fixed width of 200px var fixed_width: motion //fixed width of 200px - var fixed_width_still: still + 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 + var fixed_width_small_still: still? //under 2mb - var downsized: downsized + var downsized: downsized? //downsized still - var downsized_still: still + var downsized_still: still? //under 8mb - var downsized_large: downsized + var downsized_large: downsized? //under 5mb - var downsized_medium: downsized + var downsized_medium: downsized? //under 200kb - var downsized_small: video + var downsized_small: video? var original: motion - var original_still: still + var original_still: still? //15s looping version -// var looping: looping + var looping: looping? //mp4 format 50kb, first 1-2s of the gif - var preview: video + var preview: video? //50kb first 1-2s of the gif - var preview_gif: still + var preview_gif: still? struct motion: Codable { diff --git a/StickerSlack/SwiftUI/Emoji/StickerRow.swift b/StickerSlack/SwiftUI/Emoji/StickerRow.swift index 09dbcf5..eb099b1 100644 --- a/StickerSlack/SwiftUI/Emoji/StickerRow.swift +++ b/StickerSlack/SwiftUI/Emoji/StickerRow.swift @@ -34,10 +34,14 @@ struct StickerRow: View { Button { showTooltip.toggle() } label: { - Image("slack.logo") - .resizable().scaledToFit() - .frame(width: 20, height: 20) - .foregroundStyle(.gray) + if type(of: emoji) == Emoji.self { + Image("slack.logo") + .resizable().scaledToFit() + .frame(width: 20, height: 20) + .foregroundStyle(.gray) + } else if type(of: emoji) == Gif.self { + Text("G") + } } .buttonStyle(.borderless) .alert("From Slack", isPresented: $showTooltip) {