From ecde382a4f925fb67583d3cb9fa0e245810a2e7c Mon Sep 17 00:00:00 2001 From: arichorn <78001398+arichorn@users.noreply.github.com> Date: Thu, 27 Jul 2023 21:03:59 -0500 Subject: [PATCH] Fixed OLED & Old Dark Theme --- Source/Themes.xm | 555 +++++++++++++++++++++++++++-------------------- 1 file changed, 324 insertions(+), 231 deletions(-) diff --git a/Source/Themes.xm b/Source/Themes.xm index 2d813d1..2a4e1bd 100644 --- a/Source/Themes.xm +++ b/Source/Themes.xm @@ -17,6 +17,26 @@ static BOOL oldDarkTheme() { // Old dark theme (gray) %group gOldDarkTheme UIColor *customColor = [UIColor colorWithRed:0.129 green:0.129 blue:0.129 alpha:1.0]; +%hook YTCommonColorPalette +- (UIColor *)brandBackgroundSolid { + return self.pageStyle == 1 ? customColor : %orig; +} +- (UIColor *)brandBackgroundPrimary { + return self.pageStyle == 1 ? customColor : %orig; +} +- (UIColor *)brandBackgroundSecondary { + return self.pageStyle == 1 ? [customColor colorWithAlphaComponent:0.9] : %orig; +} +- (UIColor *)raisedBackground { + return self.pageStyle == 1 ? customColor : %orig; +} +- (UIColor *)staticBrandBlack { + return self.pageStyle == 1 ? customColor : %orig; +} +- (UIColor *)generalBackgroundA { + return self.pageStyle == 1 ? customColor : %orig; +} +%end %hook UIView - (void)setBackgroundColor:(UIColor *)color { if ([self.nextResponder isKindOfClass:NSClassFromString(@"YTPivotBarView")]) { @@ -79,161 +99,6 @@ UIColor *customColor = [UIColor colorWithRed:0.129 green:0.129 blue:0.129 alpha: %orig; } %end - -%hook YTAppView -- (UIColor *)backgroundColor:(NSInteger)pageStyle { - return pageStyle == 1 ? customColor : %orig; -} -%end - -%hook YTPivotBarView -- (UIColor *)backgroundColor:(NSInteger)pageStyle { - return pageStyle == 1 ? customColor : %orig; -} -%end - -%hook YTAsyncCollectionView -- (UIColor *)backgroundColor:(NSInteger)pageStyle { - return pageStyle == 1 ? customColor : %orig; -} -%end - -%hook YTAppViewController -- (UIColor *)backgroundColor:(NSInteger)pageStyle { - return pageStyle == 1 ? customColor : %orig; -} -%end - -%hook YTNavigationBar -- (UIColor *)backgroundColor:(NSInteger)pageStyle { - return pageStyle == 1 ? customColor : %orig; -} -%end - -%hook YTPlayerView -- (UIColor *)backgroundColor:(NSInteger)pageStyle { - return pageStyle == 1 ? customColor : %orig; -} -%end - -%hook YTCinematicContainerView -- (void)setHidden:(BOOL)arg1 { - %orig(YES); -} -%end - -%hook YTCollectionViewController -- (UIColor *)backgroundColor:(NSInteger)pageStyle { - return pageStyle == 1 ? customColor : %orig; -} -%end - -%hook YTWatchView -- (UIColor *)backgroundColor:(NSInteger)pageStyle { - return pageStyle == 1 ? customColor : %orig; -} -%end - -%hook YTChannelMobileHeaderViewController -- (UIColor *)backgroundColor:(NSInteger)pageStyle { - return pageStyle == 1 ? customColor : %orig; -} -%end - -%hook YTELMView -- (UIColor *)backgroundColor:(NSInteger)pageStyle { - return pageStyle == 1 ? customColor : %orig; -} -%end - -%hook _ASDisplayView -- (UIColor *)backgroundColor:(NSInteger)pageStyle { - return pageStyle == 1 ? customColor : %orig; -} -%end - -%hook UIDeviceWhiteColor -- (UIColor *)backgroundColor:(NSInteger)pageStyle { - return pageStyle == 1 ? customColor : %orig; -} -%end - -%hook YTHeaderViewController -- (UIColor *)backgroundColor:(NSInteger)pageStyle { - return pageStyle == 1 ? customColor : %orig; -} -- (UIColor *)barTintColor:(NSInteger)pageStyle { - return pageStyle == 1 ? customColor : %orig; -} -%end - -%hook YTInnerTubeCollectionViewController -- (UIColor *)backgroundColor:(NSInteger)pageStyle { - return pageStyle == 1 ? customColor : %orig; -} -%end - -%hook YTSettingsCell -- (UIColor *)backgroundColor:(NSInteger)pageStyle { - return pageStyle == 1 ? customColor : %orig; -} -%end - -%hook YTSearchViewController -- (UIColor *)backgroundColor:(NSInteger)pageStyle { - return pageStyle == 1 ? customColor : %orig; -} -%end - -%hook YTSectionListViewController -- (UIColor *)backgroundColor:(NSInteger)pageStyle { - return pageStyle == 1 ? customColor : %orig; -} -%end - -%hook YTWatchMiniBarViewController -- (UIColor *)backgroundColor:(NSInteger)pageStyle { - return pageStyle == 1 ? customColor : %orig; -} -%end - -%hook YTWrapperSplitViewController -- (UIColor *)backgroundColor:(NSInteger)pageStyle { - return pageStyle == 1 ? customColor : %orig; -} -%end - -// Explore -%hook ASScrollView -- (void)didMoveToWindow { - %orig; - if (isDarkMode()) { - self.backgroundColor = [UIColor clearColor]; - } -} -%end - -// Your videos -%hook ASCollectionView -- (void)didMoveToWindow { - %orig; - if (isDarkMode() && [self.nextResponder isKindOfClass:%c(_ASDisplayView)]) { - self.superview.backgroundColor = customColor; - } -} -%end - -// Sub? -%hook ELMView -- (void)didMoveToWindow { - %orig; - if (isDarkMode()) { - self.subviews[0].backgroundColor = customColor; - } -} -%end - -// iSponsorBlock %hook SponsorBlockSettingsController - (void)viewDidLoad { if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) { @@ -242,7 +107,6 @@ UIColor *customColor = [UIColor colorWithRed:0.129 green:0.129 blue:0.129 alpha: } else { return %orig; } } %end - %hook SponsorBlockViewController - (void)viewDidLoad { if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) { @@ -251,89 +115,302 @@ UIColor *customColor = [UIColor colorWithRed:0.129 green:0.129 blue:0.129 alpha: } else { return %orig; } } %end - -// Search View -%hook YTSearchBarView -- (void)setBackgroundColor:(UIColor *)color { - return isDarkMode() ? %orig(customColor) : %orig; +%hook ELMView +- (void)didMoveToWindow { + %orig; + if (isDarkMode()) { + self.subviews[0].backgroundColor = [UIColor clearColor]; + } } %end - -// History Search view -%hook YTSearchBoxView +%hook YTAsyncCollectionView - (void)setBackgroundColor:(UIColor *)color { - return isDarkMode() ? %orig(customColor) : %orig; + if ([self.nextResponder isKindOfClass:NSClassFromString(@"YTRelatedVideosCollectionViewController")]) { + color = [UIColor clearColor]; + } else if ([self.nextResponder isKindOfClass:NSClassFromString(@"YTFullscreenMetadataHighlightsCollectionViewController")]) { + color = [UIColor clearColor]; + } else { + color = customColor; + } + %orig; +} +- (UIColor *)darkBackgroundColor { + return customColor; +} +- (void)setDarkBackgroundColor:(UIColor *)color { + %orig(customColor); +} +- (void)layoutSubviews { + %orig(); + if ([self.nextResponder isKindOfClass:NSClassFromString(@"YTWatchNextResultsViewController")]) { + self.subviews[0].subviews[0].backgroundColor = customColor; + } } %end - -// Comment view -%hook YTCommentView +%hook YTPivotBarView - (void)setBackgroundColor:(UIColor *)color { - return isDarkMode() ? %orig(customColor) : %orig; + %orig(customColor); +} +%end +%hook YTHeaderView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTSubheaderContainerView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTAppView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTCollectionView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTChannelListSubMenuView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTSlideForActionsView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTPageView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTWatchView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTPlaylistMiniBarView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTEngagementPanelHeaderView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTPlaylistPanelControlsView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTHorizontalCardListView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTWatchMiniBarView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); } %end - %hook YTCreateCommentAccessoryView - (void)setBackgroundColor:(UIColor *)color { - return isDarkMode() ? %orig(customColor) : %orig; + %orig(customColor); } %end - %hook YTCreateCommentTextView - (void)setBackgroundColor:(UIColor *)color { - return isDarkMode() ? %orig(customColor) : %orig; -} -- (void)setTextColor:(UIColor *)color { // fix black text in #Shorts video's comment - return isDarkMode() ? %orig([UIColor whiteColor]) : %orig; + %orig(customColor); } %end - -%hook YTCommentDetailHeaderCell -- (void)didMoveToWindow { - %orig; - if (isDarkMode()) { - self.subviews[2].backgroundColor = customColor; - } -} -%end - -%hook YTFormattedStringLabel // YT is werid... +%hook YTSearchView - (void)setBackgroundColor:(UIColor *)color { - return isDarkMode() ? %orig([UIColor clearColor]) : %orig; + %orig(customColor); } %end - -// Live chat comment -%hook YCHLiveChatActionPanelView +%hook YTVideoView - (void)setBackgroundColor:(UIColor *)color { - return isDarkMode() ? %orig(customColor) : %orig; + %orig(customColor); +} +%end +%hook YTSearchBoxView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTTabTitlesView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTPrivacyTosFooterView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTOfflineStorageUsageView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTInlineSignInView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTFeedChannelFilterHeaderView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YCHLiveChatView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YCHLiveChatActionPanelView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); } %end - %hook YTEmojiTextView - (void)setBackgroundColor:(UIColor *)color { - return isDarkMode() ? %orig(customColor) : %orig; + %orig(customColor); } %end - -%hook YCHLiveChatView -- (void)didMoveToWindow { - %orig; - if (isDarkMode()) { - self.subviews[1].backgroundColor = customColor; - } -} -%end - -// -%hook YTBackstageCreateRepostDetailView +%hook YTTopAlignedView - (void)setBackgroundColor:(UIColor *)color { - return isDarkMode() ? %orig(customColor) : %orig; + %orig(customColor); +} +- (void)layoutSubviews { + %orig(); + MSHookIvar(self, "_contentView").backgroundColor = customColor; +} +%end +%hook GOODialogView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTNavigationBar +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +- (void)setBarTintColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTChannelMobileHeaderView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTChannelSubMenuView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTWrapperSplitView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTReelShelfCell +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTReelShelfItemView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTReelShelfView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTCommentView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTChannelListSubMenuAvatarView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTSearchBarView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YCHLiveChatBannerCell +- (void)layoutSubviews { + %orig(); + MSHookIvar(self, "_bannerContainerImageView").hidden = YES; + MSHookIvar(self, "_bannerContainerView").backgroundColor = customColor; +} +%end +%hook YTDialogContainerScrollView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTShareTitleView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTShareBusyView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTELMView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTActionSheetHeaderView +- (void)setBackgroundColor:(UIColor *)color { + %orig(customColor); +} +%end +%hook YTSearchSuggestionCollectionViewCell +- (void)updateColors { +} +%end +%hook YTShareMainView +- (void)layoutSubviews { + %orig(); + MSHookIvar(self, "_cancelButton").backgroundColor = customColor; + MSHookIvar(self, "_safeArea").backgroundColor = customColor; } %end - -// Others %hook _ASDisplayView +- (void)layoutSubviews { + %orig(); + UIResponder *responder = [self nextResponder]; + while (responder != nil) { + if ([responder isKindOfClass:NSClassFromString(@"YTActionSheetDialogViewController")]) { + self.backgroundColor = customColor; + } + if ([responder isKindOfClass:NSClassFromString(@"YTPanelLoadingStrategyViewController")]) { + self.backgroundColor = customColor; + } + if ([responder isKindOfClass:NSClassFromString(@"YTTabHeaderElementsViewController")]) { + self.backgroundColor = customColor; + } + if ([responder isKindOfClass:NSClassFromString(@"YTEditSheetControllerElementsContentViewController")]) { + self.backgroundColor = customColor; + } + responder = [responder nextResponder]; + } - (void)didMoveToWindow { %orig; if (isDarkMode()) { @@ -351,28 +428,9 @@ UIColor *customColor = [UIColor colorWithRed:0.129 green:0.129 blue:0.129 alpha: } } %end - -// Open link with... -%hook ASWAppSwitchingSheetHeaderView -- (void)setBackgroundColor:(UIColor *)color { - return isDarkMode() ? %orig(customColor) : %orig; -} -%end - -%hook ASWAppSwitchingSheetFooterView -- (void)setBackgroundColor:(UIColor *)color { - return isDarkMode() ? %orig(customColor) : %orig; -} -%end - -%hook ASWAppSwitcherCollectionViewCell -- (void)didMoveToWindow { - %orig; - if (isDarkMode()) { - self.backgroundColor = customColor; - self.subviews[1].backgroundColor = customColor; - self.superview.backgroundColor = customColor; - } +%hook YTCinematicContainerView +- (void)setHidden:(BOOL)arg1 { + %orig(YES); } %end %end @@ -380,6 +438,26 @@ UIColor *customColor = [UIColor colorWithRed:0.129 green:0.129 blue:0.129 alpha: // OLED dark mode by BandarHL UIColor* raisedColor = [UIColor blackColor]; %group gOLED +%hook YTCommonColorPalette +- (UIColor *)brandBackgroundSolid { + return self.pageStyle == 1 ? [UIColor blackColor] : %orig; +} +- (UIColor *)brandBackgroundPrimary { + return self.pageStyle == 1 ? [UIColor blackColor] : %orig; +} +- (UIColor *)brandBackgroundSecondary { + return self.pageStyle == 1 ? [[UIColor blackColor] colorWithAlphaComponent:0.9] : %orig; +} +- (UIColor *)raisedBackground { + return self.pageStyle == 1 ? [UIColor blackColor] : %orig; +} +- (UIColor *)staticBrandBlack { + return self.pageStyle == 1 ? [UIColor blackColor] : %orig; +} +- (UIColor *)generalBackgroundA { + return self.pageStyle == 1 ? [UIColor blackColor] : %orig; +} +%end %hook UIView - (void)setBackgroundColor:(UIColor *)color { if ([self.nextResponder isKindOfClass:NSClassFromString(@"YTPivotBarView")]) { @@ -754,6 +832,21 @@ UIColor* raisedColor = [UIColor blackColor]; } responder = [responder nextResponder]; } +- (void)didMoveToWindow { + %orig; + if (isDarkMode()) { + if ([self.nextResponder isKindOfClass:%c(ASScrollView)]) { self.backgroundColor = [UIColor clearColor]; } + if ([self.accessibilityIdentifier isEqualToString:@"eml.cvr"]) { self.backgroundColor = customColor; } + if ([self.accessibilityIdentifier isEqualToString:@"rich_header"]) { self.backgroundColor = customColor; } + if ([self.accessibilityIdentifier isEqualToString:@"id.ui.comment_cell"]) { self.backgroundColor = customColor; } + if ([self.accessibilityIdentifier isEqualToString:@"id.ui.cancel.button"]) { self.superview.backgroundColor = [UIColor clearColor]; } + if ([self.accessibilityIdentifier isEqualToString:@"id.elements.components.comment_composer"]) { self.backgroundColor = customColor; } + if ([self.accessibilityIdentifier isEqualToString:@"id.elements.components.video_list_entry"]) { self.backgroundColor = customColor; } + if ([self.accessibilityIdentifier isEqualToString:@"id.comment.guidelines_text"]) { self.superview.backgroundColor = customColor; } + if ([self.accessibilityIdentifier isEqualToString:@"id.comment.channel_guidelines_bottom_sheet_container"]) { self.backgroundColor = customColor; } + if ([self.accessibilityIdentifier isEqualToString:@"id.comment.channel_guidelines_entry_banner_container"]) { self.backgroundColor = customColor; } + if ([self.accessibilityIdentifier isEqualToString:@"id.comment.comment_group_detail_container"]) { self.backgroundColor = [UIColor clearColor]; } + } } %end %hook YTCinematicContainerView