From dd5ce625b59a2d8914c7b33a9e6435cdfa2dd39d Mon Sep 17 00:00:00 2001 From: arichornlover <78001398+arichornlover@users.noreply.github.com> Date: Sat, 17 Feb 2024 02:10:08 -0600 Subject: [PATCH] Create new button in the Navigation Bar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introducing the uYouPlus button in the navigation bar, it’s taken straight from YouTube Reborn but except it’s built for uYouPlus/uYouEnhanced exclusively. --- Sources/uYouPlus.xm | 65 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 3 deletions(-) diff --git a/Sources/uYouPlus.xm b/Sources/uYouPlus.xm index aba50fb..21bbba4 100644 --- a/Sources/uYouPlus.xm +++ b/Sources/uYouPlus.xm @@ -868,6 +868,65 @@ static NSString *accessGroupID() { } %end +// uYouPlus Button in Navigation Bar (for Clear Cache and Color Options) - @arichornlover +%hook YTRightNavigationButtons +%property (retain, nonatomic) YTQTMButton *uYouPlusButton; +- (NSMutableArray *)buttons { + NSString *tweakBundlePath = [[NSBundle mainBundle] pathForResource:@"uYouPlus" ofType:@"bundle"]; + NSString *uYouPlusLightSettingsPath; + NSString *uYouPlusDarkSettingsPath; + if (tweakBundlePath) { + NSBundle *tweakBundle = [NSBundle bundleWithPath:tweakBundlePath]; + uYouPlusLightSettingsPath = [tweakBundle pathForResource:@"uYouPlus_logo" ofType:@"png"]; + uYouPlusDarkSettingsPath = [tweakBundle pathForResource:@"uYouPlus_logo_dark" ofType:@"png"]; + } else { + uYouPlusLightSettingsPath = ROOT_PATH_NS(@"/Localizations/uYouPlus.bundle/uYouPlus_logo.png"); + uYouPlusDarkSettingsPath = ROOT_PATH_NS(@"/Localizations/uYouPlus.bundle/uYouPlus_logo_dark.png"); + } + NSMutableArray *retVal = %orig.mutableCopy; + [self.uYouPlusButton removeFromSuperview]; + [self addSubview:self.uYouPlusButton]; + if (!self.uYouPlusButton) { + self.uYouPlusButton = [%c(YTQTMButton) iconButton]; + [self.uYouPlusButton enableNewTouchFeedback]; + self.uYouPlusButton.frame = CGRectMake(0, 0, 40, 40); + + if ([%c(YTPageStyleController) pageStyle] == 0) { + UIImage *setButtonMode = [UIImage imageWithContentsOfFile:uYouPlusDarkSettingsPath]; + setButtonMode = [setButtonMode imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; + [self.uYouPlusButton setImage:setButtonMode forState:UIControlStateNormal]; + } + else if ([%c(YTPageStyleController) pageStyle] == 1) { + UIImage *setButtonMode = [UIImage imageWithContentsOfFile:uYouPlusLightSettingsPath]; + setButtonMode = [setButtonMode imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; + [self.uYouPlusButton setImage:setButtonMode forState:UIControlStateNormal]; + } + + [self.uYouPlusButton addTarget:self action:@selector(uYouPlusRootOptionsAction) forControlEvents:UIControlEventTouchUpInside]; + [retVal insertObject:self.uYouPlusButton atIndex:0]; + } + return retVal; +} +- (NSMutableArray *)visibleButtons { + NSMutableArray *retVal = %orig.mutableCopy; + [self setLeadingPadding:+10]; + if (self.uYouPlusButton) { + [self.uYouPlusButton removeFromSuperview]; + [self addSubview:self.uYouPlusButton]; + [retVal insertObject:self.uYouPlusButton atIndex:0]; + } + return retVal; +} +%new; +- (void)uYouPlusRootOptionsAction { + UINavigationController *uYouPlusRootOptionsControllerView = [[UINavigationController alloc] initWithRootViewController:[[RootOptionsController alloc] init]]; + [uYouPlusRootOptionsControllerView setModalPresentationStyle:UIModalPresentationFullScreen]; + + [self._viewControllerForAncestor presentViewController:uYouPlusRootOptionsControllerView animated:YES completion:nil]; +} +%end +// + // Hide the (Connect / Share / Remix / Thanks / Download / Clip / Save) Buttons under the Video Player - 17.x.x and up - @arichornlover %hook _ASDisplayView - (void)layoutSubviews { @@ -1132,9 +1191,9 @@ static NSString *accessGroupID() { if (IS_ENABLED(@"hidePreviousAndNextButton_enabled")) { %init(gHidePreviousAndNextButton); } - if (IS_ENABLED(@"replacePreviousAndNextButton_enabled")) { - %init(gReplacePreviousAndNextButton); - } +// if (IS_ENABLED(@"replacePreviousAndNextButton_enabled")) { +// %init(gReplacePreviousAndNextButton); +// } if (IS_ENABLED(@"hideOverlayDarkBackground_enabled")) { %init(gHideOverlayDarkBackground); }