2015-03-23 20:28:42 +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.
|
|
|
|
*/
|
2015-02-20 04:10:52 +00:00
|
|
|
|
|
|
|
#import <UIKit/UIKit.h>
|
|
|
|
|
2015-03-14 01:32:38 +00:00
|
|
|
#import "RCTBridge.h"
|
|
|
|
|
2015-10-26 22:39:06 +00:00
|
|
|
@protocol RCTRootViewDelegate;
|
|
|
|
|
2015-10-26 22:39:04 +00:00
|
|
|
/**
|
|
|
|
* This enum is used to define size flexibility type of the root view.
|
|
|
|
* If a dimension is flexible, the view will recalculate that dimension
|
|
|
|
* so the content fits. Recalculations are performed when the root's frame,
|
|
|
|
* size flexibility mode or content size changes. After a recalculation,
|
2015-10-26 22:39:06 +00:00
|
|
|
* rootViewDidChangeIntrinsicSize method of the RCTRootViewDelegate will be called.
|
2015-10-26 22:39:04 +00:00
|
|
|
*/
|
|
|
|
typedef NS_ENUM(NSInteger, RCTRootViewSizeFlexibility) {
|
|
|
|
RCTRootViewSizeFlexibilityNone = 0,
|
|
|
|
RCTRootViewSizeFlexibilityWidth,
|
|
|
|
RCTRootViewSizeFlexibilityHeight,
|
|
|
|
RCTRootViewSizeFlexibilityWidthAndHeight,
|
|
|
|
};
|
|
|
|
|
2015-05-28 20:16:06 +00:00
|
|
|
/**
|
|
|
|
* This notification is sent when the first subviews are added to the root view
|
|
|
|
* after the application has loaded. This is used to hide the `loadingView`, and
|
|
|
|
* is a good indicator that the application is ready to use.
|
|
|
|
*/
|
|
|
|
extern NSString *const RCTContentDidAppearNotification;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Native view used to host React-managed views within the app. Can be used just
|
|
|
|
* like any ordinary UIView. You can have multiple RCTRootViews on screen at
|
|
|
|
* once, all controlled by the same JavaScript application.
|
|
|
|
*/
|
2015-05-04 17:35:49 +00:00
|
|
|
@interface RCTRootView : UIView
|
2015-04-02 14:33:21 +00:00
|
|
|
|
2015-04-07 14:36:26 +00:00
|
|
|
/**
|
|
|
|
* - Designated initializer -
|
|
|
|
*/
|
2015-04-02 14:33:21 +00:00
|
|
|
- (instancetype)initWithBridge:(RCTBridge *)bridge
|
2015-08-17 11:38:19 +00:00
|
|
|
moduleName:(NSString *)moduleName
|
|
|
|
initialProperties:(NSDictionary *)initialProperties NS_DESIGNATED_INITIALIZER;
|
2015-03-26 01:59:42 +00:00
|
|
|
|
2015-02-20 04:10:52 +00:00
|
|
|
/**
|
2015-04-02 14:33:21 +00:00
|
|
|
* - Convenience initializer -
|
|
|
|
* A bridge will be created internally.
|
|
|
|
* This initializer is intended to be used when the app has a single RCTRootView,
|
|
|
|
* otherwise create an `RCTBridge` and pass it in via `initWithBridge:moduleName:`
|
|
|
|
* to all the instances.
|
2015-02-20 04:10:52 +00:00
|
|
|
*/
|
2015-04-02 14:33:21 +00:00
|
|
|
- (instancetype)initWithBundleURL:(NSURL *)bundleURL
|
|
|
|
moduleName:(NSString *)moduleName
|
2015-08-17 11:38:19 +00:00
|
|
|
initialProperties:(NSDictionary *)initialProperties
|
2015-04-02 14:33:21 +00:00
|
|
|
launchOptions:(NSDictionary *)launchOptions;
|
2015-02-20 04:10:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The name of the JavaScript module to execute within the
|
|
|
|
* specified scriptURL (required). Setting this will not have
|
|
|
|
* any immediate effect, but it must be done prior to loading
|
|
|
|
* the script.
|
|
|
|
*/
|
2015-03-26 01:59:42 +00:00
|
|
|
@property (nonatomic, copy, readonly) NSString *moduleName;
|
2015-02-20 04:10:52 +00:00
|
|
|
|
2015-04-07 14:36:26 +00:00
|
|
|
/**
|
|
|
|
* The bridge used by the root view. Bridges can be shared between multiple
|
|
|
|
* root views, so you can use this property to initialize another RCTRootView.
|
|
|
|
*/
|
2015-04-02 14:33:21 +00:00
|
|
|
@property (nonatomic, strong, readonly) RCTBridge *bridge;
|
2015-03-14 01:32:38 +00:00
|
|
|
|
2015-10-30 16:26:22 +00:00
|
|
|
/**
|
|
|
|
* The properties to apply to the view. Use this property to update
|
|
|
|
* application properties and rerender the view. Initialized with
|
|
|
|
* initialProperties argument of the initializer.
|
|
|
|
*
|
|
|
|
* Set this property only on the main thread.
|
|
|
|
*/
|
|
|
|
@property (nonatomic, copy, readwrite) NSDictionary *appProperties;
|
2015-02-20 04:10:52 +00:00
|
|
|
|
2015-03-14 01:32:38 +00:00
|
|
|
/**
|
2015-02-20 04:10:52 +00:00
|
|
|
* The class of the RCTJavaScriptExecutor to use with this view.
|
|
|
|
* If not specified, it will default to using RCTContextExecutor.
|
|
|
|
* Changes will take effect next time the bundle is reloaded.
|
|
|
|
*/
|
|
|
|
@property (nonatomic, strong) Class executorClass;
|
|
|
|
|
2015-10-26 22:39:04 +00:00
|
|
|
/**
|
|
|
|
* The size flexibility mode of the root view.
|
|
|
|
*/
|
|
|
|
@property (nonatomic, assign) RCTRootViewSizeFlexibility sizeFlexibility;
|
|
|
|
|
2015-10-26 22:39:06 +00:00
|
|
|
/**
|
|
|
|
* The size of the root view's content. This is set right before the
|
|
|
|
* rootViewDidChangeIntrinsicSize method of RCTRootViewDelegate is called.
|
|
|
|
*/
|
|
|
|
@property (readonly, nonatomic, assign) CGSize intrinsicSize;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The delegate that handles intrinsic size updates.
|
|
|
|
*/
|
|
|
|
@property (nonatomic, weak) id<RCTRootViewDelegate> delegate;
|
|
|
|
|
2015-02-20 04:10:52 +00:00
|
|
|
/**
|
2015-04-11 22:08:00 +00:00
|
|
|
* The backing view controller of the root view.
|
2015-02-20 04:10:52 +00:00
|
|
|
*/
|
2015-07-31 18:23:29 +00:00
|
|
|
@property (nonatomic, weak) UIViewController *reactViewController;
|
2015-04-02 14:33:21 +00:00
|
|
|
|
2015-04-11 22:08:00 +00:00
|
|
|
/**
|
|
|
|
* The React-managed contents view of the root view.
|
|
|
|
*/
|
2015-04-02 14:33:21 +00:00
|
|
|
@property (nonatomic, strong, readonly) UIView *contentView;
|
|
|
|
|
2015-05-28 20:16:06 +00:00
|
|
|
/**
|
|
|
|
* A view to display while the JavaScript is loading, so users aren't presented
|
|
|
|
* with a blank screen. By default this is nil, but you can override it with
|
|
|
|
* (for example) a UIActivityIndicatorView or a placeholder image.
|
|
|
|
*/
|
|
|
|
@property (nonatomic, strong) UIView *loadingView;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Timings for hiding the loading view after the content has loaded. Both of
|
|
|
|
* these values default to 0.25 seconds.
|
|
|
|
*/
|
|
|
|
@property (nonatomic, assign) NSTimeInterval loadingViewFadeDelay;
|
|
|
|
@property (nonatomic, assign) NSTimeInterval loadingViewFadeDuration;
|
|
|
|
|
2015-02-20 04:10:52 +00:00
|
|
|
@end
|