Merge pull request #655 from dayanch96/patch-3

Change CastConfirm's alert to YTAlertView
This commit is contained in:
Nguyễn Đạt
2022-11-12 08:44:40 +07:00
committed by GitHub
+10 -28
View File
@@ -20,6 +20,7 @@
#import "Tweaks/YouTubeHeader/YTReelWatchPlaybackOverlayView.h" #import "Tweaks/YouTubeHeader/YTReelWatchPlaybackOverlayView.h"
#import "Tweaks/YouTubeHeader/YTReelPlayerBottomButton.h" #import "Tweaks/YouTubeHeader/YTReelPlayerBottomButton.h"
#import "Tweaks/YouTubeHeader/YTReelPlayerViewController.h" #import "Tweaks/YouTubeHeader/YTReelPlayerViewController.h"
#import "Tweaks/YouTubeHeader/YTAlertView.h"
// Tweak's bundle for Localizations support - @PoomSmart - https://github.com/PoomSmart/YouPiP/commit/aea2473f64c75d73cab713e1e2d5d0a77675024f // Tweak's bundle for Localizations support - @PoomSmart - https://github.com/PoomSmart/YouPiP/commit/aea2473f64c75d73cab713e1e2d5d0a77675024f
NSBundle *uYouPlusBundle() { NSBundle *uYouPlusBundle() {
@@ -187,35 +188,16 @@ BOOL dontEatMyContent() {
%hook MDXPlaybackRouteButtonController %hook MDXPlaybackRouteButtonController
- (void)didPressButton:(id)arg1 { - (void)didPressButton:(id)arg1 {
if (castConfirm()) { if (castConfirm()) {
UIAlertController* alertController = [%c(UIAlertController) alertControllerWithTitle:LOC(@"CASTING") NSBundle *tweakBundle = uYouPlusBundle();
message:LOC(@"MSG_ARE_YOU_SURE") YTAlertView *alertView = [%c(YTAlertView) confirmationDialogWithAction:^{
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* defaultAction = [%c(UIAlertAction) actionWithTitle:LOC(@"MSG_YES") style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
%orig; %orig;
}]; } actionTitle:LOC(@"MSG_YES")];
alertView.title = LOC(@"CASTING");
UIAlertAction* noButton = [%c(UIAlertAction) alertView.subtitle = LOC(@"MSG_ARE_YOU_SURE");
actionWithTitle:LOC(@"MSG_CANCEL") [alertView show];
style:UIAlertActionStyleDefault } else {
handler: ^(UIAlertAction * action) { return %orig;
return; }
}];
[alertController addAction:defaultAction];
[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; }
} }
%end %end