2017-02-21 00:11:56 +00:00
|
|
|
/**
|
|
|
|
|
Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
|
2017-03-31 21:45:28 +00:00
|
|
|
|
2017-02-21 00:11:56 +00:00
|
|
|
The examples provided by Facebook are for non-commercial testing and evaluation
|
|
|
|
|
purposes only. Facebook reserves all rights not expressly granted.
|
2017-03-31 21:45:28 +00:00
|
|
|
|
2017-02-21 00:11:56 +00:00
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
|
FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
|
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
|
|
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#import "ObjcDemoViewController.h"
|
2017-03-31 21:45:28 +00:00
|
|
|
|
2017-02-21 00:11:56 +00:00
|
|
|
#import <IGListKit/IGListKit.h>
|
|
|
|
|
|
2017-04-07 18:20:37 +00:00
|
|
|
#import "Post.h"
|
|
|
|
|
#import "PostSectionController.h"
|
2017-02-21 00:11:56 +00:00
|
|
|
|
|
|
|
|
@interface ObjcDemoViewController () <IGListAdapterDataSource>
|
2017-03-31 21:45:28 +00:00
|
|
|
|
|
|
|
|
@property (nonatomic, strong) UICollectionView *collectionView;
|
2017-02-21 00:11:56 +00:00
|
|
|
@property (nonatomic, strong) IGListAdapter *adapter;
|
2017-04-07 18:20:37 +00:00
|
|
|
@property (nonatomic, strong) NSArray<Post *> *data;
|
2017-03-31 21:45:28 +00:00
|
|
|
|
2017-02-21 00:11:56 +00:00
|
|
|
@end
|
|
|
|
|
|
2017-03-31 21:45:28 +00:00
|
|
|
|
2017-02-21 00:11:56 +00:00
|
|
|
@implementation ObjcDemoViewController
|
|
|
|
|
|
2017-04-07 18:20:37 +00:00
|
|
|
- (void)viewDidLoad {
|
|
|
|
|
[super viewDidLoad];
|
2017-03-31 21:45:28 +00:00
|
|
|
|
2017-04-07 18:20:37 +00:00
|
|
|
self.data = @[
|
|
|
|
|
[[Post alloc] initWithUsername:@"userA" comments:@[
|
|
|
|
|
@"Luminous triangle",
|
|
|
|
|
@"Awesome",
|
|
|
|
|
@"Super clean",
|
|
|
|
|
@"Stunning shot",
|
|
|
|
|
]],
|
|
|
|
|
[[Post alloc] initWithUsername:@"userB" comments:@[
|
|
|
|
|
@"The simplicity here is superb",
|
|
|
|
|
@"thanks!",
|
|
|
|
|
@"That's always so kind of you!",
|
|
|
|
|
@"I think you might like this",
|
|
|
|
|
]],
|
|
|
|
|
[[Post alloc] initWithUsername:@"userC" comments:@[
|
|
|
|
|
@"So good",
|
|
|
|
|
]],
|
|
|
|
|
[[Post alloc] initWithUsername:@"userD" comments:@[
|
|
|
|
|
@"hope she might like it.",
|
|
|
|
|
@"I love it."
|
|
|
|
|
]],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero
|
|
|
|
|
collectionViewLayout:[UICollectionViewFlowLayout new]];
|
2017-03-31 21:45:28 +00:00
|
|
|
[self.view addSubview:self.collectionView];
|
|
|
|
|
self.adapter = [[IGListAdapter alloc] initWithUpdater:[[IGListAdapterUpdater alloc] init]
|
2017-04-21 21:24:14 +00:00
|
|
|
viewController:self];
|
2017-03-31 21:45:28 +00:00
|
|
|
|
|
|
|
|
self.adapter.collectionView = self.collectionView;
|
|
|
|
|
self.adapter.dataSource = self;
|
2017-02-21 00:11:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)viewDidLayoutSubviews {
|
|
|
|
|
[super viewDidLayoutSubviews];
|
|
|
|
|
self.collectionView.frame = self.view.bounds;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - IGListAdapterDataSource
|
|
|
|
|
|
|
|
|
|
- (NSArray<id<IGListDiffable>> *)objectsForListAdapter:(IGListAdapter *)listAdapter {
|
|
|
|
|
return self.data;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-19 15:17:56 +00:00
|
|
|
- (IGListSectionController *)listAdapter:(IGListAdapter *)listAdapter sectionControllerForObject:(id)object {
|
2017-04-07 18:20:37 +00:00
|
|
|
return [PostSectionController new];
|
2017-02-21 00:11:56 +00:00
|
|
|
}
|
|
|
|
|
|
2017-03-31 21:45:28 +00:00
|
|
|
- (UIView *)emptyViewForListAdapter:(IGListAdapter *)listAdapter {
|
|
|
|
|
return nil;
|
2017-03-07 00:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
2017-02-21 00:11:56 +00:00
|
|
|
@end
|