mirror of
https://github.com/arichornlover/uYouEnhanced.git
synced 2026-04-21 07:41:59 +00:00
fix YTCastconfirm, code clean up
This commit is contained in:
parent
2e6c19c060
commit
ec7eec660b
1 changed files with 31 additions and 37 deletions
68
uYouPlus.xm
68
uYouPlus.xm
|
|
@ -112,40 +112,41 @@ BOOL ytMiniPlayer() {
|
||||||
%end
|
%end
|
||||||
|
|
||||||
//YTCastConfirm: https://github.com/JamieBerghmans/YTCastConfirm
|
//YTCastConfirm: https://github.com/JamieBerghmans/YTCastConfirm
|
||||||
%group gYTCastconfirm
|
|
||||||
%hook MDXPlaybackRouteButtonController
|
%hook MDXPlaybackRouteButtonController
|
||||||
- (void)didPressButton:(id)arg1 {
|
- (void)didPressButton:(id)arg1 {
|
||||||
UIAlertController* alertController = [%c(UIAlertController) alertControllerWithTitle:@"Casting"
|
if (castConfirm()) {
|
||||||
message:@"Are you sure you want to start casting?"
|
UIAlertController* alertController = [%c(UIAlertController) alertControllerWithTitle:@"Casting"
|
||||||
preferredStyle:UIAlertControllerStyleAlert];
|
message:@"Are you sure you want to start casting?"
|
||||||
UIAlertAction* defaultAction = [%c(UIAlertAction) actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
|
preferredStyle:UIAlertControllerStyleAlert];
|
||||||
%orig;
|
UIAlertAction* defaultAction = [%c(UIAlertAction) actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
|
||||||
}];
|
%orig;
|
||||||
|
}];
|
||||||
|
|
||||||
UIAlertAction* noButton = [%c(UIAlertAction)
|
UIAlertAction* noButton = [%c(UIAlertAction)
|
||||||
actionWithTitle:@"Cancel"
|
actionWithTitle:@"Cancel"
|
||||||
style:UIAlertActionStyleDefault
|
style:UIAlertActionStyleDefault
|
||||||
handler: ^(UIAlertAction * action) { return; }
|
handler: ^(UIAlertAction * action) {
|
||||||
];
|
return;
|
||||||
|
}];
|
||||||
|
|
||||||
[alertController addAction:defaultAction];
|
[alertController addAction:defaultAction];
|
||||||
[alertController addAction:noButton];
|
[alertController addAction:noButton];
|
||||||
|
|
||||||
|
id rootViewController = [%c(UIApplication) sharedApplication].delegate.window.rootViewController;
|
||||||
|
if ([rootViewController isKindOfClass:[%c(UINavigationController) class]]) {
|
||||||
|
rootViewController = ((UINavigationController *)rootViewController).viewControllers.firstObject;
|
||||||
|
}
|
||||||
|
if ([rootViewController isKindOfClass:[%c(UITabBarController) class]]) {
|
||||||
|
rootViewController = ((UITabBarController *)rootViewController).selectedViewController;
|
||||||
|
}
|
||||||
|
if ([rootViewController presentedViewController] != nil) {
|
||||||
|
rootViewController = [rootViewController presentedViewController];
|
||||||
|
}
|
||||||
|
[rootViewController presentViewController:alertController animated:YES completion:nil];
|
||||||
|
} else { return %orig; }
|
||||||
|
|
||||||
id rootViewController = [%c(UIApplication) sharedApplication].delegate.window.rootViewController;
|
|
||||||
if ([rootViewController isKindOfClass:[%c(UINavigationController) class]]) {
|
|
||||||
rootViewController = ((UINavigationController *)rootViewController).viewControllers.firstObject;
|
|
||||||
}
|
|
||||||
if ([rootViewController isKindOfClass:[%c(UITabBarController) class]]) {
|
|
||||||
rootViewController = ((UITabBarController *)rootViewController).selectedViewController;
|
|
||||||
}
|
|
||||||
if ([rootViewController presentedViewController] != nil) {
|
|
||||||
rootViewController = [rootViewController presentedViewController];
|
|
||||||
}
|
|
||||||
[rootViewController presentViewController:alertController animated:YES completion:nil];
|
|
||||||
return %orig;
|
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
%end
|
|
||||||
|
|
||||||
// Workaround for https://github.com/MiRO92/uYou-for-YouTube/issues/12
|
// Workaround for https://github.com/MiRO92/uYou-for-YouTube/issues/12
|
||||||
%hook YTAdsInnerTubeContextDecorator
|
%hook YTAdsInnerTubeContextDecorator
|
||||||
|
|
@ -317,9 +318,7 @@ UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
|
||||||
if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
|
if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
|
||||||
%orig;
|
%orig;
|
||||||
self.tableView.backgroundColor = oledColor;
|
self.tableView.backgroundColor = oledColor;
|
||||||
} else {
|
} else { return %orig; }
|
||||||
return %orig();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
|
|
@ -417,9 +416,7 @@ UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
|
||||||
%hook YTCollectionSeparatorView
|
%hook YTCollectionSeparatorView
|
||||||
- (void)didMoveToWindow {
|
- (void)didMoveToWindow {
|
||||||
if (isDarkMode()) {}
|
if (isDarkMode()) {}
|
||||||
else {
|
else { return %orig; }
|
||||||
return %orig();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
|
|
@ -443,8 +440,8 @@ UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
|
||||||
%hook ASWAppSwitcherCollectionViewCell
|
%hook ASWAppSwitcherCollectionViewCell
|
||||||
- (void)didMoveToWindow {
|
- (void)didMoveToWindow {
|
||||||
if (isDarkMode()) {
|
if (isDarkMode()) {
|
||||||
%orig;
|
|
||||||
self.subviews[1].backgroundColor = oledColor;
|
self.subviews[1].backgroundColor = oledColor;
|
||||||
|
%orig;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
@ -568,7 +565,4 @@ static void replaceTab(YTIGuideResponse *response) {
|
||||||
if (bigYTMiniPlayer() && (UIDevice.currentDevice.userInterfaceIdiom != UIUserInterfaceIdiomPad)) {
|
if (bigYTMiniPlayer() && (UIDevice.currentDevice.userInterfaceIdiom != UIUserInterfaceIdiomPad)) {
|
||||||
%init(Main);
|
%init(Main);
|
||||||
}
|
}
|
||||||
if (castConfirm()) {
|
|
||||||
%init(gYTCastconfirm);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue