Skip to content

Commit 1562c88

Browse files
committed
feat: remove unused code from ASCellNode
1 parent 956cd3f commit 1562c88

File tree

2 files changed

+1
-142
lines changed

2 files changed

+1
-142
lines changed

Source/ASCellNode.h

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -213,47 +213,4 @@ typedef NS_ENUM(NSUInteger, ASCellNodeVisibilityEvent) {
213213

214214
@end
215215

216-
@interface ASCellNode (Unavailable)
217-
218-
- (instancetype)initWithLayerBlock:(ASDisplayNodeLayerBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock NS_UNAVAILABLE;
219-
220-
- (instancetype)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock NS_UNAVAILABLE;
221-
222-
- (void)setLayerBacked:(BOOL)layerBacked AS_UNAVAILABLE("ASCellNode does not support layer-backing, although subnodes may be layer-backed.");
223-
224-
@end
225-
226-
227-
/**
228-
* Simple label-style cell node. Read its source for an example of custom <ASCellNode>s.
229-
*/
230-
@interface ASTextCellNode : ASCellNode
231-
232-
/**
233-
* Initializes a text cell with given text attributes and text insets
234-
*/
235-
- (instancetype)initWithAttributes:(NSDictionary *)textAttributes insets:(UIEdgeInsets)textInsets;
236-
237-
/**
238-
* Text to display.
239-
*/
240-
@property (nullable, copy) NSString *text;
241-
242-
/**
243-
* A dictionary containing key-value pairs for text attributes. You can specify the font, text color, text shadow color, and text shadow offset using the keys listed in NSString UIKit Additions Reference.
244-
*/
245-
@property (copy) NSDictionary<NSAttributedStringKey, id> *textAttributes;
246-
247-
/**
248-
* The text inset or outset for each edge. The default value is 15.0 horizontal and 11.0 vertical padding.
249-
*/
250-
@property UIEdgeInsets textInsets;
251-
252-
/**
253-
* The text node used by this cell node.
254-
*/
255-
@property (readonly) ASTextNode *textNode;
256-
257-
@end
258-
259216
NS_ASSUME_NONNULL_END

Source/ASCellNode.mm

Lines changed: 1 addition & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -375,108 +375,10 @@ - (BOOL)shouldUseUIKitCell
375375

376376
// TODO: Consider if other calls, such as willDisplayCell, should be bridged to this class.
377377
@implementation ASWrapperCellNode : ASCellNode
378-
378+
`
379379
- (BOOL)shouldUseUIKitCell
380380
{
381381
return YES;
382382
}
383383

384384
@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

Comments
 (0)