From 6005ae72063ee3f05c6f4599f14dced9ccebdad8 Mon Sep 17 00:00:00 2001 From: Duy Tran Khanh Date: Sat, 20 Mar 2021 19:39:13 +0700 Subject: [PATCH] Stills attempting to hide home indicator Also, fixed custom controls --- Natives/LoginViewController.m | 12 ++---------- Natives/SurfaceViewController.m | 13 +++++++++++-- Natives/customcontrols/ControlButton.m | 7 +++++++ Natives/ios_uikit_bridge.m | 5 +++-- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/Natives/LoginViewController.m b/Natives/LoginViewController.m index 62c214f1..10156605 100644 --- a/Natives/LoginViewController.m +++ b/Natives/LoginViewController.m @@ -111,15 +111,7 @@ void loginAccountInput(UINavigationController *controller, int type, const char* [scrollView addSubview:button_login_account]; } --(BOOL)prefersHomeIndicatorAutoHidden { - return YES; -} - -- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures { - return UIRectEdgeBottom; -} - --(void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection API_AVAILABLE(ios(13.0)) { +- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection API_AVAILABLE(ios(13.0)) { if(@available(iOS 13.0, *)) { if (UITraitCollection.currentTraitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) { self.view.backgroundColor = [UIColor blackColor]; @@ -228,7 +220,7 @@ void loginAccountInput(UINavigationController *controller, int type, const char* [self.navigationController pushViewController:vc animated:YES]; } --(void)loginMojangWithUsername:(NSString*)input_username password:(NSString*)input_password { +- (void)loginMojangWithUsername:(NSString*)input_username password:(NSString*)input_password { NSString *input_uuid = [[NSUUID UUID] UUIDString]; NSURLSession *session = [NSURLSession sharedSession]; diff --git a/Natives/SurfaceViewController.m b/Natives/SurfaceViewController.m index 399a9513..f7fc0cff 100644 --- a/Natives/SurfaceViewController.m +++ b/Natives/SurfaceViewController.m @@ -147,13 +147,14 @@ int notchOffset; } NSError *cc_error; - if (YES /* FIXME, temp skip */ || !cc_file || !fread(cc_data, cc_size, 1, cc_file)) { + if (!cc_file || !fread(cc_data, cc_size, 1, cc_file)) { NSLog(@"Error: could not read \"default.json\", fallbacking to default control.\n%s", strerror(errno)); fclose(cc_file); } else { fclose(cc_file); NSLog(@"%s", cc_data); - NSDictionary *cc_dictionary = [NSJSONSerialization JSONObjectWithData:@(cc_data) options:kNilOptions error:&cc_error]; + NSData* cc_objc_data = [@(cc_data) dataUsingEncoding:NSUTF8StringEncoding]; + NSDictionary *cc_dictionary = [NSJSONSerialization JSONObjectWithData:cc_objc_data options:kNilOptions error:&cc_error]; if (cc_error != nil) { showDialog(self, @"Error parsing JSON", cc_error.localizedDescription); } else { @@ -232,6 +233,14 @@ int notchOffset; [self setupGL]; } +- (BOOL)prefersHomeIndicatorAutoHidden { + return YES; +} + +- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures { + return UIRectEdgeAll; +} + #pragma mark - MetalANGLE stuff - (void)dealloc diff --git a/Natives/customcontrols/ControlButton.m b/Natives/customcontrols/ControlButton.m index c20405b9..17e4bb5d 100644 --- a/Natives/customcontrols/ControlButton.m +++ b/Natives/customcontrols/ControlButton.m @@ -8,6 +8,13 @@ /** * To compatible with Android, NSArray (ControlData) * will store the scaled values. + * + * TODO implement: + * - dynamicX + * - dynamicY + * - isDynamicBtn + * - scaledAt + * - (maybe more) */ + (id)initWithProperties:(NSMutableDictionary *)propArray { diff --git a/Natives/ios_uikit_bridge.m b/Natives/ios_uikit_bridge.m index 678f2bf5..d47bb1be 100644 --- a/Natives/ios_uikit_bridge.m +++ b/Natives/ios_uikit_bridge.m @@ -106,16 +106,17 @@ void UIKit_setButtonSkippable() { void UIKit_launchMinecraftSurfaceVC() { dispatch_async(dispatch_get_main_queue(), ^{ - LauncherViewController *rootController = nil; + UIViewController *rootController = nil; if (@available(iOS 13.0, *)) { rootController = UIApplication.sharedApplication.windows.lastObject.rootViewController; } else { - rootController =(LauncherViewController*) [[(AppDelegate*) [[UIApplication sharedApplication]delegate] window] rootViewController]; + rootController =(UIViewController*) [[(AppDelegate*) [[UIApplication sharedApplication]delegate] window] rootViewController]; } UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MinecraftSurface" bundle:nil]; SurfaceViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"MinecraftSurfaceVC"]; vc.modalPresentationStyle = UIModalPresentationFullScreen; [rootController presentViewController:vc animated:YES completion:nil]; + // rootController.childForScreenEdgesDeferringSystemGestures = vc; }); }