diff --git a/Sources/uYouPlusPatches.h b/Sources/uYouPlusPatches.h index 95df553..b8734c0 100644 --- a/Sources/uYouPlusPatches.h +++ b/Sources/uYouPlusPatches.h @@ -44,4 +44,7 @@ @end @interface DownloadedCell : UITableViewCell - (void)updatePageStyles; +@end +@interface UILabel (uYou) ++ (id)_defaultColor; @end \ No newline at end of file diff --git a/Sources/uYouPlusPatches.xm b/Sources/uYouPlusPatches.xm index bcc5c46..d05f611 100644 --- a/Sources/uYouPlusPatches.xm +++ b/Sources/uYouPlusPatches.xm @@ -104,28 +104,53 @@ // Fix uYou's appearance not updating if the app is backgrounded DownloadsPagerVC *downloadsPagerVC; +NSUInteger selectedTabIndex; static void refreshUYouAppearance() { if (!downloadsPagerVC) return; + // View pager [downloadsPagerVC updatePageStyles]; + // Views for (UIViewController *vc in [downloadsPagerVC viewControllers]) { if ([vc isKindOfClass:%c(DownloadingVC)]) { + // `Downloading` view [(DownloadingVC *)vc updatePageStyles]; for (UITableViewCell *cell in [(DownloadingVC *)vc tableView].visibleCells) if ([cell isKindOfClass:%c(DownloadingCell)]) [(DownloadingCell *)cell updatePageStyles]; - } else if ([vc isKindOfClass:%c(DownloadedVC)]) { + } + else if ([vc isKindOfClass:%c(DownloadedVC)]) { + // `All`, `Audios`, `Videos`, `Shorts` views [(DownloadedVC *)vc updatePageStyles]; for (UITableViewCell *cell in [(DownloadedVC *)vc tableView].visibleCells) if ([cell isKindOfClass:%c(DownloadedCell)]) [(DownloadedCell *)cell updatePageStyles]; } } + // View pager tabs + for (UIView *subview in [downloadsPagerVC view].subviews) { + if ([subview isKindOfClass:[UIScrollView class]]) { + UIScrollView *tabs = (UIScrollView *)subview; + NSUInteger i = 0; + for (UIView *item in tabs.subviews) { + if ([item isKindOfClass:[UILabel class]]) { + // Tab label + UILabel *tabLabel = (UILabel *)item; + if (i == selectedTabIndex) {} // Selected tab should be excluded + else [tabLabel setTextColor:[UILabel _defaultColor]]; + i++; + } + } + } + } } %hook DownloadsPagerVC - (instancetype)init { downloadsPagerVC = %orig; return downloadsPagerVC; } +- (void)viewPager:(id)viewPager didChangeTabToIndex:(NSUInteger)arg1 fromTabIndex:(NSUInteger)arg2 { + %orig; selectedTabIndex = arg1; +} %end %hook UIViewController - (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {