2018-08-16 20:33:58 +00:00
|
|
|
#import "RCTWKWebViewManager.h"
|
2018-08-16 20:33:53 +00:00
|
|
|
|
2018-08-16 20:33:58 +00:00
|
|
|
#import "RCTUIManager.h"
|
|
|
|
#import "RCTWKWebView.h"
|
2018-08-16 20:33:53 +00:00
|
|
|
|
|
|
|
@implementation RCTWKWebViewManager
|
|
|
|
|
|
|
|
RCT_EXPORT_MODULE()
|
|
|
|
|
|
|
|
- (UIView *)view
|
|
|
|
{
|
|
|
|
return [RCTWKWebView new];
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(source, NSDictionary)
|
2018-08-16 20:33:55 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(onLoadingStart, RCTDirectEventBlock)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(onLoadingFinish, RCTDirectEventBlock)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(onLoadingError, RCTDirectEventBlock)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(injectedJavaScript, NSString)
|
2018-08-16 20:33:53 +00:00
|
|
|
|
2018-08-16 20:33:58 +00:00
|
|
|
/**
|
|
|
|
* Expose methods to enable messaging the webview.
|
|
|
|
*/
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(messagingEnabled, BOOL)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(onMessage, RCTDirectEventBlock)
|
|
|
|
|
|
|
|
RCT_EXPORT_METHOD(postMessage:(nonnull NSNumber *)reactTag message:(NSString *)message)
|
|
|
|
{
|
|
|
|
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWKWebView *> *viewRegistry) {
|
|
|
|
RCTWKWebView *view = viewRegistry[reactTag];
|
|
|
|
if (![view isKindOfClass:[RCTWKWebView class]]) {
|
|
|
|
RCTLogError(@"Invalid view returned from registry, expecting RCTWebView, got: %@", view);
|
|
|
|
} else {
|
|
|
|
[view postMessage:message];
|
|
|
|
}
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
2018-08-16 20:34:01 +00:00
|
|
|
RCT_REMAP_VIEW_PROPERTY(bounces, _webView.scrollView.bounces, BOOL)
|
2018-08-16 20:34:05 +00:00
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(scrollEnabled, BOOL, RCTWKWebView) {
|
|
|
|
view.scrollEnabled = json == nil ? true : [RCTConvert BOOL: json];
|
|
|
|
}
|
2018-08-16 20:34:01 +00:00
|
|
|
|
2018-08-16 20:33:53 +00:00
|
|
|
@end
|