Skip to content

Commit

Permalink
update OLED dark theme
Browse files Browse the repository at this point in the history
  • Loading branch information
qnblackcat committed Feb 21, 2024
1 parent 5df3bfb commit 0da6da0
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 103 deletions.
19 changes: 10 additions & 9 deletions Sources/uYouPlusThemes.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
#import <YouTubeHeader/YTCommonColorPalette.h>
#import <YouTubeHeader/ASCollectionView.h>
#import <YouTubeHeader/_ASDisplayView.h>
#import "uYouPlus.h"

@interface YCHLiveChatView : UIView
@end
// @interface YCHLiveChatView : UIView
// @end

@interface YTFullscreenEngagementOverlayView : UIView
@end

@interface YTRelatedVideosView : UIView
@end

@interface ELMView : UIView
@end
// @interface ELMView : UIView
// @end

@interface ASWAppSwitcherCollectionViewCell : UIView
@end
Expand All @@ -26,11 +27,8 @@
@interface UIKeyboardDockView : UIView
@end

@interface _ASDisplayView : UIView
@end

@interface YTCommentDetailHeaderCell : UIView
@end
// @interface YTCommentDetailHeaderCell : UIView
// @end

@interface SponsorBlockSettingsController : UITableViewController
@end
Expand All @@ -44,6 +42,9 @@
@interface UIPredictionViewController : UIViewController
@end

@interface TUIEmojiSearchView : UIView
@end

@interface FRPreferences : UITableViewController
@end

Expand Down
226 changes: 132 additions & 94 deletions Sources/uYouPlusThemes.xm
Original file line number Diff line number Diff line change
Expand Up @@ -118,30 +118,37 @@ UIColor* raisedColor = [UIColor colorWithRed:0.035 green:0.035 blue:0.035 alpha:
- (void)didMoveToWindow {
%orig;
if (IS_DARK_APPEARANCE_ENABLED) {
self.backgroundColor = [UIColor clearColor];
self.backgroundColor = [UIColor blackColor];
}
}
%end

// Your videos
// Download sort
%hook GOODialogView
- (void)setBackgroundColor:(UIColor *)color {
return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blackColor]) : %orig;
}
%end

// Playlist sort
%hook ASCollectionView
- (void)didMoveToWindow {
%orig;
if (IS_DARK_APPEARANCE_ENABLED && [self.nextResponder isKindOfClass:%c(_ASDisplayView)]) {
self.superview.backgroundColor = [UIColor blackColor];
self.backgroundColor = [UIColor blackColor];
}
}
%end

// Sub menu?
%hook ELMView
- (void)didMoveToWindow {
%orig;
if (IS_DARK_APPEARANCE_ENABLED) {
// self.subviews[0].backgroundColor = [UIColor clearColor];
}
}
%end
// %hook ELMView
// - (void)didMoveToWindow {
// %orig;
// if (IS_DARK_APPEARANCE_ENABLED) {
// // self.subviews[0].backgroundColor = [UIColor clearColor];
// }
// }
// %end

// iSponsorBlock
%hook SponsorBlockSettingsController
Expand All @@ -163,110 +170,135 @@ UIColor* raisedColor = [UIColor colorWithRed:0.035 green:0.035 blue:0.035 alpha:
%end

// Search view
%hook YTSearchBarView
- (void)setBackgroundColor:(UIColor *)color {
return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blackColor]) : %orig;
}
%end
// %hook YTSearchBarView
// - (void)setBackgroundColor:(UIColor *)color {
// return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blueColor]) : %orig;
// }
// %end

// History search view
%hook YTSearchBoxView
- (void)setBackgroundColor:(UIColor *)color {
return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blackColor]) : %orig;
// %hook YTSearchBoxView
// - (void)setBackgroundColor:(UIColor *)color {
// return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blackColor]) : %orig;

}
%end
// }
// %end

