mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-17 03:40:18 +00:00
no message
This commit is contained in:
parent
34b6e37b8c
commit
8997e0626e
@ -61,6 +61,10 @@
|
|||||||
return [self layoutThatFits:constrainedSize parentSize:constrainedSize.max];
|
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
|
- (ASLayout *)layoutThatFits:(ASSizeRange)constrainedSize parentSize:(CGSize)parentSize
|
||||||
{
|
{
|
||||||
ASDN::MutexLocker l(__instanceLock__);
|
ASDN::MutexLocker l(__instanceLock__);
|
||||||
|
|||||||
@ -186,6 +186,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
* @note This method should not be called directly outside of ASDisplayNode; use -layoutThatFits: or -calculatedLayout instead.
|
* @note This method should not be called directly outside of ASDisplayNode; use -layoutThatFits: or -calculatedLayout instead.
|
||||||
*/
|
*/
|
||||||
- (ASLayout *)calculateLayoutThatFits:(ASSizeRange)constrainedSize;
|
- (ASLayout *)calculateLayoutThatFits:(ASSizeRange)constrainedSize;
|
||||||
|
- (CGSize)calculateSizeThatFits:(CGSize)contrainedSize;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ASDisplayNode's implementation of -layoutThatFits:parentSize: calls this method to resolve the node's size
|
* ASDisplayNode's implementation of -layoutThatFits:parentSize: calls this method to resolve the node's size
|
||||||
|
|||||||
@ -793,6 +793,7 @@ extern NSInteger const ASDefaultDrawingPriority;
|
|||||||
* @see [ASDisplayNode(Subclassing) calculateLayoutThatFits:]
|
* @see [ASDisplayNode(Subclassing) calculateLayoutThatFits:]
|
||||||
*/
|
*/
|
||||||
- (ASLayout *)layoutThatFits:(ASSizeRange)constrainedSize;
|
- (ASLayout *)layoutThatFits:(ASSizeRange)constrainedSize;
|
||||||
|
- (CGSize)measure:(CGSize)constrainedSize;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|||||||
@ -35,7 +35,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// For deallocation of objects on the main thread across multiple run loops.
|
/// 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);
|
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
|
// 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.
|
// that compiles with them to actually inline, we both declare and define these in the header.
|
||||||
|
|||||||
@ -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) 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
|
@property(nonatomic, readwrite, assign, getter=isSecureTextEntry) BOOL secureTextEntry; // default is NO
|
||||||
|
|
||||||
|
- (void)dropAutocorrection;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface ASEditableTextNode (Unavailable)
|
@interface ASEditableTextNode (Unavailable)
|
||||||
@ -206,6 +208,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
*/
|
*/
|
||||||
- (void)editableTextNodeDidFinishEditing:(ASEditableTextNode *)editableTextNode;
|
- (void)editableTextNodeDidFinishEditing:(ASEditableTextNode *)editableTextNode;
|
||||||
|
|
||||||
|
- (BOOL)editableTextNodeShouldPaste:(ASEditableTextNode *)editableTextNode;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|||||||
@ -80,6 +80,8 @@
|
|||||||
BOOL _shouldBlockPanGesture;
|
BOOL _shouldBlockPanGesture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@property (nonatomic, copy) bool (^shouldPaste)();
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation ASPanningOverriddenUITextView
|
@implementation ASPanningOverriddenUITextView
|
||||||
@ -103,6 +105,30 @@
|
|||||||
[super setContentSize:contentSize];
|
[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
|
#endif
|
||||||
|
|
||||||
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
|
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
|
||||||
@ -120,7 +146,7 @@
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
@interface ASEditableTextNode () <UITextViewDelegate, NSLayoutManagerDelegate>
|
@interface ASEditableTextNode () <UITextViewDelegate, NSLayoutManagerDelegate, UIGestureRecognizerDelegate>
|
||||||
{
|
{
|
||||||
@private
|
@private
|
||||||
// Configuration.
|
// Configuration.
|
||||||
@ -227,7 +253,18 @@
|
|||||||
configureTextView(_placeholderTextKitComponents.textView);
|
configureTextView(_placeholderTextKitComponents.textView);
|
||||||
|
|
||||||
// Create and configure our text view.
|
// 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.scrollEnabled = _scrollEnabled;
|
||||||
_textKitComponents.textView.delegate = self;
|
_textKitComponents.textView.delegate = self;
|
||||||
#if TARGET_OS_IOS
|
#if TARGET_OS_IOS
|
||||||
@ -241,6 +278,32 @@
|
|||||||
|
|
||||||
// once view is loaded, setters set directly on view
|
// once view is loaded, setters set directly on view
|
||||||
_textInputTraits = nil;
|
_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
|
- (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
|
#pragma mark - Core
|
||||||
- (void)_updateDisplayingPlaceholder
|
- (void)_updateDisplayingPlaceholder
|
||||||
{
|
{
|
||||||
|
|||||||
@ -15,6 +15,8 @@
|
|||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#ifndef MINIMAL_ASDK
|
||||||
|
|
||||||
#import <AsyncDisplayKit/ASImageNode.h>
|
#import <AsyncDisplayKit/ASImageNode.h>
|
||||||
|
|
||||||
#import <AsyncDisplayKit/ASAssert.h>
|
#import <AsyncDisplayKit/ASAssert.h>
|
||||||
@ -150,7 +152,6 @@ NSString *const ASAnimatedImageDefaultRunLoopMode = NSRunLoopCommonModes;
|
|||||||
[(ASNetworkImageNode *)self _locked_setDefaultImage:coverImage];
|
[(ASNetworkImageNode *)self _locked_setDefaultImage:coverImage];
|
||||||
} else if (_displayLink == nil || _displayLink.paused == YES) {
|
} else if (_displayLink == nil || _displayLink.paused == YES) {
|
||||||
[self _locked_setImage:coverImage];
|
[self _locked_setImage:coverImage];
|
||||||
#ifndef MINIMAL_ASDK
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -395,3 +396,5 @@ NSString *const ASAnimatedImageDefaultRunLoopMode = NSRunLoopCommonModes;
|
|||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@ -20,7 +20,9 @@
|
|||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
#ifndef MINIMAL_ASDK
|
||||||
@protocol ASAnimatedImageProtocol;
|
@protocol ASAnimatedImageProtocol;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Image modification block. Use to transform an image before display.
|
* Image modification block. Use to transform an image before display.
|
||||||
@ -143,6 +145,7 @@ typedef UIImage * _Nullable (^asimagenode_modification_block_t)(UIImage *image);
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
#ifndef MINIMAL_ASDK
|
||||||
@interface ASImageNode (AnimatedImage)
|
@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;
|
- (void)animatedImageSet:(id <ASAnimatedImageProtocol>)newAnimatedImage previousAnimatedImage:(id <ASAnimatedImageProtocol>)previousAnimatedImage;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
#endif
|
||||||
|
|
||||||
@interface ASImageNode (Unavailable)
|
@interface ASImageNode (Unavailable)
|
||||||
|
|
||||||
|
|||||||
@ -190,7 +190,9 @@ typedef void (^ASImageNodeDrawParametersBlock)(ASWeakMapEntry *entry);
|
|||||||
_cropRect = CGRectMake(0.5, 0.5, 0, 0);
|
_cropRect = CGRectMake(0.5, 0.5, 0, 0);
|
||||||
_cropDisplayBounds = CGRectNull;
|
_cropDisplayBounds = CGRectNull;
|
||||||
_placeholderColor = ASDisplayNodeDefaultPlaceholderColor();
|
_placeholderColor = ASDisplayNodeDefaultPlaceholderColor();
|
||||||
|
#ifndef MINIMAL_ASDK
|
||||||
_animatedImageRunLoopMode = ASAnimatedImageDefaultRunLoopMode;
|
_animatedImageRunLoopMode = ASAnimatedImageDefaultRunLoopMode;
|
||||||
|
#endif
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@ -198,7 +200,9 @@ typedef void (^ASImageNodeDrawParametersBlock)(ASWeakMapEntry *entry);
|
|||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
// Invalidate all components around animated images
|
// Invalidate all components around animated images
|
||||||
|
#ifndef MINIMAL_ASDK
|
||||||
[self invalidateAnimatedImage];
|
[self invalidateAnimatedImage];
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Placeholder
|
#pragma mark - Placeholder
|
||||||
|
|||||||
@ -21,6 +21,7 @@ extern NSString *const ASAnimatedImageDefaultRunLoopMode;
|
|||||||
|
|
||||||
@interface ASImageNode ()
|
@interface ASImageNode ()
|
||||||
{
|
{
|
||||||
|
#ifndef MINIMAL_ASDK
|
||||||
ASDN::Mutex _displayLinkLock;
|
ASDN::Mutex _displayLinkLock;
|
||||||
id <ASAnimatedImageProtocol> _animatedImage;
|
id <ASAnimatedImageProtocol> _animatedImage;
|
||||||
BOOL _animatedImagePaused;
|
BOOL _animatedImagePaused;
|
||||||
@ -31,21 +32,24 @@ extern NSString *const ASAnimatedImageDefaultRunLoopMode;
|
|||||||
//accessed on main thread only
|
//accessed on main thread only
|
||||||
CFTimeInterval _playHead;
|
CFTimeInterval _playHead;
|
||||||
NSUInteger _playedLoops;
|
NSUInteger _playedLoops;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@property (nonatomic, assign) CFTimeInterval lastDisplayLinkFire;
|
@property (nonatomic, assign) CFTimeInterval lastDisplayLinkFire;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
#ifndef MINIMAL_ASDK
|
||||||
@interface ASImageNode (AnimatedImagePrivate)
|
@interface ASImageNode (AnimatedImagePrivate)
|
||||||
|
|
||||||
- (void)_locked_setAnimatedImage:(id <ASAnimatedImageProtocol>)animatedImage;
|
- (void)_locked_setAnimatedImage:(id <ASAnimatedImageProtocol>)animatedImage;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
@interface ASImageNode (AnimatedImageInvalidation)
|
@interface ASImageNode (AnimatedImageInvalidation)
|
||||||
|
|
||||||
- (void)invalidateAnimatedImage;
|
- (void)invalidateAnimatedImage;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@ -15,6 +15,8 @@
|
|||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#ifndef MINIMAL_ASDK
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import <vector>
|
#import <vector>
|
||||||
#import <AsyncDisplayKit/ASObjectDescriptionHelpers.h>
|
#import <AsyncDisplayKit/ASObjectDescriptionHelpers.h>
|
||||||
@ -217,3 +219,5 @@ NSString *NSStringFromASHierarchyChangeType(_ASHierarchyChangeType changeType);
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@ -15,6 +15,8 @@
|
|||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#ifndef MINIMAL_ASDK
|
||||||
|
|
||||||
#import <AsyncDisplayKit/_ASHierarchyChangeSet.h>
|
#import <AsyncDisplayKit/_ASHierarchyChangeSet.h>
|
||||||
#import <AsyncDisplayKit/ASInternalHelpers.h>
|
#import <AsyncDisplayKit/ASInternalHelpers.h>
|
||||||
#import <AsyncDisplayKit/NSIndexSet+ASHelpers.h>
|
#import <AsyncDisplayKit/NSIndexSet+ASHelpers.h>
|
||||||
@ -1007,3 +1009,5 @@ NSString *NSStringFromASHierarchyChangeType(_ASHierarchyChangeType changeType)
|
|||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user