mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-16 11:20:18 +00:00
A simpler, cleaner implementation
This commit is contained in:
parent
3c71289927
commit
6b38000941
@ -23,7 +23,7 @@
|
|||||||
@abstract Access to underlying UITextView for more configuration options.
|
@abstract Access to underlying UITextView for more configuration options.
|
||||||
@warning This property should only be used on the main thread and should not be accessed before the editable text node's view is created.
|
@warning This property should only be used on the main thread and should not be accessed before the editable text node's view is created.
|
||||||
*/
|
*/
|
||||||
@property (nonatomic, readwrite, strong) UITextView *textView;
|
@property (nonatomic, readonly, strong) UITextView *textView;
|
||||||
|
|
||||||
//! @abstract The attributes to apply to new text being entered by the user.
|
//! @abstract The attributes to apply to new text being entered by the user.
|
||||||
@property (nonatomic, readwrite, strong) NSDictionary *typingAttributes;
|
@property (nonatomic, readwrite, strong) NSDictionary *typingAttributes;
|
||||||
|
|||||||
@ -41,7 +41,6 @@
|
|||||||
{
|
{
|
||||||
@private
|
@private
|
||||||
// Configuration.
|
// Configuration.
|
||||||
UITextView *_textView;
|
|
||||||
NSDictionary *_typingAttributes;
|
NSDictionary *_typingAttributes;
|
||||||
|
|
||||||
// Core.
|
// Core.
|
||||||
@ -78,7 +77,6 @@
|
|||||||
_textKitComponents = [ASTextKitComponents componentsWithAttributedSeedString:nil textContainerSize:CGSizeZero];
|
_textKitComponents = [ASTextKitComponents componentsWithAttributedSeedString:nil textContainerSize:CGSizeZero];
|
||||||
_textKitComponents.layoutManager.delegate = self;
|
_textKitComponents.layoutManager.delegate = self;
|
||||||
_wordKerner = [[ASTextNodeWordKerner alloc] init];
|
_wordKerner = [[ASTextNodeWordKerner alloc] init];
|
||||||
_textView = [[_ASDisabledPanUITextView alloc] initWithFrame:CGRectZero textContainer:_textKitComponents.textContainer];
|
|
||||||
|
|
||||||
// Create the placeholder scaffolding.
|
// Create the placeholder scaffolding.
|
||||||
_placeholderTextKitComponents = [ASTextKitComponents componentsWithAttributedSeedString:nil textContainerSize:CGSizeZero];
|
_placeholderTextKitComponents = [ASTextKitComponents componentsWithAttributedSeedString:nil textContainerSize:CGSizeZero];
|
||||||
@ -135,7 +133,7 @@
|
|||||||
[self.view addSubview:_placeholderTextKitComponents.textView];
|
[self.view addSubview:_placeholderTextKitComponents.textView];
|
||||||
|
|
||||||
// Create and configure our text view.
|
// Create and configure our text view.
|
||||||
_textKitComponents.textView = _textView;
|
_textKitComponents.textView = self.textView;
|
||||||
//_textKitComponents.textView = NO; // Unfortunately there's a bug here with iOS 7 DP5 that causes the text-view to only be one line high when scrollEnabled is NO. rdar://14729288
|
//_textKitComponents.textView = NO; // Unfortunately there's a bug here with iOS 7 DP5 that causes the text-view to only be one line high when scrollEnabled is NO. rdar://14729288
|
||||||
_textKitComponents.textView.delegate = self;
|
_textKitComponents.textView.delegate = self;
|
||||||
_textKitComponents.textView.editable = YES;
|
_textKitComponents.textView.editable = YES;
|
||||||
@ -190,25 +188,15 @@
|
|||||||
#pragma mark - Configuration
|
#pragma mark - Configuration
|
||||||
@synthesize delegate = _delegate;
|
@synthesize delegate = _delegate;
|
||||||
|
|
||||||
#pragma mark -
|
|
||||||
@dynamic textView;
|
|
||||||
|
|
||||||
- (UITextView *)textView
|
- (UITextView *)textView
|
||||||
{
|
{
|
||||||
ASDisplayNodeAssertMainThread();
|
ASDisplayNodeAssertMainThread();
|
||||||
if (!_textView) {
|
if (!_textKitComponents.textView) {
|
||||||
_textView = [[_ASDisabledPanUITextView alloc] initWithFrame:CGRectZero textContainer:_textKitComponents.textContainer];
|
_textKitComponents.textView = [[_ASDisabledPanUITextView alloc] initWithFrame:CGRectZero textContainer:_textKitComponents.textContainer];
|
||||||
}
|
}
|
||||||
return _textView;
|
return _textKitComponents.textView;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setTextView:(UITextView *)textView
|
|
||||||
{
|
|
||||||
ASDisplayNodeAssertMainThread();
|
|
||||||
_textView = textView;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
@dynamic typingAttributes;
|
@dynamic typingAttributes;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user