mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Add API to ASViewController to automatically adjust the range mode of the containing node based on view events
This commit is contained in:
@@ -30,6 +30,9 @@ 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.
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#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"
|
||||||
|
|
||||||
@implementation ASViewController
|
@implementation ASViewController
|
||||||
{
|
{
|
||||||
@@ -38,6 +39,8 @@
|
|||||||
ASDisplayNodeAssertNotNil(node, @"Node must not be nil");
|
ASDisplayNodeAssertNotNil(node, @"Node must not be nil");
|
||||||
ASDisplayNodeAssertTrue(!node.layerBacked);
|
ASDisplayNodeAssertTrue(!node.layerBacked);
|
||||||
_node = node;
|
_node = node;
|
||||||
|
|
||||||
|
_automaticallyAdjustRangeModeBasedOnViewEvents = NO;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@@ -68,6 +71,26 @@
|
|||||||
[super viewWillAppear:animated];
|
[super viewWillAppear:animated];
|
||||||
_ensureDisplayed = YES;
|
_ensureDisplayed = YES;
|
||||||
[_node recursivelyFetchData];
|
[_node recursivelyFetchData];
|
||||||
|
|
||||||
|
[self updateCurrentRangeModeWithModeIfPossible:ASLayoutRangeModeFull];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)viewDidDisappear:(BOOL)animated
|
||||||
|
{
|
||||||
|
[super viewDidDisappear:animated];
|
||||||
|
|
||||||
|
[self updateCurrentRangeModeWithModeIfPossible:ASLayoutRangeModeMinimum];
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Update Range Mode
|
||||||
|
|
||||||
|
- (void)updateCurrentRangeModeWithModeIfPossible:(ASLayoutRangeMode)rangeMode
|
||||||
|
{
|
||||||
|
if (!self.automaticallyAdjustRangeModeBasedOnViewEvents) { return; }
|
||||||
|
if (![_node conformsToProtocol:@protocol(ASRangeControllerUpdateRangeProtocol)]) { return; }
|
||||||
|
|
||||||
|
id<ASRangeControllerUpdateRangeProtocol> updateRangeNode = (id<ASRangeControllerUpdateRangeProtocol>)_node;
|
||||||
|
[updateRangeNode updateCurrentRangeWithMode:rangeMode];
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Layout Helpers
|
// MARK: - Layout Helpers
|
||||||
|
|||||||
Reference in New Issue
Block a user