mirror of
https://github.com/neon443/StickerSlack.git
synced 2026-11-30 12:44:51 +00:00
new test gif
made some things optional in gifobject
This commit is contained in:
3 files changed
+124
-26
No files matched your search
+103
-9
@@ -16,14 +16,14 @@ struct Gif: StickerProtocol {
|
|||||||
let urlString = remoteImageURL.absoluteString
|
let urlString = remoteImageURL.absoluteString
|
||||||
let split = urlString.split(separator: ".")
|
let split = urlString.split(separator: ".")
|
||||||
let fileExtension = ".\(split.last ?? "png")"
|
let fileExtension = ".\(split.last ?? "png")"
|
||||||
|
|
||||||
return GifHoarder.container.absoluteString+id+fileExtension
|
return GifHoarder.container.absoluteString+id+fileExtension
|
||||||
}
|
}
|
||||||
var remoteImageURL: URL
|
var remoteImageURL: URL
|
||||||
|
|
||||||
// enum CodingKeys: String, CodingKey {
|
// enum CodingKeys: String, CodingKey {
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
|
|
||||||
init(
|
init(
|
||||||
name: String,
|
name: String,
|
||||||
@@ -45,7 +45,7 @@ struct Gif: StickerProtocol {
|
|||||||
|
|
||||||
if let uiImage = UIImage(data: data),
|
if let uiImage = UIImage(data: data),
|
||||||
let cgImage = uiImage.cgImage,
|
let cgImage = uiImage.cgImage,
|
||||||
!self.localImageURLString.contains(".gif"),
|
!self.localImageURLString.contains(".gif"),
|
||||||
cgImage.width < 300 || cgImage.height < 300 {
|
cgImage.width < 300 || cgImage.height < 300 {
|
||||||
data = resize(image: uiImage, to: CGSize(width: 300, height: 300)).pngData()!
|
data = resize(image: uiImage, to: CGSize(width: 300, height: 300)).pngData()!
|
||||||
}
|
}
|
||||||
@@ -54,8 +54,102 @@ struct Gif: StickerProtocol {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
static var test: Gif = Gif(
|
static var test: Gif = GifObject(
|
||||||
name: "doesheknow",
|
type: "gif",
|
||||||
url: URL(string: "https://media1.tenor.com/m/FN9udnZmQU8AAAAd/does-he-know-batman.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
|
||||||
}
|
}
|
||||||
@@ -11,47 +11,47 @@ struct GiphyImages: Codable {
|
|||||||
//fixed height of 200px
|
//fixed height of 200px
|
||||||
var fixed_height: motion
|
var fixed_height: motion
|
||||||
//fixed height of 200px still
|
//fixed height of 200px still
|
||||||
var fixed_height_still: still
|
var fixed_height_still: still?
|
||||||
//fixed height 200px with 6 frames
|
//fixed height 200px with 6 frames
|
||||||
var fixed_height_downsampled: downsampled
|
var fixed_height_downsampled: downsampled
|
||||||
|
|
||||||
//fixed height of 100px
|
//fixed height of 100px
|
||||||
var fixed_height_small: motion
|
var fixed_height_small: motion
|
||||||
//fixed height of 100px still
|
//fixed height of 100px still
|
||||||
var fixed_height_small_still: still
|
var fixed_height_small_still: still?
|
||||||
|
|
||||||
//fixed width of 200px
|
//fixed width of 200px
|
||||||
var fixed_width: motion
|
var fixed_width: motion
|
||||||
//fixed width of 200px
|
//fixed width of 200px
|
||||||
var fixed_width_still: still
|
var fixed_width_still: still?
|
||||||
//fixed width 200px with 6 frames
|
//fixed width 200px with 6 frames
|
||||||
var fixed_width_downsampled: downsampled
|
var fixed_width_downsampled: downsampled
|
||||||
|
|
||||||
//fixed width of 100px
|
//fixed width of 100px
|
||||||
var fixed_width_small: motion
|
var fixed_width_small: motion
|
||||||
//fixed width of 100px still
|
//fixed width of 100px still
|
||||||
var fixed_width_small_still: still
|
var fixed_width_small_still: still?
|
||||||
|
|
||||||
//under 2mb
|
//under 2mb
|
||||||
var downsized: downsized
|
var downsized: downsized?
|
||||||
//downsized still
|
//downsized still
|
||||||
var downsized_still: still
|
var downsized_still: still?
|
||||||
//under 8mb
|
//under 8mb
|
||||||
var downsized_large: downsized
|
var downsized_large: downsized?
|
||||||
//under 5mb
|
//under 5mb
|
||||||
var downsized_medium: downsized
|
var downsized_medium: downsized?
|
||||||
//under 200kb
|
//under 200kb
|
||||||
var downsized_small: video
|
var downsized_small: video?
|
||||||
|
|
||||||
var original: motion
|
var original: motion
|
||||||
var original_still: still
|
var original_still: still?
|
||||||
|
|
||||||
//15s looping version
|
//15s looping version
|
||||||
// var looping: looping
|
var looping: looping?
|
||||||
//mp4 format 50kb, first 1-2s of the gif
|
//mp4 format 50kb, first 1-2s of the gif
|
||||||
var preview: video
|
var preview: video?
|
||||||
//50kb first 1-2s of the gif
|
//50kb first 1-2s of the gif
|
||||||
var preview_gif: still
|
var preview_gif: still?
|
||||||
|
|
||||||
|
|
||||||
struct motion: Codable {
|
struct motion: Codable {
|
||||||
|
|||||||
@@ -34,10 +34,14 @@ struct StickerRow<T: Hoarder>: View {
|
|||||||
Button {
|
Button {
|
||||||
showTooltip.toggle()
|
showTooltip.toggle()
|
||||||
} label: {
|
} label: {
|
||||||
Image("slack.logo")
|
if type(of: emoji) == Emoji.self {
|
||||||
.resizable().scaledToFit()
|
Image("slack.logo")
|
||||||
.frame(width: 20, height: 20)
|
.resizable().scaledToFit()
|
||||||
.foregroundStyle(.gray)
|
.frame(width: 20, height: 20)
|
||||||
|
.foregroundStyle(.gray)
|
||||||
|
} else if type(of: emoji) == Gif.self {
|
||||||
|
Text("G")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.buttonStyle(.borderless)
|
.buttonStyle(.borderless)
|
||||||
.alert("From Slack", isPresented: $showTooltip) {
|
.alert("From Slack", isPresented: $showTooltip) {
|
||||||
|
|||||||