-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] add ImageModifier #815
Conversation
Thanks for the p-r. I have to say it is a much bigger one than I expected! IMO, it would be sufficient to just provide a single and light wrapper type to meet all the needs, just similar to the existing import Foundation
/// Request modifier of image downloader.
public protocol ImageModifier {
func modified(for image: Image) -> Image?
}
struct DefaultImageModifier: ImageModifier {
static let `default` = DefaultImageModifier()
private init() {}
func modified(for image: Image) -> Image? {
return image
}
}
public struct AnyImageModifier: ImageModifier {
let block: (Image) -> Image?
public func modified(for image: Image) -> Image? {
return block(image)
}
public init(modify: @escaping (Image) -> Image? ) {
block = modify
}
} By passing a modifying block to How do you think about it? Does the |
That's a fair point; I guess it is a bit over-architected. I'll rework it to be more like A few thoughts:
|
add AlignmentRectInsetsImageModifier
Alright, please let me know what you think of the changes! @onevcat |
@ethansinjin Great work!
Yes, I totally agree with you.
The original thought is letting users have a chance to return |
I think I could do the last part of applying the modifier later. Once it has been done, I will release an update version. Thank you! |
Thanks for merging! |
[WIP] add ImageModifier
Resolves #810
This adds an ImageModifier, allowing edits to be performed on a concrete type of
Image
(ex. UIImage) right before the image is used/displayed.I've created the
KingfisherOptionsInfoItem
case andImageModifier
struct, but the actual modifier isn't being run yet. I'd like advice on where exactly to run the modifier. I think it should go indownloadAndCacheImage
andtryToRetrieveImageFromCache
, but I'm not sure; there might be a better place for it.TODO:
modify()
method somewhere inKingfisherManager.swift