mirror of
https://github.com/neon443/StickerSlack.git
synced 2026-11-30 12:44:51 +00:00
might have fixed the hitches on downloadedview
This commit is contained in:
6 files changed
+54
-22
No files matched your search
@@ -153,6 +153,8 @@
|
||||
A9EC46AE2F6D9E5800E066E6 /* StickerType.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9BE30EB2F5AFE1E00A57668 /* StickerType.swift */; };
|
||||
A9F7B3802F8951210071F198 /* 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 */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@@ -258,6 +260,7 @@
|
||||
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>"; };
|
||||
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 */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -366,6 +369,7 @@
|
||||
A94F3E632F9E384D00FA6995 /* TableView */,
|
||||
A94F3E642F9E385300FA6995 /* CollectionView */,
|
||||
A9C52F712F89A85F00078588 /* ShareSheet.swift */,
|
||||
A9FB3EE22FA7AB3A00030E2A /* UIKitGifView.swift */,
|
||||
);
|
||||
path = UIKit;
|
||||
sourceTree = "<group>";
|
||||
@@ -696,6 +700,7 @@
|
||||
files = (
|
||||
A949B1F42EA04E8200215164 /* ContentView.swift in Sources */,
|
||||
A9CD6C382EDDE37500B7F421 /* EmojiPackManager.swift in Sources */,
|
||||
A9FB3EE42FA7AB3A00030E2A /* UIKitGifView.swift in Sources */,
|
||||
A949B1F52EA04E8200215164 /* StickerSlackApp.swift in Sources */,
|
||||
A9A7A4452F68360900BB84C6 /* Pagination.swift in Sources */,
|
||||
A9104C802EB4022500D160EA /* MSSticker.swift in Sources */,
|
||||
@@ -815,6 +820,7 @@
|
||||
A9EC46AD2F6D9E4600E066E6 /* Hoarder.swift in Sources */,
|
||||
A9A7A4682F6AA17C00BB84C6 /* Int.swift in Sources */,
|
||||
A9C172DC2EB8C9AC008A7885 /* Trie.swift in Sources */,
|
||||
A9FB3EE32FA7AB3A00030E2A /* UIKitGifView.swift in Sources */,
|
||||
A9C52F7A2F89BB0800078588 /* EmojiTableViewCell.swift in Sources */,
|
||||
A957C1752ECCE2CE00EA3EE9 /* SettingsView.swift in Sources */,
|
||||
A9CD6C362EDDE22800B7F421 /* EmojiPackDetailView.swift in Sources */,
|
||||
|
||||
@@ -209,6 +209,7 @@ class EmojiHoarder: BaseHoarder {
|
||||
|
||||
override nonisolated func download(emoji: (any StickerProtocol)?, skipStoreIndex: Bool = false) async {
|
||||
guard let emoji else { return }
|
||||
guard !downloadedStickers.contains(emoji.name) else { return }
|
||||
await super.download(emoji: emoji, skipStoreIndex: skipStoreIndex)
|
||||
|
||||
await MainActor.run {
|
||||
|
||||
@@ -11,6 +11,7 @@ import SwiftUI
|
||||
import WebKit
|
||||
|
||||
struct GifView: View {
|
||||
@State var sticker: StickerProtocol?
|
||||
@State var url: URL
|
||||
@State var gif: [(frame: CGImage, showFor: Double)] = []
|
||||
@State var currentI: Int = 0
|
||||
@@ -18,22 +19,24 @@ struct GifView: View {
|
||||
|
||||
@State var timer: Timer?
|
||||
|
||||
nonisolated func run() async {
|
||||
guard await 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)]
|
||||
func run() async {
|
||||
guard url.pathExtension == "gif" else {
|
||||
Task.detached {
|
||||
if let data = try? await URLSession.shared.data(from: url).0,
|
||||
let uiImage = UIImage(data: data),
|
||||
let cgImage = uiImage.cgImage {
|
||||
withAnimation(.spring(duration: 0.2)) {
|
||||
self.gif = [(cgImage, 1)]
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
do {
|
||||
if await gif.isEmpty {
|
||||
if gif.isEmpty {
|
||||
let frames = try await GifManager.gifFrom(url: url)
|
||||
withAnimation(.spring) {
|
||||
withAnimation(.spring(duration: 0.2)) {
|
||||
self.gif = frames
|
||||
}
|
||||
}
|
||||
@@ -43,8 +46,8 @@ struct GifView: View {
|
||||
print("falied loading or empty gif")
|
||||
return
|
||||
}
|
||||
if await timer != nil {
|
||||
await timer!.invalidate()
|
||||
if timer != nil {
|
||||
timer!.invalidate()
|
||||
timer = nil
|
||||
}
|
||||
|
||||
@@ -55,7 +58,7 @@ struct GifView: View {
|
||||
currentI += 1
|
||||
}
|
||||
}
|
||||
await RunLoop.main.add(timer!, forMode: .common)
|
||||
RunLoop.main.add(timer!, forMode: .common)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
@@ -65,15 +68,13 @@ struct GifView: View {
|
||||
ProgressView()
|
||||
.modifier(fadeIn())
|
||||
} else if url.pathExtension == "gif" {
|
||||
TimelineView(.animation) { tl in
|
||||
if currentI < gif.count {
|
||||
Image(uiImage: .init(cgImage: gif[currentI].frame))
|
||||
.resizable().scaledToFit()
|
||||
}
|
||||
}
|
||||
.onDisappear {
|
||||
timer?.invalidate()
|
||||
timer = nil
|
||||
if currentI < gif.count {
|
||||
Image(uiImage: .init(cgImage: gif[currentI].frame))
|
||||
.resizable().scaledToFit()
|
||||
.onDisappear {
|
||||
timer?.invalidate()
|
||||
timer = nil
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if let frame = gif.first {
|
||||
|
||||
@@ -38,6 +38,10 @@ extension StickerProtocol {
|
||||
return try? MSSticker(contentsOfFileURL: localImageURL, localizedDescription: name)
|
||||
}
|
||||
|
||||
var isLocal: Bool {
|
||||
return FileManager.default.fileExists(atPath: localImageURLString)
|
||||
}
|
||||
|
||||
var image: UIImage? {
|
||||
if FileManager.default.fileExists(atPath: localImageURLString),
|
||||
let data = try? Data(contentsOf: localImageURL),
|
||||
|
||||
@@ -13,7 +13,7 @@ struct StickerPreview: View {
|
||||
@State var gifImage: Image?
|
||||
|
||||
var body: some View {
|
||||
if sticker.image != nil {
|
||||
if sticker.isLocal {
|
||||
//local
|
||||
GifView(url: sticker.localImageURL)
|
||||
} else {
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||