mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-05 20:22:15 +00:00
Enable ASRangeControllerUpdateRangeProtocol by default if view controller or node support it. (#2133)
This commit is contained in:
parent
04ecd4180e
commit
e3091737ca
@ -68,7 +68,7 @@ typedef ASTraitCollection * _Nonnull (^ASDisplayTraitsForTraitWindowSizeBlock)(C
|
||||
* Automatically adjust range mode based on view events. If you set this to YES, the view controller or its node
|
||||
* must conform to the ASRangeControllerUpdateRangeProtocol.
|
||||
*
|
||||
* Default value is NO.
|
||||
* Default value is YES *if* node or view controller conform to ASRangeControllerUpdateRangeProtocol otherwise it is NO.
|
||||
*/
|
||||
@property (nonatomic, assign) BOOL automaticallyAdjustRangeModeBasedOnViewEvents;
|
||||
|
||||
|
@ -29,7 +29,6 @@
|
||||
NSInteger _visibilityDepth;
|
||||
BOOL _selfConformsToRangeModeProtocol;
|
||||
BOOL _nodeConformsToRangeModeProtocol;
|
||||
BOOL _didCheckRangeModeProtocolConformance;
|
||||
}
|
||||
|
||||
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
|
||||
@ -54,7 +53,9 @@
|
||||
ASDisplayNodeAssertTrue(!node.layerBacked);
|
||||
_node = node;
|
||||
|
||||
_automaticallyAdjustRangeModeBasedOnViewEvents = NO;
|
||||
_selfConformsToRangeModeProtocol = [self conformsToProtocol:@protocol(ASRangeControllerUpdateRangeProtocol)];
|
||||
_nodeConformsToRangeModeProtocol = [_node conformsToProtocol:@protocol(ASRangeControllerUpdateRangeProtocol)];
|
||||
_automaticallyAdjustRangeModeBasedOnViewEvents = _selfConformsToRangeModeProtocol || _nodeConformsToRangeModeProtocol;
|
||||
|
||||
return self;
|
||||
}
|
||||
@ -168,22 +169,18 @@ ASVisibilityDepthImplementation;
|
||||
|
||||
- (void)setAutomaticallyAdjustRangeModeBasedOnViewEvents:(BOOL)automaticallyAdjustRangeModeBasedOnViewEvents
|
||||
{
|
||||
_automaticallyAdjustRangeModeBasedOnViewEvents = automaticallyAdjustRangeModeBasedOnViewEvents;
|
||||
if (automaticallyAdjustRangeModeBasedOnViewEvents != _automaticallyAdjustRangeModeBasedOnViewEvents) {
|
||||
if (automaticallyAdjustRangeModeBasedOnViewEvents && _selfConformsToRangeModeProtocol == NO && _nodeConformsToRangeModeProtocol == NO) {
|
||||
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);
|
||||
}
|
||||
_automaticallyAdjustRangeModeBasedOnViewEvents = automaticallyAdjustRangeModeBasedOnViewEvents;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updateCurrentRangeModeWithModeIfPossible:(ASLayoutRangeMode)rangeMode
|
||||
{
|
||||
if (!_automaticallyAdjustRangeModeBasedOnViewEvents) { return; }
|
||||
|
||||
if (!_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);
|
||||
}
|
||||
}
|
||||
|
||||
if (_selfConformsToRangeModeProtocol) {
|
||||
id<ASRangeControllerUpdateRangeProtocol> rangeUpdater = (id<ASRangeControllerUpdateRangeProtocol>)self;
|
||||
[rangeUpdater updateCurrentRangeWithMode:rangeMode];
|
||||
|
Loading…
x
Reference in New Issue
Block a user