Skip to content

Commit

Permalink
uYou download dialog UI tweaks
Browse files Browse the repository at this point in the history
Use colored uYou logo for better contrast in dark mode
Add space between uYou label and video title
  • Loading branch information
therealFoxster committed Sep 7, 2024
1 parent e92fe42 commit 256abd6
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Sources/uYouPlus.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
#import <YouTubeHeader/ELMPBElement.h>
#import <YouTubeHeader/ELMPBProperties.h>
#import <YouTubeHeader/ELMPBIdentifierProperties.h>
#import <YouTubeHeader/YTMainAppControlsOverlayView.h>
@interface YTMainAppControlsOverlayView(uYou)
// #import <YouTubeHeader/YTMainAppControlsOverlayView.h>
@interface YTMainAppControlsOverlayView: UIView
- (void)uYou;
@end

Expand Down Expand Up @@ -77,8 +77,8 @@ static NSString *const kFlex = @"flex_enabled";
@end

// Hide autoplay switch / CC button
@interface YTMainAppControlsOverlayView : UIView
@end
// @interface YTMainAppControlsOverlayView : UIView
// @end

// Skips content warning before playing *some videos - @PoomSmart
@interface YTPlayabilityResolutionUserActionUIController : NSObject
Expand Down
1 change: 1 addition & 0 deletions Sources/uYouPlusPatches.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#import <YouTubeHeader/YTCommonColorPalette.h>
#import <YouTubeHeader/GOODialogView.h>
#import "uYouPlus.h"

@interface YTSingleVideoController : NSObject
Expand Down
53 changes: 53 additions & 0 deletions Sources/uYouPlusPatches.xm
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,59 @@ static void refreshUYouAppearance() {
- (void)beginEnlargeAnimation {}
%end

%hook GOODialogView
- (id)imageView {
UIImageView *imageView = %orig;

if ([[self titleLabel].text containsString:@"uYou\n"]) {
// // Invert uYou logo in download dialog if dark mode is enabled
// if ([[NSUserDefaults standardUserDefaults] integerForKey:@"page_style"] == 0)
// return imageView;
// // https://gist.github.com/coryalder/3113a43734f5e0e4b497
// UIImage *image = [imageView image];
// CIImage *ciImage = [[CIImage alloc] initWithImage:image];
// CIFilter *filter = [CIFilter filterWithName:@"CIColorInvert"];
// [filter setDefaults];
// [filter setValue:ciImage forKey:kCIInputImageKey];
// CIContext *context = [CIContext contextWithOptions:nil];
// CIImage *output = [filter outputImage];
// CGImageRef cgImage = [context createCGImage:output fromRect:[output extent]];
// UIImage *icon = [UIImage imageWithCGImage:cgImage];
// CGImageRelease(cgImage);

// Load icon_clipped.png from uYouBundle.bundle
NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"uYouBundle" ofType:@"bundle"];
NSBundle *bundle = [NSBundle bundleWithPath:bundlePath];
NSString *iconPath = [bundle pathForResource:@"icon_clipped" ofType:@"png"];
UIImage *icon = [UIImage imageWithContentsOfFile:iconPath];
[imageView setImage:icon];

// Resize image to 30x30
// https://stackoverflow.com/a/2658801/19227228
CGSize size = CGSizeMake(30, 30);
UIGraphicsBeginImageContextWithOptions(size, NO, 0.0);
[icon drawInRect:CGRectMake(0, 0, size.width, size.height)];
UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

[imageView setImage:resizedImage];
}

return imageView;
}
// Increase space between uYou label and video title
- (id)titleLabel {
UILabel *titleLabel = %orig;
if ([titleLabel.text containsString:@"uYou\n"] &&
![titleLabel.text containsString:@"uYou\n\n"]
) {
NSString *text = [titleLabel.text stringByReplacingOccurrencesOfString:@"uYou\n" withString:@"uYou\n\n"];
[titleLabel setText:text];
}
return titleLabel;
}
%end

%ctor {
%init;
// if (@available(iOS 16, *)) {
Expand Down

0 comments on commit 256abd6

Please sign in to comment.