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

introduction of ASGraphicsCreateImageWithTraitCollectionAndOptions #1675

Conversation

vovasty
Copy link
Contributor

@vovasty vovasty commented Sep 13, 2019

ASGraphicsCreateImageWithOptions uses global trait collection cause it runs in the background, thus colors, etc. in work block might receive wrong trait collection (e.g. switching dark/light mode when app in the background).
ASGraphicsCreateImageWithTraitCollectionAndOptions solves this problem by taking a trait collection as a parameter and running a drawing code inside of [[UITraitCollection -performAsCurrentTraitCollection:]

@vovasty vovasty force-pushed the vlad/ASGraphicsCreateImageWithTraitCollectionAndOptions branch from 329075e to 0c79bbe Compare September 16, 2019 05:53
@@ -130,3 +130,5 @@
#import <AsyncDisplayKit/IGListAdapter+AsyncDisplayKit.h>
#import <AsyncDisplayKit/AsyncDisplayKit+IGListKitMethods.h>
#import <AsyncDisplayKit/ASLayout+IGListKit.h>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove this whitespace.

@vovasty vovasty force-pushed the vlad/ASGraphicsCreateImageWithTraitCollectionAndOptions branch 3 times, most recently from 0c8d59d to 2c29705 Compare September 16, 2019 17:39
Source/Details/ASGraphicsContext.h Outdated Show resolved Hide resolved
*
* @return The rendered image. You can also render intermediary images using UIGraphicsGetImageFromCurrentImageContext.
*/
NS_AVAILABLE_IOS(13)
Copy link
Contributor

@rahul-malik rahul-malik Sep 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use AS_AVAILABLE_IOS_TVOS(13,13)

@vovasty vovasty force-pushed the vlad/ASGraphicsCreateImageWithTraitCollectionAndOptions branch from 2c29705 to 11e5992 Compare September 16, 2019 19:28
@vovasty vovasty force-pushed the vlad/ASGraphicsCreateImageWithTraitCollectionAndOptions branch from 11e5992 to 5a207b5 Compare September 16, 2019 19:53
@@ -27,6 +28,22 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return The rendered image. You can also render intermediary images using UIGraphicsGetImageFromCurrentImageContext.
*/
AS_EXTERN UIImage *ASGraphicsCreateImageWithOptions(CGSize size, BOOL opaque, CGFloat scale, UIImage * _Nullable sourceImage, asdisplaynode_iscancelled_block_t NS_NOESCAPE _Nullable isCancelled, void (NS_NOESCAPE ^work)());
AS_EXTERN UIImage *ASGraphicsCreateImageWithOptions(CGSize size, BOOL opaque, CGFloat scale, UIImage * _Nullable sourceImage, asdisplaynode_iscancelled_block_t NS_NOESCAPE _Nullable isCancelled, void (NS_NOESCAPE ^work)(void));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we deprecate? There is ASDISPLAYNODE_DEPRECATED_MSG which can be used here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is appropriate to deprecate since it the existing interface is insufficient for correctness.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just talked to @vovasty and we'll deprecate in a follow-up PR

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

Successfully merging this pull request may close these issues.

None yet

3 participants