mirror of
https://github.com/GLEGram/GLEGram-iOS.git
synced 2026-04-24 03:46:23 +02:00
4647310322
Based on Swiftgram 12.5 (Telegram iOS 12.5). All GLEGram features ported and organized in GLEGram/ folder. Features: Ghost Mode, Saved Deleted Messages, Content Protection Bypass, Font Replacement, Fake Profile, Chat Export, Plugin System, and more. See CHANGELOG_12.5.md for full details.
75 lines
2.7 KiB
Objective-C
75 lines
2.7 KiB
Objective-C
#import "TGDraggableCollectionViewFlowLayout.h"
|
|
|
|
@implementation TGDraggableCollectionViewFlowLayout
|
|
|
|
- (UICollectionViewLayoutAttributes *)initialLayoutAttributesForAppearingItemAtIndexPath:(NSIndexPath *)itemIndexPath
|
|
{
|
|
if (itemIndexPath == nil)
|
|
return nil;
|
|
|
|
UICollectionViewLayoutAttributes *attributes = [super initialLayoutAttributesForAppearingItemAtIndexPath:itemIndexPath];
|
|
attributes.transform3D = CATransform3DMakeTranslation(0, 0, itemIndexPath.row + 1);
|
|
attributes.zIndex = itemIndexPath.row + 1;
|
|
|
|
return attributes;
|
|
}
|
|
|
|
- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)itemIndexPath
|
|
{
|
|
if (itemIndexPath == nil)
|
|
return nil;
|
|
|
|
UICollectionViewLayoutAttributes *attributes = [super layoutAttributesForItemAtIndexPath:itemIndexPath];
|
|
attributes.transform3D = CATransform3DMakeTranslation(0, 0, 1000 + itemIndexPath.row + 1);
|
|
attributes.zIndex = 1000 + itemIndexPath.row + 1;
|
|
|
|
return attributes;
|
|
}
|
|
|
|
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect
|
|
{
|
|
NSArray *originalAttributes = [super layoutAttributesForElementsInRect:rect];
|
|
|
|
if (self.destinationIndexPath == nil)
|
|
{
|
|
if (self.hiddenIndexPath == nil)
|
|
return originalAttributes;
|
|
|
|
for (UICollectionViewLayoutAttributes *layoutAttributes in originalAttributes)
|
|
{
|
|
if (layoutAttributes.representedElementCategory != UICollectionElementCategoryCell)
|
|
continue;
|
|
|
|
if ([layoutAttributes.indexPath isEqual:self.hiddenIndexPath])
|
|
layoutAttributes.hidden = true;
|
|
}
|
|
return originalAttributes;
|
|
}
|
|
|
|
for (UICollectionViewLayoutAttributes *layoutAttributes in originalAttributes)
|
|
{
|
|
if (layoutAttributes.representedElementCategory != UICollectionElementCategoryCell)
|
|
continue;
|
|
|
|
NSIndexPath *indexPath = layoutAttributes.indexPath;
|
|
if ([indexPath isEqual:self.hiddenIndexPath])
|
|
layoutAttributes.hidden = true;
|
|
|
|
if ([indexPath isEqual:self.destinationIndexPath])
|
|
{
|
|
layoutAttributes.indexPath = self.sourceIndexPath;
|
|
}
|
|
else
|
|
{
|
|
if (indexPath.item <= self.sourceIndexPath.item && indexPath.item > self.destinationIndexPath.item)
|
|
layoutAttributes.indexPath = [NSIndexPath indexPathForItem:indexPath.item - 1 inSection:indexPath.section];
|
|
else if (indexPath.item >= self.sourceIndexPath.item && indexPath.item < self.destinationIndexPath.item)
|
|
layoutAttributes.indexPath = [NSIndexPath indexPathForItem:indexPath.item + 1 inSection:indexPath.section];
|
|
}
|
|
}
|
|
|
|
return originalAttributes;
|
|
}
|
|
|
|
@end
|