forked from TextureGroup/Texture
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build a Tips system (TextureGroup#19)
- Loading branch information
1 parent
92c1c1b
commit 67387c0
Showing
33 changed files
with
1,048 additions
and
37 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -427,5 +427,11 @@ - (void)layout | |
} | ||
} | ||
} | ||
|
||
- (BOOL)supportsLayerBacking | ||
{ | ||
return NO; | ||
} | ||
|
||
@end | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// ASNodeAncestorEnumerator.h | ||
// AsyncDisplayKit | ||
// | ||
// Created by Adlai Holler on 4/12/17. | ||
// Copyright © 2017 Facebook. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <AsyncDisplayKit/ASDisplayNode.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface ASDisplayNode (Ancestry) | ||
|
||
- (NSEnumerator *)ancestorEnumeratorWithSelf:(BOOL)includeSelf; | ||
|
||
/** | ||
* e.g. "(<MYTextNode: 0xFFFF>, <MYTextContainingNode: 0xFFFF>, <MYCellNode: 0xFFFF>)" | ||
*/ | ||
@property (atomic, copy, readonly) NSString *ancestryDescription; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// | ||
// ASNodeAncestorEnumerator.m | ||
// AsyncDisplayKit | ||
// | ||
// Created by Adlai Holler on 4/12/17. | ||
// Copyright © 2017 Facebook. All rights reserved. | ||
// | ||
|
||
#import "ASDisplayNode+Ancestry.h" | ||
|
||
AS_SUBCLASSING_RESTRICTED | ||
@interface ASNodeAncestryEnumerator : NSEnumerator | ||
@end | ||
|
||
@implementation ASNodeAncestryEnumerator { | ||
/// Would be nice to use __unsafe_unretained but nodes can be | ||
/// deallocated on arbitrary threads so nope. | ||
__weak ASDisplayNode * _nextNode; | ||
} | ||
|
||
- (instancetype)initWithNode:(ASDisplayNode *)node | ||
{ | ||
if (self = [super init]) { | ||
_nextNode = node; | ||
} | ||
return self; | ||
} | ||
|
||
- (id)nextObject | ||
{ | ||
ASDisplayNode *node = _nextNode; | ||
_nextNode = [node supernode]; | ||
return node; | ||
} | ||
|
||
@end | ||
|
||
@implementation ASDisplayNode (Ancestry) | ||
|
||
- (NSEnumerator *)ancestorEnumeratorWithSelf:(BOOL)includeSelf | ||
{ | ||
ASDisplayNode *node = includeSelf ? self : self.supernode; | ||
return [[ASNodeAncestryEnumerator alloc] initWithNode:node]; | ||
} | ||
|
||
- (NSString *)ancestryDescription | ||
{ | ||
NSMutableArray *strings = [NSMutableArray array]; | ||
for (ASDisplayNode *node in [self ancestorEnumeratorWithSelf:YES]) { | ||
[strings addObject:ASObjectDescriptionMakeTiny(node)]; | ||
} | ||
return strings.description; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// AsyncDisplayKit+Tips.h | ||
// AsyncDisplayKit | ||
// | ||
// Created by Adlai Holler on 4/12/17. | ||
// Copyright © 2017 Facebook. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <AsyncDisplayKit/ASDisplayNode.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
typedef void(^ASTipDisplayBlock)(ASDisplayNode *node, NSString *message); | ||
|
||
/** | ||
* The methods added to ASDisplayNode to control the tips system. | ||
* | ||
* To enable tips, define AS_ENABLE_TIPS=1 (e.g. modify ASBaseDefines.h). | ||
*/ | ||
@interface ASDisplayNode (Tips) | ||
|
||
/** | ||
* Whether this class should have tips active. Default YES. | ||
* | ||
* NOTE: This property is for _disabling_ tips on a per-class basis, | ||
* if they become annoying or have false-positives. The tips system | ||
* is completely disabled unless you define AS_ENABLE_TIPS=1. | ||
*/ | ||
@property (class) BOOL enableTips; | ||
|
||
/** | ||
* A block to be run on the main thread to show text when a tip is tapped. | ||
* | ||
* If nil, the default, the message is just logged to the console with the | ||
* ancestry of the node. | ||
*/ | ||
@property (class, nonatomic, copy, null_resettable) ASTipDisplayBlock tipDisplayBlock; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
Oops, something went wrong.