-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new iOS 11 api adjustedContentInset support
Summary: adopt adjustedContentInset instead of contentInset on iOS 11 - [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. - [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md) Closes #1020 Reviewed By: manicakes Differential Revision: D6513703 Pulled By: rnystrom fbshipit-source-id: 5d718f2cb30361959ca5ba8238746427223cb5fd
- Loading branch information
1 parent
74c5fb3
commit e63a0e7
Showing
12 changed files
with
1,146 additions
and
967 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1,006 changes: 507 additions & 499 deletions
1,006
Examples/Examples-iOS/Pods/Pods.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
926 changes: 467 additions & 459 deletions
926
Examples/Examples-tvOS/Pods/Pods.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* 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 <UIKit/UIKit.h> | ||
|
||
@interface UIScrollView (IGListKit) | ||
|
||
- (UIEdgeInsets) ig_contentInset; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* 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 "UIScrollView+IGListKit.h" | ||
|
||
@implementation UIScrollView (IGListKit) | ||
|
||
- (UIEdgeInsets) ig_contentInset | ||
{ | ||
#ifdef __IPHONE_11_0 | ||
if (@available(iOS 11,*)) { | ||
return self.adjustedContentInset; | ||
} else { | ||
return self.contentInset; | ||
} | ||
#else | ||
return self.contentInset; | ||
#endif | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// | ||
// 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 <XCTest/XCTest.h> | ||
|
||
#import <IGListKit/IGListKit.h> | ||
#import "UIScrollView+IGListKit.h" | ||
#import "IGListTestHelpers.h" | ||
#import "IGListAdapterInternal.h" | ||
|
||
static const CGRect kStackTestFrame = (CGRect){{0.0, 0.0}, {320.0, 480.0}}; | ||
|
||
@interface IGListContentInsetTests : XCTestCase<IGListAdapterDataSource> | ||
|
||
@property (nonatomic, strong) IGListAdapter *adapter; | ||
|
||
@property (nonatomic, strong) UIWindow *window; | ||
@property (nonatomic, strong) UIViewController *viewController; | ||
@property (nonatomic, strong) UICollectionView *collectionView; | ||
|
||
@end | ||
|
||
@implementation IGListContentInsetTests | ||
|
||
- (void)setUp { | ||
[super setUp]; | ||
|
||
self.viewController = [UIViewController new]; | ||
|
||
IGListCollectionViewLayout *layout = [[IGListCollectionViewLayout alloc] initWithStickyHeaders:NO | ||
topContentInset:0 | ||
stretchToEdge:YES]; | ||
self.collectionView = [[UICollectionView alloc] initWithFrame:kStackTestFrame | ||
collectionViewLayout:layout]; | ||
self.collectionView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; | ||
[self.viewController.view addSubview:self.collectionView]; | ||
|
||
self.adapter = [[IGListAdapter alloc] initWithUpdater:[IGListAdapterUpdater new] | ||
viewController:self.viewController]; | ||
self.adapter.dataSource = self; | ||
self.adapter.collectionView = self.collectionView; | ||
|
||
self.window = [[UIWindow alloc] initWithFrame:kStackTestFrame]; | ||
self.window.rootViewController = self.viewController; | ||
} | ||
|
||
- (void)tearDown { | ||
// Put teardown code here. This method is called after the invocation of each test method in the class. | ||
[super tearDown]; | ||
|
||
self.adapter = nil; | ||
self.viewController = nil; | ||
self.collectionView = nil; | ||
} | ||
|
||
- (void) testCollectionViewContentInset { | ||
const UIEdgeInsets inset = UIEdgeInsetsMake(10, 0, 10, 0); | ||
self.collectionView.contentInset = inset; | ||
IGAssertEqualInsets(self.collectionView.ig_contentInset, inset.top, inset.left, inset.bottom, inset.right); | ||
id<IGListCollectionContext> context = self.adapter; | ||
IGAssertEqualInsets(context.adjustedContainerInset, inset.top, inset.left, inset.bottom, inset.right); | ||
} | ||
|
||
#pragma mark - IGListAdapterDataSource | ||
|
||
- (NSArray<id <IGListDiffable>> *)objectsForListAdapter:(IGListAdapter *)listAdapter { | ||
return @[]; | ||
} | ||
|
||
- (IGListSectionController *) listAdapter:(IGListAdapter *)listAdapter sectionControllerForObject:(id)object { | ||
return nil; | ||
} | ||
|
||
- (UIView *) emptyViewForListAdapter:(IGListAdapter *)listAdapter { | ||
return nil; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters