diff --git a/Source/Themes.xm b/Source/Themes.xm index e19fb8f..bb222bb 100644 --- a/Source/Themes.xm +++ b/Source/Themes.xm @@ -3,6 +3,7 @@ #define IS_DARK_APPEARANCE_ENABLED ([[NSUserDefaults standardUserDefaults] integerForKey:@"page_style"] == 1) #define IS_OLD_DARK_THEME_SELECTED (APP_THEME_IDX == 1) #define IS_OLED_DARK_THEME_SELECTED (APP_THEME_IDX == 2) +#define IS_CUSTOM_DARK_THEME_SELECTED (APP_THEME_IDX == 3) # pragma mark - Old dark theme (lighter grey) @@ -86,7 +87,7 @@ UIColor* raisedColor = [UIColor colorWithRed:0.035 green:0.035 blue:0.035 alpha:1.0]; -%group gOLED +%group gCustomTheme %hook YTCommonColorPalette - (UIColor *)baseBackground { return self.pageStyle == 1 ? [UIColor blackColor] : %orig; @@ -365,6 +366,290 @@ UIColor* raisedColor = [UIColor colorWithRed:0.035 green:0.035 blue:0.035 alpha: %end %end +# pragma mark - OLED dark mode by BandarHL + +UIColor *customHexColor; + +%group gOLED +%hook YTCommonColorPalette +- (UIColor *)baseBackground { + return self.pageStyle == 1 ? [UIColor customHexColor] : %orig; +} +- (UIColor *)brandBackgroundSolid { + return self.pageStyle == 1 ? [UIColor customHexColor] : %orig; +} +- (UIColor *)brandBackgroundPrimary { + return self.pageStyle == 1 ? [UIColor customHexColor] : %orig; +} +- (UIColor *)brandBackgroundSecondary { + return self.pageStyle == 1 ? [[UIColor customHexColor] colorWithAlphaComponent:0.9] : %orig; +} +- (UIColor *)raisedBackground { + return self.pageStyle == 1 ? [UIColor customHexColor] : %orig; +} +- (UIColor *)staticBrandBlack { + return self.pageStyle == 1 ? [UIColor customHexColor] : %orig; +} +- (UIColor *)generalBackgroundA { + return self.pageStyle == 1 ? [UIColor customHexColor] : %orig; +} +%end + +// uYou settings +%hook UITableViewCell +- (void)_layoutSystemBackgroundView { + %orig; + UIView *systemBackgroundView = [self valueForKey:@"_systemBackgroundView"]; + NSString *backgroundViewKey = class_getInstanceVariable(systemBackgroundView.class, "_colorView") ? @"_colorView" : @"_backgroundView"; + ((UIView *)[systemBackgroundView valueForKey:backgroundViewKey]).backgroundColor = [UIColor customHexColor]; +} +- (void)_layoutSystemBackgroundView:(BOOL)arg1 { + %orig; + ((UIView *)[[self valueForKey:@"_systemBackgroundView"] valueForKey:@"_colorView"]).backgroundColor = [UIColor customHexColor]; +} +%end + +%hook settingsReorderTable +- (void)viewDidLayoutSubviews { + %orig; + self.tableView.backgroundColor = [UIColor customHexColor]; +} +%end + +%hook FRPSelectListTable +- (void)viewDidLayoutSubviews { + %orig; + self.tableView.backgroundColor = [UIColor customHexColor]; +} +%end + +%hook FRPreferences +- (void)viewDidLayoutSubviews { + %orig; + self.tableView.backgroundColor = [UIColor customHexColor]; +} +%end + +%hook YTInnerTubeCollectionViewController +- (UIColor *)backgroundColor:(NSInteger)pageStyle { + return pageStyle == 1 ? [UIColor customHexColor] : %orig; +} +%end + +// Explore +%hook ASScrollView +- (void)didMoveToWindow { + %orig; + if (IS_DARK_APPEARANCE_ENABLED) { + self.backgroundColor = [UIColor clearColor]; + } +} +%end + +// Your videos +%hook ASCollectionView +- (void)didMoveToWindow { + %orig; + if (IS_DARK_APPEARANCE_ENABLED && [self.nextResponder isKindOfClass:%c(_ASDisplayView)]) { + self.superview.backgroundColor = [UIColor customHexColor]; + } +} +%end + +// Sub menu? +%hook ELMView +- (void)didMoveToWindow { + %orig; + if (IS_DARK_APPEARANCE_ENABLED) { + // self.subviews[0].backgroundColor = [UIColor clearColor]; + } +} +%end + +// iSponsorBlock +%hook SponsorBlockSettingsController +- (void)viewDidLoad { + if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) { + %orig; + self.tableView.backgroundColor = [UIColor customHexColor]; + } else { return %orig; } +} +%end + +%hook SponsorBlockViewController +- (void)viewDidLoad { + if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) { + %orig; + self.view.backgroundColor = [UIColor customHexColor]; + } else { return %orig; } +} +%end + +// Search view +%hook YTSearchBarView +- (void)setBackgroundColor:(UIColor *)color { + return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor customHexColor]) : %orig; +} +%end + +// History search view +%hook YTSearchBoxView +- (void)setBackgroundColor:(UIColor *)color { + return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor customHexColor]) : %orig; + +} +%end + +// Comment view +%hook YTCommentView +- (void)setBackgroundColor:(UIColor *)color { + return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor customHexColor]) : %orig; +} +%end + +%hook YTCreateCommentAccessoryView +- (void)setBackgroundColor:(UIColor *)color { + return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor customHexColor]) : %orig; +} +%end + +%hook YTCreateCommentTextView +- (void)setBackgroundColor:(UIColor *)color { + return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor customHexColor]) : %orig; +} +- (void)setTextColor:(UIColor *)color { // fix black text in #Shorts video's comment + return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor whiteColor]) : %orig; +} +%end + +%hook YTCommentDetailHeaderCell +- (void)didMoveToWindow { + %orig; + if (IS_DARK_APPEARANCE_ENABLED) { + // self.subviews[2].backgroundColor = [UIColor customHexColor]; + } +} +%end + +%hook YTFormattedStringLabel // YT is werid... +- (void)setBackgroundColor:(UIColor *)color { + return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor clearColor]) : %orig; +} +%end + +// Live chat comment +%hook YCHLiveChatActionPanelView +- (void)setBackgroundColor:(UIColor *)color { + return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor customHexColor]) : %orig; +} +%end + +%hook YTEmojiTextView +- (void)setBackgroundColor:(UIColor *)color { + return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor customHexColor]) : %orig; +} +%end + +%hook YCHLiveChatView +- (void)didMoveToWindow { + %orig; + if (IS_DARK_APPEARANCE_ENABLED) { + // self.subviews[1].backgroundColor = [UIColor customHexColor]; + } +} +%end + +%hook YTCollectionView +- (void)setBackgroundColor:(UIColor *)color { + return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor customHexColor]) : %orig; +} +%end + +// +%hook YTBackstageCreateRepostDetailView +- (void)setBackgroundColor:(UIColor *)color { + return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor customHexColor]) : %orig; +} +%end + +// Others +%hook _ASDisplayView +- (void)layoutSubviews { + %orig; + if (IS_DARK_APPEARANCE_ENABLED) { + UIResponder *responder = [self nextResponder]; + while (responder != nil) { + if ([responder isKindOfClass:NSClassFromString(@"YTActionSheetDialogViewController")]) { + self.backgroundColor = [UIColor customHexColor]; + } + if ([responder isKindOfClass:NSClassFromString(@"YTPanelLoadingStrategyViewController")]) { + self.backgroundColor = [UIColor customHexColor]; + } + if ([responder isKindOfClass:NSClassFromString(@"YTTabHeaderElementsViewController")]) { + self.backgroundColor = [UIColor customHexColor]; + } + if ([responder isKindOfClass:NSClassFromString(@"YTEditSheetControllerElementsContentViewController")]) { + self.backgroundColor = [UIColor customHexColor]; + } + responder = [responder nextResponder]; + } + } +} +- (void)didMoveToWindow { + %orig; + if (IS_DARK_APPEARANCE_ENABLED) { + if ([self.nextResponder isKindOfClass:%c(ASScrollView)]) { self.backgroundColor = [UIColor clearColor]; } + if ([self.accessibilityIdentifier isEqualToString:@"brand_promo.view"]) { self.backgroundColor = [UIColor customHexColor]; } + if ([self.accessibilityIdentifier isEqualToString:@"eml.cvr"]) { self.backgroundColor = [UIColor customHexColor]; } + if ([self.accessibilityIdentifier isEqualToString:@"eml.topic_channel_details"]) { self.backgroundColor = [UIColor customHexColor]; } + if ([self.accessibilityIdentifier isEqualToString:@"eml.live_chat_text_message"]) { self.backgroundColor = [UIColor customHexColor]; } + if ([self.accessibilityIdentifier isEqualToString:@"rich_header"]) { self.backgroundColor = [UIColor customHexColor]; } + if ([self.accessibilityIdentifier isEqualToString:@"id.ui.comment_cell"]) { self.backgroundColor = [UIColor customHexColor]; } + if ([self.accessibilityIdentifier isEqualToString:@"id.ui.comment_thread"]) { self.backgroundColor = [UIColor customHexColor]; } + if ([self.accessibilityIdentifier isEqualToString:@"id.ui.cancel.button"]) { self.superview.backgroundColor = [UIColor clearColor]; } + if ([self.accessibilityIdentifier isEqualToString:@"id.elements.components.comment_composer"]) { self.backgroundColor = [UIColor customHexColor]; } + if ([self.accessibilityIdentifier isEqualToString:@"id.elements.components.filter_chip_bar"]) { self.backgroundColor = [UIColor customHexColor]; } + if ([self.accessibilityIdentifier isEqualToString:@"id.elements.components.video_list_entry"]) { self.backgroundColor = [UIColor customHexColor]; } + if ([self.accessibilityIdentifier isEqualToString:@"id.comment.guidelines_text"]) { self.superview.backgroundColor = [UIColor customHexColor]; } + if ([self.accessibilityIdentifier isEqualToString:@"id.comment.timed_comments_welcome"]) { self.superview.backgroundColor = self.backgroundColor = [UIColor customHexColor]; } + if ([self.accessibilityIdentifier isEqualToString:@"id.comment.channel_guidelines_bottom_sheet_container"]) { self.backgroundColor = [UIColor customHexColor]; } + if ([self.accessibilityIdentifier isEqualToString:@"id.comment.channel_guidelines_entry_banner_container"]) { self.superview.backgroundColor = self.backgroundColor = [UIColor customHexColor]; } + if ([self.accessibilityIdentifier isEqualToString:@"id.comment.comment_group_detail_container"]) { self.backgroundColor = [UIColor clearColor]; } + } +} +%end + +// Open link with... +%hook ASWAppSwitchingSheetHeaderView +- (void)setBackgroundColor:(UIColor *)color { + return IS_DARK_APPEARANCE_ENABLED ? %orig(raisedColor) : %orig; +} +%end + +%hook ASWAppSwitchingSheetFooterView +- (void)setBackgroundColor:(UIColor *)color { + return IS_DARK_APPEARANCE_ENABLED ? %orig(raisedColor) : %orig; +} +%end + +%hook ASWAppSwitcherCollectionViewCell +- (void)didMoveToWindow { + %orig; + if (IS_DARK_APPEARANCE_ENABLED) { + self.backgroundColor = raisedColor; + // self.subviews[1].backgroundColor = raisedColor; + self.superview.backgroundColor = raisedColor; + } +} +%end + +// Incompatibility with the new YT Dark theme +%hook YTColdConfig +- (BOOL)uiSystemsClientGlobalConfigUseDarkerPaletteBgColorForNative { return NO; } +%end +%end + + # pragma mark - OLED keyboard by @ichitaso <3 - http://gist.github.com/ichitaso/935100fd53a26f18a9060f7195a1be0e %group gOLEDKB @@ -402,6 +687,9 @@ UIColor* raisedColor = [UIColor colorWithRed:0.035 green:0.035 blue:0.035 alpha: %end %ctor { + if (IS_CUSTOM_DARK_THEME_SELECTED) { + %init(gCustomTheme); + } if (IS_OLED_DARK_THEME_SELECTED) { %init(gOLED); }