Kingfisher icon indicating copy to clipboard operation
Kingfisher copied to clipboard

[SwiftUI] Add a way to supply a failure view

Open brzzdev opened this issue 1 year ago • 2 comments

Check List

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.

brzzdev avatar May 24 '23 12:05 brzzdev