Improve logic around choosing the range mode automatically and update documentation around logic

This commit is contained in:
Michael Schneider 2016-03-16 13:37:33 -07:00
parent 8d771f930a
commit 41ca796ef4
2 changed files with 10 additions and 11 deletions

View File

@ -63,7 +63,7 @@ static UIApplicationState __ApplicationState = UIApplicationStateActive;
+ (BOOL)isFirstRangeUpdateForRangeMode:(ASLayoutRangeMode)rangeMode
{
return (rangeMode == ASLayoutRangeModeInvalid);
return (rangeMode == ASLayoutRangeModeInvalid);
}
+ (ASLayoutRangeMode)rangeModeForInterfaceState:(ASInterfaceState)interfaceState
@ -191,7 +191,7 @@ static UIApplicationState __ApplicationState = UIApplicationStateActive;
ASLayoutRangeMode rangeMode = _currentRangeMode;
// If the range mode is explicitly set via updateCurrentRangeWithMode: it will last in that mode until the
// range controller becomes visible again or explicitly changes the range mode again
if (!_didUpdateCurrentRange || ASInterfaceStateIncludesVisible(selfInterfaceState)) {
if (!_didUpdateCurrentRange && ASInterfaceStateIncludesVisible(selfInterfaceState)) {
rangeMode = [ASRangeController rangeModeForInterfaceState:selfInterfaceState currentRangeMode:_currentRangeMode];
}
@ -234,10 +234,7 @@ static UIApplicationState __ApplicationState = UIApplicationStateActive;
_allPreviousIndexPaths = allCurrentIndexPaths;
_currentRangeMode = rangeMode;
// Reset the current range mode only if the range controller comes visible
if (ASInterfaceStateIncludesVisible(selfInterfaceState)) {
_didUpdateCurrentRange = NO;
}
_didUpdateCurrentRange = NO;
if (!_rangeIsValid) {
[allIndexPaths addObjectsFromArray:ASIndexPathsForTwoDimensionalArray(allNodes)];

View File

@ -13,18 +13,20 @@
#import "ASTableNode.h"
/**
* Update the range mode for a range controller to a specific range mode until the node that contains the range
* Update the range mode for a range controller to a explicitly set range mode until the node that contains the range
* controller becomes visible again
*
* Logic for the automatic range mode:
* 1. If there are no visible node paths available nothing is to be done and no range update is done
* 2. The initial range update always will be ASLayoutRangeModeCount (ASLayoutRangeModeMinimum) as it's the initial fetch
* 3. If the range mode is explicitly set via updateCurrentRangeWithMode: it will last in that mode until the range controller becomes visible and a new range update was triggered or a new range mode via updateCurrentRangeWithMode: is set
* 1. If there are no visible node paths available nothing is to be done and no range update will happen
* 2. The initial range update if the range controller is visible always will be ASLayoutRangeModeCount
* (ASLayoutRangeModeMinimum) as it's the initial fetch
* 3. The range mode set explicitly via updateCurrentRangeWithMode: will last at least one range update. After that it
the range controller will use the explicit set range mode until it becomes visible and a new range update was
triggered or a new range mode via updateCurrentRangeWithMode: is set
* 4. If range mode is not explicitly set the range mode is variying based if the range controller is visible or not
*/
@protocol ASRangeControllerUpdateRangeProtocol <NSObject>
/**