mirror of
https://github.com/arichornlover/uYouEnhanced.git
synced 2026-04-21 03:32:08 +00:00
Experimental LowContrastMode.xm
An update that reimagines the tweak as if it were in iOS 16 Tweak is backwards compatible with iOS 15 but you will not have access to certain iOS 16 features.
This commit is contained in:
parent
dfc796faec
commit
006f300e3c
1 changed files with 176 additions and 86 deletions
|
|
@ -18,11 +18,7 @@ static inline BOOL customContrastMode() {
|
||||||
return IS_ENABLED(@"lowContrastMode_enabled") && contrastMode() == 1;
|
return IS_ENABLED(@"lowContrastMode_enabled") && contrastMode() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// static inline UIColor *activeColor() {
|
// Low Contrast Mode v1.7.2 (Compatible with YouTube v19.01.1-v20.33.2)
|
||||||
// return customContrastMode() && lcmHexColor ? lcmHexColor : kLowContrastColor;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Low Contrast Mode v1.7.1.1 (Compatible with only YouTube v19.01.1-v20.21.6)
|
|
||||||
%group gLowContrastMode
|
%group gLowContrastMode
|
||||||
%hook UIColor
|
%hook UIColor
|
||||||
+ (UIColor *)colorNamed:(NSString *)name {
|
+ (UIColor *)colorNamed:(NSString *)name {
|
||||||
|
|
@ -41,41 +37,64 @@ static inline BOOL customContrastMode() {
|
||||||
%end
|
%end
|
||||||
|
|
||||||
%hook YTCommonColorPalette
|
%hook YTCommonColorPalette
|
||||||
|
+ (id)darkPalette {
|
||||||
|
id palette = %orig;
|
||||||
|
if (UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
|
||||||
|
[palette setValue:kLowContrastColor forKey:@"textPrimary"];
|
||||||
|
[palette setValue:kLowContrastColor forKey:@"textSecondary"];
|
||||||
|
[palette setValue:kLowContrastColor forKey:@"overlayTextPrimary"];
|
||||||
|
[palette setValue:kLowContrastColor forKey:@"overlayTextSecondary"];
|
||||||
|
[palette setValue:kLowContrastColor forKey:@"iconActive"];
|
||||||
|
[palette setValue:kLowContrastColor forKey:@"iconActiveOther"];
|
||||||
|
[palette setValue:kLowContrastColor forKey:@"brandIconActive"];
|
||||||
|
[palette setValue:kLowContrastColor forKey:@"staticBrandWhite"];
|
||||||
|
[palette setValue:kLowContrastColor forKey:@"overlayIconActiveOther"];
|
||||||
|
[palette setValue:[kLowContrastColor colorWithAlphaComponent:0.7] forKey:@"overlayIconInactive"];
|
||||||
|
[palette setValue:[kLowContrastColor colorWithAlphaComponent:0.3] forKey:@"overlayIconDisabled"];
|
||||||
|
[palette setValue:[kLowContrastColor colorWithAlphaComponent:0.2] forKey:@"overlayFilledButtonActive"];
|
||||||
|
}
|
||||||
|
return palette;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (id)lightPalette {
|
||||||
|
return %orig;
|
||||||
|
}
|
||||||
|
|
||||||
- (UIColor *)textPrimary {
|
- (UIColor *)textPrimary {
|
||||||
return self.pageStyle == 1 ? kDefaultTextColor : %orig;
|
return UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? kLowContrastColor : %orig;
|
||||||
}
|
}
|
||||||
- (UIColor *)textSecondary {
|
- (UIColor *)textSecondary {
|
||||||
return self.pageStyle == 1 ? kDefaultTextColor : %orig;
|
return UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? kLowContrastColor : %orig;
|
||||||
}
|
}
|
||||||
- (UIColor *)overlayTextPrimary {
|
- (UIColor *)overlayTextPrimary {
|
||||||
return self.pageStyle == 1 ? kDefaultTextColor : %orig;
|
return UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? kLowContrastColor : %orig;
|
||||||
}
|
}
|
||||||
- (UIColor *)overlayTextSecondary {
|
- (UIColor *)overlayTextSecondary {
|
||||||
return self.pageStyle == 1 ? kDefaultTextColor : %orig;
|
return UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? kLowContrastColor : %orig;
|
||||||
}
|
}
|
||||||
- (UIColor *)iconActive {
|
- (UIColor *)iconActive {
|
||||||
return self.pageStyle == 1 ? kDefaultTextColor : %orig;
|
return UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? kLowContrastColor : %orig;
|
||||||
}
|
}
|
||||||
- (UIColor *)iconActiveOther {
|
- (UIColor *)iconActiveOther {
|
||||||
return self.pageStyle == 1 ? kDefaultTextColor : %orig;
|
return UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? kLowContrastColor : %orig;
|
||||||
}
|
}
|
||||||
- (UIColor *)brandIconActive {
|
- (UIColor *)brandIconActive {
|
||||||
return self.pageStyle == 1 ? kDefaultTextColor : %orig;
|
return UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? kLowContrastColor : %orig;
|
||||||
}
|
}
|
||||||
- (UIColor *)staticBrandWhite {
|
- (UIColor *)staticBrandWhite {
|
||||||
return self.pageStyle == 1 ? kDefaultTextColor : %orig;
|
return UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? kLowContrastColor : %orig;
|
||||||
}
|
}
|
||||||
- (UIColor *)overlayIconActiveOther {
|
- (UIColor *)overlayIconActiveOther {
|
||||||
return self.pageStyle == 1 ? kDefaultTextColor : %orig;
|
return UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? kLowContrastColor : %orig;
|
||||||
}
|
}
|
||||||
- (UIColor *)overlayIconInactive {
|
- (UIColor *)overlayIconInactive {
|
||||||
return self.pageStyle == 1 ? [kDefaultTextColor colorWithAlphaComponent:0.7] : %orig;
|
return UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? [kLowContrastColor colorWithAlphaComponent:0.7] : %orig;
|
||||||
}
|
}
|
||||||
- (UIColor *)overlayIconDisabled {
|
- (UIColor *)overlayIconDisabled {
|
||||||
return self.pageStyle == 1 ? [kDefaultTextColor colorWithAlphaComponent:0.3] : %orig;
|
return UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? [kLowContrastColor colorWithAlphaComponent:0.3] : %orig;
|
||||||
}
|
}
|
||||||
- (UIColor *)overlayFilledButtonActive {
|
- (UIColor *)overlayFilledButtonActive {
|
||||||
return self.pageStyle == 1 ? [kDefaultTextColor colorWithAlphaComponent:0.2] : %orig;
|
return UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? [kLowContrastColor colorWithAlphaComponent:0.2] : %orig;
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
|
|
@ -93,9 +112,9 @@ static inline BOOL customContrastMode() {
|
||||||
%hook _ASDisplayView
|
%hook _ASDisplayView
|
||||||
- (void)layoutSubviews {
|
- (void)layoutSubviews {
|
||||||
%orig;
|
%orig;
|
||||||
NSArray<NSString *> *targetLabels = @[@"connect account", @"Thanks", @"Save to playlist", @"Report"];
|
NSArray<NSString *> *targetLabels = @[@"connect account", @"Thanks", @"Save to playlist", @"Report", @"Share", @"Like", @"Dislike"];
|
||||||
for (UIView *subview in self.subviews) {
|
for (UIView *subview in self.subviews) {
|
||||||
if ([targetLabels containsObject:subview.accessibilityLabel]) {
|
if ([targetLabels containsObject:subview.accessibilityLabel] && UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
|
||||||
subview.backgroundColor = kLowContrastColor;
|
subview.backgroundColor = kLowContrastColor;
|
||||||
if ([subview isKindOfClass:[UILabel class]]) {
|
if ([subview isKindOfClass:[UILabel class]]) {
|
||||||
((UILabel *)subview).textColor = [UIColor blackColor];
|
((UILabel *)subview).textColor = [UIColor blackColor];
|
||||||
|
|
@ -128,9 +147,13 @@ static inline BOOL customContrastMode() {
|
||||||
|
|
||||||
%hook YTQTMButton
|
%hook YTQTMButton
|
||||||
- (void)setImage:(UIImage *)image {
|
- (void)setImage:(UIImage *)image {
|
||||||
UIImage *tintedImage = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
|
if (UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
|
||||||
[self setTintColor:kDefaultTextColor];
|
UIImage *tintedImage = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
|
||||||
%orig(tintedImage);
|
[self setTintColor:kDefaultTextColor];
|
||||||
|
%orig(tintedImage);
|
||||||
|
} else {
|
||||||
|
%orig;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
|
|
@ -160,97 +183,117 @@ static inline BOOL customContrastMode() {
|
||||||
|
|
||||||
%hook UILabel
|
%hook UILabel
|
||||||
+ (void)load {
|
+ (void)load {
|
||||||
[[UILabel appearance] setTextColor:kDefaultTextColor];
|
if (@available(iOS 16.0, *)) {
|
||||||
|
[[UILabel appearance] setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
|
||||||
|
[[UILabel appearance] setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
|
||||||
|
}
|
||||||
|
if (UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
|
||||||
|
[[UILabel appearance] setTextColor:kDefaultTextColor];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
- (void)setTextColor:(UIColor *)textColor {
|
- (void)setTextColor:(UIColor *)textColor {
|
||||||
%orig(kDefaultTextColor);
|
%orig(UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? kDefaultTextColor : textColor);
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
%hook UITextField
|
%hook UITextField
|
||||||
- (void)setTextColor:(UIColor *)textColor {
|
- (void)setTextColor:(UIColor *)textColor {
|
||||||
%orig(kDefaultTextColor);
|
%orig(UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? kDefaultTextColor : textColor);
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
%hook UITextView
|
%hook UITextView
|
||||||
- (void)setTextColor:(UIColor *)textColor {
|
- (void)setTextColor:(UIColor *)textColor {
|
||||||
%orig(kDefaultTextColor);
|
%orig(UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? kDefaultTextColor : textColor);
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
%hook UISearchBar
|
%hook UISearchBar
|
||||||
- (void)setTextColor:(UIColor *)textColor {
|
- (void)setTextColor:(UIColor *)textColor {
|
||||||
%orig(kDefaultTextColor);
|
%orig(UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? kDefaultTextColor : textColor);
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
%hook UISegmentedControl
|
%hook UISegmentedControl
|
||||||
- (void)setTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state {
|
- (void)setTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state {
|
||||||
NSMutableDictionary *modifiedAttributes = [NSMutableDictionary dictionaryWithDictionary:attributes];
|
if (UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
|
||||||
modifiedAttributes[NSForegroundColorAttributeName] = kDefaultTextColor;
|
NSMutableDictionary *modifiedAttributes = [NSMutableDictionary dictionaryWithDictionary:attributes];
|
||||||
%orig(modifiedAttributes, state);
|
modifiedAttributes[NSForegroundColorAttributeName] = kDefaultTextColor;
|
||||||
|
%orig(modifiedAttributes, state);
|
||||||
|
} else {
|
||||||
|
%orig;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
%hook UIButton
|
%hook UIButton
|
||||||
- (void)setTitleColor:(UIColor *)color forState:(UIControlState)state {
|
- (void)setTitleColor:(UIColor *)color forState:(UIControlState)state {
|
||||||
%orig(kDefaultTextColor, state);
|
%orig(UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? kDefaultTextColor : color, state);
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
%hook UIBarButtonItem
|
%hook UIBarButtonItem
|
||||||
- (void)setTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state {
|
- (void)setTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state {
|
||||||
NSMutableDictionary *modifiedAttributes = [NSMutableDictionary dictionaryWithDictionary:attributes];
|
if (UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
|
||||||
modifiedAttributes[NSForegroundColorAttributeName] = kDefaultTextColor;
|
NSMutableDictionary *modifiedAttributes = [NSMutableDictionary dictionaryWithDictionary:attributes];
|
||||||
%orig(modifiedAttributes, state);
|
modifiedAttributes[NSForegroundColorAttributeName] = kDefaultTextColor;
|
||||||
|
%orig(modifiedAttributes, state);
|
||||||
|
} else {
|
||||||
|
%orig;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
%hook NSAttributedString
|
%hook NSAttributedString
|
||||||
- (instancetype)initWithString:(NSString *)str attributes:(NSDictionary<NSAttributedStringKey, id> *)attrs {
|
- (instancetype)initWithString:(NSString *)str attributes:(NSDictionary<NSAttributedStringKey, id> *)attrs {
|
||||||
NSMutableDictionary *modifiedAttributes = [NSMutableDictionary dictionaryWithDictionary:attrs];
|
if (UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
|
||||||
modifiedAttributes[NSForegroundColorAttributeName] = kDefaultTextColor;
|
NSMutableDictionary *modifiedAttributes = [NSMutableDictionary dictionaryWithDictionary:attrs];
|
||||||
return %orig(str, modifiedAttributes);
|
modifiedAttributes[NSForegroundColorAttributeName] = kDefaultTextColor;
|
||||||
|
return %orig(str, modifiedAttributes);
|
||||||
|
}
|
||||||
|
return %orig;
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
%hook CATextLayer
|
%hook CATextLayer
|
||||||
- (void)setTextColor:(CGColorRef)textColor {
|
- (void)setTextColor:(CGColorRef)textColor {
|
||||||
%orig(kDefaultTextColor.CGColor);
|
%orig(UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? kDefaultTextColor.CGColor : textColor);
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
%hook ASTextNode
|
%hook ASTextNode
|
||||||
- (NSAttributedString *)attributedString {
|
- (NSAttributedString *)attributedString {
|
||||||
NSAttributedString *original = %orig;
|
NSAttributedString *original = %orig;
|
||||||
NSMutableAttributedString *modified = [original mutableCopy];
|
if (UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
|
||||||
[modified addAttribute:NSForegroundColorAttributeName value:kDefaultTextColor range:NSMakeRange(0, modified.length)];
|
NSMutableAttributedString *modified = [original mutableCopy];
|
||||||
return modified;
|
[modified addAttribute:NSForegroundColorAttributeName value:kDefaultTextColor range:NSMakeRange(0, modified.length)];
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
return original;
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
%hook ASTextFieldNode
|
%hook ASTextFieldNode
|
||||||
- (void)setTextColor:(UIColor *)textColor {
|
- (void)setTextColor:(UIColor *)textColor {
|
||||||
%orig(kDefaultTextColor);
|
%orig(UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? kDefaultTextColor : textColor);
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
%hook ASTextView
|
%hook ASTextView
|
||||||
- (void)setTextColor:(UIColor *)textColor {
|
- (void)setTextColor:(UIColor *)textColor {
|
||||||
%orig(kDefaultTextColor);
|
%orig(UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? kDefaultTextColor : textColor);
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
%hook ASButtonNode
|
%hook ASButtonNode
|
||||||
- (void)setTextColor:(UIColor *)textColor {
|
- (void)setTextColor:(UIColor *)textColor {
|
||||||
%orig(kDefaultTextColor);
|
%orig(UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? kDefaultTextColor : textColor);
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
%hook UIControl
|
%hook UIControl
|
||||||
- (UIColor *)backgroundColor {
|
- (UIColor *)backgroundColor {
|
||||||
return [UIColor blackColor];
|
return UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? [UIColor blackColor] : %orig;
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
%end
|
%end
|
||||||
|
|
@ -274,41 +317,64 @@ static inline BOOL customContrastMode() {
|
||||||
%end
|
%end
|
||||||
|
|
||||||
%hook YTCommonColorPalette
|
%hook YTCommonColorPalette
|
||||||
|
+ (id)darkPalette {
|
||||||
|
id palette = %orig;
|
||||||
|
if (UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
|
||||||
|
[palette setValue:lcmHexColor forKey:@"textPrimary"];
|
||||||
|
[palette setValue:lcmHexColor forKey:@"textSecondary"];
|
||||||
|
[palette setValue:lcmHexColor forKey:@"overlayTextPrimary"];
|
||||||
|
[palette setValue:lcmHexColor forKey:@"overlayTextSecondary"];
|
||||||
|
[palette setValue:lcmHexColor forKey:@"iconActive"];
|
||||||
|
[palette setValue:lcmHexColor forKey:@"iconActiveOther"];
|
||||||
|
[palette setValue:lcmHexColor forKey:@"brandIconActive"];
|
||||||
|
[palette setValue:lcmHexColor forKey:@"staticBrandWhite"];
|
||||||
|
[palette setValue:lcmHexColor forKey:@"overlayIconActiveOther"];
|
||||||
|
[palette setValue:[lcmHexColor colorWithAlphaComponent:0.7] forKey:@"overlayIconInactive"];
|
||||||
|
[palette setValue:[lcmHexColor colorWithAlphaComponent:0.3] forKey:@"overlayIconDisabled"];
|
||||||
|
[palette setValue:[lcmHexColor colorWithAlphaComponent:0.2] forKey:@"overlayFilledButtonActive"];
|
||||||
|
}
|
||||||
|
return palette;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (id)lightPalette {
|
||||||
|
return %orig; // No changes for Light Mode
|
||||||
|
}
|
||||||
|
|
||||||
- (UIColor *)textPrimary {
|
- (UIColor *)textPrimary {
|
||||||
return self.pageStyle == 1 ? kDefaultTextColor : %orig;
|
return UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? lcmHexColor : %orig;
|
||||||
}
|
}
|
||||||
- (UIColor *)textSecondary {
|
- (UIColor *)textSecondary {
|
||||||
return self.pageStyle == 1 ? kDefaultTextColor : %orig;
|
return UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? lcmHexColor : %orig;
|
||||||
}
|
}
|
||||||
- (UIColor *)overlayTextPrimary {
|
- (UIColor *)overlayTextPrimary {
|
||||||
return self.pageStyle == 1 ? kDefaultTextColor : %orig;
|
return UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? lcmHexColor : %orig;
|
||||||
}
|
}
|
||||||
- (UIColor *)overlayTextSecondary {
|
- (UIColor *)overlayTextSecondary {
|
||||||
return self.pageStyle == 1 ? kDefaultTextColor : %orig;
|
return UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? lcmHexColor : %orig;
|
||||||
}
|
}
|
||||||
- (UIColor *)iconActive {
|
- (UIColor *)iconActive {
|
||||||
return self.pageStyle == 1 ? kDefaultTextColor : %orig;
|
return UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? lcmHexColor : %orig;
|
||||||
}
|
}
|
||||||
- (UIColor *)iconActiveOther {
|
- (UIColor *)iconActiveOther {
|
||||||
return self.pageStyle == 1 ? kDefaultTextColor : %orig;
|
return UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? lcmHexColor : %orig;
|
||||||
}
|
}
|
||||||
- (UIColor *)brandIconActive {
|
- (UIColor *)brandIconActive {
|
||||||
return self.pageStyle == 1 ? kDefaultTextColor : %orig;
|
return UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? lcmHexColor : %orig;
|
||||||
}
|
}
|
||||||
- (UIColor *)staticBrandWhite {
|
- (UIColor *)staticBrandWhite {
|
||||||
return self.pageStyle == 1 ? kDefaultTextColor : %orig;
|
return UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? lcmHexColor : %orig;
|
||||||
}
|
}
|
||||||
- (UIColor *)overlayIconActiveOther {
|
- (UIColor *)overlayIconActiveOther {
|
||||||
return self.pageStyle == 1 ? kDefaultTextColor : %orig;
|
return UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? lcmHexColor : %orig;
|
||||||
}
|
}
|
||||||
- (UIColor *)overlayIconInactive {
|
- (UIColor *)overlayIconInactive {
|
||||||
return self.pageStyle == 1 ? [kDefaultTextColor colorWithAlphaComponent:0.7] : %orig;
|
return UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? [lcmHexColor colorWithAlphaComponent:0.7] : %orig;
|
||||||
}
|
}
|
||||||
- (UIColor *)overlayIconDisabled {
|
- (UIColor *)overlayIconDisabled {
|
||||||
return self.pageStyle == 1 ? [kDefaultTextColor colorWithAlphaComponent:0.3] : %orig;
|
return UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? [lcmHexColor colorWithAlphaComponent:0.3] : %orig;
|
||||||
}
|
}
|
||||||
- (UIColor *)overlayFilledButtonActive {
|
- (UIColor *)overlayFilledButtonActive {
|
||||||
return self.pageStyle == 1 ? [kDefaultTextColor colorWithAlphaComponent:0.2] : %orig;
|
return UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? [lcmHexColor colorWithAlphaComponent:0.2] : %orig;
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
|
|
@ -326,9 +392,9 @@ static inline BOOL customContrastMode() {
|
||||||
%hook _ASDisplayView
|
%hook _ASDisplayView
|
||||||
- (void)layoutSubviews {
|
- (void)layoutSubviews {
|
||||||
%orig;
|
%orig;
|
||||||
NSArray<NSString *> *targetLabels = @[@"connect account", @"Thanks", @"Save to playlist", @"Report"];
|
NSArray<NSString *> *targetLabels = @[@"connect account", @"Thanks", @"Save to playlist", @"Report", @"Share", @"Like", @"Dislike"];
|
||||||
for (UIView *subview in self.subviews) {
|
for (UIView *subview in self.subviews) {
|
||||||
if ([targetLabels containsObject:subview.accessibilityLabel]) {
|
if ([targetLabels containsObject:subview.accessibilityLabel] && UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
|
||||||
subview.backgroundColor = lcmHexColor;
|
subview.backgroundColor = lcmHexColor;
|
||||||
if ([subview isKindOfClass:[UILabel class]]) {
|
if ([subview isKindOfClass:[UILabel class]]) {
|
||||||
((UILabel *)subview).textColor = [UIColor blackColor];
|
((UILabel *)subview).textColor = [UIColor blackColor];
|
||||||
|
|
@ -361,9 +427,13 @@ static inline BOOL customContrastMode() {
|
||||||
|
|
||||||
%hook YTQTMButton
|
%hook YTQTMButton
|
||||||
- (void)setImage:(UIImage *)image {
|
- (void)setImage:(UIImage *)image {
|
||||||
UIImage *tintedImage = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
|
if (UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
|
||||||
[self setTintColor:kDefaultTextColor];
|
UIImage *tintedImage = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
|
||||||
%orig(tintedImage);
|
[self setTintColor:kDefaultTextColor];
|
||||||
|
%orig(tintedImage);
|
||||||
|
} else {
|
||||||
|
%orig;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
|
|
@ -393,97 +463,117 @@ static inline BOOL customContrastMode() {
|
||||||
|
|
||||||
%hook UILabel
|
%hook UILabel
|
||||||
+ (void)load {
|
+ (void)load {
|
||||||
[[UILabel appearance] setTextColor:kDefaultTextColor];
|
if (@available(iOS 16.0, *)) {
|
||||||
|
[[UILabel appearance] setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
|
||||||
|
[[UILabel appearance] setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
|
||||||
|
}
|
||||||
|
if (UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
|
||||||
|
[[UILabel appearance] setTextColor:kDefaultTextColor];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
- (void)setTextColor:(UIColor *)textColor {
|
- (void)setTextColor:(UIColor *)textColor {
|
||||||
%orig(kDefaultTextColor);
|
%orig(UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? kDefaultTextColor : textColor);
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
%hook UITextField
|
%hook UITextField
|
||||||
- (void)setTextColor:(UIColor *)textColor {
|
- (void)setTextColor:(UIColor *)textColor {
|
||||||
%orig(kDefaultTextColor);
|
%orig(UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? kDefaultTextColor : textColor);
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
%hook UITextView
|
%hook UITextView
|
||||||
- (void)setTextColor:(UIColor *)textColor {
|
- (void)setTextColor:(UIColor *)textColor {
|
||||||
%orig(kDefaultTextColor);
|
%orig(UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? kDefaultTextColor : textColor);
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
%hook UISearchBar
|
%hook UISearchBar
|
||||||
- (void)setTextColor:(UIColor *)textColor {
|
- (void)setTextColor:(UIColor *)textColor {
|
||||||
%orig(kDefaultTextColor);
|
%orig(UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? kDefaultTextColor : textColor);
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
%hook UISegmentedControl
|
%hook UISegmentedControl
|
||||||
- (void)setTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state {
|
- (void)setTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state {
|
||||||
NSMutableDictionary *modifiedAttributes = [NSMutableDictionary dictionaryWithDictionary:attributes];
|
if (UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
|
||||||
modifiedAttributes[NSForegroundColorAttributeName] = kDefaultTextColor;
|
NSMutableDictionary *modifiedAttributes = [NSMutableDictionary dictionaryWithDictionary:attributes];
|
||||||
%orig(modifiedAttributes, state);
|
modifiedAttributes[NSForegroundColorAttributeName] = kDefaultTextColor;
|
||||||
|
%orig(modifiedAttributes, state);
|
||||||
|
} else {
|
||||||
|
%orig;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
%hook UIButton
|
%hook UIButton
|
||||||
- (void)setTitleColor:(UIColor *)color forState:(UIControlState)state {
|
- (void)setTitleColor:(UIColor *)color forState:(UIControlState)state {
|
||||||
%orig(kDefaultTextColor, state);
|
%orig(UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? kDefaultTextColor : color, state);
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
%hook UIBarButtonItem
|
%hook UIBarButtonItem
|
||||||
- (void)setTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state {
|
- (void)setTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state {
|
||||||
NSMutableDictionary *modifiedAttributes = [NSMutableDictionary dictionaryWithDictionary:attributes];
|
if (UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
|
||||||
modifiedAttributes[NSForegroundColorAttributeName] = kDefaultTextColor;
|
NSMutableDictionary *modifiedAttributes = [NSMutableDictionary dictionaryWithDictionary:attributes];
|
||||||
%orig(modifiedAttributes, state);
|
modifiedAttributes[NSForegroundColorAttributeName] = kDefaultTextColor;
|
||||||
|
%orig(modifiedAttributes, state);
|
||||||
|
} else {
|
||||||
|
%orig;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
%hook NSAttributedString
|
%hook NSAttributedString
|
||||||
- (instancetype)initWithString:(NSString *)str attributes:(NSDictionary<NSAttributedStringKey, id> *)attrs {
|
- (instancetype)initWithString:(NSString *)str attributes:(NSDictionary<NSAttributedStringKey, id> *)attrs {
|
||||||
NSMutableDictionary *modifiedAttributes = [NSMutableDictionary dictionaryWithDictionary:attrs];
|
if (UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
|
||||||
modifiedAttributes[NSForegroundColorAttributeName] = kDefaultTextColor;
|
MutableDictionary *modifiedAttributes = [NSMutableDictionary dictionaryWithDictionary:attrs];
|
||||||
return %orig(str, modifiedAttributes);
|
modifiedAttributes[NSForegroundColorAttributeName] = kDefaultTextColor;
|
||||||
|
return %orig(str, modifiedAttributes);
|
||||||
|
}
|
||||||
|
return %orig;
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
%hook CATextLayer
|
%hook CATextLayer
|
||||||
- (void)setTextColor:(CGColorRef)color {
|
- (void)setTextColor:(CGColorRef)textColor {
|
||||||
%orig(kDefaultTextColor.CGColor);
|
%orig(UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? kDefaultTextColor.CGColor : textColor);
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
%hook ASTextNode
|
%hook ASTextNode
|
||||||
- (NSAttributedString *)attributedString {
|
- (NSAttributedString *)attributedString {
|
||||||
NSAttributedString *original = %orig;
|
NSAttributedString *original = %orig;
|
||||||
NSMutableAttributedString *modified = [original mutableCopy];
|
if (UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
|
||||||
[modified addAttribute:NSForegroundColorAttributeName value:kDefaultTextColor range:NSMakeRange(0, modified.length)];
|
NSMutableAttributedString *modified = [original mutableCopy];
|
||||||
return modified;
|
[modified addAttribute:NSForegroundColorAttributeName value:kDefaultTextColor range:NSMakeRange(0, modified.length)];
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
return original;
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
%hook ASTextFieldNode
|
%hook ASTextFieldNode
|
||||||
- (void)setTextColor:(UIColor *)textColor {
|
- (void)setTextColor:(UIColor *)textColor {
|
||||||
%orig(kDefaultTextColor);
|
%orig(UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? kDefaultTextColor : textColor);
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
%hook ASTextView
|
%hook ASTextView
|
||||||
- (void)setTextColor:(UIColor *)textColor {
|
- (void)setTextColor:(UIColor *)textColor {
|
||||||
%orig(kDefaultTextColor);
|
%orig(UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? kDefaultTextColor : textColor);
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
%hook ASButtonNode
|
%hook ASButtonNode
|
||||||
- (void)setTextColor:(UIColor *)textColor {
|
- (void)setTextColor:(UIColor *)textColor {
|
||||||
%orig(kDefaultTextColor);
|
%orig(UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? kDefaultTextColor : textColor);
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
%hook UIControl
|
%hook UIControl
|
||||||
- (UIColor *)backgroundColor {
|
- (UIColor *)backgroundColor {
|
||||||
return [UIColor blackColor];
|
return UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? [UIColor blackColor] : %orig;
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
%end
|
%end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue