kill IGListCollectionView. GH issue #409

Summary: Remove `IGListCollectionView` per #409. Use plain old `UICollectionView`.

Reviewed By: rnystrom

Differential Revision: D4640425

fbshipit-source-id: 871b75eaeb1c9f2a40fe8f3fd81b209661704587
This commit is contained in:
Jesse Squires
2017-03-06 14:54:21 -08:00
committed by Facebook Github Bot
parent 2e996e283e
commit 3fb2ac0d60
100 changed files with 1073 additions and 1174 deletions

View File

@@ -20,7 +20,7 @@ final class DemosViewController: UIViewController, IGListAdapterDataSource {
lazy var adapter: IGListAdapter = {
return IGListAdapter(updater: IGListAdapterUpdater(), viewController: self, workingRangeSize: 0)
}()
let collectionView = IGListCollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
let demos: [DemoItem] = [
DemoItem(name: "Tail Loading", controllerClass: LoadMoreViewController.self),

View File

@@ -20,7 +20,7 @@ class DisplayViewController: UIViewController, IGListAdapterDataSource {
lazy var adapter: IGListAdapter = {
return IGListAdapter(updater: IGListAdapterUpdater(), viewController: self, workingRangeSize: 0)
}()
let collectionView = IGListCollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
override func viewDidLoad() {
super.viewDidLoad()

View File

@@ -20,7 +20,8 @@ final class EmptyViewController: UIViewController, IGListAdapterDataSource, Remo
lazy var adapter: IGListAdapter = {
return IGListAdapter(updater: IGListAdapterUpdater(), viewController: self, workingRangeSize: 0)
}()
let collectionView = IGListCollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
let emptyLabel: UILabel = {
let label = UILabel()
@@ -32,12 +33,8 @@ final class EmptyViewController: UIViewController, IGListAdapterDataSource, Remo
}()
var tally = 4
var data = [
1,
2,
3,
4
]
var data = [1, 2, 3, 4]
override func viewDidLoad() {
super.viewDidLoad()
@@ -87,5 +84,5 @@ final class EmptyViewController: UIViewController, IGListAdapterDataSource, Remo
data.remove(at: index)
adapter.performUpdates(animated: true, completion: nil)
}
}

View File

@@ -20,7 +20,7 @@ final class LoadMoreViewController: UIViewController, IGListAdapterDataSource, U
lazy var adapter: IGListAdapter = {
return IGListAdapter(updater: IGListAdapterUpdater(), viewController: self, workingRangeSize: 0)
}()
let collectionView = IGListCollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
lazy var items = Array(0...20)
var loading = false

View File

@@ -20,9 +20,9 @@ final class MixedDataViewController: UIViewController, IGListAdapterDataSource {
lazy var adapter: IGListAdapter = {
return IGListAdapter(updater: IGListAdapterUpdater(), viewController: self, workingRangeSize: 0)
}()
let collectionView = IGListCollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
let data = [
let data: [Any] = [
"Maecenas faucibus mollis interdum. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.",
GridItem(color: UIColor(red: 237/255.0, green: 73/255.0, blue: 86/255.0, alpha: 1), itemCount: 6),
User(pk: 2, name: "Ryan Olson", handle: "ryanolsonk"),
@@ -35,7 +35,7 @@ final class MixedDataViewController: UIViewController, IGListAdapterDataSource {
"Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.",
GridItem(color: UIColor(red: 163/255.0, green: 42/255.0, blue: 186/255.0, alpha: 1), itemCount: 7),
User(pk: 1, name: "Ryan Nystrom", handle: "_ryannystrom"),
] as [Any]
]
let segments: [(String, Any.Type?)] = [
("All", nil),
@@ -43,6 +43,7 @@ final class MixedDataViewController: UIViewController, IGListAdapterDataSource {
("Text", String.self),
("Users", User.self)
]
var selectedClass: Any.Type?
override func viewDidLoad() {
@@ -68,14 +69,14 @@ final class MixedDataViewController: UIViewController, IGListAdapterDataSource {
adapter.performUpdates(animated: true, completion: nil)
}
//MARK: IGListAdapterDataSource
// MARK: IGListAdapterDataSource
func objects(for listAdapter: IGListAdapter) -> [IGListDiffable] {
guard selectedClass != nil else {
return data.map { $0 as! IGListDiffable }
}
return data.filter { type(of: $0) == selectedClass! }
.map { $0 as! IGListDiffable }
.map { $0 as! IGListDiffable }
}
func listAdapter(_ listAdapter: IGListAdapter, sectionControllerFor object: Any) -> IGListSectionController {
@@ -87,5 +88,4 @@ final class MixedDataViewController: UIViewController, IGListAdapterDataSource {
}
func emptyView(for listAdapter: IGListAdapter) -> UIView? { return nil }
}

View File

@@ -20,9 +20,9 @@ final class NestedAdapterViewController: UIViewController, IGListAdapterDataSour
lazy var adapter: IGListAdapter = {
return IGListAdapter(updater: IGListAdapterUpdater(), viewController: self, workingRangeSize: 0)
}()
let collectionView = IGListCollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
let data = [
let data: [Any] = [
"Ridiculus Elit Tellus Purus Aenean",
"Condimentum Sollicitudin Adipiscing",
14,
@@ -31,7 +31,7 @@ final class NestedAdapterViewController: UIViewController, IGListAdapterDataSour
6,
"Tellus Nibh Ipsum Inceptos",
2
] as [Any]
]
override func viewDidLoad() {
super.viewDidLoad()

View File

@@ -1,9 +1,9 @@
/**
Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
The examples provided by Facebook are for non-commercial testing and evaluation
purposes only. Facebook reserves all rights not expressly granted.
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
@@ -13,6 +13,7 @@
*/
#import "ObjcDemoViewController.h"
#import <IGListKit/IGListKit.h>
#import "UserInfoSectionController.h"
@@ -24,13 +25,62 @@
#import "PhotoCell.h"
@interface ObjcDemoViewController () <IGListAdapterDataSource>
@property (nonatomic, strong) IGListCollectionView *collectionView;
@property (nonatomic, strong) UICollectionView *collectionView;
@property (nonatomic, strong) IGListAdapter *adapter;
@property (nonatomic, strong) NSArray *data;
@end
@implementation ObjcDemoViewController
#pragma mark - Setup
- (void)setupUI {
UICollectionViewLayout *layout = [[UICollectionViewFlowLayout alloc] init];
self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
[self.view addSubview:self.collectionView];
self.adapter = [[IGListAdapter alloc] initWithUpdater:[[IGListAdapterUpdater alloc] init]
viewController:self
workingRangeSize:0];
self.adapter.collectionView = self.collectionView;
self.adapter.dataSource = self;
UserInfo *userA = [[UserInfo alloc] initWithName:@"userA"];
UserInfo *userB = [[UserInfo alloc] initWithName:@"userB"];
UserInfo *userC = [[UserInfo alloc] initWithName:@"userC"];
UserInfo *userD = [[UserInfo alloc] initWithName:@"userD"];
self.data = @[ userA,
@"Image-Placeholder-String",
@"", @"Luminous triangle",
@"Awesome",
@"Super clean",
@"Stunning shot",
userB,
@"Image-Placeholder-String",
@"",
@"The simplicity here is superb",
@"thanks!", @"That's always so kind of you!",
@"I think you might like this",
userC,
@"Image-Placeholder-String",
@"",
@"So good comment",
userD,
@"Image-Placeholder-String",
@"",
@"hope she might like it.",
@"I love it."
];
}
#pragma mark - View lifecycle
- (void)viewDidLoad {
[super viewDidLoad];
[self setupUI];
@@ -41,20 +91,6 @@
self.collectionView.frame = self.view.bounds;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
#pragma mark - setupUI
- (void)setupUI {
[self.view addSubview:self.collectionView];
self.adapter.collectionView = self.collectionView;
self.adapter.dataSource = self;
}
#pragma mark - IGListAdapterDataSource
- (NSArray<id<IGListDiffable>> *)objectsForListAdapter:(IGListAdapter *)listAdapter {
@@ -73,61 +109,12 @@
} else {
return [[UserInfoSectionController alloc] init];
}
return nil;
}
- (UIView *)emptyViewForListAdapter:(IGListAdapter *)listAdapter {
return nil;
}
#pragma mark - Custom Accessors
- (IGListAdapter *)adapter {
if (!_adapter) {
_adapter = [[IGListAdapter alloc] initWithUpdater:[[IGListAdapterUpdater alloc] init]
viewController:self
workingRangeSize:0];
}
return _adapter;
}
- (IGListCollectionView *)collectionView {
if (!_collectionView) {
UICollectionViewLayout *layout = [[UICollectionViewFlowLayout alloc] init];
_collectionView = [[IGListCollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
}
return _collectionView;
}
- (NSArray *)data {
if (!_data) {
UserInfo *userA = [[UserInfo alloc] initWithName:@"userA"];
UserInfo *userB = [[UserInfo alloc] initWithName:@"userB"];
UserInfo *userC = [[UserInfo alloc] initWithName:@"userC"];
UserInfo *userD = [[UserInfo alloc] initWithName:@"userD"];
_data = @[userA,
@"Image-Placeholder-String",
@"", @"Luminous triangle",
@"Awesome",
@"Super clean",
@"Stunning shot",
userB,
@"Image-Placeholder-String",
@"",
@"The simplicity here is superb",
@"thanks!", @"That's always so kind of you!",
@"I think you might like this",
userC,
@"Image-Placeholder-String",
@"",
@"So good comment",
userD,
@"Image-Placeholder-String",
@"",
@"hope she might like it.",
@"I love it."];
}
return _data;
}
@end

View File

@@ -20,7 +20,7 @@ final class SearchViewController: UIViewController, IGListAdapterDataSource, Sea
lazy var adapter: IGListAdapter = {
return IGListAdapter(updater: IGListAdapterUpdater(), viewController: self, workingRangeSize: 0)
}()
let collectionView = IGListCollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
lazy var words: [String] = {
let str = "Humblebrag skateboard tacos viral small batch blue bottle, schlitz fingerstache etsy squid. Listicle tote bag helvetica XOXO literally, meggings cardigan kickstarter roof party deep v selvage scenester venmo truffaut. You probably haven't heard of them fanny pack austin next level 3 wolf moon. Everyday carry offal brunch 8-bit, keytar banjo pinterest leggings hashtag wolf raw denim butcher. Single-origin coffee try-hard echo park neutra, cornhole banh mi meh austin readymade tacos taxidermy pug tattooed. Cold-pressed +1 ethical, four loko cardigan meh forage YOLO health goth sriracha kale chips. Mumblecore cardigan humblebrag, lo-fi typewriter truffaut leggings health goth."
var words = [String]()

View File

@@ -20,10 +20,10 @@ final class SelfSizingCellsViewController: UIViewController, IGListAdapterDataSo
lazy var adapter: IGListAdapter = {
return IGListAdapter(updater: IGListAdapterUpdater(), viewController: self, workingRangeSize: 0)
}()
let collectionView: IGListCollectionView = {
let collectionView: UICollectionView = {
let layout = UICollectionViewFlowLayout()
layout.estimatedItemSize = CGSize(width: 100, height: 40)
let collectionView = IGListCollectionView(frame: .zero, collectionViewLayout: layout)
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
collectionView.backgroundColor = UIColor(red: 0.831372549, green: 0.945098039, blue: 0.964705882, alpha: 1)
return collectionView
}()

View File

@@ -21,7 +21,7 @@ final class SingleSectionStoryboardViewController: UIViewController, IGListAdapt
return IGListAdapter(updater: IGListAdapterUpdater(), viewController: self, workingRangeSize: 0)
}()
@IBOutlet weak var collectionView: IGListCollectionView!
@IBOutlet weak var collectionView: UICollectionView!
let data = Array(0..<20)

View File

@@ -21,7 +21,7 @@ final class SingleSectionViewController: UIViewController, IGListAdapterDataSour
return IGListAdapter(updater: IGListAdapterUpdater(), viewController: self, workingRangeSize: 0)
}()
let collectionView = IGListCollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
let data = Array(0..<20)

View File

@@ -20,7 +20,8 @@ final class StackedViewController: UIViewController, IGListAdapterDataSource {
lazy var adapter: IGListAdapter = {
return IGListAdapter(updater: IGListAdapterUpdater(), viewController: self, workingRangeSize: 1)
}()
let collectionView = IGListCollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
let data = [128, 256, 64]
@@ -55,5 +56,4 @@ final class StackedViewController: UIViewController, IGListAdapterDataSource {
}
func emptyView(for listAdapter: IGListAdapter) -> UIView? { return nil }
}

View File

@@ -17,7 +17,7 @@ import IGListKit
final class StoryboardViewController: UIViewController, IGListAdapterDataSource, StoryboardLabelSectionControllerDelegate {
@IBOutlet weak var collectionView: IGListCollectionView!
@IBOutlet weak var collectionView: UICollectionView!
lazy var adapter: IGListAdapter = {
return IGListAdapter(updater: IGListAdapterUpdater(), viewController: self, workingRangeSize: 0)

View File

@@ -20,7 +20,7 @@ final class SupplementaryViewController: UIViewController, IGListAdapterDataSour
lazy var adapter: IGListAdapter = {
return IGListAdapter(updater: IGListAdapterUpdater(), viewController: self, workingRangeSize: 0)
}()
let collectionView = IGListCollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
let feedItems = [
FeedItem(pk: 1, user: User(pk: 100, name: "Jesse", handle: "jesse_squires"), comments: ["You rock!", "Hmm you sure about that?"]),

View File

@@ -21,7 +21,7 @@ final class WorkingRangeViewController: UIViewController, IGListAdapterDataSourc
return IGListAdapter(updater: IGListAdapterUpdater(), viewController: self, workingRangeSize: 2)
}()
let collectionView = IGListCollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
let data: [Int] = {
var set = Set<Int>() // only use unique values
@@ -44,7 +44,7 @@ final class WorkingRangeViewController: UIViewController, IGListAdapterDataSourc
collectionView.frame = view.bounds
}
//MARK: IGListAdapterDataSource
// MARK: IGListAdapterDataSource
func objects(for listAdapter: IGListAdapter) -> [IGListDiffable] {
return data as [IGListDiffable]