faster gifView for images

This commit is contained in:
neon443 committed 2026-04-10 20:11:01 +01:00
1 parent 99500e7b08
commit fc1e812d4f
4 files changed
+68 -38

No files matched your search

+13
View File
@@ -246,6 +246,19 @@ class EmojiHoarder: BaseHoarder {
self.showWelcome = newValue
}
func loadEmojiPacks() {
}
func saveEmojiPacks() {
var toStore: [URL] = []
for pack in emojiPacks {
toStore.append(pack.shareLink())
}
guard let encoded = try? JSONEncoder().encode(toStore) else { return }
}
func generateLetterStats() {
var result: [EmojiHoarder.LetterStat] = []
for child in trie.root.children {
+23 -8
View File
@@ -18,6 +18,17 @@ struct GifView: View {
@State var timer: Timer?
func run() async {
guard url.pathExtension == "gif" else {
if let data = try? await URLSession.shared.data(from: url).0,
let uiImage = UIImage(data: data),
let cgImage = uiImage.cgImage {
withAnimation(.spring) {
self.gif = [(cgImage, 1)]
}
}
return
}
do {
if gif.isEmpty {
let frames = try await GifManager.gifFrom(url: url)
@@ -48,26 +59,30 @@ struct GifView: View {
var body: some View {
// /*@START_MENU_TOKEN@*//*@PLACEHOLDER=Hello, world!@*/Text("Hello, world!")/*@END_MENU_TOKEN@*/
TimelineView(.animation) { tl in
VStack {
Group {
if gif.isEmpty {
ProgressView()
.controlSize(.large)
.frame(maxWidth: .infinity, maxHeight: .infinity)
} else {
} else if url.pathExtension == "gif" {
TimelineView(.animation) { tl in
if currentI < gif.count {
let image = Image(uiImage: .init(cgImage: gif[currentI].frame))
image
Image(uiImage: .init(cgImage: gif[currentI].frame))
.resizable().scaledToFit()
}
}
}
.transition(.scale)
}
.onDisappear {
timer?.invalidate()
timer = nil
}
} else {
if let frame = gif.first {
Image(uiImage: .init(cgImage: frame.frame))
.resizable().scaledToFit()
}
}
}
.transition(.scale)
.onAppear {
Task {
await run()
+30 -29
View File
@@ -134,35 +134,36 @@ extension EmojiPack {
"loll",
"bleh",
"uhh",
"communist",
"ufahh",
"uhafh",
"uhgfh",
"uoohh",
"ujyhgghh",
"uhfgh",
"ujg3thh",
"uyhh",
"ughhhh",
"uvhh",
"ujrg3tjthhg",
"ujherh",
"uxhggrh",
"ushgrq3geallh",
"u hrgqh",
"ujjjjjyhgh",
"uherhh",
"uhhesh",
"hhreruhgh",
"u hffh",
"uh h",
"uaugerhh",
"u4h3h",
"u4hh",
"ueyhh ",
"u erthh",
"uhujh",
"ujkkkkhh"
"communist"
// "communist",
// "ufahh",
// "uhafh",
// "uhgfh",
// "uoohh",
// "ujyhgghh",
// "uhfgh",
// "ujg3thh",
// "uyhh",
// "ughhhh",
// "uvhh",
// "ujrg3tjthhg",
// "ujherh",
// "uxhggrh",
// "ushgrq3geallh",
// "u hrgqh",
// "ujjjjjyhgh",
// "uherhh",
// "uhhesh",
// "hhreruhgh",
// "u hffh",
// "uh h",
// "uaugerhh",
// "u4h3h",
// "u4hh",
// "ueyhh ",
// "u erthh",
// "uhujh",
// "ujkkkkhh"
]
)
}
@@ -81,6 +81,7 @@ struct EmojiPackDetailView: View {
.blur(radius: 5)
.shadow(color: .purple, radius: 5)
}
.padding()
}
let columns: Int = max(1, Int((geo.size.width - 2*spacing) / (minColWidth + spacing)))
@@ -172,7 +173,7 @@ struct EmojiPackDetailView: View {
}
}
.onDisappear {
print("disappear")
hoarder.
}
}
}
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.