From 188c398ccbb5a0fb3862f0160299b354c7d33791 Mon Sep 17 00:00:00 2001 From: aricloverEXALT <157071384+aricloverEXALT@users.noreply.github.com> Date: Sun, 12 Jan 2025 13:50:42 -0600 Subject: [PATCH] Update YTPivotBarReorder.m --- Sources/YTPivotBarReorder.m | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Sources/YTPivotBarReorder.m b/Sources/YTPivotBarReorder.m index 0fd1c1e..5bdba8d 100644 --- a/Sources/YTPivotBarReorder.m +++ b/Sources/YTPivotBarReorder.m @@ -5,6 +5,7 @@ #import #import #import +#import @interface YTPivotBarReorder () @@ -24,7 +25,7 @@ self.navigationItem.rightBarButtonItem = closeButton; UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; - layout.itemSize = CGSizeMake(100, 100); + layout.itemSize = CGSizeMake(80, 80); layout.scrollDirection = UICollectionViewScrollDirectionHorizontal; self.collectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:layout]; @@ -33,7 +34,7 @@ self.collectionView.dragDelegate = self; self.collectionView.dropDelegate = self; self.collectionView.dragInteractionEnabled = YES; - self.collectionView.backgroundColor = [UIColor colorWithRed:0.129 green:0.129 blue:0.129 alpha:1.0]; // Pivot bar background color + self.collectionView.backgroundColor = [UIColor colorWithRed:0.129 green:0.129 blue:0.129 alpha:1.0]; [self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"Cell"]; [self.view addSubview:self.collectionView]; @@ -52,7 +53,7 @@ YTIPivotBarRenderer *pivotBarRenderer = [guideRenderers pivotBarRenderer]; for (YTIPivotBarSupportedRenderers *renderer in [pivotBarRenderer itemsArray]) { YTIPivotBarItemRenderer *itemRenderer = [renderer pivotBarItemRenderer]; - if (itemRenderer) { + if (itemRenderer && itemRenderer.isVisible) { [activeTabs addObject:itemRenderer]; } } @@ -70,13 +71,21 @@ UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath]; UIImageView *iconView = [[UIImageView alloc] initWithFrame:cell.contentView.bounds]; YTIPivotBarItemRenderer *itemRenderer = self.pivotBarItems[indexPath.row]; - iconView.image = itemRenderer.icon; + iconView.image = [self imageFromYTIIcon:itemRenderer.icon]; iconView.tintColor = [UIColor whiteColor]; iconView.contentMode = UIViewContentModeScaleAspectFit; [cell.contentView addSubview:iconView]; return cell; } +- (UIImage *)imageFromYTIIcon:(YTIIcon *)icon { + // Implement the conversion from YTIIcon to UIImage + // This is a placeholder implementation and should be replaced with actual conversion logic + NSURL *url = [NSURL URLWithString:icon.iconURL]; + NSData *data = [NSData dataWithContentsOfURL:url]; + return [UIImage imageWithData:data]; +} + - (NSArray *)collectionView:(UICollectionView *)collectionView itemsForBeginningDragSession:(id)session atIndexPath:(NSIndexPath *)indexPath { NSItemProvider *itemProvider = [[NSItemProvider alloc] initWithObject:self.pivotBarItems[indexPath.row]]; UIDragItem *dragItem = [[UIDragItem alloc] initWithItemProvider:itemProvider];