// Comment view
%hook YTCommentView
- (void)setBackgroundColor:(UIColor *)color {
return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blackColor]) : %orig;
}
%end

%hook YTCreateCommentAccessoryView
- (void)setBackgroundColor:(UIColor *)color {
return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blackColor]) : %orig;
}
%end

%hook YTCreateCommentTextView
- (void)setBackgroundColor:(UIColor *)color {
return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blackColor]) : %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 blackColor];
}
}
%end

%hook YTFormattedStringLabel // YT is werid...
- (void)setBackgroundColor:(UIColor *)color {
return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor clearColor]) : %orig;
}
%end
// %hook YTCommentView
// - (void)setBackgroundColor:(UIColor *)color {
// return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blackColor]) : %orig;
// }
// %end

// %hook YTCreateCommentAccessoryView
// - (void)setBackgroundColor:(UIColor *)color {
// return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blackColor]) : %orig;
// }
// %end

// %hook YTCreateCommentTextView
// - (void)setBackgroundColor:(UIColor *)color {
// return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blackColor]) : %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 blackColor];
// }
// }
// %end

// %hook YTFormattedStringLabel // YT is werid...
// - (void)setBackgroundColor:(UIColor *)color {
// return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor greenColor]) : %orig;
// }
// %end

// Live chat comment
%hook YCHLiveChatActionPanelView
- (void)setBackgroundColor:(UIColor *)color {
return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blackColor]) : %orig;
}
%end

%hook YTEmojiTextView
- (void)setBackgroundColor:(UIColor *)color {
return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blackColor]) : %orig;
}
%end

%hook YCHLiveChatView
- (void)didMoveToWindow {
%orig;
if (IS_DARK_APPEARANCE_ENABLED) {
// self.subviews[1].backgroundColor = [UIColor blackColor];
}
}
%end

%hook YTCollectionView
- (void)setBackgroundColor:(UIColor *)color {
return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blackColor]) : %orig;
}
%end
// %hook YCHLiveChatActionPanelView
// - (void)setBackgroundColor:(UIColor *)color {
// return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor greenColor]) : %orig;
// }
// %end

// %hook YTEmojiTextView
// - (void)setBackgroundColor:(UIColor *)color {
// return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor greenColor]) : %orig;
// }
// %end

// %hook YCHLiveChatView
// - (void)didMoveToWindow {
// %orig;
// if (IS_DARK_APPEARANCE_ENABLED) {
// // self.subviews[1].backgroundColor = [UIColor blackColor];
// }
// }
// %end

// %hook YTCollectionView
// - (void)setBackgroundColor:(UIColor *)color {
// return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor greenColor]) : %orig;
// }
// %end

//
%hook YTBackstageCreateRepostDetailView
- (void)setBackgroundColor:(UIColor *)color {
return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blackColor]) : %orig;
}
%end
// %hook YTBackstageCreateRepostDetailView
// - (void)setBackgroundColor:(UIColor *)color {
// return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor greenColor]) : %orig;
// }
// %end

