Skip to content

Commit

Permalink
kill IGListCollectionView. GH issue #409
Browse files Browse the repository at this point in the history
Summary: Remove `IGListCollectionView` per #409. Use plain old `UICollectionView`.

Reviewed By: rnystrom

Differential Revision: D4640425

fbshipit-source-id: 871b75eaeb1c9f2a40fe8f3fd81b209661704587
  • Loading branch information
jessesquires authored and facebook-github-bot committed Mar 6, 2017
1 parent 2e996e2 commit 3fb2ac0
Show file tree
Hide file tree
Showing 100 changed files with 1,057 additions and 1,158 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ This release closes the [3.0.0 milestone](https://github.com/Instagram/IGListKit

- Renamed `IGListAdapterUpdaterDelegate` method to `listAdapterUpdater:didPerformBatchUpdates:collectionView:`. [Vincent Peng](https://github.com/vincent-peng) [(#491)](https://github.com/Instagram/IGListKit/pull/491)

- `IGListCollectionView` has been completely removed in favor of using plain old `UICollectionView`. See discussion at [#409](https://github.com/Instagram/IGListKit/issues/409) for details. [Jesse Squires](https://github.com/jessesquires) [(tbd)](https://github.com/Instagram/IGListKit/pull/tbd)

### Enhancements

Expand All @@ -41,7 +42,6 @@ This release closes the [3.0.0 milestone](https://github.com/Instagram/IGListKit

- Added `-[IGListAdapter visibleIndexPathsForSectionController:]` API. [Malecks](https://github.com/Malecks) [(#465)](https://github.com/Instagram/IGListKit/pull/465)


### Fixes

- Gracefully handle a `nil` section controller returned by an `IGListAdapterDataSource`. [Ryan Nystrom](https://github.com/rnystrom) [(tbd)](https://github.com/Instagram/IGListKit/pull/tbd)
Expand Down
3 changes: 3 additions & 0 deletions Examples/Examples-iOS/IGListKitExamples/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
window = UIWindow(frame: UIScreen.main.bounds)
window?.rootViewController = UINavigationController(rootViewController: DemosViewController())
window?.makeKeyAndVisible()

UICollectionView.appearance().backgroundColor = .white

return true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="LKS-vo-Ytk" customClass="IGListCollectionView">
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="LKS-vo-Ytk">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<collectionViewLayout key="collectionViewLayout" id="fUa-Xb-tfX" customClass="IGListCollectionViewLayout">
Expand Down Expand Up @@ -94,7 +94,7 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="Lqf-9C-lS3" customClass="IGListCollectionView">
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="Lqf-9C-lS3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="vuu-gE-rAa">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -87,5 +84,5 @@ final class EmptyViewController: UIViewController, IGListAdapterDataSource, Remo
data.remove(at: index)
adapter.performUpdates(animated: true, completion: nil)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -35,14 +35,15 @@ 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),
("Colors", GridItem.self),
("Text", String.self),
("Users", User.self)
]

var selectedClass: Any.Type?

override func viewDidLoad() {
Expand All @@ -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 {
Expand All @@ -87,5 +88,4 @@ final class MixedDataViewController: UIViewController, IGListAdapterDataSource {
}

func emptyView(for listAdapter: IGListAdapter) -> UIView? { return nil }

}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -31,7 +31,7 @@ final class NestedAdapterViewController: UIViewController, IGListAdapterDataSour
6,
"Tellus Nibh Ipsum Inceptos",
2
] as [Any]
]

override func viewDidLoad() {
super.viewDidLoad()
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -13,6 +13,7 @@
*/

#import "ObjcDemoViewController.h"

#import <IGListKit/IGListKit.h>

#import "UserInfoSectionController.h"
Expand All @@ -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];
Expand All @@ -41,20 +91,6 @@ - (void)viewDidLayoutSubviews {
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 {
Expand All @@ -73,61 +109,12 @@ - (void)setupUI {
} else {
return [[UserInfoSectionController alloc] init];
}
}

- (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;
- (UIView *)emptyViewForListAdapter:(IGListAdapter *)listAdapter {
return nil;
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -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]()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Loading

0 comments on commit 3fb2ac0

Please sign in to comment.