Skip to content
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

RemoteImageView rendering mode #131

Closed
Alex293 opened this issue Oct 28, 2016 · 5 comments
Closed

RemoteImageView rendering mode #131

Alex293 opened this issue Oct 28, 2016 · 5 comments

Comments

@Alex293
Copy link
Contributor

Alex293 commented Oct 28, 2016

Hi i'm playing with RemoteImageView and as it get its image from the net choosing the rendering mode can be useful. I've added a quick fix for it and it works :

in class RemoteImageView add :

public var renderingMode : UIImageRenderingMode?

and in updateViews() replace :

image = imageResource?.typedContent(ifNone: placeholderImage)

by :

if let renderingMode = renderingMode
{
    image = imageResource?.typedContent(ifNone: placeholderImage)?.withRenderingMode(renderingMode)
} else {
    image = imageResource?.typedContent(ifNone: placeholderImage)
}

This is a quick draw, there may be a better way to do it ?

@pcantrell
Copy link
Member

You could configure withRenderingMode(…) as a transformer at the service level, but I tend to agree that this would be a good thing to be able to include independently on each image view.

There are other UIImage methods it seems like people might also want to apply to the downloaded image, such as resizableImage(withCapInsets:) and imageFlippedForRightToLeftLayoutDirection(). Instead of duplicating portions of the UIImage API for each one, RemoteImageView could provide a custom transform-on-set closure:

public var imageTransform: (UIImage?) -> UIImage? = { $0 }
image = imageTransform(imageResource?.typedContent(ifNone: placeholderImage))

…and then you’d do:

someImageView.imageTransform = { $0?.withRenderingMode(.alwaysTemplate) }

How would you feel about that?

@Alex293
Copy link
Contributor Author

Alex293 commented Oct 30, 2016

Indeed that would be very convenient !

@pcantrell
Copy link
Member

Good, let’s do it. I’m keeping new functionality frozen until the imminent 1.0 release is out the door. (Very soon!) Once it’s done, this easy fix can go in the first follow-up release.

@Alex293
Copy link
Contributor Author

Alex293 commented Nov 9, 2016

I've tested this in my project this is perfect

@pcantrell
Copy link
Member

1.0 is out. Feel free to submit a PR for this.

pcantrell added a commit that referenced this issue Dec 19, 2016
Some small improvements to SiestaUI proposed in #131 and in #155
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants