diff --git a/Sources/YTPivotBarReorder.m b/Sources/YTPivotBarReorder.m index a058af3..aa99e71 100644 --- a/Sources/YTPivotBarReorder.m +++ b/Sources/YTPivotBarReorder.m @@ -1,5 +1,10 @@ #import "YTPivotBarReorder.h" #import "uYouPlus.h" +#import +#import +#import +#import +#import @interface YTPivotBarReorder () @@ -28,7 +33,25 @@ [self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"Cell"]; [self.view addSubview:self.collectionView]; - self.pivotBarItems = [@[@"Home", @"Shorts", @"Subscriptions", @"Notifications", @"Library"] mutableCopy]; + [self loadActivePivotTabs]; +} + +- (void)loadActivePivotTabs { + // Assuming we have a method to get the YTIGuideResponse + YTIGuideResponse *guideResponse = [self getGuideResponse]; + NSMutableArray *activeTabs = [NSMutableArray array]; + + for (YTIGuideResponseSupportedRenderers *guideRenderers in [guideResponse itemsArray]) { + YTIPivotBarRenderer *pivotBarRenderer = [guideRenderers pivotBarRenderer]; + for (YTIPivotBarSupportedRenderers *renderer in [pivotBarRenderer itemsArray]) { + YTIPivotBarItemRenderer *itemRenderer = [renderer pivotBarItemRenderer]; + NSString *title = [[itemRenderer title] string]; + [activeTabs addObject:title]; + } + } + + self.pivotBarItems = activeTabs; + [self.collectionView reloadData]; } - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { @@ -70,4 +93,10 @@ } } +- (YTIGuideResponse *)getGuideResponse { + // Implement method to get the YTIGuideResponse + // For now, returning nil + return nil; +} + @end