diff --git a/Sources/uYouPlusPatches.h b/Sources/uYouPlusPatches.h index 0675e85..95df553 100644 --- a/Sources/uYouPlusPatches.h +++ b/Sources/uYouPlusPatches.h @@ -24,4 +24,24 @@ // uYou theme fix // @interface YTAppDelegate () // @property(nonatomic, strong) id downloadsVC; -// @end \ No newline at end of file +// @end + +// Fix uYou's appearance not updating if the app is backgrounded +@interface DownloadsPagerVC : UIViewController +- (NSArray *)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 \ No newline at end of file diff --git a/Sources/uYouPlusPatches.xm b/Sources/uYouPlusPatches.xm index 2db21e7..bcc5c46 100644 --- a/Sources/uYouPlusPatches.xm +++ b/Sources/uYouPlusPatches.xm @@ -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, *)) {