Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix all project coding warnings in examples folder #1582

Merged
merged 2 commits into from
Jul 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion examples/ASDKTube/Sample/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
[[UINavigationBar appearance] setBarTintColor:[UIColor lighOrangeColor]];
[[UINavigationBar appearance] setTranslucent:NO];

[application setStatusBarStyle:UIStatusBarStyleLightContent];


return YES;
Expand Down
5 changes: 5 additions & 0 deletions examples/ASDKTube/Sample/Controller/VideoFeedNodeController.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ - (void)viewDidLoad
[_tableNode reloadData];
}

- (UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleLightContent;
}

- (void)generateFeedData
{
_videoFeedData = [[NSMutableArray alloc] init];
Expand Down
8 changes: 6 additions & 2 deletions examples/ASDKgram/Sample/Utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0
//

NS_ASSUME_NONNULL_BEGIN

@interface UIColor (Additions)

+ (UIColor *)backgroundColor;
Expand All @@ -33,7 +35,9 @@

+ (NSAttributedString *)attributedStringWithString:(NSString *)string
fontSize:(CGFloat)size
color:(UIColor *)color
firstWordColor:(UIColor *)firstWordColor;
color:(nullable UIColor *)color
firstWordColor:(nullable UIColor *)firstWordColor;

@end

NS_ASSUME_NONNULL_END
8 changes: 4 additions & 4 deletions examples/CatDealsCollectionView/Sample/ItemViewModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ - (instancetype)init
_identifier = atomic_fetch_add(&nextID, 1);
_titleText = [self randomObjectFromArray:titles];
_firstInfoText = [self randomObjectFromArray:firstInfos];
_secondInfoText = [NSString stringWithFormat:@"%zd+ bought", [self randomNumberInRange:5 to:6000]];
_originalPriceText = [NSString stringWithFormat:@"$%zd", [self randomNumberInRange:40 to:90]];
_finalPriceText = [NSString stringWithFormat:@"$%zd", [self randomNumberInRange:5 to:30]];
_secondInfoText = [NSString stringWithFormat:@"%u+ bought", [self randomNumberInRange:5 to:6000]];
_originalPriceText = [NSString stringWithFormat:@"$%u", [self randomNumberInRange:40 to:90]];
_finalPriceText = [NSString stringWithFormat:@"$%u", [self randomNumberInRange:5 to:30]];
_soldOutText = (arc4random() % 5 == 0) ? @"SOLD OUT" : nil;
_distanceLabelText = [NSString stringWithFormat:@"%zd mi", [self randomNumberInRange:1 to:20]];
_distanceLabelText = [NSString stringWithFormat:@"%u mi", [self randomNumberInRange:1 to:20]];
if (arc4random() % 2 == 0) {
_badgeText = [self randomObjectFromArray:badges];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ - (void)layout
{
[super layout];

_collectionNode.view.contentInset = UIEdgeInsetsMake(0.0, kOuterPadding, 0.0, kOuterPadding);
_collectionNode.contentInset = UIEdgeInsetsMake(0.0, kOuterPadding, 0.0, kOuterPadding);

// Manually layout the divider.
CGFloat pixelHeight = 1.0f / [[UIScreen mainScreen] scale];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ + (UIColor *)randomColor
return [UIColor colorWithHue:hue saturation:saturation brightness:brightness alpha:1];
}

+ (void)drawRect:(CGRect)bounds withParameters:(id<NSObject>)parameters isCancelled:(asdisplaynode_iscancelled_block_t)isCancelledBlock isRasterizing:(BOOL)isRasterizing
+ (void)drawRect:(CGRect)bounds withParameters:(id<NSObject>)parameters isCancelled:(NS_NOESCAPE asdisplaynode_iscancelled_block_t)isCancelledBlock isRasterizing:(BOOL)isRasterizing
{
CGFloat locations[3];
NSMutableArray *colors = [NSMutableArray arrayWithCapacity:3];
Expand Down
2 changes: 1 addition & 1 deletion examples/SocialAppLayout-Inverted/Sample/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ - (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
CGFloat inset = [self topBarsHeight];
self.tableNode.view.contentInset = UIEdgeInsetsMake(-inset, 0, inset, 0);
self.tableNode.contentInset = UIEdgeInsetsMake(-inset, 0, inset, 0);
self.tableNode.view.scrollIndicatorInsets = UIEdgeInsetsMake(-inset, 0, inset, 0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ - (NSInteger)tableNode:(ASTableNode *)tableNode numberOfRowsInSection:(NSInteger

- (ASCellNode *)tableNode:(ASTableNode *)tableNode nodeForRowAtIndexPath:(NSIndexPath *)indexPath
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should migrate to the -nodeBlock data source method as well. Not a blocker for this PR though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find there're a few other example projects which also need to migrate to the -nodeBlock data source method, will create a new PR for fixing this issue altogether :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @nguyenhuy , the PR is ready at #1596

RandomCoreGraphicsNode *elementNode = [[RandomCoreGraphicsNode alloc] init];
NSString *content = [[NSIndexPath indexPathForRow:indexPath.row inSection:_pageNumber] description];
RandomCoreGraphicsNode *elementNode = [[RandomCoreGraphicsNode alloc] initWithContent:content];
elementNode.style.preferredSize = _elementSize;
elementNode.indexPath = [NSIndexPath indexPathForRow:indexPath.row inSection:_pageNumber];

return elementNode;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
#import <AsyncDisplayKit/AsyncDisplayKit.h>

@interface RandomCoreGraphicsNode : ASCellNode
{
ASTextNode *_indexPathTextNode;
}

@property NSIndexPath *indexPath;
- (instancetype)initWithContent:(NSString *)content;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#import "RandomCoreGraphicsNode.h"
#import <AsyncDisplayKit/ASDisplayNode+Subclasses.h>

@implementation RandomCoreGraphicsNode

@synthesize indexPath = _indexPath;
@implementation RandomCoreGraphicsNode {
ASTextNode *_indexPathTextNode;
}

+ (UIColor *)randomColor
{
Expand All @@ -22,7 +22,7 @@ + (UIColor *)randomColor
return [UIColor colorWithHue:hue saturation:saturation brightness:brightness alpha:1];
}

+ (void)drawRect:(CGRect)bounds withParameters:(id<NSObject>)parameters isCancelled:(asdisplaynode_iscancelled_block_t)isCancelledBlock isRasterizing:(BOOL)isRasterizing
+ (void)drawRect:(CGRect)bounds withParameters:(id<NSObject>)parameters isCancelled:(NS_NOESCAPE asdisplaynode_iscancelled_block_t)isCancelledBlock isRasterizing:(BOOL)isRasterizing
{
CGFloat locations[3];
NSMutableArray *colors = [NSMutableArray arrayWithCapacity:3];
Expand All @@ -44,35 +44,19 @@ + (void)drawRect:(CGRect)bounds withParameters:(id<NSObject>)parameters isCancel
CGColorSpaceRelease(colorSpace);
}

- (instancetype)init
- (instancetype)initWithContent:(NSString *)content
{
if (!(self = [super init])) {
return nil;
}

_indexPathTextNode = [[ASTextNode alloc] init];
_indexPathTextNode.attributedText = [[NSAttributedString alloc] initWithString:content attributes:nil];
[self addSubnode:_indexPathTextNode];

return self;
}

- (void)setIndexPath:(NSIndexPath *)indexPath
{
@synchronized (self) {
_indexPath = indexPath;
_indexPathTextNode.attributedText = [[NSAttributedString alloc] initWithString:[indexPath description] attributes:nil];
}
}

- (NSIndexPath *)indexPath
{
NSIndexPath *indexPath = nil;
@synchronized (self) {
indexPath = _indexPath;
}
return indexPath;
}

- (void)layout
{
[super layout];
Expand Down