might have fixed the hitches on downloadedview

This commit is contained in:
neon443 committed 2026-05-03 17:46:59 +01:00
1 parent ba09d82aec
commit 0294e4b60b
6 files changed
+54 -22

No files matched your search

+6
View File
@@ -153,6 +153,8 @@
A9EC46AE2F6D9E5800E066E6 /* StickerType.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9BE30EB2F5AFE1E00A57668 /* StickerType.swift */; }; A9EC46AE2F6D9E5800E066E6 /* StickerType.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9BE30EB2F5AFE1E00A57668 /* StickerType.swift */; };
A9F7B3802F8951210071F198 /* EmojiPackImporterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9F7B37F2F8951210071F198 /* EmojiPackImporterView.swift */; }; A9F7B3802F8951210071F198 /* EmojiPackImporterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9F7B37F2F8951210071F198 /* EmojiPackImporterView.swift */; };
A9F7B3812F8951210071F198 /* EmojiPackImporterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9F7B37F2F8951210071F198 /* EmojiPackImporterView.swift */; }; A9F7B3812F8951210071F198 /* EmojiPackImporterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9F7B37F2F8951210071F198 /* EmojiPackImporterView.swift */; };
A9FB3EE32FA7AB3A00030E2A /* UIKitGifView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9FB3EE22FA7AB3A00030E2A /* UIKitGifView.swift */; };
A9FB3EE42FA7AB3A00030E2A /* UIKitGifView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9FB3EE22FA7AB3A00030E2A /* UIKitGifView.swift */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */ /* Begin PBXContainerItemProxy section */
@@ -258,6 +260,7 @@
A9EB72462EB948C400658CEB /* StickerRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StickerRow.swift; sourceTree = "<group>"; }; A9EB72462EB948C400658CEB /* StickerRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StickerRow.swift; sourceTree = "<group>"; };
A9EB724C2EB94A6B00658CEB /* TrieTestingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrieTestingView.swift; sourceTree = "<group>"; }; A9EB724C2EB94A6B00658CEB /* TrieTestingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrieTestingView.swift; sourceTree = "<group>"; };
A9F7B37F2F8951210071F198 /* EmojiPackImporterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPackImporterView.swift; sourceTree = "<group>"; }; A9F7B37F2F8951210071F198 /* EmojiPackImporterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPackImporterView.swift; sourceTree = "<group>"; };
A9FB3EE22FA7AB3A00030E2A /* UIKitGifView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIKitGifView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
@@ -366,6 +369,7 @@
A94F3E632F9E384D00FA6995 /* TableView */, A94F3E632F9E384D00FA6995 /* TableView */,
A94F3E642F9E385300FA6995 /* CollectionView */, A94F3E642F9E385300FA6995 /* CollectionView */,
A9C52F712F89A85F00078588 /* ShareSheet.swift */, A9C52F712F89A85F00078588 /* ShareSheet.swift */,
A9FB3EE22FA7AB3A00030E2A /* UIKitGifView.swift */,
); );
path = UIKit; path = UIKit;
sourceTree = "<group>"; sourceTree = "<group>";
@@ -696,6 +700,7 @@
files = ( files = (
A949B1F42EA04E8200215164 /* ContentView.swift in Sources */, A949B1F42EA04E8200215164 /* ContentView.swift in Sources */,
A9CD6C382EDDE37500B7F421 /* EmojiPackManager.swift in Sources */, A9CD6C382EDDE37500B7F421 /* EmojiPackManager.swift in Sources */,
A9FB3EE42FA7AB3A00030E2A /* UIKitGifView.swift in Sources */,
A949B1F52EA04E8200215164 /* StickerSlackApp.swift in Sources */, A949B1F52EA04E8200215164 /* StickerSlackApp.swift in Sources */,
A9A7A4452F68360900BB84C6 /* Pagination.swift in Sources */, A9A7A4452F68360900BB84C6 /* Pagination.swift in Sources */,
A9104C802EB4022500D160EA /* MSSticker.swift in Sources */, A9104C802EB4022500D160EA /* MSSticker.swift in Sources */,
@@ -815,6 +820,7 @@
A9EC46AD2F6D9E4600E066E6 /* Hoarder.swift in Sources */, A9EC46AD2F6D9E4600E066E6 /* Hoarder.swift in Sources */,
A9A7A4682F6AA17C00BB84C6 /* Int.swift in Sources */, A9A7A4682F6AA17C00BB84C6 /* Int.swift in Sources */,
A9C172DC2EB8C9AC008A7885 /* Trie.swift in Sources */, A9C172DC2EB8C9AC008A7885 /* Trie.swift in Sources */,
A9FB3EE32FA7AB3A00030E2A /* UIKitGifView.swift in Sources */,
A9C52F7A2F89BB0800078588 /* EmojiTableViewCell.swift in Sources */, A9C52F7A2F89BB0800078588 /* EmojiTableViewCell.swift in Sources */,
A957C1752ECCE2CE00EA3EE9 /* SettingsView.swift in Sources */, A957C1752ECCE2CE00EA3EE9 /* SettingsView.swift in Sources */,
A9CD6C362EDDE22800B7F421 /* EmojiPackDetailView.swift in Sources */, A9CD6C362EDDE22800B7F421 /* EmojiPackDetailView.swift in Sources */,
+1
View File
@@ -209,6 +209,7 @@ class EmojiHoarder: BaseHoarder {
override nonisolated func download(emoji: (any StickerProtocol)?, skipStoreIndex: Bool = false) async { override nonisolated func download(emoji: (any StickerProtocol)?, skipStoreIndex: Bool = false) async {
guard let emoji else { return } guard let emoji else { return }
guard !downloadedStickers.contains(emoji.name) else { return }
await super.download(emoji: emoji, skipStoreIndex: skipStoreIndex) await super.download(emoji: emoji, skipStoreIndex: skipStoreIndex)
await MainActor.run { await MainActor.run {
+22 -21
View File
@@ -11,6 +11,7 @@ import SwiftUI
import WebKit import WebKit
struct GifView: View { struct GifView: View {
@State var sticker: StickerProtocol?
@State var url: URL @State var url: URL
@State var gif: [(frame: CGImage, showFor: Double)] = [] @State var gif: [(frame: CGImage, showFor: Double)] = []
@State var currentI: Int = 0 @State var currentI: Int = 0
@@ -18,22 +19,24 @@ struct GifView: View {
@State var timer: Timer? @State var timer: Timer?
nonisolated func run() async { func run() async {
guard await url.pathExtension == "gif" else { guard url.pathExtension == "gif" else {
if let data = try? await URLSession.shared.data(from: url).0, Task.detached {
let uiImage = UIImage(data: data), if let data = try? await URLSession.shared.data(from: url).0,
let cgImage = uiImage.cgImage { let uiImage = UIImage(data: data),
withAnimation(.spring) { let cgImage = uiImage.cgImage {
self.gif = [(cgImage, 1)] withAnimation(.spring(duration: 0.2)) {
self.gif = [(cgImage, 1)]
}
} }
} }
return return
} }
do { do {
if await gif.isEmpty { if gif.isEmpty {
let frames = try await GifManager.gifFrom(url: url) let frames = try await GifManager.gifFrom(url: url)
withAnimation(.spring) { withAnimation(.spring(duration: 0.2)) {
self.gif = frames self.gif = frames
} }
} }
@@ -43,8 +46,8 @@ struct GifView: View {
print("falied loading or empty gif") print("falied loading or empty gif")
return return
} }
if await timer != nil { if timer != nil {
await timer!.invalidate() timer!.invalidate()
timer = nil timer = nil
} }
@@ -55,7 +58,7 @@ struct GifView: View {
currentI += 1 currentI += 1
} }
} }
await RunLoop.main.add(timer!, forMode: .common) RunLoop.main.add(timer!, forMode: .common)
} }
var body: some View { var body: some View {
@@ -65,15 +68,13 @@ struct GifView: View {
ProgressView() ProgressView()
.modifier(fadeIn()) .modifier(fadeIn())
} else if url.pathExtension == "gif" { } else if url.pathExtension == "gif" {
TimelineView(.animation) { tl in if currentI < gif.count {
if currentI < gif.count { Image(uiImage: .init(cgImage: gif[currentI].frame))
Image(uiImage: .init(cgImage: gif[currentI].frame)) .resizable().scaledToFit()
.resizable().scaledToFit() .onDisappear {
} timer?.invalidate()
} timer = nil
.onDisappear { }
timer?.invalidate()
timer = nil
} }
} else { } else {
if let frame = gif.first { if let frame = gif.first {
+4
View File
@@ -38,6 +38,10 @@ extension StickerProtocol {
return try? MSSticker(contentsOfFileURL: localImageURL, localizedDescription: name) return try? MSSticker(contentsOfFileURL: localImageURL, localizedDescription: name)
} }
var isLocal: Bool {
return FileManager.default.fileExists(atPath: localImageURLString)
}
var image: UIImage? { var image: UIImage? {
if FileManager.default.fileExists(atPath: localImageURLString), if FileManager.default.fileExists(atPath: localImageURLString),
let data = try? Data(contentsOf: localImageURL), let data = try? Data(contentsOf: localImageURL),
@@ -13,7 +13,7 @@ struct StickerPreview: View {
@State var gifImage: Image? @State var gifImage: Image?
var body: some View { var body: some View {
if sticker.image != nil { if sticker.isLocal {
//local //local
GifView(url: sticker.localImageURL) GifView(url: sticker.localImageURL)
} else { } else {
+20
View File
@@ -0,0 +1,20 @@
//
// UIKitGifView.swift
// StickerSlack
//
// Created by neon443 on 03/05/2026.
//
import Foundation
import UIKit
class UIKitGifView: UIImageView {
override init(image: UIImage?) {
// <#code#>
super.init(image: image)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
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.