Browse Source

Animate inline and profile pics too

Changelog-Fixed: Animated gif are now show inline and in profile pictures
profile-edit
Paul Miller 2 years ago
committed by William Casarin
parent
commit
54700e944c
  1. 14
      damus/Components/ImageCarousel.swift
  2. 9
      damus/Views/ProfilePicView.swift

14
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)

9
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)))
}

Loading…
Cancel
Save