Skip to content

Commit

Permalink
Merge pull request qnblackcat#1315 from therealFoxster/main
Browse files Browse the repository at this point in the history
Update DontEatMyContent + reenable uYou appearance patch
  • Loading branch information
therealFoxster authored Feb 20, 2024
2 parents 684ba19 + 9a3c6be commit 707c846
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 58 deletions.
114 changes: 57 additions & 57 deletions Sources/uYouPlusPatches.xm
Original file line number Diff line number Diff line change
Expand Up @@ -116,63 +116,63 @@
%end

// 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)]) {
// // `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 {
// %orig;
// refreshUYouAppearance();
// }
// %end
static DownloadsPagerVC *downloadsPagerVC;
static NSUInteger selectedTabIndex;
%hook DownloadsPagerVC
- (id)init {
downloadsPagerVC = %orig;
return downloadsPagerVC;
}
- (void)viewPager:(id)viewPager didChangeTabToIndex:(NSUInteger)arg1 fromTabIndex:(NSUInteger)arg2 {
%orig; selectedTabIndex = arg1;
}
%end
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)]) {
// `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 UIViewController
- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
%orig;
dispatch_async(dispatch_get_main_queue(), ^{
refreshUYouAppearance();
});
}
%end

// Prevent uYou's playback from colliding with YouTube's
%hook PlayerVC
Expand Down
2 changes: 1 addition & 1 deletion Tweaks/DontEatMyContent
Submodule DontEatMyContent updated 7 files
+3 −0 .gitmodules
+18 −0 Settings.h
+1 −4 Settings.x
+17 −115 Tweak.h
+1 −8 Tweak.x
+1 −0 YTHeaders
+1 −1 control

0 comments on commit 707c846

Please sign in to comment.