@@ -375,108 +375,10 @@ - (BOOL)shouldUseUIKitCell
375
375
376
376
// TODO: Consider if other calls, such as willDisplayCell, should be bridged to this class.
377
377
@implementation ASWrapperCellNode : ASCellNode
378
-
378
+ `
379
379
- (BOOL )shouldUseUIKitCell
380
380
{
381
381
return YES ;
382
382
}
383
383
384
384
@end
385
-
386
-
387
- #pragma mark -
388
- #pragma mark ASTextCellNode
389
-
390
- @implementation ASTextCellNode {
391
- NSDictionary <NSAttributedStringKey , id > *_textAttributes;
392
- UIEdgeInsets _textInsets;
393
- NSString *_text;
394
- }
395
-
396
- static const CGFloat kASTextCellNodeDefaultFontSize = 18 .0f ;
397
- static const CGFloat kASTextCellNodeDefaultHorizontalPadding = 15 .0f ;
398
- static const CGFloat kASTextCellNodeDefaultVerticalPadding = 11 .0f ;
399
-
400
- - (instancetype )init
401
- {
402
- return [self initWithAttributes: [ASTextCellNode defaultTextAttributes ] insets: [ASTextCellNode defaultTextInsets ]];
403
- }
404
-
405
- - (instancetype )initWithAttributes : (NSDictionary *)textAttributes insets : (UIEdgeInsets)textInsets
406
- {
407
- self = [super init ];
408
- if (self) {
409
- _textInsets = textInsets;
410
- _textAttributes = [textAttributes copy ];
411
- _textNode = [[ASTextNode alloc ] init ];
412
- self.automaticallyManagesSubnodes = YES ;
413
- }
414
- return self;
415
- }
416
-
417
- - (ASLayoutSpec *)layoutSpecThatFits : (ASSizeRange)constrainedSize
418
- {
419
- return [ASInsetLayoutSpec insetLayoutSpecWithInsets: self .textInsets child: self .textNode];
420
- }
421
-
422
- + (NSDictionary *)defaultTextAttributes
423
- {
424
- return @{NSFontAttributeName : [UIFont systemFontOfSize: kASTextCellNodeDefaultFontSize ]};
425
- }
426
-
427
- + (UIEdgeInsets)defaultTextInsets
428
- {
429
- return UIEdgeInsetsMake (kASTextCellNodeDefaultVerticalPadding , kASTextCellNodeDefaultHorizontalPadding , kASTextCellNodeDefaultVerticalPadding , kASTextCellNodeDefaultHorizontalPadding );
430
- }
431
-
432
- - (NSDictionary *)textAttributes
433
- {
434
- return ASLockedSelf (_textAttributes);
435
- }
436
-
437
- - (void )setTextAttributes : (NSDictionary *)textAttributes
438
- {
439
- ASDisplayNodeAssertNotNil (textAttributes, @" Invalid text attributes" );
440
- ASLockScopeSelf ();
441
- if (ASCompareAssignCopy (_textAttributes, textAttributes)) {
442
- [self locked_updateAttributedText ];
443
- }
444
- }
445
-
446
- - (UIEdgeInsets)textInsets
447
- {
448
- return ASLockedSelf (_textInsets);
449
- }
450
-
451
- - (void )setTextInsets : (UIEdgeInsets)textInsets
452
- {
453
- if (ASLockedSelfCompareAssignCustom (_textInsets, textInsets, UIEdgeInsetsEqualToEdgeInsets)) {
454
- [self setNeedsLayout ];
455
- }
456
- }
457
-
458
- - (NSString *)text
459
- {
460
- return ASLockedSelf (_text);
461
- }
462
-
463
- - (void )setText : (NSString *)text
464
- {
465
- ASLockScopeSelf ();
466
- if (ASCompareAssignCopy (_text, text)) {
467
- [self locked_updateAttributedText ];
468
- }
469
- }
470
-
471
- - (void )locked_updateAttributedText
472
- {
473
- if (_text == nil ) {
474
- _textNode.attributedText = nil ;
475
- return ;
476
- }
477
-
478
- _textNode.attributedText = [[NSAttributedString alloc ] initWithString: _text attributes: _textAttributes];
479
- [self setNeedsLayout ];
480
- }
481
-
482
- @end
0 commit comments