mirror of
https://github.com/neon443/StickerSlack.git
synced 2026-11-30 12:44:51 +00:00
animations in emojirow
animated deleting/downloading emojis stopped it glitching when downloading/deleting an emoji removed refresh() and uiID cos its not necessary sob moved downloadImage() to stickerprotocol extension bundled an image so test emoji loading is faster
This commit is contained in:
10 files changed
+77
-65
No files matched your search
@@ -33,6 +33,25 @@ extension StickerProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
nonisolated
|
||||
func downloadImage() async throws {
|
||||
if let data = try? await Data(contentsOf: localImageURL),
|
||||
let _ = UIImage(data: data) {
|
||||
return
|
||||
}
|
||||
|
||||
var (data, _) = try await URLSession.shared.data(from: remoteImageURL)
|
||||
|
||||
if let uiImage = UIImage(data: data),
|
||||
let cgImage = uiImage.cgImage,
|
||||
await !self.localImageURLString.contains(".gif"),
|
||||
cgImage.width < 300 || cgImage.height < 300 {
|
||||
data = await resize(image: uiImage, to: CGSize(width: 300, height: 300)).pngData()!
|
||||
}
|
||||
try! await data.write(to: localImageURL)
|
||||
return
|
||||
}
|
||||
|
||||
func deleteImage() {
|
||||
try? FileManager.default.removeItem(at: localImageURL)
|
||||
return
|
||||
|
||||
@@ -10,7 +10,6 @@ import Messages
|
||||
|
||||
protocol StickerProtocol: Codable, Identifiable, Hashable {
|
||||
var id: UUID { get set }
|
||||
var uiID: UUID { get set }
|
||||
var name: String { get set }
|
||||
|
||||
var localImageURL: URL { get }
|
||||
@@ -24,7 +23,6 @@ protocol StickerProtocol: Codable, Identifiable, Hashable {
|
||||
|
||||
func downloadImage() async throws
|
||||
func deleteImage()
|
||||
mutating func refresh()
|
||||
func resize(image: UIImage, to targetSize: CGSize) -> UIImage
|
||||
static var test: Self { get }
|
||||
}
|
||||