Skip to content

Commit

Permalink
Fixes UIKit version of ASDKGram (#1521)
Browse files Browse the repository at this point in the history
* Several fixes for UIKit version of ASDKGram

* Remove PhotoCollectionViewCell
  • Loading branch information
maicki authored May 29, 2019
1 parent 08d5e81 commit a2abd00
Show file tree
Hide file tree
Showing 9 changed files with 135 additions and 213 deletions.
6 changes: 0 additions & 6 deletions examples/ASDKgram/Sample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
768843851CAA37EF00D8629E /* ImageURLModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 7688436D1CAA37EF00D8629E /* ImageURLModel.m */; };
768843891CAA37EF00D8629E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 768843711CAA37EF00D8629E /* main.m */; };
7688438B1CAA37EF00D8629E /* PhotoCellNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 768843731CAA37EF00D8629E /* PhotoCellNode.m */; };
7688438C1CAA37EF00D8629E /* PhotoCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 768843741CAA37EF00D8629E /* PhotoCollectionViewCell.m */; };
7688438D1CAA37EF00D8629E /* PhotoFeedModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 768843751CAA37EF00D8629E /* PhotoFeedModel.m */; };
7688438E1CAA37EF00D8629E /* PhotoFeedNodeController.m in Sources */ = {isa = PBXBuildFile; fileRef = 768843761CAA37EF00D8629E /* PhotoFeedNodeController.m */; };
768843901CAA37EF00D8629E /* PhotoModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 768843781CAA37EF00D8629E /* PhotoModel.m */; };
Expand Down Expand Up @@ -49,7 +48,6 @@
768843511CAA37EF00D8629E /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = AppDelegate.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
768843561CAA37EF00D8629E /* ImageURLModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = ImageURLModel.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
7688435B1CAA37EF00D8629E /* PhotoCellNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = PhotoCellNode.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
7688435C1CAA37EF00D8629E /* PhotoCollectionViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = PhotoCollectionViewCell.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
7688435D1CAA37EF00D8629E /* PhotoFeedModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = PhotoFeedModel.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
7688435E1CAA37EF00D8629E /* PhotoFeedNodeController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = PhotoFeedNodeController.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
768843601CAA37EF00D8629E /* PhotoModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = PhotoModel.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
Expand All @@ -62,7 +60,6 @@
7688436D1CAA37EF00D8629E /* ImageURLModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = ImageURLModel.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
768843711CAA37EF00D8629E /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = main.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
768843731CAA37EF00D8629E /* PhotoCellNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = PhotoCellNode.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
768843741CAA37EF00D8629E /* PhotoCollectionViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = PhotoCollectionViewCell.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
768843751CAA37EF00D8629E /* PhotoFeedModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = PhotoFeedModel.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
768843761CAA37EF00D8629E /* PhotoFeedNodeController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = PhotoFeedNodeController.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
768843781CAA37EF00D8629E /* PhotoModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = PhotoModel.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
Expand Down Expand Up @@ -236,8 +233,6 @@
children = (
768843611CAA37EF00D8629E /* PhotoTableViewCell.h */,
768843791CAA37EF00D8629E /* PhotoTableViewCell.m */,
7688435C1CAA37EF00D8629E /* PhotoCollectionViewCell.h */,
768843741CAA37EF00D8629E /* PhotoCollectionViewCell.m */,
);
name = UIKit;
sourceTree = "<group>";
Expand Down Expand Up @@ -364,7 +359,6 @@
buildActionMask = 2147483647;
files = (
768843891CAA37EF00D8629E /* main.m in Sources */,
7688438C1CAA37EF00D8629E /* PhotoCollectionViewCell.m in Sources */,
768843921CAA37EF00D8629E /* PhotoFeedViewController.m in Sources */,
76229A781CBB79E000B62CEF /* WindowWithStatusBarUnderlay.m in Sources */,
768843961CAA37EF00D8629E /* Utilities.m in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion examples/ASDKgram/Sample/PhotoCellNode.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ - (instancetype)initWithPhotoObject:(PhotoModel *)photo;
// FIXME: autocomplete for this line seems broken
[_userAvatarImageNode setImageModificationBlock:^UIImage *(UIImage *image) {
CGSize profileImageSize = CGSizeMake(USER_IMAGE_HEIGHT, USER_IMAGE_HEIGHT);
return [image makeCircularImageWithSize:profileImageSize];
return [image makeCircularImageWithSize:profileImageSize backgroundColor:nil];
}];

_photoImageNode = [[ASNetworkImageNode alloc] init];
Expand Down
16 changes: 0 additions & 16 deletions examples/ASDKgram/Sample/PhotoCollectionViewCell.h

This file was deleted.

58 changes: 0 additions & 58 deletions examples/ASDKgram/Sample/PhotoCollectionViewCell.m

This file was deleted.

2 changes: 2 additions & 0 deletions examples/ASDKgram/Sample/PhotoFeedBaseController.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ - (void)insertNewRows:(NSArray *)newPhotos
NSIndexPath *path = [NSIndexPath indexPathForRow:row inSection:section];
[indexPaths addObject:path];
}
[self.tableView beginUpdates];
[self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone];
[self.tableView endUpdates];
}

- (UIStatusBarStyle)preferredStatusBarStyle
Expand Down
21 changes: 14 additions & 7 deletions examples/ASDKgram/Sample/PhotoFeedViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@

#define AUTO_TAIL_LOADING_NUM_SCREENFULS 2.5

static NSString *TableViewCellIdentifier = @"PhotoCell";

@interface PhotoFeedViewController () <UITableViewDelegate, UITableViewDataSource>
@end

@implementation PhotoFeedViewController
{
@implementation PhotoFeedViewController {
UITableView *_tableView;
}

Expand All @@ -45,10 +46,16 @@ - (instancetype)init
- (void)viewDidLoad
{
[super viewDidLoad];

[self.view addSubview:_tableView];
[_tableView registerClass:[PhotoTableViewCell class] forCellReuseIdentifier:TableViewCellIdentifier];
}

- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];

_tableView.frame = self.view.bounds;
[_tableView registerClass:[PhotoTableViewCell class] forCellReuseIdentifier:@"photoCell"];
}

#pragma mark - Subclassing
Expand All @@ -74,7 +81,7 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
PhotoTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"photoCell" forIndexPath:indexPath];
PhotoTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:TableViewCellIdentifier forIndexPath:indexPath];
[cell updateCellWithPhotoObject:[self.photoFeed objectAtIndex:indexPath.row]];

return cell;
Expand All @@ -83,13 +90,13 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(nonnull NSIndexPath *)indexPath
{
PhotoModel *photo = [self.photoFeed objectAtIndex:indexPath.row];
return [PhotoTableViewCell heightForPhotoModel:photo withWidth:self.view.bounds.size.width];
return [PhotoTableViewCell heightForPhotoModel:photo withWidth:CGRectGetWidth(tableView.bounds)];
}

#pragma mark - UITableViewDelegate methods

// table automatic tail loading
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGFloat currentOffSetY = scrollView.contentOffset.y;
CGFloat contentHeight = scrollView.contentSize.height;
Expand Down
Loading

0 comments on commit a2abd00

Please sign in to comment.