no message

This commit is contained in:
Peter 2018-01-09 13:19:25 +04:00
parent 34b6e37b8c
commit 8997e0626e
12 changed files with 114 additions and 4 deletions

View File

@ -61,6 +61,10 @@
return [self layoutThatFits:constrainedSize parentSize:constrainedSize.max];
}
- (CGSize)measure:(CGSize)constrainedSize {
return [self layoutThatFits:ASSizeRangeMake(CGSizeZero, constrainedSize)].size;
}
- (ASLayout *)layoutThatFits:(ASSizeRange)constrainedSize parentSize:(CGSize)parentSize
{
ASDN::MutexLocker l(__instanceLock__);

View File

@ -186,6 +186,7 @@ NS_ASSUME_NONNULL_BEGIN
* @note This method should not be called directly outside of ASDisplayNode; use -layoutThatFits: or -calculatedLayout instead.
*/
- (ASLayout *)calculateLayoutThatFits:(ASSizeRange)constrainedSize;
- (CGSize)calculateSizeThatFits:(CGSize)contrainedSize;
/**
* ASDisplayNode's implementation of -layoutThatFits:parentSize: calls this method to resolve the node's size

View File

@ -793,6 +793,7 @@ extern NSInteger const ASDefaultDrawingPriority;
* @see [ASDisplayNode(Subclassing) calculateLayoutThatFits:]
*/
- (ASLayout *)layoutThatFits:(ASSizeRange)constrainedSize;
- (CGSize)measure:(CGSize)constrainedSize;
@end

View File

@ -35,7 +35,13 @@
#endif
/// For deallocation of objects on the main thread across multiple run loops.
#ifdef __cplusplus
extern "C" {
#endif
extern void ASPerformMainThreadDeallocation(id _Nullable __strong * _Nonnull objectPtr);
#ifdef __cplusplus
}
#endif
// Because inline methods can't be extern'd and need to be part of the translation unit of code
// that compiles with them to actually inline, we both declare and define these in the header.

View File

@ -139,6 +139,8 @@ NS_ASSUME_NONNULL_BEGIN
@property(nonatomic, readwrite, assign) BOOL enablesReturnKeyAutomatically; // default is NO (when YES, will automatically disable return key when text widget has zero-length contents, and will automatically enable when text widget has non-zero-length contents)
@property(nonatomic, readwrite, assign, getter=isSecureTextEntry) BOOL secureTextEntry; // default is NO
- (void)dropAutocorrection;
@end
@interface ASEditableTextNode (Unavailable)
@ -206,6 +208,7 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (void)editableTextNodeDidFinishEditing:(ASEditableTextNode *)editableTextNode;
- (BOOL)editableTextNodeShouldPaste:(ASEditableTextNode *)editableTextNode;
@end

View File

@ -80,6 +80,8 @@
BOOL _shouldBlockPanGesture;
}
@property (nonatomic, copy) bool (^shouldPaste)();
@end
@implementation ASPanningOverriddenUITextView
@ -103,6 +105,30 @@
[super setContentSize:contentSize];
}
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
if (action == @selector(paste:))
return true;
if (action == @selector(toggleUnderline:)) {
return false;
}
return [super canPerformAction:action withSender:sender];
}
- (id)targetForAction:(SEL)action withSender:(id)__unused sender
{
return [super targetForAction:action withSender:sender];
}
- (void)paste:(id)sender
{
if (_shouldPaste == nil || _shouldPaste()) {
[super paste:sender];
}
}
#endif
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
@ -120,7 +146,7 @@
@end
#pragma mark -
@interface ASEditableTextNode () <UITextViewDelegate, NSLayoutManagerDelegate>
@interface ASEditableTextNode () <UITextViewDelegate, NSLayoutManagerDelegate, UIGestureRecognizerDelegate>
{
@private
// Configuration.
@ -227,7 +253,18 @@
configureTextView(_placeholderTextKitComponents.textView);
// Create and configure our text view.
_textKitComponents.textView = [[ASPanningOverriddenUITextView alloc] initWithFrame:CGRectZero textContainer:_textKitComponents.textContainer];
ASPanningOverriddenUITextView *textView = [[ASPanningOverriddenUITextView alloc] initWithFrame:CGRectZero textContainer:_textKitComponents.textContainer];
__weak ASEditableTextNode *weakSelf = self;
textView.shouldPaste = ^bool{
__strong ASEditableTextNode *strongSelf = weakSelf;
if (strongSelf != nil) {
if ([strongSelf->_delegate respondsToSelector:@selector(editableTextNodeShouldPaste:)]) {
return [strongSelf->_delegate editableTextNodeShouldPaste:self];
}
}
return true;
};
_textKitComponents.textView = textView;
_textKitComponents.textView.scrollEnabled = _scrollEnabled;
_textKitComponents.textView.delegate = self;
#if TARGET_OS_IOS
@ -241,6 +278,32 @@
// once view is loaded, setters set directly on view
_textInputTraits = nil;
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGesture:)];
tapRecognizer.cancelsTouchesInView = false;
tapRecognizer.delaysTouchesBegan = false;
tapRecognizer.delaysTouchesEnded = false;
tapRecognizer.delegate = self;
[self.view addGestureRecognizer:tapRecognizer];
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
return true;
}
- (void)tapGesture:(UITapGestureRecognizer *)recognizer {
static Class promptClass = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
promptClass = NSClassFromString([[NSString alloc] initWithFormat:@"%@AutocorrectInlinePrompt", @"UI"]);
});
if (recognizer.state == UIGestureRecognizerStateEnded) {
UIView *result = [self hitTest:[recognizer locationInView:self.view] withEvent:nil];
if (result != nil && [result class] == promptClass) {
[self dropAutocorrection];
}
}
}
- (CGSize)calculateSizeThatFits:(CGSize)constrainedSize
@ -456,6 +519,15 @@
}
}
- (void)dropAutocorrection {
_isPreservingSelection = YES; // Used in -textViewDidChangeSelection: to avoid informing our delegate about our preservation.
[_textKitComponents.textView.inputDelegate textWillChange:_textKitComponents.textView];
[_textKitComponents.textView.inputDelegate textDidChange:_textKitComponents.textView];
_isPreservingSelection = NO;
}
#pragma mark - Core
- (void)_updateDisplayingPlaceholder
{

View File

@ -15,6 +15,8 @@
// http://www.apache.org/licenses/LICENSE-2.0
//
#ifndef MINIMAL_ASDK
#import <AsyncDisplayKit/ASImageNode.h>
#import <AsyncDisplayKit/ASAssert.h>
@ -150,7 +152,6 @@ NSString *const ASAnimatedImageDefaultRunLoopMode = NSRunLoopCommonModes;
[(ASNetworkImageNode *)self _locked_setDefaultImage:coverImage];
} else if (_displayLink == nil || _displayLink.paused == YES) {
[self _locked_setImage:coverImage];
#ifndef MINIMAL_ASDK
}
#endif
}
@ -395,3 +396,5 @@ NSString *const ASAnimatedImageDefaultRunLoopMode = NSRunLoopCommonModes;
}
@end
#endif

