Skip to content

Commit

Permalink
Update uYouPlusPatches.xm
Browse files Browse the repository at this point in the history
  • Loading branch information
arichornlover authored Sep 12, 2024
1 parent 88f821d commit ba125c3
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions Sources/uYouPlusPatches.xm
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ static BOOL showNativeShareSheet(NSString *serializedShareEntity, UIView *source

/* -------------------- iPad Layout -------------------- */

%group gYouTubeNativeShare // YouTube Native Share Option - 0.2.3 - Supports YouTube v17.33.2-v19.34.2
%hook YTAccountScopedCommandResponderEvent
- (void)send {
GPBExtensionDescriptor *shareEntityEndpointDescriptor = [%c(YTIShareEntityEndpoint) shareEntityEndpoint];
Expand Down Expand Up @@ -197,6 +198,7 @@ static BOOL showNativeShareSheet(NSString *serializedShareEntity, UIView *source
return %orig;
}
%end
%end

//

Expand Down Expand Up @@ -335,11 +337,67 @@ 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 (IS_ENABLED(@"googleSignInPatch_enabled")) {
%init(gGoogleSignInPatch);
}
if (IS_ENABLED(@"youtubeNativeShare_enabled")) {
%init(gYouTubeNativeShare);
}
// if (@available(iOS 16, *)) {
// %init(iOS16);
// }
Expand Down

0 comments on commit ba125c3

Please sign in to comment.