mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
[ASViewController] Allow VC to conform to range updating protocol, log message if impossible to update
This commit is contained in:
@@ -27,6 +27,9 @@
|
||||
BOOL _automaticallyAdjustRangeModeBasedOnViewEvents;
|
||||
BOOL _parentManagesVisibilityDepth;
|
||||
NSInteger _visibilityDepth;
|
||||
BOOL _selfConformsToRangeModeProtocol;
|
||||
BOOL _nodeConformsToRangeModeProtocol;
|
||||
BOOL _didCheckRangeModeProtocolConformance;
|
||||
}
|
||||
|
||||
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
|
||||
@@ -172,17 +175,29 @@ ASVisibilityDepthImplementation;
|
||||
- (void)setAutomaticallyAdjustRangeModeBasedOnViewEvents:(BOOL)automaticallyAdjustRangeModeBasedOnViewEvents
|
||||
{
|
||||
_automaticallyAdjustRangeModeBasedOnViewEvents = automaticallyAdjustRangeModeBasedOnViewEvents;
|
||||
if (automaticallyAdjustRangeModeBasedOnViewEvents && !_didCheckRangeModeProtocolConformance) {
|
||||
_selfConformsToRangeModeProtocol = [self conformsToProtocol:@protocol(ASRangeControllerUpdateRangeProtocol)];
|
||||
_nodeConformsToRangeModeProtocol = [_node conformsToProtocol:@protocol(ASRangeControllerUpdateRangeProtocol)];
|
||||
_didCheckRangeModeProtocolConformance = YES;
|
||||
if (!_selfConformsToRangeModeProtocol && !_nodeConformsToRangeModeProtocol) {
|
||||
NSLog(@"Warning: automaticallyAdjustRangeModeBasedOnViewEvents set to YES in %@, but range mode updating is not possible because neither view controller nor node %@ conform to ASRangeControllerUpdateRangeProtocol.", self, _node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updateCurrentRangeModeWithModeIfPossible:(ASLayoutRangeMode)rangeMode
|
||||
{
|
||||
if (!_automaticallyAdjustRangeModeBasedOnViewEvents) { return; }
|
||||
if (![_node conformsToProtocol:@protocol(ASRangeControllerUpdateRangeProtocol)]) {
|
||||
return;
|
||||
|
||||
if (_selfConformsToRangeModeProtocol) {
|
||||
id<ASRangeControllerUpdateRangeProtocol> rangeUpdater = (id<ASRangeControllerUpdateRangeProtocol>)self;
|
||||
[rangeUpdater updateCurrentRangeWithMode:rangeMode];
|
||||
}
|
||||
|
||||
if (_nodeConformsToRangeModeProtocol) {
|
||||
id<ASRangeControllerUpdateRangeProtocol> rangeUpdater = (id<ASRangeControllerUpdateRangeProtocol>)_node;
|
||||
[rangeUpdater updateCurrentRangeWithMode:rangeMode];
|
||||
}
|
||||
|
||||
id<ASRangeControllerUpdateRangeProtocol> updateRangeNode = (id<ASRangeControllerUpdateRangeProtocol>)_node;
|
||||
[updateRangeNode updateCurrentRangeWithMode:rangeMode];
|
||||
}
|
||||
|
||||
#pragma mark - Layout Helpers
|
||||
|
||||
Reference in New Issue
Block a user