-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add storyboard support #39 #92
Changes from 1 commit
fb4dae1
38721a6
e9c4f6d
098a7db
a2cde80
9b680db
720a022
1fd2f38
d530d76
acfaf9b
d09f0f6
be9b86b
d6d17fb
6bdd64c
9d31a1a
55bc6ba
df586a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,5 +10,4 @@ import UIKit | |
|
||
class StoryboardCell: UICollectionViewCell { | ||
@IBOutlet weak var textLabel: UILabel! | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,8 +89,8 @@ IGLK_SUBCLASSING_RESTRICTED | |
(usually "self") or the IGListAdapter. Pass in locally scoped objects or use weak references! | ||
*/ | ||
- (instancetype)initWithStoryboardCellIdentifier:(NSString *)identifier | ||
configureBlock:(IGListSingleSectionCellConfigureBlock)configureBlock | ||
sizeBlock:(IGListSingleSectionCellSizeBlock)sizeBlock; | ||
configureBlock:(IGListSingleSectionCellConfigureBlock)configureBlock | ||
sizeBlock:(IGListSingleSectionCellSizeBlock)sizeBlock; | ||
|
||
/** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is great! |
||
An optional delegate that handles selection and deselection. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,12 +55,12 @@ - (instancetype)initWithNibName:(NSString *)nibName | |
} | ||
|
||
- (instancetype)initWithStoryboardCellIdentifier:(NSString *)identifier | ||
configureBlock:(IGListSingleSectionCellConfigureBlock)configureBlock | ||
sizeBlock:(IGListSingleSectionCellSizeBlock)sizeBlock { | ||
configureBlock:(IGListSingleSectionCellConfigureBlock)configureBlock | ||
sizeBlock:(IGListSingleSectionCellSizeBlock)sizeBlock { | ||
IGParameterAssert(identifier != nil); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's assert There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
IGParameterAssert(configureBlock != nil); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need an assert for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rnystrom What about the other two init funcions |
||
if (self = [super init]) { | ||
_identifier = identifier; | ||
_identifier = [identifier copy]; | ||
_configureBlock = [configureBlock copy]; | ||
_sizeBlock = [sizeBlock copy]; | ||
} | ||
|
@@ -89,8 +89,8 @@ - (UICollectionViewCell *)cellForItemAtIndex:(NSInteger)index { | |
atIndex:index]; | ||
} else if ([self.identifier length] > 0) { | ||
cell = [collectionContext dequeueReusableCellFromStoryboardWithIdentifier:self.identifier | ||
forSectionController:self | ||
atIndex:index]; | ||
forSectionController:self | ||
atIndex:index]; | ||
} else { | ||
cell = [collectionContext dequeueReusableCellOfClass:self.cellClass forSectionController:self atIndex:index]; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* Copyright (c) 2016-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
#import <IGListKit/IGListAdapterDataSource.h> | ||
|
||
#import "IGTestObject.h" | ||
|
||
@interface IGTestSingleStoryboardItemDataSource : NSObject <IGListAdapterDataSource> | ||
|
||
@property (nonatomic, strong) NSArray <IGTestObject *> *objects; | ||
|
||
@end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Copyright (c) 2016-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
#import "IGTestSingleStoryboardItemDataSource.h" | ||
|
||
#import <IGListKit/IGListSingleSectionController.h> | ||
|
||
#import "IGTestStoryboardCell.h" | ||
|
||
@implementation IGTestSingleStoryboardItemDataSource | ||
|
||
- (NSArray<id<IGListDiffable>> *)objectsForListAdapter:(IGListAdapter *)listAdapter { | ||
return self.objects; | ||
} | ||
|
||
- (IGListSectionController<IGListSectionType> *)listAdapter:(IGListAdapter *)listAdapter sectionControllerForObject:(id)object | ||
{ | ||
void (^configureBlock)(id, __kindof UICollectionViewCell *) = ^(IGTestObject *item, IGTestStoryboardCell *cell) { | ||
cell.label.text = [item.value description]; | ||
}; | ||
CGSize (^sizeBlock)(id<IGListCollectionContext>) = ^CGSize(id<IGListCollectionContext> collectionContext) { | ||
return CGSizeMake([collectionContext containerSize].width, 44); | ||
}; | ||
return [[IGListSingleSectionController alloc] initWithStoryboardCellIdentifier:@"IGTestStoryboardCell" | ||
configureBlock:configureBlock | ||
sizeBlock:sizeBlock]; | ||
} | ||
|
||
- (UIView *)emptyViewForListAdapter:(IGListAdapter *)listAdapter { | ||
return nil; | ||
} | ||
|
||
@end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: space between
//MARK:
and function