mirror of
https://github.com/arichornlover/uYouEnhanced.git
synced 2026-04-21 11:52:00 +00:00
Fix uYou tab labels appearance not refreshing
This commit is contained in:
parent
34fa42f721
commit
e4d1875ae8
2 changed files with 29 additions and 1 deletions
|
|
@ -44,4 +44,7 @@
|
||||||
@end
|
@end
|
||||||
@interface DownloadedCell : UITableViewCell
|
@interface DownloadedCell : UITableViewCell
|
||||||
- (void)updatePageStyles;
|
- (void)updatePageStyles;
|
||||||
|
@end
|
||||||
|
@interface UILabel (uYou)
|
||||||
|
+ (id)_defaultColor;
|
||||||
@end
|
@end
|
||||||
|
|
@ -104,28 +104,53 @@
|
||||||
|
|
||||||
// Fix uYou's appearance not updating if the app is backgrounded
|
// Fix uYou's appearance not updating if the app is backgrounded
|
||||||
DownloadsPagerVC *downloadsPagerVC;
|
DownloadsPagerVC *downloadsPagerVC;
|
||||||
|
NSUInteger selectedTabIndex;
|
||||||
static void refreshUYouAppearance() {
|
static void refreshUYouAppearance() {
|
||||||
if (!downloadsPagerVC) return;
|
if (!downloadsPagerVC) return;
|
||||||
|
// View pager
|
||||||
[downloadsPagerVC updatePageStyles];
|
[downloadsPagerVC updatePageStyles];
|
||||||
|
// Views
|
||||||
for (UIViewController *vc in [downloadsPagerVC viewControllers]) {
|
for (UIViewController *vc in [downloadsPagerVC viewControllers]) {
|
||||||
if ([vc isKindOfClass:%c(DownloadingVC)]) {
|
if ([vc isKindOfClass:%c(DownloadingVC)]) {
|
||||||
|
// `Downloading` view
|
||||||
[(DownloadingVC *)vc updatePageStyles];
|
[(DownloadingVC *)vc updatePageStyles];
|
||||||
for (UITableViewCell *cell in [(DownloadingVC *)vc tableView].visibleCells)
|
for (UITableViewCell *cell in [(DownloadingVC *)vc tableView].visibleCells)
|
||||||
if ([cell isKindOfClass:%c(DownloadingCell)])
|
if ([cell isKindOfClass:%c(DownloadingCell)])
|
||||||
[(DownloadingCell *)cell updatePageStyles];
|
[(DownloadingCell *)cell updatePageStyles];
|
||||||
} else if ([vc isKindOfClass:%c(DownloadedVC)]) {
|
}
|
||||||
|
else if ([vc isKindOfClass:%c(DownloadedVC)]) {
|
||||||
|
// `All`, `Audios`, `Videos`, `Shorts` views
|
||||||
[(DownloadedVC *)vc updatePageStyles];
|
[(DownloadedVC *)vc updatePageStyles];
|
||||||
for (UITableViewCell *cell in [(DownloadedVC *)vc tableView].visibleCells)
|
for (UITableViewCell *cell in [(DownloadedVC *)vc tableView].visibleCells)
|
||||||
if ([cell isKindOfClass:%c(DownloadedCell)])
|
if ([cell isKindOfClass:%c(DownloadedCell)])
|
||||||
[(DownloadedCell *)cell updatePageStyles];
|
[(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
|
%hook DownloadsPagerVC
|
||||||
- (instancetype)init {
|
- (instancetype)init {
|
||||||
downloadsPagerVC = %orig;
|
downloadsPagerVC = %orig;
|
||||||
return downloadsPagerVC;
|
return downloadsPagerVC;
|
||||||
}
|
}
|
||||||
|
- (void)viewPager:(id)viewPager didChangeTabToIndex:(NSUInteger)arg1 fromTabIndex:(NSUInteger)arg2 {
|
||||||
|
%orig; selectedTabIndex = arg1;
|
||||||
|
}
|
||||||
%end
|
%end
|
||||||
%hook UIViewController
|
%hook UIViewController
|
||||||
- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
|
- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue