mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
[ASCollectionView] Call -invalidateFlowLayoutDelegateMetrics when rotating. #trivial (#616)
* [ASCollectionView] Ensure -invalidateFlowLayoutDelegateMetrics is called for UIKit passthrough cells. This allows rotation to work properly when rotating UIKit passthrough cells that need to change width. * [ASCollectionView] No need to verify node is still in model to handle view-only notifications.
This commit is contained in:
@@ -369,6 +369,7 @@ static NSString * const kReuseIdentifier = @"_ASCollectionReuseIdentifier";
|
|||||||
{
|
{
|
||||||
[_dataController relayoutAllNodesWithInvalidationBlock:^{
|
[_dataController relayoutAllNodesWithInvalidationBlock:^{
|
||||||
[self.collectionViewLayout invalidateLayout];
|
[self.collectionViewLayout invalidateLayout];
|
||||||
|
[self invalidateFlowLayoutDelegateMetrics];
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1165,9 +1166,8 @@ static NSString * const kReuseIdentifier = @"_ASCollectionReuseIdentifier";
|
|||||||
{
|
{
|
||||||
if (_asyncDelegateFlags.interopWillDisplayCell) {
|
if (_asyncDelegateFlags.interopWillDisplayCell) {
|
||||||
ASCellNode *node = [self nodeForItemAtIndexPath:indexPath];
|
ASCellNode *node = [self nodeForItemAtIndexPath:indexPath];
|
||||||
NSIndexPath *modelIndexPath = [self indexPathForNode:node];
|
if (node.shouldUseUIKitCell) {
|
||||||
if (modelIndexPath && node.shouldUseUIKitCell) {
|
[(id <ASCollectionDelegateInterop>)_asyncDelegate collectionView:collectionView willDisplayCell:rawCell forItemAtIndexPath:indexPath];
|
||||||
[(id <ASCollectionDelegateInterop>)_asyncDelegate collectionView:collectionView willDisplayCell:rawCell forItemAtIndexPath:modelIndexPath];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1226,9 +1226,8 @@ static NSString * const kReuseIdentifier = @"_ASCollectionReuseIdentifier";
|
|||||||
{
|
{
|
||||||
if (_asyncDelegateFlags.interopDidEndDisplayingCell) {
|
if (_asyncDelegateFlags.interopDidEndDisplayingCell) {
|
||||||
ASCellNode *node = [self nodeForItemAtIndexPath:indexPath];
|
ASCellNode *node = [self nodeForItemAtIndexPath:indexPath];
|
||||||
NSIndexPath *modelIndexPath = [self indexPathForNode:node];
|
if (node.shouldUseUIKitCell) {
|
||||||
if (modelIndexPath && node.shouldUseUIKitCell) {
|
[(id <ASCollectionDelegateInterop>)_asyncDelegate collectionView:collectionView didEndDisplayingCell:rawCell forItemAtIndexPath:indexPath];
|
||||||
[(id <ASCollectionDelegateInterop>)_asyncDelegate collectionView:collectionView didEndDisplayingCell:rawCell forItemAtIndexPath:modelIndexPath];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1271,10 +1270,9 @@ static NSString * const kReuseIdentifier = @"_ASCollectionReuseIdentifier";
|
|||||||
- (void)collectionView:(UICollectionView *)collectionView willDisplaySupplementaryView:(UICollectionReusableView *)rawView forElementKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath
|
- (void)collectionView:(UICollectionView *)collectionView willDisplaySupplementaryView:(UICollectionReusableView *)rawView forElementKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
if (_asyncDelegateFlags.interopWillDisplaySupplementaryView) {
|
if (_asyncDelegateFlags.interopWillDisplaySupplementaryView) {
|
||||||
ASCellNode *node = [self nodeForItemAtIndexPath:indexPath];
|
ASCellNode *node = [self supplementaryNodeForElementKind:elementKind atIndexPath:indexPath];
|
||||||
NSIndexPath *modelIndexPath = [self indexPathForNode:node];
|
if (node.shouldUseUIKitCell) {
|
||||||
if (modelIndexPath && node.shouldUseUIKitCell) {
|
[(id <ASCollectionDelegateInterop>)_asyncDelegate collectionView:collectionView willDisplaySupplementaryView:rawView forElementKind:elementKind atIndexPath:indexPath];
|
||||||
[(id <ASCollectionDelegateInterop>)_asyncDelegate collectionView:collectionView willDisplaySupplementaryView:rawView forElementKind:elementKind atIndexPath:modelIndexPath];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1312,10 +1310,9 @@ static NSString * const kReuseIdentifier = @"_ASCollectionReuseIdentifier";
|
|||||||
- (void)collectionView:(UICollectionView *)collectionView didEndDisplayingSupplementaryView:(UICollectionReusableView *)rawView forElementOfKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath
|
- (void)collectionView:(UICollectionView *)collectionView didEndDisplayingSupplementaryView:(UICollectionReusableView *)rawView forElementOfKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
if (_asyncDelegateFlags.interopdidEndDisplayingSupplementaryView) {
|
if (_asyncDelegateFlags.interopdidEndDisplayingSupplementaryView) {
|
||||||
ASCellNode *node = [self nodeForItemAtIndexPath:indexPath];
|
ASCellNode *node = [self supplementaryNodeForElementKind:elementKind atIndexPath:indexPath];
|
||||||
NSIndexPath *modelIndexPath = [self indexPathForNode:node];
|
if (node.shouldUseUIKitCell) {
|
||||||
if (modelIndexPath && node.shouldUseUIKitCell) {
|
[(id <ASCollectionDelegateInterop>)_asyncDelegate collectionView:collectionView didEndDisplayingSupplementaryView:rawView forElementOfKind:elementKind atIndexPath:indexPath];
|
||||||
[(id <ASCollectionDelegateInterop>)_asyncDelegate collectionView:collectionView didEndDisplayingSupplementaryView:rawView forElementOfKind:elementKind atIndexPath:modelIndexPath];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2253,18 +2250,17 @@ static NSString * const kReuseIdentifier = @"_ASCollectionReuseIdentifier";
|
|||||||
*/
|
*/
|
||||||
- (void)layer:(CALayer *)layer didChangeBoundsWithOldValue:(CGRect)oldBounds newValue:(CGRect)newBounds
|
- (void)layer:(CALayer *)layer didChangeBoundsWithOldValue:(CGRect)oldBounds newValue:(CGRect)newBounds
|
||||||
{
|
{
|
||||||
if (_hasDataControllerLayoutDelegate) {
|
CGSize newSize = newBounds.size;
|
||||||
// Let the layout delegate handle bounds changes if it's available.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (self.collectionViewLayout == nil) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
CGSize lastUsedSize = _lastBoundsSizeUsedForMeasuringNodes;
|
CGSize lastUsedSize = _lastBoundsSizeUsedForMeasuringNodes;
|
||||||
if (CGSizeEqualToSize(lastUsedSize, newBounds.size)) {
|
if (CGSizeEqualToSize(lastUsedSize, newSize)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_lastBoundsSizeUsedForMeasuringNodes = newBounds.size;
|
if (_hasDataControllerLayoutDelegate || self.collectionViewLayout == nil) {
|
||||||
|
// Let the layout delegate handle bounds changes if it's available. If no layout, it will init in the new state.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_lastBoundsSizeUsedForMeasuringNodes = newSize;
|
||||||
|
|
||||||
// Laying out all nodes is expensive.
|
// Laying out all nodes is expensive.
|
||||||
// We only need to do this if the bounds changed in the non-scrollable direction.
|
// We only need to do this if the bounds changed in the non-scrollable direction.
|
||||||
@@ -2275,12 +2271,11 @@ static NSString * const kReuseIdentifier = @"_ASCollectionReuseIdentifier";
|
|||||||
BOOL fixedVertically = (ASScrollDirectionContainsVerticalDirection (scrollDirection) == NO);
|
BOOL fixedVertically = (ASScrollDirectionContainsVerticalDirection (scrollDirection) == NO);
|
||||||
BOOL fixedHorizontally = (ASScrollDirectionContainsHorizontalDirection(scrollDirection) == NO);
|
BOOL fixedHorizontally = (ASScrollDirectionContainsHorizontalDirection(scrollDirection) == NO);
|
||||||
|
|
||||||
BOOL changedInNonScrollingDirection = (fixedHorizontally && newBounds.size.width != lastUsedSize.width) || (fixedVertically && newBounds.size.height != lastUsedSize.height);
|
BOOL changedInNonScrollingDirection = (fixedHorizontally && newSize.width != lastUsedSize.width) ||
|
||||||
|
(fixedVertically && newSize.height != lastUsedSize.height);
|
||||||
|
|
||||||
if (changedInNonScrollingDirection) {
|
if (changedInNonScrollingDirection) {
|
||||||
[_dataController relayoutAllNodesWithInvalidationBlock:^{
|
[self relayoutItems];
|
||||||
[self.collectionViewLayout invalidateLayout];
|
|
||||||
}];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user