Fix uYou's appearance not updating if the app is backgrounded

This commit is contained in:
Foxster 2023-12-25 13:58:20 -08:00
parent ed90d07421
commit ca9791f732
2 changed files with 53 additions and 1 deletions

View file

@ -24,4 +24,24 @@
// uYou theme fix
// @interface YTAppDelegate ()
// @property(nonatomic, strong) id downloadsVC;
// @end
// @end
// Fix uYou's appearance not updating if the app is backgrounded
@interface DownloadsPagerVC : UIViewController
- (NSArray<UIViewController *> *)viewControllers;
- (void)updatePageStyles;
@end
@interface DownloadingVC : UIViewController
- (void)updatePageStyles;
- (UITableView *)tableView;
@end
@interface DownloadingCell : UITableViewCell
- (void)updatePageStyles;
@end
@interface DownloadedVC : UIViewController
- (void)updatePageStyles;
- (UITableView *)tableView;
@end
@interface DownloadedCell : UITableViewCell
- (void)updatePageStyles;
@end

View file

@ -102,6 +102,38 @@
}
%end
// Fix uYou's appearance not updating if the app is backgrounded
DownloadsPagerVC *downloadsPagerVC;
static void refreshUYouAppearance() {
if (!downloadsPagerVC) return;
[downloadsPagerVC updatePageStyles];
for (UIViewController *vc in [downloadsPagerVC viewControllers]) {
if ([vc isKindOfClass:%c(DownloadingVC)]) {
[(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)]) {
[(DownloadedVC *)vc updatePageStyles];
for (UITableViewCell *cell in [(DownloadedVC *)vc tableView].visibleCells)
if ([cell isKindOfClass:%c(DownloadedCell)])
[(DownloadedCell *)cell updatePageStyles];
}
}
}
%hook DownloadsPagerVC
- (instancetype)init {
downloadsPagerVC = %orig;
return downloadsPagerVC;
}
%end
%hook UIViewController
- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
%orig;
refreshUYouAppearance();
}
%end
%ctor {
%init;
if (@available(iOS 16, *)) {