mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-14 16:08:51 +00:00
Add an ASEditableTextNode initializer that allows customization of its ASTextKitComponents
This commit is contained in:
parent
f8f3585764
commit
0d52176e03
@ -7,6 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#import <AsyncDisplayKit/ASDisplayNode.h>
|
#import <AsyncDisplayKit/ASDisplayNode.h>
|
||||||
|
#import <AsyncDisplayKit/ASTextKitHelpers.h>
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@ -18,6 +19,17 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
*/
|
*/
|
||||||
@interface ASEditableTextNode : ASDisplayNode
|
@interface ASEditableTextNode : ASDisplayNode
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @abstract Initializes a editable text node with a provided TextKit stack.
|
||||||
|
*
|
||||||
|
* @param textKitComponents The TextKit stack used to render text.
|
||||||
|
* @param placeholderTextKitComponents The TextKit stack used to render placeholder text.
|
||||||
|
*
|
||||||
|
* @returns An initialized ASEditableTextNode.
|
||||||
|
*/
|
||||||
|
- (instancetype)initWithTextKitComponents:(ASTextKitComponents *)textKitComponents
|
||||||
|
placeholderTextKitComponents:(ASTextKitComponents *)placeholderTextKitComponents;
|
||||||
|
|
||||||
//! @abstract The text node's delegate, which must conform to the <ASEditableTextNodeDelegate> protocol.
|
//! @abstract The text node's delegate, which must conform to the <ASEditableTextNodeDelegate> protocol.
|
||||||
@property (nonatomic, readwrite, weak) id <ASEditableTextNodeDelegate> delegate;
|
@property (nonatomic, readwrite, weak) id <ASEditableTextNodeDelegate> delegate;
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
#import "ASDisplayNode+Subclasses.h"
|
#import "ASDisplayNode+Subclasses.h"
|
||||||
#import "ASEqualityHelpers.h"
|
#import "ASEqualityHelpers.h"
|
||||||
#import "ASTextKitHelpers.h"
|
|
||||||
#import "ASTextNodeWordKerner.h"
|
#import "ASTextNodeWordKerner.h"
|
||||||
#import "ASThread.h"
|
#import "ASThread.h"
|
||||||
|
|
||||||
@ -93,6 +92,13 @@
|
|||||||
|
|
||||||
#pragma mark - NSObject Overrides
|
#pragma mark - NSObject Overrides
|
||||||
- (instancetype)init
|
- (instancetype)init
|
||||||
|
{
|
||||||
|
return [self initWithTextKitComponents:[ASTextKitComponents componentsWithAttributedSeedString:nil textContainerSize:CGSizeZero]
|
||||||
|
placeholderTextKitComponents:[ASTextKitComponents componentsWithAttributedSeedString:nil textContainerSize:CGSizeZero]];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithTextKitComponents:(ASTextKitComponents *)textKitComponents
|
||||||
|
placeholderTextKitComponents:(ASTextKitComponents *)placeholderTextKitComponents
|
||||||
{
|
{
|
||||||
if (!(self = [super init]))
|
if (!(self = [super init]))
|
||||||
return nil;
|
return nil;
|
||||||
@ -101,14 +107,14 @@
|
|||||||
_scrollEnabled = YES;
|
_scrollEnabled = YES;
|
||||||
|
|
||||||
// Create the scaffolding for the text view.
|
// Create the scaffolding for the text view.
|
||||||
_textKitComponents = [ASTextKitComponents componentsWithAttributedSeedString:nil textContainerSize:CGSizeZero];
|
_textKitComponents = textKitComponents;
|
||||||
_textKitComponents.layoutManager.delegate = self;
|
_textKitComponents.layoutManager.delegate = self;
|
||||||
_wordKerner = [[ASTextNodeWordKerner alloc] init];
|
_wordKerner = [[ASTextNodeWordKerner alloc] init];
|
||||||
_returnKeyType = UIReturnKeyDefault;
|
_returnKeyType = UIReturnKeyDefault;
|
||||||
_textContainerInset = UIEdgeInsetsZero;
|
_textContainerInset = UIEdgeInsetsZero;
|
||||||
|
|
||||||
// Create the placeholder scaffolding.
|
// Create the placeholder scaffolding.
|
||||||
_placeholderTextKitComponents = [ASTextKitComponents componentsWithAttributedSeedString:nil textContainerSize:CGSizeZero];
|
_placeholderTextKitComponents = placeholderTextKitComponents;
|
||||||
_placeholderTextKitComponents.layoutManager.delegate = self;
|
_placeholderTextKitComponents.layoutManager.delegate = self;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
#import <AsyncDisplayKit/ASButtonNode.h>
|
#import <AsyncDisplayKit/ASButtonNode.h>
|
||||||
#import <AsyncDisplayKit/ASMapNode.h>
|
#import <AsyncDisplayKit/ASMapNode.h>
|
||||||
#import <AsyncDisplayKit/ASVideoNode.h>
|
#import <AsyncDisplayKit/ASVideoNode.h>
|
||||||
|
|
||||||
#import <AsyncDisplayKit/ASEditableTextNode.h>
|
#import <AsyncDisplayKit/ASEditableTextNode.h>
|
||||||
|
|
||||||
#import <AsyncDisplayKit/ASBasicImageDownloader.h>
|
#import <AsyncDisplayKit/ASBasicImageDownloader.h>
|
||||||
@ -77,5 +76,6 @@
|
|||||||
#import <AsyncDisplayKit/UICollectionViewLayout+ASConvenience.h>
|
#import <AsyncDisplayKit/UICollectionViewLayout+ASConvenience.h>
|
||||||
#import <AsyncDisplayKit/UIView+ASConvenience.h>
|
#import <AsyncDisplayKit/UIView+ASConvenience.h>
|
||||||
#import <AsyncDisplayKit/ASRunLoopQueue.h>
|
#import <AsyncDisplayKit/ASRunLoopQueue.h>
|
||||||
|
#import <AsyncDisplayKit/ASTextKitHelpers.h>
|
||||||
|
|
||||||
#import <AsyncDisplayKit/AsyncDisplayKit+Debug.h>
|
#import <AsyncDisplayKit/AsyncDisplayKit+Debug.h>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user