mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-10 14:35:42 +00:00
Improve logic around choosing the range mode automatically and update documentation around logic
This commit is contained in:
parent
8d771f930a
commit
41ca796ef4
@ -63,7 +63,7 @@ static UIApplicationState __ApplicationState = UIApplicationStateActive;
|
|||||||
|
|
||||||
+ (BOOL)isFirstRangeUpdateForRangeMode:(ASLayoutRangeMode)rangeMode
|
+ (BOOL)isFirstRangeUpdateForRangeMode:(ASLayoutRangeMode)rangeMode
|
||||||
{
|
{
|
||||||
return (rangeMode == ASLayoutRangeModeInvalid);
|
return (rangeMode == ASLayoutRangeModeInvalid);
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (ASLayoutRangeMode)rangeModeForInterfaceState:(ASInterfaceState)interfaceState
|
+ (ASLayoutRangeMode)rangeModeForInterfaceState:(ASInterfaceState)interfaceState
|
||||||
@ -191,7 +191,7 @@ static UIApplicationState __ApplicationState = UIApplicationStateActive;
|
|||||||
ASLayoutRangeMode rangeMode = _currentRangeMode;
|
ASLayoutRangeMode rangeMode = _currentRangeMode;
|
||||||
// If the range mode is explicitly set via updateCurrentRangeWithMode: it will last in that mode until the
|
// 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
|
// 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];
|
rangeMode = [ASRangeController rangeModeForInterfaceState:selfInterfaceState currentRangeMode:_currentRangeMode];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,10 +234,7 @@ static UIApplicationState __ApplicationState = UIApplicationStateActive;
|
|||||||
_allPreviousIndexPaths = allCurrentIndexPaths;
|
_allPreviousIndexPaths = allCurrentIndexPaths;
|
||||||
|
|
||||||
_currentRangeMode = rangeMode;
|
_currentRangeMode = rangeMode;
|
||||||
// Reset the current range mode only if the range controller comes visible
|
_didUpdateCurrentRange = NO;
|
||||||
if (ASInterfaceStateIncludesVisible(selfInterfaceState)) {
|
|
||||||
_didUpdateCurrentRange = NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_rangeIsValid) {
|
if (!_rangeIsValid) {
|
||||||
[allIndexPaths addObjectsFromArray:ASIndexPathsForTwoDimensionalArray(allNodes)];
|
[allIndexPaths addObjectsFromArray:ASIndexPathsForTwoDimensionalArray(allNodes)];
|
||||||
|
@ -13,18 +13,20 @@
|
|||||||
#import "ASTableNode.h"
|
#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
|
* controller becomes visible again
|
||||||
*
|
*
|
||||||
* Logic for the automatic range mode:
|
* 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
|
* 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 always will be ASLayoutRangeModeCount (ASLayoutRangeModeMinimum) as it's the initial fetch
|
* 2. The initial range update if the range controller is visible always will be ASLayoutRangeModeCount
|
||||||
* 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
|
* (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
|
* 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>
|
@protocol ASRangeControllerUpdateRangeProtocol <NSObject>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user