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

[ASTextNode2] Provide compiler flag to enable ASTextNode2 for all usages. #410

Merged
merged 5 commits into from
Jul 3, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AsyncDisplayKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@
CCCCCCE41EC3EF060087FE10 /* NSParagraphStyle+ASText.m in Sources */ = {isa = PBXBuildFile; fileRef = CCCCCCD41EC3EF060087FE10 /* NSParagraphStyle+ASText.m */; };
CCCCCCE71EC3F0FC0087FE10 /* NSAttributedString+ASText.h in Headers */ = {isa = PBXBuildFile; fileRef = CCCCCCE51EC3F0FC0087FE10 /* NSAttributedString+ASText.h */; };
CCCCCCE81EC3F0FC0087FE10 /* NSAttributedString+ASText.m in Sources */ = {isa = PBXBuildFile; fileRef = CCCCCCE61EC3F0FC0087FE10 /* NSAttributedString+ASText.m */; };
CCD523111EBD658C001F2191 /* ASTextNode2.h in Headers */ = {isa = PBXBuildFile; fileRef = CCD5230F1EBD658C001F2191 /* ASTextNode2.h */; };
CCD523111EBD658C001F2191 /* ASTextNode2.h in Headers */ = {isa = PBXBuildFile; fileRef = CCD5230F1EBD658C001F2191 /* ASTextNode2.h */; settings = {ATTRIBUTES = (Public, ); }; };
CCD523121EBD658C001F2191 /* ASTextNode2.mm in Sources */ = {isa = PBXBuildFile; fileRef = CCD523101EBD658C001F2191 /* ASTextNode2.mm */; };
CCDD148B1EEDCD9D0020834E /* ASCollectionModernDataSourceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CCDD148A1EEDCD9D0020834E /* ASCollectionModernDataSourceTests.m */; };
CCF18FF41D2575E300DF5895 /* NSIndexSet+ASHelpers.h in Headers */ = {isa = PBXBuildFile; fileRef = CC4981BA1D1C7F65004E13CC /* NSIndexSet+ASHelpers.h */; settings = {ATTRIBUTES = (Private, ); }; };
Expand Down
19 changes: 17 additions & 2 deletions Source/ASTextNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,18 @@
// http://www.apache.org/licenses/LICENSE-2.0
//

#import <AsyncDisplayKit/ASAvailability.h>
#import <AsyncDisplayKit/ASControlNode.h>
#if ASTEXTNODE2_ENABLED
#import <AsyncDisplayKit/ASTextNode2.h>
#endif

NS_ASSUME_NONNULL_BEGIN

@protocol ASTextNodeDelegate;

#if !ASTEXTNODE2_ENABLED

/**
* Highlight styles.
*/
Expand Down Expand Up @@ -232,6 +238,13 @@ typedef NS_ENUM(NSUInteger, ASTextNodeHighlightStyle) {

@end

#else

@interface ASTextNode : ASTextNode2
@end

#endif

/**
* @abstract Text node delegate.
*/
Expand Down Expand Up @@ -287,6 +300,8 @@ typedef NS_ENUM(NSUInteger, ASTextNodeHighlightStyle) {

@end

#if !ASTEXTNODE2_ENABLED

@interface ASTextNode (Unavailable)

- (instancetype)initWithLayerBlock:(ASDisplayNodeLayerBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock __unavailable;
Expand Down Expand Up @@ -319,6 +334,6 @@ typedef NS_ENUM(NSUInteger, ASTextNodeHighlightStyle) {

@end

NS_ASSUME_NONNULL_END

#endif

NS_ASSUME_NONNULL_END
9 changes: 9 additions & 0 deletions Source/ASTextNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#import <AsyncDisplayKit/ASTextNode.h>
#import <AsyncDisplayKit/ASTextNode2.h>

#if !ASTEXTNODE2_ENABLED
#import <AsyncDisplayKit/ASTextNode+Beta.h>

#include <mutex>
Expand Down Expand Up @@ -1471,3 +1473,10 @@ - (NSAttributedString *)truncationAttributedString
}

@end

#else

@implementation ASTextNode
@end

#endif
4 changes: 4 additions & 0 deletions Source/Base/ASAvailability.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
#define YOGA __has_include(YOGA_HEADER_PATH)
#endif

#ifndef ASTEXTNODE2_ENABLED
#define ASTEXTNODE2_ENABLED 0
#endif

#define AS_PIN_REMOTE_IMAGE __has_include(<PINRemoteImage/PINRemoteImage.h>)
#define AS_IG_LIST_KIT __has_include(<IGListKit/IGListKit.h>)

Expand Down
19 changes: 19 additions & 0 deletions Source/Private/ASTextNode2.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,27 @@

#import <AsyncDisplayKit/ASControlNode.h>

#if !ASTEXTNODE2_ENABLED
// Import this to get ASTextNodeHighlightStyle
#import <AsyncDisplayKit/ASTextNode.h>
#else
@protocol ASTextNodeDelegate;

/**
* Highlight styles.
*/
typedef NS_ENUM(NSUInteger, ASTextNodeHighlightStyle) {
/**
* Highlight style for text on a light background.
*/
ASTextNodeHighlightStyleLight,

/**
* Highlight style for text on a dark background.
*/
ASTextNodeHighlightStyleDark
};
#endif

NS_ASSUME_NONNULL_BEGIN

Expand Down
1 change: 1 addition & 0 deletions Source/Private/ASTextNode2.mm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
//

#import <AsyncDisplayKit/ASTextNode2.h>
#import <AsyncDisplayKit/ASTextNode.h> // Definition of ASTextNodeDelegate
Copy link
Member Author

Choose a reason for hiding this comment

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

In the future everything will be merged. However, in a separate diff, we could clean this up to add an ASTextNodeDefinitions.h or similar to declare both the highlight enum and the delegate protocol.

I'm aiming to keep this particular diff quick, but it does raise the question of what our migration path should be to ASTextNode2.


#import <tgmath.h>
#import <deque>
Expand Down