commit 54700e944c03908493d5e843ed3dfd69721ae32c
parent 5f93c580eba64099c4b235525e664ad44f16df88
Author: Paul Miller <paul@paul.lol>
Date: Tue, 20 Dec 2022 00:17:12 -0600
Animate inline and profile pics too
Changelog-Fixed: Animated gif are now show inline and in profile pictures
Diffstat:
2 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/damus/Components/ImageCarousel.swift b/damus/Components/ImageCarousel.swift
@@ -17,11 +17,14 @@ struct ImageViewer: View {
VStack{
Text(url.lastPathComponent)
- KFImage(url)
+ KFAnimatedImage(url)
+ .configure { view in
+ view.framePreloadCount = 3
+ }
+ .cacheOriginalImage()
.loadDiskFileSynchronously()
.scaleFactor(UIScreen.main.scale)
.fade(duration: 0.1)
- .resizable()
.aspectRatio(contentMode: .fit)
.tabItem {
Text(url.absoluteString)
@@ -43,11 +46,14 @@ struct ImageCarousel: View {
var body: some View {
TabView {
ForEach(urls, id: \.absoluteString) { url in
- KFImage(url)
+ KFAnimatedImage(url)
+ .configure { view in
+ view.framePreloadCount = 3
+ }
+ .cacheOriginalImage()
.loadDiskFileSynchronously()
.scaleFactor(UIScreen.main.scale)
.fade(duration: 0.1)
- .resizable()
.aspectRatio(contentMode: .fit)
.tabItem {
Text(url.absoluteString)
diff --git a/damus/Views/ProfilePicView.swift b/damus/Views/ProfilePicView.swift
@@ -56,16 +56,19 @@ struct ProfilePicView: View {
Group {
let pic = picture ?? profiles.lookup(id: pubkey)?.picture ?? robohash(pubkey)
let url = URL(string: pic)
- let processor = ResizingImageProcessor(referenceSize: CGSize(width: size, height: size))
- KFImage.url(url)
+ KFAnimatedImage(url)
+ .configure { view in
+ view.framePreloadCount = 1
+ }
.placeholder { _ in
Placeholder
}
- .setProcessor(processor)
+ .cacheOriginalImage()
.scaleFactor(UIScreen.main.scale)
.loadDiskFileSynchronously()
.fade(duration: 0.1)
+ .frame(width: size, height: size)
.clipShape(Circle())
.overlay(Circle().stroke(highlight_color(highlight), lineWidth: pfp_line_width(highlight)))
}