72 lines
2.0 KiB
Objective-C
72 lines
2.0 KiB
Objective-C
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*/
|
|
|
|
#import "RCTModalHostViewController.h"
|
|
|
|
#import "RCTLog.h"
|
|
#import "RCTModalHostView.h"
|
|
|
|
@implementation RCTModalHostViewController
|
|
{
|
|
CGRect _lastViewFrame;
|
|
UIStatusBarStyle _preferredStatusBarStyle;
|
|
BOOL _preferredStatusBarHidden;
|
|
}
|
|
|
|
- (instancetype)init
|
|
{
|
|
if (!(self = [super init])) {
|
|
return nil;
|
|
}
|
|
|
|
_preferredStatusBarStyle = [[UIApplication sharedApplication] statusBarStyle];
|
|
_preferredStatusBarHidden = [[UIApplication sharedApplication] isStatusBarHidden];
|
|
|
|
return self;
|
|
}
|
|
|
|
- (void)viewDidLayoutSubviews
|
|
{
|
|
[super viewDidLayoutSubviews];
|
|
|
|
if (self.boundsDidChangeBlock && !CGRectEqualToRect(_lastViewFrame, self.view.frame)) {
|
|
self.boundsDidChangeBlock(self.view.bounds);
|
|
_lastViewFrame = self.view.frame;
|
|
}
|
|
}
|
|
|
|
- (UIStatusBarStyle)preferredStatusBarStyle
|
|
{
|
|
return _preferredStatusBarStyle;
|
|
}
|
|
|
|
- (BOOL)prefersStatusBarHidden
|
|
{
|
|
return _preferredStatusBarHidden;
|
|
}
|
|
|
|
#if RCT_DEV
|
|
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
|
|
{
|
|
UIInterfaceOrientationMask appSupportedOrientationsMask = [[UIApplication sharedApplication] supportedInterfaceOrientationsForWindow:[[UIApplication sharedApplication] keyWindow]];
|
|
if (!(_supportedInterfaceOrientations & appSupportedOrientationsMask)) {
|
|
RCTLogError(@"Modal was presented with 0x%x orientations mask but the application only supports 0x%x."
|
|
@"Add more interface orientations to your app's Info.plist to fix this."
|
|
@"NOTE: This will crash in non-dev mode.",
|
|
(unsigned)_supportedInterfaceOrientations,
|
|
(unsigned)appSupportedOrientationsMask);
|
|
return UIInterfaceOrientationMaskAll;
|
|
}
|
|
|
|
return _supportedInterfaceOrientations;
|
|
}
|
|
#endif
|
|
|
|
@end
|