2017-12-04 21:31:40 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
*
|
2018-02-17 02:24:55 +00:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2017-12-04 21:31:40 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#import <UIKit/UIKit.h>
|
|
|
|
|
2018-03-03 03:32:09 +00:00
|
|
|
#import <React/RCTSurfaceDelegate.h>
|
2017-12-04 21:31:40 +00:00
|
|
|
#import <React/RCTSurfaceSizeMeasureMode.h>
|
|
|
|
#import <React/RCTSurfaceStage.h>
|
|
|
|
|
|
|
|
@class RCTBridge;
|
|
|
|
@class RCTSurface;
|
|
|
|
|
|
|
|
typedef UIView *(^RCTSurfaceHostingViewActivityIndicatorViewFactory)();
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
/**
|
|
|
|
* UIView subclass which providers interoperability between UIKit and
|
|
|
|
* Surface regarding layout and life-cycle.
|
|
|
|
* This class can be used as easy-to-use general purpose integration point
|
|
|
|
* of ReactNative-powered experiences in UIKit based apps.
|
|
|
|
*/
|
2018-03-03 03:32:09 +00:00
|
|
|
@interface RCTSurfaceHostingView : UIView <RCTSurfaceDelegate>
|
2017-12-04 21:31:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Designated initializer.
|
|
|
|
* Instanciates a view with given Surface object.
|
|
|
|
* Note: The view retains the surface object.
|
|
|
|
*/
|
2018-03-20 00:33:04 +00:00
|
|
|
- (instancetype)initWithSurface:(RCTSurface *)surface
|
|
|
|
sizeMeasureMode:(RCTSurfaceSizeMeasureMode)sizeMeasureMode NS_DESIGNATED_INITIALIZER;
|
2017-12-04 21:31:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Convenience initializer.
|
|
|
|
* Instanciates a Surface object with given `bridge`, `moduleName`, and
|
|
|
|
* `initialProperties`, and then use it to instanciate a view.
|
|
|
|
*/
|
|
|
|
- (instancetype)initWithBridge:(RCTBridge *)bridge
|
|
|
|
moduleName:(NSString *)moduleName
|
2018-03-20 00:33:04 +00:00
|
|
|
initialProperties:(NSDictionary *)initialProperties
|
|
|
|
sizeMeasureMode:(RCTSurfaceSizeMeasureMode)sizeMeasureMode;
|
2017-12-04 21:31:40 +00:00
|
|
|
|
2018-03-03 03:32:09 +00:00
|
|
|
/**
|
2018-03-06 02:29:39 +00:00
|
|
|
* Create an instance of RCTSurface to be hosted.
|
2018-03-03 03:32:09 +00:00
|
|
|
*/
|
2018-03-06 02:29:39 +00:00
|
|
|
- (RCTSurface *)createSurfaceWithBridge:(RCTBridge *)bridge
|
|
|
|
moduleName:(NSString *)moduleName
|
|
|
|
initialProperties:(NSDictionary *)initialProperties;
|
2018-03-03 03:32:09 +00:00
|
|
|
|
2017-12-04 21:31:40 +00:00
|
|
|
/**
|
|
|
|
* Surface object which is currently using to power the view.
|
|
|
|
* Read-only.
|
|
|
|
*/
|
|
|
|
@property (nonatomic, strong, readonly) RCTSurface *surface;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Size measure mode which are defining relationship between UIKit and ReactNative
|
|
|
|
* layout approaches.
|
|
|
|
* Defaults to `RCTSurfaceSizeMeasureModeWidthAtMost | RCTSurfaceSizeMeasureModeHeightAtMost`.
|
|
|
|
*/
|
|
|
|
@property (nonatomic, assign) RCTSurfaceSizeMeasureMode sizeMeasureMode;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Activity indicator factory.
|
|
|
|
* A hosting view may use this block to instantiate and display custom activity
|
|
|
|
* (loading) indicator (aka "spinner") when it needed.
|
|
|
|
* Defaults to `nil` (no activity indicator).
|
|
|
|
*/
|
|
|
|
@property (nonatomic, copy, nullable) RCTSurfaceHostingViewActivityIndicatorViewFactory activityIndicatorViewFactory;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|