mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 14:45:21 +00:00
Proper relayout if size changes
This commit is contained in:
@@ -29,6 +29,12 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
*/
|
||||
- (void)nodeDidRelayout:(ASCellNode *)node sizeChanged:(BOOL)sizeChanged;
|
||||
|
||||
/// Returns the constrained size for the given node
|
||||
- (ASSizeRange)constrainedSizeForNode:(ASCellNode *)node;
|
||||
|
||||
// TODO: coalesc: Maybe we should push the relayout of nodes to the table / collection node?
|
||||
//- (void)relayoutNodeIfNeecessary:(ASCellNode *)node;
|
||||
|
||||
/*
|
||||
* Methods to be called whenever the selection or highlight state changes
|
||||
* on ASCellNode. UIKit internally stores these values to update reusable cells.
|
||||
|
||||
@@ -120,9 +120,8 @@ static NSMutableSet *__cellClassesForVisibilityNotifications = nil; // See +init
|
||||
|
||||
- (void)didInvalidateSize
|
||||
{
|
||||
// TODO: coalesc: Ask the UITableView for the proper constrained size it can layout
|
||||
CGSize oldSize = self.calculatedSize;
|
||||
CGSize newSize = [self sizeThatFits:CGSizeMake(CGRectGetWidth(self.bounds), CGFLOAT_MAX)];
|
||||
CGSize newSize = [self layoutThatFits:[self constrainedSize]].size;
|
||||
|
||||
if (CGSizeEqualToSize(oldSize, newSize) == NO) {
|
||||
self.frame = {self.frame.origin, newSize};
|
||||
@@ -174,6 +173,14 @@ static NSMutableSet *__cellClassesForVisibilityNotifications = nil; // See +init
|
||||
}
|
||||
}
|
||||
|
||||
- (ASSizeRange)constrainedSize
|
||||
{
|
||||
if (_interactionDelegate != nil) {
|
||||
return [_interactionDelegate constrainedSizeForNode:self];
|
||||
}
|
||||
return ASSizeRangeMake(CGSizeZero, CGSizeMake(CGRectGetWidth(self.bounds), CGFLOAT_MAX));
|
||||
}
|
||||
|
||||
- (void)setSelected:(BOOL)selected
|
||||
{
|
||||
if (_selected != selected) {
|
||||
|
||||
@@ -1579,6 +1579,11 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
|
||||
}
|
||||
}
|
||||
|
||||
- (ASSizeRange)constrainedSizeForNode:(ASCellNode *)node
|
||||
{
|
||||
return [self.layoutInspector collectionView:self constrainedSizeForNodeAtIndexPath:[self indexPathForNode:node]];
|
||||
}
|
||||
|
||||
- (void)nodeDidRelayout:(ASCellNode *)node sizeChanged:(BOOL)sizeChanged
|
||||
{
|
||||
ASDisplayNodeAssertMainThread();
|
||||
|
||||
@@ -1568,6 +1568,11 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
|
||||
}
|
||||
}
|
||||
|
||||
- (ASSizeRange)constrainedSizeForNode:(ASCellNode *)node
|
||||
{
|
||||
return [self dataController:self.dataController constrainedSizeForNodeAtIndexPath:[self indexPathForNode:node]];
|
||||
}
|
||||
|
||||
- (void)nodeDidRelayout:(ASCellNode *)node sizeChanged:(BOOL)sizeChanged
|
||||
{
|
||||
ASDisplayNodeAssertMainThread();
|
||||
|
||||
Reference in New Issue
Block a user