IGListKit/Tests/Objects/IGListTestSection.m
Ryan Nystrom 4e9b0bb4c4 Prevent negative spaces for items and supplementaries
Summary:
If a negative height/width comes down, cap it to `0.0`.

Issue fixed: #566

Also fixes t16455632 internally.

- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
Closes https://github.com/Instagram/IGListKit/pull/583

Differential Revision: D4797520

Pulled By: jessesquires

fbshipit-source-id: 3eeec5244a445bb451460286b4f006ca0d9c67d1
2017-03-29 15:01:08 -07:00

49 lines
1.2 KiB
Objective-C

/**
* 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 "IGListTestSection.h"
@implementation IGListTestSection
- (instancetype)init {
if (self = [super init]) {
_size = CGSizeMake(100, 10);
}
return self;
}
- (NSArray <Class> *)cellClasses {
return @[UICollectionViewCell.class];
}
- (NSInteger)numberOfItems {
return self.items;
}
- (CGSize)sizeForItemAtIndex:(NSInteger)index {
return self.size;
}
- (UICollectionViewCell *)cellForItemAtIndex:(NSInteger)index {
return [self.collectionContext dequeueReusableCellOfClass:UICollectionViewCell.class
forSectionController:self
atIndex:index];
}
- (void)didUpdateToObject:(id)object {
if ([object isKindOfClass:[NSNumber class]]) {
self.items = [object integerValue];
}
}
- (void)didSelectItemAtIndex:(NSInteger)index {
self.wasSelected = YES;
}
@end