I just started to use Kingfisher to display web images using SwiftUI. However, I seem to have a problem when the image is inside an animated view.
I have a side menu that slides in from the left with a user's profile picture on my app. When using SiftUI's default Image
, the image follows the sidebar when appearing on the screen. However, when using Kingfisher, the picture directly appears at its final destination. It does not slide in with the rest of the view.
Here is the code for my profile picture View
struct ProfilePictureView: View {
let user: User?
let size: CGFloat
var body: some View {
let hasProfilePicture = !(user?.profilePicture?.path?.isEmpty ?? true)
return VStack {
if (hasProfilePicture) {
KFImage.url(URL(string: (user?.profilePicture?.path)!))
.resizable()
.clipShape(Circle())
.aspectRatio(contentMode: .fit)
.frame(width: size, height: size)
} else {
Image("paw")
.resizable()
.clipShape(Circle())
.aspectRatio(contentMode: .fit)
.frame(width: size, height: size)
}
}
}
}
The side menu itself appears using the withAnimation
function.
Would any of you have suggestions or solutions for the problem I'm having?