View File

@ -20,7 +20,9 @@
NS_ASSUME_NONNULL_BEGIN
#ifndef MINIMAL_ASDK
@protocol ASAnimatedImageProtocol;
#endif
/**
* Image modification block. Use to transform an image before display.
@ -143,6 +145,7 @@ typedef UIImage * _Nullable (^asimagenode_modification_block_t)(UIImage *image);
@end
#ifndef MINIMAL_ASDK
@interface ASImageNode (AnimatedImage)
/**
@ -183,6 +186,7 @@ typedef UIImage * _Nullable (^asimagenode_modification_block_t)(UIImage *image);
- (void)animatedImageSet:(id <ASAnimatedImageProtocol>)newAnimatedImage previousAnimatedImage:(id <ASAnimatedImageProtocol>)previousAnimatedImage;
@end
#endif
@interface ASImageNode (Unavailable)

View File

@ -190,7 +190,9 @@ typedef void (^ASImageNodeDrawParametersBlock)(ASWeakMapEntry *entry);
_cropRect = CGRectMake(0.5, 0.5, 0, 0);
_cropDisplayBounds = CGRectNull;
_placeholderColor = ASDisplayNodeDefaultPlaceholderColor();
#ifndef MINIMAL_ASDK
_animatedImageRunLoopMode = ASAnimatedImageDefaultRunLoopMode;
#endif
return self;
}
@ -198,7 +200,9 @@ typedef void (^ASImageNodeDrawParametersBlock)(ASWeakMapEntry *entry);
- (void)dealloc
{
// Invalidate all components around animated images
#ifndef MINIMAL_ASDK
[self invalidateAnimatedImage];
#endif
}
#pragma mark - Placeholder

View File

@ -21,6 +21,7 @@ extern NSString *const ASAnimatedImageDefaultRunLoopMode;
@interface ASImageNode ()
{
#ifndef MINIMAL_ASDK
ASDN::Mutex _displayLinkLock;
id <ASAnimatedImageProtocol> _animatedImage;
BOOL _animatedImagePaused;
@ -31,21 +32,24 @@ extern NSString *const ASAnimatedImageDefaultRunLoopMode;
//accessed on main thread only
CFTimeInterval _playHead;
NSUInteger _playedLoops;
#endif
}
@property (nonatomic, assign) CFTimeInterval lastDisplayLinkFire;
@end
#ifndef MINIMAL_ASDK
@interface ASImageNode (AnimatedImagePrivate)
- (void)_locked_setAnimatedImage:(id <ASAnimatedImageProtocol>)animatedImage;
@end
@interface ASImageNode (AnimatedImageInvalidation)
- (void)invalidateAnimatedImage;
@end
#endif

View File

@ -15,6 +15,8 @@
// http://www.apache.org/licenses/LICENSE-2.0
//
#ifndef MINIMAL_ASDK
#import <Foundation/Foundation.h>
#import <vector>
#import <AsyncDisplayKit/ASObjectDescriptionHelpers.h>
@ -217,3 +219,5 @@ NSString *NSStringFromASHierarchyChangeType(_ASHierarchyChangeType changeType);
@end
NS_ASSUME_NONNULL_END
#endif

View File

@ -15,6 +15,8 @@
// http://www.apache.org/licenses/LICENSE-2.0
//
#ifndef MINIMAL_ASDK
#import <AsyncDisplayKit/_ASHierarchyChangeSet.h>
#import <AsyncDisplayKit/ASInternalHelpers.h>
#import <AsyncDisplayKit/NSIndexSet+ASHelpers.h>
@ -1007,3 +1009,5 @@ NSString *NSStringFromASHierarchyChangeType(_ASHierarchyChangeType changeType)
}
@end
#endif