Move automatic range update to a private API

This commit is contained in:
Michael Schneider
2016-02-29 10:52:29 -08:00
parent 760f4ada91
commit aca5b14c2b
11 changed files with 69 additions and 26 deletions

View File

@@ -258,6 +258,8 @@
68EE0DBE1C1B4ED300BA1B99 /* ASMainSerialQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 68EE0DBB1C1B4ED300BA1B99 /* ASMainSerialQueue.h */; }; 68EE0DBE1C1B4ED300BA1B99 /* ASMainSerialQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 68EE0DBB1C1B4ED300BA1B99 /* ASMainSerialQueue.h */; };
68EE0DBF1C1B4ED300BA1B99 /* ASMainSerialQueue.mm in Sources */ = {isa = PBXBuildFile; fileRef = 68EE0DBC1C1B4ED300BA1B99 /* ASMainSerialQueue.mm */; }; 68EE0DBF1C1B4ED300BA1B99 /* ASMainSerialQueue.mm in Sources */ = {isa = PBXBuildFile; fileRef = 68EE0DBC1C1B4ED300BA1B99 /* ASMainSerialQueue.mm */; };
68EE0DC01C1B4ED300BA1B99 /* ASMainSerialQueue.mm in Sources */ = {isa = PBXBuildFile; fileRef = 68EE0DBC1C1B4ED300BA1B99 /* ASMainSerialQueue.mm */; }; 68EE0DC01C1B4ED300BA1B99 /* ASMainSerialQueue.mm in Sources */ = {isa = PBXBuildFile; fileRef = 68EE0DBC1C1B4ED300BA1B99 /* ASMainSerialQueue.mm */; };
69F10C861C84C35D0026140C /* ASRangeControllerUpdateRangeProtocol+Beta.h in Headers */ = {isa = PBXBuildFile; fileRef = 69F10C851C84C35D0026140C /* ASRangeControllerUpdateRangeProtocol+Beta.h */; settings = {ATTRIBUTES = (Public, ); }; };
69F10C871C84C35D0026140C /* ASRangeControllerUpdateRangeProtocol+Beta.h in Headers */ = {isa = PBXBuildFile; fileRef = 69F10C851C84C35D0026140C /* ASRangeControllerUpdateRangeProtocol+Beta.h */; settings = {ATTRIBUTES = (Public, ); }; };
6BDC61F61979037800E50D21 /* AsyncDisplayKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BDC61F51978FEA400E50D21 /* AsyncDisplayKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; 6BDC61F61979037800E50D21 /* AsyncDisplayKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BDC61F51978FEA400E50D21 /* AsyncDisplayKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
92DD2FE31BF4B97E0074C9DD /* ASMapNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 92DD2FE11BF4B97E0074C9DD /* ASMapNode.h */; settings = {ATTRIBUTES = (Public, ); }; }; 92DD2FE31BF4B97E0074C9DD /* ASMapNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 92DD2FE11BF4B97E0074C9DD /* ASMapNode.h */; settings = {ATTRIBUTES = (Public, ); }; };
92DD2FE41BF4B97E0074C9DD /* ASMapNode.mm in Sources */ = {isa = PBXBuildFile; fileRef = 92DD2FE21BF4B97E0074C9DD /* ASMapNode.mm */; }; 92DD2FE41BF4B97E0074C9DD /* ASMapNode.mm in Sources */ = {isa = PBXBuildFile; fileRef = 92DD2FE21BF4B97E0074C9DD /* ASMapNode.mm */; };
@@ -718,6 +720,7 @@
68B027791C1A79CC0041016B /* ASDisplayNode+Beta.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ASDisplayNode+Beta.h"; sourceTree = "<group>"; }; 68B027791C1A79CC0041016B /* ASDisplayNode+Beta.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ASDisplayNode+Beta.h"; sourceTree = "<group>"; };
68EE0DBB1C1B4ED300BA1B99 /* ASMainSerialQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASMainSerialQueue.h; sourceTree = "<group>"; }; 68EE0DBB1C1B4ED300BA1B99 /* ASMainSerialQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASMainSerialQueue.h; sourceTree = "<group>"; };
68EE0DBC1C1B4ED300BA1B99 /* ASMainSerialQueue.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASMainSerialQueue.mm; sourceTree = "<group>"; }; 68EE0DBC1C1B4ED300BA1B99 /* ASMainSerialQueue.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASMainSerialQueue.mm; sourceTree = "<group>"; };
69F10C851C84C35D0026140C /* ASRangeControllerUpdateRangeProtocol+Beta.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ASRangeControllerUpdateRangeProtocol+Beta.h"; sourceTree = "<group>"; };
6BDC61F51978FEA400E50D21 /* AsyncDisplayKit.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; path = AsyncDisplayKit.h; sourceTree = "<group>"; }; 6BDC61F51978FEA400E50D21 /* AsyncDisplayKit.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; path = AsyncDisplayKit.h; sourceTree = "<group>"; };
92DD2FE11BF4B97E0074C9DD /* ASMapNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASMapNode.h; sourceTree = "<group>"; }; 92DD2FE11BF4B97E0074C9DD /* ASMapNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASMapNode.h; sourceTree = "<group>"; };
92DD2FE21BF4B97E0074C9DD /* ASMapNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASMapNode.mm; sourceTree = "<group>"; }; 92DD2FE21BF4B97E0074C9DD /* ASMapNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASMapNode.mm; sourceTree = "<group>"; };
@@ -1115,6 +1118,7 @@
058D09E9195D050800B7D73C /* ASMutableAttributedStringBuilder.m */, 058D09E9195D050800B7D73C /* ASMutableAttributedStringBuilder.m */,
055F1A3619ABD413004DAFF1 /* ASRangeController.h */, 055F1A3619ABD413004DAFF1 /* ASRangeController.h */,
055F1A3719ABD413004DAFF1 /* ASRangeController.mm */, 055F1A3719ABD413004DAFF1 /* ASRangeController.mm */,
69F10C851C84C35D0026140C /* ASRangeControllerUpdateRangeProtocol+Beta.h */,
296A0A311A951715005ACEAA /* ASScrollDirection.h */, 296A0A311A951715005ACEAA /* ASScrollDirection.h */,
205F0E111B371BD7007741D0 /* ASScrollDirection.m */, 205F0E111B371BD7007741D0 /* ASScrollDirection.m */,
058D0A12195D050800B7D73C /* ASThread.h */, 058D0A12195D050800B7D73C /* ASThread.h */,
@@ -1338,6 +1342,7 @@
E5711A2B1C840C81009619D4 /* ASIndexedNodeContext.h in Headers */, E5711A2B1C840C81009619D4 /* ASIndexedNodeContext.h in Headers */,
257754C21BEE458E00737CA5 /* ASTextKitCoreTextAdditions.h in Headers */, 257754C21BEE458E00737CA5 /* ASTextKitCoreTextAdditions.h in Headers */,
A373200F1C571B730011FC94 /* ASTextNode+Beta.h in Headers */, A373200F1C571B730011FC94 /* ASTextNode+Beta.h in Headers */,
69F10C861C84C35D0026140C /* ASRangeControllerUpdateRangeProtocol+Beta.h in Headers */,
92DD2FE31BF4B97E0074C9DD /* ASMapNode.h in Headers */, 92DD2FE31BF4B97E0074C9DD /* ASMapNode.h in Headers */,
AC026B691BD57D6F00BBC17E /* ASChangeSetDataController.h in Headers */, AC026B691BD57D6F00BBC17E /* ASChangeSetDataController.h in Headers */,
058D0A71195D05F800B7D73C /* _AS-objc-internal.h in Headers */, 058D0A71195D05F800B7D73C /* _AS-objc-internal.h in Headers */,
@@ -1475,6 +1480,7 @@
files = ( files = (
AC026B6A1BD57D6F00BBC17E /* ASChangeSetDataController.h in Headers */, AC026B6A1BD57D6F00BBC17E /* ASChangeSetDataController.h in Headers */,
B35062481B010EFD0018CF92 /* _AS-objc-internal.h in Headers */, B35062481B010EFD0018CF92 /* _AS-objc-internal.h in Headers */,
69F10C871C84C35D0026140C /* ASRangeControllerUpdateRangeProtocol+Beta.h in Headers */,
B350623C1B010EFD0018CF92 /* _ASAsyncTransaction.h in Headers */, B350623C1B010EFD0018CF92 /* _ASAsyncTransaction.h in Headers */,
B350623F1B010EFD0018CF92 /* _ASAsyncTransactionContainer.h in Headers */, B350623F1B010EFD0018CF92 /* _ASAsyncTransactionContainer.h in Headers */,
B13CA1011C52004900E031AB /* ASCollectionNode+Beta.h in Headers */, B13CA1011C52004900E031AB /* ASCollectionNode+Beta.h in Headers */,

View File

@@ -9,7 +9,6 @@
#import <AsyncDisplayKit/ASCollectionView.h> #import <AsyncDisplayKit/ASCollectionView.h>
@protocol ASCollectionViewLayoutFacilitatorProtocol; @protocol ASCollectionViewLayoutFacilitatorProtocol;
@protocol ASRangeControllerUpdateRangeProtocol;
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@@ -17,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
* ASCollectionNode is a node based class that wraps an ASCollectionView. It can be used * ASCollectionNode is a node based class that wraps an ASCollectionView. It can be used
* as a subnode of another node, and provide room for many (great) features and improvements later on. * as a subnode of another node, and provide room for many (great) features and improvements later on.
*/ */
@interface ASCollectionNode : ASDisplayNode <ASRangeControllerUpdateRangeProtocol> @interface ASCollectionNode : ASDisplayNode
- (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout *)layout; - (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout *)layout;
- (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout; - (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout;

View File

@@ -10,7 +10,7 @@
#import "ASCollectionInternal.h" #import "ASCollectionInternal.h"
#import "ASCollectionViewLayoutFacilitatorProtocol.h" #import "ASCollectionViewLayoutFacilitatorProtocol.h"
#import "ASDisplayNode+Subclasses.h" #import "ASDisplayNode+Subclasses.h"
#import "ASRangeController.h" #import "ASRangeControllerUpdateRangeProtocol+Beta.h"
#include <vector> #include <vector>
@interface _ASCollectionPendingState : NSObject @interface _ASCollectionPendingState : NSObject

View File

@@ -8,13 +8,11 @@
#import <AsyncDisplayKit/ASTableView.h> #import <AsyncDisplayKit/ASTableView.h>
@protocol ASRangeControllerUpdateRangeProtocol;
/** /**
* ASTableNode is a node based class that wraps an ASTableView. It can be used * ASTableNode is a node based class that wraps an ASTableView. It can be used
* as a subnode of another node, and provide room for many (great) features and improvements later on. * as a subnode of another node, and provide room for many (great) features and improvements later on.
*/ */
@interface ASTableNode : ASDisplayNode <ASRangeControllerUpdateRangeProtocol> @interface ASTableNode : ASDisplayNode
- (instancetype)init; // UITableViewStylePlain - (instancetype)init; // UITableViewStylePlain
- (instancetype)initWithStyle:(UITableViewStyle)style; - (instancetype)initWithStyle:(UITableViewStyle)style;

View File

@@ -9,7 +9,7 @@
#import "ASFlowLayoutController.h" #import "ASFlowLayoutController.h"
#import "ASTableViewInternal.h" #import "ASTableViewInternal.h"
#import "ASDisplayNode+Subclasses.h" #import "ASDisplayNode+Subclasses.h"
#import "ASRangeController.h" #import "ASRangeControllerUpdateRangeProtocol+Beta.h"
@interface _ASTablePendingState : NSObject @interface _ASTablePendingState : NSObject
@property (weak, nonatomic) id <ASTableDelegate> delegate; @property (weak, nonatomic) id <ASTableDelegate> delegate;

View File

@@ -30,9 +30,6 @@ NS_ASSUME_NONNULL_BEGIN
// Refer to examples/SynchronousConcurrency, AsyncViewController.m // Refer to examples/SynchronousConcurrency, AsyncViewController.m
@property (nonatomic, assign) BOOL neverShowPlaceholders; @property (nonatomic, assign) BOOL neverShowPlaceholders;
/// Automatically adjust the range mode based on view evenets if the containing node confirms to the ASRangeControllerUpdateRangeProtocol
@property (nonatomic, assign) BOOL automaticallyAdjustRangeModeBasedOnViewEvents;
/** /**
* The constrained size used to measure the backing node. * The constrained size used to measure the backing node.

View File

@@ -11,13 +11,15 @@
#import "ASDimension.h" #import "ASDimension.h"
#import "ASDisplayNode+FrameworkPrivate.h" #import "ASDisplayNode+FrameworkPrivate.h"
#import "ASDisplayNode+Beta.h" #import "ASDisplayNode+Beta.h"
#import "ASRangeController.h" #import "ASRangeControllerUpdateRangeProtocol+Beta.h"
@implementation ASViewController @implementation ASViewController
{ {
BOOL _ensureDisplayed; BOOL _ensureDisplayed;
} }
@synthesize automaticallyAdjustsScrollViewInsets = _automaticallyAdjustRangeModeBasedOnViewEvents;
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil - (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{ {
ASDisplayNodeAssert(NO, @"ASViewController requires using -initWithNode:"); ASDisplayNodeAssert(NO, @"ASViewController requires using -initWithNode:");
@@ -82,7 +84,7 @@
[self updateCurrentRangeModeWithModeIfPossible:ASLayoutRangeModeMinimum]; [self updateCurrentRangeModeWithModeIfPossible:ASLayoutRangeModeMinimum];
} }
// MARK: - Update Range Mode #pragma mark - Automatic range mode
- (void)updateCurrentRangeModeWithModeIfPossible:(ASLayoutRangeMode)rangeMode - (void)updateCurrentRangeModeWithModeIfPossible:(ASLayoutRangeMode)rangeMode
{ {
@@ -93,7 +95,7 @@
[updateRangeNode updateCurrentRangeWithMode:rangeMode]; [updateRangeNode updateCurrentRangeWithMode:rangeMode];
} }
// MARK: - Layout Helpers #pragma mark - Layout Helpers
- (ASSizeRange)nodeConstrainedSize - (ASSizeRange)nodeConstrainedSize
{ {

View File

@@ -34,6 +34,7 @@
#import <AsyncDisplayKit/ASPagerNode.h> #import <AsyncDisplayKit/ASPagerNode.h>
#import <AsyncDisplayKit/ASViewController.h> #import <AsyncDisplayKit/ASViewController.h>
#import <AsyncDisplayKit/ASRangeControllerUpdateRangeProtocol+Beta.h>
#import <AsyncDisplayKit/ASChangeSetDataController.h> #import <AsyncDisplayKit/ASChangeSetDataController.h>

View File

@@ -45,10 +45,6 @@ NS_ASSUME_NONNULL_BEGIN
*/ */
- (void)visibleNodeIndexPathsDidChangeWithScrollDirection:(ASScrollDirection)scrollDirection; - (void)visibleNodeIndexPathsDidChangeWithScrollDirection:(ASScrollDirection)scrollDirection;
/// This is a way for a one way update of range with a given mode.
- (void)updateCurrentRangeWithMode:(ASLayoutRangeMode)rangeMode;
/** /**
* Add the sized node for `indexPath` as a subview of `contentView`. * Add the sized node for `indexPath` as a subview of `contentView`.
* *
@@ -82,14 +78,6 @@ NS_ASSUME_NONNULL_BEGIN
@end @end
@protocol ASRangeControllerUpdateRangeProtocol <NSObject>
/**
* Updates the current range mode of the range controller for at least the next range update.
*/
- (void)updateCurrentRangeWithMode:(ASLayoutRangeMode)rangeMode;
@end
/** /**
* Data source for ASRangeController. * Data source for ASRangeController.

View File

@@ -138,7 +138,10 @@
NSMutableOrderedSet<NSIndexPath *> *allIndexPaths = [[NSMutableOrderedSet alloc] initWithSet:visibleIndexPaths]; NSMutableOrderedSet<NSIndexPath *> *allIndexPaths = [[NSMutableOrderedSet alloc] initWithSet:visibleIndexPaths];
ASInterfaceState selfInterfaceState = [_dataSource interfaceStateForRangeController:self]; ASInterfaceState selfInterfaceState = [_dataSource interfaceStateForRangeController:self];
ASLayoutRangeMode rangeMode = (_currentRangeMode == ASLayoutRangeModeInvalid) ? ASLayoutRangeModeMinimum : _currentRangeMode; ASLayoutRangeMode rangeMode = _currentRangeMode;
if (rangeMode == ASLayoutRangeModeInvalid) {
rangeMode = ASLayoutRangeModeMinimum;
}
ASRangeTuningParameters parametersFetchData = [_layoutController tuningParametersForRangeMode:rangeMode ASRangeTuningParameters parametersFetchData = [_layoutController tuningParametersForRangeMode:rangeMode
rangeType:ASLayoutRangeTypeFetchData]; rangeType:ASLayoutRangeTypeFetchData];

View File

@@ -0,0 +1,49 @@
/* Copyright (c) 2014-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 "ASLayoutRangeType.h"
#import "ASViewController.h"
#import "ASRangeController.h"
#import "ASCollectionNode.h"
#import "ASTableNode.h"
@protocol ASRangeControllerUpdateRangeProtocol <NSObject>
/**
* Updates the current range mode of the range controller for at least the next range update.
*/
- (void)updateCurrentRangeWithMode:(ASLayoutRangeMode)rangeMode;
@end
@interface ASRangeController (ASRangeControllerUpdateRangeProtocol) <ASRangeControllerUpdateRangeProtocol>
/// This is a way for a one way update of range with a given mode.
- (void)updateCurrentRangeWithMode:(ASLayoutRangeMode)rangeMode;
@end
@interface ASCollectionNode (ASRangeControllerUpdateRangeProtocol) <ASRangeControllerUpdateRangeProtocol>
@end
@interface ASTableNode (ASRangeControllerUpdateRangeProtocol) <ASRangeControllerUpdateRangeProtocol>
@end
@interface ASViewController (ASRangeControllerUpdateRangeProtocol)
/// Automatically adjust range mode based on view evenets if the containing node confirms to the ASRangeControllerUpdateRangeProtocol
@property (nonatomic, assign) BOOL automaticallyAdjustRangeModeBasedOnViewEvents;
@end