Compare commits

..
0 Commits
6 changed files with 34 additions and 134 deletions

No files matched your search

+9 -103
View File
@@ -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,102 +54,8 @@ struct Gif: StickerProtocol {
return
}
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
static var test: Gif = Gif(
name: "doesheknow",
url: URL(string: "https://media1.tenor.com/m/FN9udnZmQU8AAAAd/does-he-know-batman.gif")!
)
}
+13 -13
View File
@@ -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 {
-1
View File
@@ -29,7 +29,6 @@ struct BrowseView: View {
case .giphyGifs:
ForEach(gifHoarder.trendingGifs) { gif in
StickerRow(hoarder: emojiHoarder, emoji: gif)
.listRowSeparator(.hidden)
}
}
}
+4 -8
View File
@@ -34,14 +34,10 @@ struct StickerRow<T: Hoarder>: View {
Button {
showTooltip.toggle()
} label: {
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")
}
Image("slack.logo")
.resizable().scaledToFit()
.frame(width: 20, height: 20)
.foregroundStyle(.gray)
}
.buttonStyle(.borderless)
.alert("From Slack", isPresented: $showTooltip) {
+5 -5
View File
@@ -34,15 +34,15 @@ struct SearchView: View {
if currentSearch != nil {
withAnimation { currentSearch?.cancel() }
}
// currentSearch = Task {
let result = hoarder.trie.search(for: searchTerm)
currentSearch = Task {
let result = await hoarder.trie.search(for: searchTerm)
guard !Task.isCancelled else { return }
// await MainActor.run {
await MainActor.run {
withAnimation(.snappy) {
searchResult = result
}
// }
// }
}
}
}
}
}
+3 -4
View File
@@ -18,12 +18,11 @@ class Trie: ObservableObject {
var root: TrieNode = TrieNode()
var dict: [String:Emoji] = [:]
var wordlist: Set<String> = []
// var previousSearchTerm
var wordlist: [String] = []
func insert(word: String) {
let word = word.lowercased()
wordlist.insert(word)
wordlist.append(word)
var currentNode = root
let indices = word.indices
let last = indices.last
@@ -43,7 +42,7 @@ class Trie: ObservableObject {
}
func search(for query: String) -> [String] {
var result: Set<String> = wordlist
var result: Set<String> = Set(wordlist)
for word in query.split(separator: " ") {
result = result.filter { $0.localizedCaseInsensitiveContains(word) }
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.