45 lines
1.3 KiB
Objective-C
45 lines
1.3 KiB
Objective-C
#import "RCTWKWebViewManager.h"
|
|
|
|
#import "RCTUIManager.h"
|
|
#import "RCTWKWebView.h"
|
|
|
|
@implementation RCTWKWebViewManager
|
|
|
|
RCT_EXPORT_MODULE()
|
|
|
|
- (UIView *)view
|
|
{
|
|
return [RCTWKWebView new];
|
|
}
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(source, NSDictionary)
|
|
RCT_EXPORT_VIEW_PROPERTY(onLoadingStart, RCTDirectEventBlock)
|
|
RCT_EXPORT_VIEW_PROPERTY(onLoadingFinish, RCTDirectEventBlock)
|
|
RCT_EXPORT_VIEW_PROPERTY(onLoadingError, RCTDirectEventBlock)
|
|
RCT_EXPORT_VIEW_PROPERTY(injectedJavaScript, NSString)
|
|
|
|
/**
|
|
* 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];
|
|
}
|
|
}];
|
|
}
|
|
|
|
RCT_REMAP_VIEW_PROPERTY(bounces, _webView.scrollView.bounces, BOOL)
|
|
RCT_CUSTOM_VIEW_PROPERTY(scrollEnabled, BOOL, RCTWKWebView) {
|
|
view.scrollEnabled = json == nil ? true : [RCTConvert BOOL: json];
|
|
}
|
|
|
|
@end
|