From 0da6da06af5fb5be00b0a81e1c9fc6f878429eb5 Mon Sep 17 00:00:00 2001 From: qnblackcat Date: Wed, 21 Feb 2024 14:42:53 +0700 Subject: [PATCH] update OLED dark theme --- Sources/uYouPlusThemes.h | 19 ++-- Sources/uYouPlusThemes.xm | 226 ++++++++++++++++++++++---------------- 2 files changed, 142 insertions(+), 103 deletions(-) diff --git a/Sources/uYouPlusThemes.h b/Sources/uYouPlusThemes.h index 5e007f26aa..63ae3b2230 100644 --- a/Sources/uYouPlusThemes.h +++ b/Sources/uYouPlusThemes.h @@ -1,9 +1,10 @@ #import #import +#import #import "uYouPlus.h" -@interface YCHLiveChatView : UIView -@end +// @interface YCHLiveChatView : UIView +// @end @interface YTFullscreenEngagementOverlayView : UIView @end @@ -11,8 +12,8 @@ @interface YTRelatedVideosView : UIView @end -@interface ELMView : UIView -@end +// @interface ELMView : UIView +// @end @interface ASWAppSwitcherCollectionViewCell : UIView @end @@ -26,11 +27,8 @@ @interface UIKeyboardDockView : UIView @end -@interface _ASDisplayView : UIView -@end - -@interface YTCommentDetailHeaderCell : UIView -@end +// @interface YTCommentDetailHeaderCell : UIView +// @end @interface SponsorBlockSettingsController : UITableViewController @end @@ -44,6 +42,9 @@ @interface UIPredictionViewController : UIViewController @end +@interface TUIEmojiSearchView : UIView +@end + @interface FRPreferences : UITableViewController @end diff --git a/Sources/uYouPlusThemes.xm b/Sources/uYouPlusThemes.xm index 233662f69f..77ae1c96d8 100644 --- a/Sources/uYouPlusThemes.xm +++ b/Sources/uYouPlusThemes.xm @@ -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 @@ -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 @@ -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; } } @@ -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;