Merge pull request #45693 from naithar/feature/ios-loading_screen-3.2
[3.2] [iOS] Native loading screen implementation
This commit is contained in:
commit
92859d7b2b
|
@ -37,12 +37,20 @@
|
||||||
|
|
||||||
class String;
|
class String;
|
||||||
|
|
||||||
|
@class GodotView;
|
||||||
@protocol DisplayLayer;
|
@protocol DisplayLayer;
|
||||||
@protocol GodotViewRendererProtocol;
|
@protocol GodotViewRendererProtocol;
|
||||||
|
|
||||||
|
@protocol GodotViewDelegate
|
||||||
|
|
||||||
|
- (BOOL)godotViewFinishedSetup:(GodotView *)view;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
@interface GodotView : UIView
|
@interface GodotView : UIView
|
||||||
|
|
||||||
@property(assign, nonatomic) id<GodotViewRendererProtocol> renderer;
|
@property(assign, nonatomic) id<GodotViewRendererProtocol> renderer;
|
||||||
|
@property(assign, nonatomic) id<GodotViewDelegate> delegate;
|
||||||
|
|
||||||
@property(assign, readonly, nonatomic) BOOL isActive;
|
@property(assign, readonly, nonatomic) BOOL isActive;
|
||||||
|
|
||||||
|
|
|
@ -113,6 +113,7 @@ static const int max_touches = 8;
|
||||||
[self stopRendering];
|
[self stopRendering];
|
||||||
|
|
||||||
self.renderer = nil;
|
self.renderer = nil;
|
||||||
|
self.delegate = nil;
|
||||||
|
|
||||||
if (self.renderingLayer) {
|
if (self.renderingLayer) {
|
||||||
[self.renderingLayer removeFromSuperlayer];
|
[self.renderingLayer removeFromSuperlayer];
|
||||||
|
@ -235,6 +236,14 @@ static const int max_touches = 8;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (self.delegate) {
|
||||||
|
BOOL delegateFinishedSetup = [self.delegate godotViewFinishedSetup:self];
|
||||||
|
|
||||||
|
if (!delegateFinishedSetup) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[self handleMotion];
|
[self handleMotion];
|
||||||
[self.renderer renderOnView:self];
|
[self.renderer renderOnView:self];
|
||||||
|
|
||||||
|
|
|
@ -37,12 +37,14 @@
|
||||||
#import "native_video_view.h"
|
#import "native_video_view.h"
|
||||||
#include "os_iphone.h"
|
#include "os_iphone.h"
|
||||||
|
|
||||||
@interface ViewController ()
|
@interface ViewController () <GodotViewDelegate>
|
||||||
|
|
||||||
@property(strong, nonatomic) GodotViewRenderer *renderer;
|
@property(strong, nonatomic) GodotViewRenderer *renderer;
|
||||||
@property(strong, nonatomic) GodotNativeVideoView *videoView;
|
@property(strong, nonatomic) GodotNativeVideoView *videoView;
|
||||||
@property(strong, nonatomic) GodotKeyboardInputView *keyboardView;
|
@property(strong, nonatomic) GodotKeyboardInputView *keyboardView;
|
||||||
|
|
||||||
|
@property(strong, nonatomic) UIView *godotLoadingOverlay;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation ViewController
|
@implementation ViewController
|
||||||
|
@ -61,6 +63,7 @@
|
||||||
self.view = view;
|
self.view = view;
|
||||||
|
|
||||||
view.renderer = self.renderer;
|
view.renderer = self.renderer;
|
||||||
|
view.delegate = self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
|
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
|
||||||
|
@ -96,6 +99,7 @@
|
||||||
[super viewDidLoad];
|
[super viewDidLoad];
|
||||||
|
|
||||||
[self observeKeyboard];
|
[self observeKeyboard];
|
||||||
|
[self displayLoadingOverlay];
|
||||||
|
|
||||||
if (@available(iOS 11.0, *)) {
|
if (@available(iOS 11.0, *)) {
|
||||||
[self setNeedsUpdateOfScreenEdgesDeferringSystemGestures];
|
[self setNeedsUpdateOfScreenEdgesDeferringSystemGestures];
|
||||||
|
@ -120,6 +124,31 @@
|
||||||
object:nil];
|
object:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)displayLoadingOverlay {
|
||||||
|
NSBundle *bundle = [NSBundle mainBundle];
|
||||||
|
NSString *storyboardName = @"Launch Screen";
|
||||||
|
|
||||||
|
if ([bundle pathForResource:storyboardName ofType:@"storyboardc"] == nil) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UIStoryboard *launchStoryboard = [UIStoryboard storyboardWithName:storyboardName bundle:bundle];
|
||||||
|
|
||||||
|
UIViewController *controller = [launchStoryboard instantiateInitialViewController];
|
||||||
|
self.godotLoadingOverlay = controller.view;
|
||||||
|
self.godotLoadingOverlay.frame = self.view.bounds;
|
||||||
|
self.godotLoadingOverlay.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
|
||||||
|
|
||||||
|
[self.view addSubview:self.godotLoadingOverlay];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)godotViewFinishedSetup:(GodotView *)view {
|
||||||
|
[self.godotLoadingOverlay removeFromSuperview];
|
||||||
|
self.godotLoadingOverlay = nil;
|
||||||
|
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)dealloc {
|
- (void)dealloc {
|
||||||
[self.videoView stopVideo];
|
[self.videoView stopVideo];
|
||||||
self.videoView = nil;
|
self.videoView = nil;
|
||||||
|
@ -128,6 +157,11 @@
|
||||||
|
|
||||||
self.renderer = nil;
|
self.renderer = nil;
|
||||||
|
|
||||||
|
if (self.godotLoadingOverlay) {
|
||||||
|
[self.godotLoadingOverlay removeFromSuperview];
|
||||||
|
self.godotLoadingOverlay = nil;
|
||||||
|
}
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue