Kingfisher
Kingfisher copied to clipboard
[SwiftUI] Add a way to supply a failure view
Check List
- [✅] I have read the wiki page and cheat sheet, but there is no information I need.
- [✅] I have searched in existing issues, but did not find a same one.
- [✅] I want to report a problem instead of asking a question. It'd better to use kingfisher tag in Stack Overflow to ask a question.
Issue Description
I'm really liking the new contentConfigure
function and the ability to pass back a SwiftUI View using the completed image.
My issue lies when the image fails, contentConfigure still gets called, and has the potential to create unwanted behaviour.
Example:
KFImage(url)
.contentConfigure { image in
image
.resizable()
.aspectRatio(contentMode: .fill)
}
.placeholder {
Image(systemName: "questionmark.circle.fill")
.resizable()
.aspectRatio(contentMode: .fit)
.padding(.horizontal, 8)
}
Currently, the placeholder is used if the image fails, but it gets passed to contentConfigure and becomes fill instead of fit.
I would love an option to only use contentConfigure only for successful images, or to have access to the result of the image call within contentConfigure. onSuccess and onFailure also don't work for this use case.