2015-07-28 14:31:26 +00:00
|
|
|
/**
|
|
|
|
* 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"
|
|
|
|
|
2016-09-22 19:46:29 +00:00
|
|
|
#import "RCTLog.h"
|
2016-09-07 13:06:12 +00:00
|
|
|
#import "RCTModalHostView.h"
|
|
|
|
|
2015-11-25 11:09:00 +00:00
|
|
|
@implementation RCTModalHostViewController
|
|
|
|
{
|
2015-09-19 00:18:09 +00:00
|
|
|
CGRect _lastViewFrame;
|
2016-09-27 13:19:45 +00:00
|
|
|
#if !TARGET_OS_TV
|
2016-08-29 20:56:54 +00:00
|
|
|
UIStatusBarStyle _preferredStatusBarStyle;
|
|
|
|
BOOL _preferredStatusBarHidden;
|
2016-09-27 13:19:45 +00:00
|
|
|
#endif
|
2016-08-29 20:56:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (instancetype)init
|
|
|
|
{
|
|
|
|
if (!(self = [super init])) {
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2016-09-27 13:19:45 +00:00
|
|
|
#if !TARGET_OS_TV
|
2017-04-01 10:16:52 +00:00
|
|
|
_preferredStatusBarStyle = [RCTSharedApplication() statusBarStyle];
|
|
|
|
_preferredStatusBarHidden = [RCTSharedApplication() isStatusBarHidden];
|
2016-09-27 13:19:45 +00:00
|
|
|
#endif
|
2016-08-29 20:56:54 +00:00
|
|
|
|
|
|
|
return self;
|
2015-09-19 00:18:09 +00:00
|
|
|
}
|
2015-07-28 14:31:26 +00:00
|
|
|
|
|
|
|
- (void)viewDidLayoutSubviews
|
|
|
|
{
|
|
|
|
[super viewDidLayoutSubviews];
|
|
|
|
|
2015-09-19 00:18:09 +00:00
|
|
|
if (self.boundsDidChangeBlock && !CGRectEqualToRect(_lastViewFrame, self.view.frame)) {
|
2015-07-28 14:31:26 +00:00
|
|
|
self.boundsDidChangeBlock(self.view.bounds);
|
2015-09-19 00:18:09 +00:00
|
|
|
_lastViewFrame = self.view.frame;
|
2015-07-28 14:31:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-27 13:19:45 +00:00
|
|
|
#if !TARGET_OS_TV
|
2016-08-29 20:56:54 +00:00
|
|
|
- (UIStatusBarStyle)preferredStatusBarStyle
|
|
|
|
{
|
|
|
|
return _preferredStatusBarStyle;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)prefersStatusBarHidden
|
|
|
|
{
|
|
|
|
return _preferredStatusBarHidden;
|
|
|
|
}
|
|
|
|
|
2016-09-22 19:46:29 +00:00
|
|
|
#if RCT_DEV
|
|
|
|
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
|
|
|
|
{
|
2017-04-01 10:16:52 +00:00
|
|
|
UIInterfaceOrientationMask appSupportedOrientationsMask = [RCTSharedApplication() supportedInterfaceOrientationsForWindow:[RCTSharedApplication() keyWindow]];
|
2016-09-22 19:46:29 +00:00
|
|
|
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;
|
|
|
|
}
|
2016-10-05 14:15:25 +00:00
|
|
|
#endif // RCT_DEV
|
|
|
|
#endif // !TARGET_OS_TV
|
|
|
|
|
2016-09-22 19:46:29 +00:00
|
|
|
|
2015-07-28 14:31:26 +00:00
|
|
|
@end
|