// Others
%hook _ASDisplayView
- (void)didMoveToWindow {
%orig;
if (IS_DARK_APPEARANCE_ENABLED) {
if ([self.nextResponder isKindOfClass:%c(ASScrollView)]) { self.backgroundColor = [UIColor clearColor]; }
if ([self.accessibilityIdentifier isEqualToString:@"eml.cvr"]) { self.backgroundColor = [UIColor blackColor]; }

// is this good?
UIResponder *responder = self.nextResponder;
UIViewController *closestViewController = nil;

while (responder != nil) {
if ([responder isKindOfClass:[UIViewController class]]) {
closestViewController = (UIViewController *)responder;
break;
}
responder = responder.nextResponder;
}

if ([NSStringFromClass([closestViewController class]) isEqualToString:@"YTActionSheetDialogViewController"] &&
(([NSStringFromClass([self.superview class]) isEqualToString:@"YTELMView"]) ||
[NSStringFromClass([self.superview class]) isEqualToString:@"_ASDisplayView"] ||
[NSStringFromClass([self.superview class]) isEqualToString:@"ELMView"])) {

self.backgroundColor = [UIColor clearColor];

}

// Save video bottom
if ([NSStringFromClass([closestViewController class]) isEqualToString:@"YTBottomSheetController"]) { self.backgroundColor = [UIColor clearColor]; }

// if ([self.nextResponder isKindOfClass:%c(ASScrollView)]) { self.backgroundColor = [UIColor clearColor]; }
// if ([self.accessibilityIdentifier isEqualToString:@"eml.cvr"]) { self.backgroundColor = [UIColor blackColor]; }
if ([self.accessibilityIdentifier isEqualToString:@"eml.live_chat_text_message"]) { self.backgroundColor = [UIColor blackColor]; }
if ([self.accessibilityIdentifier isEqualToString:@"rich_header"]) { self.backgroundColor = [UIColor blackColor]; }
// if ([self.accessibilityIdentifier isEqualToString:@"rich_header"]) { self.backgroundColor = [UIColor blackColor]; }
if ([self.accessibilityIdentifier isEqualToString:@"id.ui.comment_cell"]) { self.backgroundColor = [UIColor blackColor]; }
if ([self.accessibilityIdentifier isEqualToString:@"id.ui.cancel.button"]) { self.superview.backgroundColor = [UIColor clearColor]; }
// 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 blackColor]; }
if ([self.accessibilityIdentifier isEqualToString:@"id.elements.components.video_list_entry"]) { self.backgroundColor = [UIColor blackColor]; }
if ([self.accessibilityIdentifier isEqualToString:@"id.comment.guidelines_text"]) { self.superview.backgroundColor = [UIColor blackColor]; }
if ([self.accessibilityIdentifier isEqualToString:@"id.comment.channel_guidelines_bottom_sheet_container"]) { self.backgroundColor = [UIColor blackColor]; }
// if ([self.accessibilityIdentifier isEqualToString:@"id.comment.channel_guidelines_bottom_sheet_container"]) { self.backgroundColor = [UIColor blackColor]; }
if ([self.accessibilityIdentifier isEqualToString:@"id.comment.channel_guidelines_entry_banner_container"]) { self.backgroundColor = [UIColor blackColor]; }
if ([self.accessibilityIdentifier isEqualToString:@"id.comment.comment_group_detail_container"]) { self.backgroundColor = [UIColor clearColor]; }
if ([self.accessibilityIdentifier hasPrefix:@"id.elements.components.overflow_menu_item_"]) { self.backgroundColor = [UIColor clearColor]; }
// if ([self.accessibilityIdentifier hasPrefix:@"id.elements.components.overflow_menu_item_"]) { self.backgroundColor = [UIColor clearColor]; }
}
}
%end
Expand All @@ -289,7 +321,6 @@ UIColor* raisedColor = [UIColor colorWithRed:0.035 green:0.035 blue:0.035 alpha:
%orig;
if (IS_DARK_APPEARANCE_ENABLED) {
self.backgroundColor = raisedColor;
// self.subviews[1].backgroundColor = raisedColor;
self.superview.backgroundColor = raisedColor;
}
}
Expand All @@ -304,6 +335,13 @@ UIColor* raisedColor = [UIColor colorWithRed:0.035 green:0.035 blue:0.035 alpha:
# pragma mark - OLED keyboard by @ichitaso <3 - http://gist.github.com/ichitaso/935100fd53a26f18a9060f7195a1be0e

%group gOLEDKB
%hook TUIEmojiSearchView
- (void)didMoveToWindow {
%orig;
self.backgroundColor = [UIColor blackColor];
}
%end

%hook UIPredictionViewController
- (void)loadView {
%orig;
Expand Down

0 comments on commit 0da6da0

Please sign in to comment.