From ba125c3c33033b2f63badf59dba8ffa82108c1ef Mon Sep 17 00:00:00 2001 From: arichornlover <78001398+arichornlover@users.noreply.github.com> Date: Thu, 12 Sep 2024 17:56:26 -0500 Subject: [PATCH] Update uYouPlusPatches.xm --- Sources/uYouPlusPatches.xm | 58 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/Sources/uYouPlusPatches.xm b/Sources/uYouPlusPatches.xm index 95e9acc..df8935a 100644 --- a/Sources/uYouPlusPatches.xm +++ b/Sources/uYouPlusPatches.xm @@ -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]; @@ -197,6 +198,7 @@ static BOOL showNativeShareSheet(NSString *serializedShareEntity, UIView *source return %orig; } %end +%end // @@ -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); // }