mirror of
https://github.com/status-im/react-native-webview.git
synced 2025-02-23 09:18:38 +00:00
Merge pull request #49 from react-native-community/renaming/rct-rnc
Renaming/rct->rnc to fix ios build
This commit is contained in:
commit
6c911952c5
@ -1,5 +0,0 @@
|
|||||||
#import <React/RCTViewManager.h>
|
|
||||||
|
|
||||||
@interface RCTUIWebViewManager : RCTViewManager
|
|
||||||
|
|
||||||
@end
|
|
@ -1,6 +1,6 @@
|
|||||||
#import <React/RCTView.h>
|
#import <React/RCTView.h>
|
||||||
|
|
||||||
@class RCTUIWebView;
|
@class RNCUIWebView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Special scheme used to pass messages to the injectedJavaScript
|
* Special scheme used to pass messages to the injectedJavaScript
|
||||||
@ -10,17 +10,17 @@
|
|||||||
*/
|
*/
|
||||||
extern NSString *const RNCJSNavigationScheme;
|
extern NSString *const RNCJSNavigationScheme;
|
||||||
|
|
||||||
@protocol RCTUIWebViewDelegate <NSObject>
|
@protocol RNCUIWebViewDelegate <NSObject>
|
||||||
|
|
||||||
- (BOOL)webView:(RCTUIWebView *)webView
|
- (BOOL)webView:(RNCUIWebView *)webView
|
||||||
shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
|
shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
|
||||||
withCallback:(RCTDirectEventBlock)callback;
|
withCallback:(RCTDirectEventBlock)callback;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface RCTUIWebView : RCTView
|
@interface RNCUIWebView : RCTView
|
||||||
|
|
||||||
@property (nonatomic, weak) id<RCTUIWebViewDelegate> delegate;
|
@property (nonatomic, weak) id<RNCUIWebViewDelegate> delegate;
|
||||||
|
|
||||||
@property (nonatomic, copy) NSDictionary *source;
|
@property (nonatomic, copy) NSDictionary *source;
|
||||||
@property (nonatomic, assign) UIEdgeInsets contentInset;
|
@property (nonatomic, assign) UIEdgeInsets contentInset;
|
@ -1,4 +1,4 @@
|
|||||||
#import "RCTUIWebView.h"
|
#import "RNCUIWebView.h"
|
||||||
|
|
||||||
// #import <UIKit/UIKit.h>
|
// #import <UIKit/UIKit.h>
|
||||||
#import <React/RCTAutoInsetsProtocol.h>
|
#import <React/RCTAutoInsetsProtocol.h>
|
||||||
@ -13,7 +13,7 @@ NSString *const RNCJSNavigationScheme = @"react-js-navigation";
|
|||||||
|
|
||||||
static NSString *const kPostMessageHost = @"postMessage";
|
static NSString *const kPostMessageHost = @"postMessage";
|
||||||
|
|
||||||
@interface RCTUIWebView () <UIWebViewDelegate, RCTAutoInsetsProtocol>
|
@interface RNCUIWebView () <UIWebViewDelegate, RCTAutoInsetsProtocol>
|
||||||
|
|
||||||
@property (nonatomic, copy) RCTDirectEventBlock onLoadingStart;
|
@property (nonatomic, copy) RCTDirectEventBlock onLoadingStart;
|
||||||
@property (nonatomic, copy) RCTDirectEventBlock onLoadingFinish;
|
@property (nonatomic, copy) RCTDirectEventBlock onLoadingFinish;
|
||||||
@ -23,7 +23,7 @@ static NSString *const kPostMessageHost = @"postMessage";
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation RCTUIWebView
|
@implementation RNCUIWebView
|
||||||
{
|
{
|
||||||
UIWebView *_webView;
|
UIWebView *_webView;
|
||||||
NSString *_injectedJavaScript;
|
NSString *_injectedJavaScript;
|
5
ios/RNCUIWebViewManager.h
Normal file
5
ios/RNCUIWebViewManager.h
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#import <React/RCTViewManager.h>
|
||||||
|
|
||||||
|
@interface RNCUIWebViewManager : RCTViewManager
|
||||||
|
|
||||||
|
@end
|
@ -1,15 +1,15 @@
|
|||||||
#import "RCTUIWebViewManager.h"
|
#import "RNCUIWebViewManager.h"
|
||||||
|
|
||||||
#import <React/RCTBridge.h>
|
#import <React/RCTBridge.h>
|
||||||
#import <React/RCTUIManager.h>
|
#import <React/RCTUIManager.h>
|
||||||
#import <React/UIView+React.h>
|
#import <React/UIView+React.h>
|
||||||
#import "RCTUIWebView.h"
|
#import "RNCUIWebView.h"
|
||||||
|
|
||||||
@interface RCTUIWebViewManager () <RCTUIWebViewDelegate>
|
@interface RNCUIWebViewManager () <RNCUIWebViewDelegate>
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation RCTUIWebViewManager
|
@implementation RNCUIWebViewManager
|
||||||
{
|
{
|
||||||
NSConditionLock *_shouldStartLoadLock;
|
NSConditionLock *_shouldStartLoadLock;
|
||||||
BOOL _shouldStartLoad;
|
BOOL _shouldStartLoad;
|
||||||
@ -19,7 +19,7 @@ RCT_EXPORT_MODULE()
|
|||||||
|
|
||||||
- (UIView *)view
|
- (UIView *)view
|
||||||
{
|
{
|
||||||
RCTUIWebView *webView = [RCTUIWebView new];
|
RNCUIWebView *webView = [RNCUIWebView new];
|
||||||
webView.delegate = self;
|
webView.delegate = self;
|
||||||
return webView;
|
return webView;
|
||||||
}
|
}
|
||||||
@ -44,10 +44,10 @@ RCT_REMAP_VIEW_PROPERTY(dataDetectorTypes, _webView.dataDetectorTypes, UIDataDet
|
|||||||
|
|
||||||
RCT_EXPORT_METHOD(goBack:(nonnull NSNumber *)reactTag)
|
RCT_EXPORT_METHOD(goBack:(nonnull NSNumber *)reactTag)
|
||||||
{
|
{
|
||||||
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTUIWebView *> *viewRegistry) {
|
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCUIWebView *> *viewRegistry) {
|
||||||
RCTUIWebView *view = viewRegistry[reactTag];
|
RNCUIWebView *view = viewRegistry[reactTag];
|
||||||
if (![view isKindOfClass:[RCTUIWebView class]]) {
|
if (![view isKindOfClass:[RNCUIWebView class]]) {
|
||||||
RCTLogError(@"Invalid view returned from registry, expecting RCTUIWebView, got: %@", view);
|
RCTLogError(@"Invalid view returned from registry, expecting RNCUIWebView, got: %@", view);
|
||||||
} else {
|
} else {
|
||||||
[view goBack];
|
[view goBack];
|
||||||
}
|
}
|
||||||
@ -57,9 +57,9 @@ RCT_EXPORT_METHOD(goBack:(nonnull NSNumber *)reactTag)
|
|||||||
RCT_EXPORT_METHOD(goForward:(nonnull NSNumber *)reactTag)
|
RCT_EXPORT_METHOD(goForward:(nonnull NSNumber *)reactTag)
|
||||||
{
|
{
|
||||||
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||||
RCTUIWebView *view = viewRegistry[reactTag];
|
RNCUIWebView *view = viewRegistry[reactTag];
|
||||||
if (![view isKindOfClass:[RCTUIWebView class]]) {
|
if (![view isKindOfClass:[RNCUIWebView class]]) {
|
||||||
RCTLogError(@"Invalid view returned from registry, expecting RCTUIWebView, got: %@", view);
|
RCTLogError(@"Invalid view returned from registry, expecting RNCUIWebView, got: %@", view);
|
||||||
} else {
|
} else {
|
||||||
[view goForward];
|
[view goForward];
|
||||||
}
|
}
|
||||||
@ -68,10 +68,10 @@ RCT_EXPORT_METHOD(goForward:(nonnull NSNumber *)reactTag)
|
|||||||
|
|
||||||
RCT_EXPORT_METHOD(reload:(nonnull NSNumber *)reactTag)
|
RCT_EXPORT_METHOD(reload:(nonnull NSNumber *)reactTag)
|
||||||
{
|
{
|
||||||
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTUIWebView *> *viewRegistry) {
|
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCUIWebView *> *viewRegistry) {
|
||||||
RCTUIWebView *view = viewRegistry[reactTag];
|
RNCUIWebView *view = viewRegistry[reactTag];
|
||||||
if (![view isKindOfClass:[RCTUIWebView class]]) {
|
if (![view isKindOfClass:[RNCUIWebView class]]) {
|
||||||
RCTLogError(@"Invalid view returned from registry, expecting RCTUIWebView, got: %@", view);
|
RCTLogError(@"Invalid view returned from registry, expecting RNCUIWebView, got: %@", view);
|
||||||
} else {
|
} else {
|
||||||
[view reload];
|
[view reload];
|
||||||
}
|
}
|
||||||
@ -80,10 +80,10 @@ RCT_EXPORT_METHOD(reload:(nonnull NSNumber *)reactTag)
|
|||||||
|
|
||||||
RCT_EXPORT_METHOD(stopLoading:(nonnull NSNumber *)reactTag)
|
RCT_EXPORT_METHOD(stopLoading:(nonnull NSNumber *)reactTag)
|
||||||
{
|
{
|
||||||
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTUIWebView *> *viewRegistry) {
|
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCUIWebView *> *viewRegistry) {
|
||||||
RCTUIWebView *view = viewRegistry[reactTag];
|
RNCUIWebView *view = viewRegistry[reactTag];
|
||||||
if (![view isKindOfClass:[RCTUIWebView class]]) {
|
if (![view isKindOfClass:[RNCUIWebView class]]) {
|
||||||
RCTLogError(@"Invalid view returned from registry, expecting RCTUIWebView, got: %@", view);
|
RCTLogError(@"Invalid view returned from registry, expecting RNCUIWebView, got: %@", view);
|
||||||
} else {
|
} else {
|
||||||
[view stopLoading];
|
[view stopLoading];
|
||||||
}
|
}
|
||||||
@ -92,10 +92,10 @@ RCT_EXPORT_METHOD(stopLoading:(nonnull NSNumber *)reactTag)
|
|||||||
|
|
||||||
RCT_EXPORT_METHOD(postMessage:(nonnull NSNumber *)reactTag message:(NSString *)message)
|
RCT_EXPORT_METHOD(postMessage:(nonnull NSNumber *)reactTag message:(NSString *)message)
|
||||||
{
|
{
|
||||||
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTUIWebView *> *viewRegistry) {
|
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCUIWebView *> *viewRegistry) {
|
||||||
RCTUIWebView *view = viewRegistry[reactTag];
|
RNCUIWebView *view = viewRegistry[reactTag];
|
||||||
if (![view isKindOfClass:[RCTUIWebView class]]) {
|
if (![view isKindOfClass:[RNCUIWebView class]]) {
|
||||||
RCTLogError(@"Invalid view returned from registry, expecting RCTUIWebView, got: %@", view);
|
RCTLogError(@"Invalid view returned from registry, expecting RNCUIWebView, got: %@", view);
|
||||||
} else {
|
} else {
|
||||||
[view postMessage:message];
|
[view postMessage:message];
|
||||||
}
|
}
|
||||||
@ -104,10 +104,10 @@ RCT_EXPORT_METHOD(postMessage:(nonnull NSNumber *)reactTag message:(NSString *)m
|
|||||||
|
|
||||||
RCT_EXPORT_METHOD(injectJavaScript:(nonnull NSNumber *)reactTag script:(NSString *)script)
|
RCT_EXPORT_METHOD(injectJavaScript:(nonnull NSNumber *)reactTag script:(NSString *)script)
|
||||||
{
|
{
|
||||||
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTUIWebView *> *viewRegistry) {
|
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCUIWebView *> *viewRegistry) {
|
||||||
RCTUIWebView *view = viewRegistry[reactTag];
|
RNCUIWebView *view = viewRegistry[reactTag];
|
||||||
if (![view isKindOfClass:[RCTUIWebView class]]) {
|
if (![view isKindOfClass:[RNCUIWebView class]]) {
|
||||||
RCTLogError(@"Invalid view returned from registry, expecting RCTUIWebView, got: %@", view);
|
RCTLogError(@"Invalid view returned from registry, expecting RNCUIWebView, got: %@", view);
|
||||||
} else {
|
} else {
|
||||||
[view injectJavaScript:script];
|
[view injectJavaScript:script];
|
||||||
}
|
}
|
||||||
@ -116,7 +116,7 @@ RCT_EXPORT_METHOD(injectJavaScript:(nonnull NSNumber *)reactTag script:(NSString
|
|||||||
|
|
||||||
#pragma mark - Exported synchronous methods
|
#pragma mark - Exported synchronous methods
|
||||||
|
|
||||||
- (BOOL)webView:(__unused RCTUIWebView *)webView
|
- (BOOL)webView:(__unused RNCUIWebView *)webView
|
||||||
shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
|
shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
|
||||||
withCallback:(RCTDirectEventBlock)callback
|
withCallback:(RCTDirectEventBlock)callback
|
||||||
{
|
{
|
@ -9,19 +9,19 @@
|
|||||||
#import <React/RCTDefines.h>
|
#import <React/RCTDefines.h>
|
||||||
#import <WebKit/WebKit.h>
|
#import <WebKit/WebKit.h>
|
||||||
|
|
||||||
@class RCTWKWebView;
|
@class RNCWKWebView;
|
||||||
|
|
||||||
@protocol RCTWKWebViewDelegate <NSObject>
|
@protocol RNCWKWebViewDelegate <NSObject>
|
||||||
|
|
||||||
- (BOOL)webView:(RCTWKWebView *)webView
|
- (BOOL)webView:(RNCWKWebView *)webView
|
||||||
shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
|
shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
|
||||||
withCallback:(RCTDirectEventBlock)callback;
|
withCallback:(RCTDirectEventBlock)callback;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface RCTWKWebView : RCTView
|
@interface RNCWKWebView : RCTView
|
||||||
|
|
||||||
@property (nonatomic, weak) id<RCTWKWebViewDelegate> delegate;
|
@property (nonatomic, weak) id<RNCWKWebViewDelegate> delegate;
|
||||||
@property (nonatomic, copy) NSDictionary *source;
|
@property (nonatomic, copy) NSDictionary *source;
|
||||||
@property (nonatomic, assign) BOOL messagingEnabled;
|
@property (nonatomic, assign) BOOL messagingEnabled;
|
||||||
@property (nonatomic, copy) NSString *injectedJavaScript;
|
@property (nonatomic, copy) NSString *injectedJavaScript;
|
@ -5,13 +5,13 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "RCTWKWebView.h"
|
#import "RNCWKWebView.h"
|
||||||
#import <React/RCTConvert.h>
|
#import <React/RCTConvert.h>
|
||||||
#import <React/RCTAutoInsetsProtocol.h>
|
#import <React/RCTAutoInsetsProtocol.h>
|
||||||
|
|
||||||
static NSString *const MessageHanderName = @"ReactNative";
|
static NSString *const MessageHanderName = @"ReactNative";
|
||||||
|
|
||||||
@interface RCTWKWebView () <WKUIDelegate, WKNavigationDelegate, WKScriptMessageHandler, UIScrollViewDelegate, RCTAutoInsetsProtocol>
|
@interface RNCWKWebView () <WKUIDelegate, WKNavigationDelegate, WKScriptMessageHandler, UIScrollViewDelegate, RCTAutoInsetsProtocol>
|
||||||
@property (nonatomic, copy) RCTDirectEventBlock onLoadingStart;
|
@property (nonatomic, copy) RCTDirectEventBlock onLoadingStart;
|
||||||
@property (nonatomic, copy) RCTDirectEventBlock onLoadingFinish;
|
@property (nonatomic, copy) RCTDirectEventBlock onLoadingFinish;
|
||||||
@property (nonatomic, copy) RCTDirectEventBlock onLoadingError;
|
@property (nonatomic, copy) RCTDirectEventBlock onLoadingError;
|
||||||
@ -20,7 +20,7 @@ static NSString *const MessageHanderName = @"ReactNative";
|
|||||||
@property (nonatomic, copy) WKWebView *webView;
|
@property (nonatomic, copy) WKWebView *webView;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation RCTWKWebView
|
@implementation RNCWKWebView
|
||||||
{
|
{
|
||||||
UIColor * _savedBackgroundColor;
|
UIColor * _savedBackgroundColor;
|
||||||
}
|
}
|
||||||
@ -206,7 +206,7 @@ static NSString *const MessageHanderName = @"ReactNative";
|
|||||||
{
|
{
|
||||||
[super layoutSubviews];
|
[super layoutSubviews];
|
||||||
|
|
||||||
// Ensure webview takes the position and dimensions of RCTWKWebView
|
// Ensure webview takes the position and dimensions of RNCWKWebView
|
||||||
_webView.frame = self.bounds;
|
_webView.frame = self.bounds;
|
||||||
}
|
}
|
||||||
|
|
@ -7,5 +7,5 @@
|
|||||||
|
|
||||||
#import <React/RCTViewManager.h>
|
#import <React/RCTViewManager.h>
|
||||||
|
|
||||||
@interface RCTWKWebViewManager : RCTViewManager
|
@interface RNCWKWebViewManager : RCTViewManager
|
||||||
@end
|
@end
|
@ -5,16 +5,16 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "RCTWKWebViewManager.h"
|
#import "RNCWKWebViewManager.h"
|
||||||
|
|
||||||
#import <React/RCTUIManager.h>
|
#import <React/RCTUIManager.h>
|
||||||
#import <React/RCTDefines.h>
|
#import <React/RCTDefines.h>
|
||||||
#import "RCTWKWebView.h"
|
#import "RNCWKWebView.h"
|
||||||
|
|
||||||
@interface RCTWKWebViewManager () <RCTWKWebViewDelegate>
|
@interface RNCWKWebViewManager () <RNCWKWebViewDelegate>
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation RCTWKWebViewManager
|
@implementation RNCWKWebViewManager
|
||||||
{
|
{
|
||||||
NSConditionLock *_shouldStartLoadLock;
|
NSConditionLock *_shouldStartLoadLock;
|
||||||
BOOL _shouldStartLoad;
|
BOOL _shouldStartLoad;
|
||||||
@ -24,7 +24,7 @@ RCT_EXPORT_MODULE()
|
|||||||
|
|
||||||
- (UIView *)view
|
- (UIView *)view
|
||||||
{
|
{
|
||||||
RCTWKWebView *webView = [RCTWKWebView new];
|
RNCWKWebView *webView = [RNCWKWebView new];
|
||||||
webView.delegate = self;
|
webView.delegate = self;
|
||||||
return webView;
|
return webView;
|
||||||
}
|
}
|
||||||
@ -51,34 +51,34 @@ RCT_EXPORT_VIEW_PROPERTY(onMessage, RCTDirectEventBlock)
|
|||||||
|
|
||||||
RCT_EXPORT_METHOD(postMessage:(nonnull NSNumber *)reactTag message:(NSString *)message)
|
RCT_EXPORT_METHOD(postMessage:(nonnull NSNumber *)reactTag message:(NSString *)message)
|
||||||
{
|
{
|
||||||
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWKWebView *> *viewRegistry) {
|
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCWKWebView *> *viewRegistry) {
|
||||||
RCTWKWebView *view = viewRegistry[reactTag];
|
RNCWKWebView *view = viewRegistry[reactTag];
|
||||||
if (![view isKindOfClass:[RCTWKWebView class]]) {
|
if (![view isKindOfClass:[RNCWKWebView class]]) {
|
||||||
RCTLogError(@"Invalid view returned from registry, expecting RCTWebView, got: %@", view);
|
RCTLogError(@"Invalid view returned from registry, expecting RNCWKWebView, got: %@", view);
|
||||||
} else {
|
} else {
|
||||||
[view postMessage:message];
|
[view postMessage:message];
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
RCT_CUSTOM_VIEW_PROPERTY(bounces, BOOL, RCTWKWebView) {
|
RCT_CUSTOM_VIEW_PROPERTY(bounces, BOOL, RNCWKWebView) {
|
||||||
view.bounces = json == nil ? true : [RCTConvert BOOL: json];
|
view.bounces = json == nil ? true : [RCTConvert BOOL: json];
|
||||||
}
|
}
|
||||||
|
|
||||||
RCT_CUSTOM_VIEW_PROPERTY(scrollEnabled, BOOL, RCTWKWebView) {
|
RCT_CUSTOM_VIEW_PROPERTY(scrollEnabled, BOOL, RNCWKWebView) {
|
||||||
view.scrollEnabled = json == nil ? true : [RCTConvert BOOL: json];
|
view.scrollEnabled = json == nil ? true : [RCTConvert BOOL: json];
|
||||||
}
|
}
|
||||||
|
|
||||||
RCT_CUSTOM_VIEW_PROPERTY(decelerationRate, CGFloat, RCTWKWebView) {
|
RCT_CUSTOM_VIEW_PROPERTY(decelerationRate, CGFloat, RNCWKWebView) {
|
||||||
view.decelerationRate = json == nil ? UIScrollViewDecelerationRateNormal : [RCTConvert CGFloat: json];
|
view.decelerationRate = json == nil ? UIScrollViewDecelerationRateNormal : [RCTConvert CGFloat: json];
|
||||||
}
|
}
|
||||||
|
|
||||||
RCT_EXPORT_METHOD(injectJavaScript:(nonnull NSNumber *)reactTag script:(NSString *)script)
|
RCT_EXPORT_METHOD(injectJavaScript:(nonnull NSNumber *)reactTag script:(NSString *)script)
|
||||||
{
|
{
|
||||||
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWKWebView *> *viewRegistry) {
|
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCWKWebView *> *viewRegistry) {
|
||||||
RCTWKWebView *view = viewRegistry[reactTag];
|
RNCWKWebView *view = viewRegistry[reactTag];
|
||||||
if (![view isKindOfClass:[RCTWKWebView class]]) {
|
if (![view isKindOfClass:[RNCWKWebView class]]) {
|
||||||
RCTLogError(@"Invalid view returned from registry, expecting RCTWebView, got: %@", view);
|
RCTLogError(@"Invalid view returned from registry, expecting RNCWKWebView, got: %@", view);
|
||||||
} else {
|
} else {
|
||||||
[view injectJavaScript:script];
|
[view injectJavaScript:script];
|
||||||
}
|
}
|
||||||
@ -87,10 +87,10 @@ RCT_EXPORT_METHOD(injectJavaScript:(nonnull NSNumber *)reactTag script:(NSString
|
|||||||
|
|
||||||
RCT_EXPORT_METHOD(goBack:(nonnull NSNumber *)reactTag)
|
RCT_EXPORT_METHOD(goBack:(nonnull NSNumber *)reactTag)
|
||||||
{
|
{
|
||||||
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWKWebView *> *viewRegistry) {
|
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCWKWebView *> *viewRegistry) {
|
||||||
RCTWKWebView *view = viewRegistry[reactTag];
|
RNCWKWebView *view = viewRegistry[reactTag];
|
||||||
if (![view isKindOfClass:[RCTWKWebView class]]) {
|
if (![view isKindOfClass:[RNCWKWebView class]]) {
|
||||||
RCTLogError(@"Invalid view returned from registry, expecting RCTWebView, got: %@", view);
|
RCTLogError(@"Invalid view returned from registry, expecting RNCWKWebView, got: %@", view);
|
||||||
} else {
|
} else {
|
||||||
[view goBack];
|
[view goBack];
|
||||||
}
|
}
|
||||||
@ -99,10 +99,10 @@ RCT_EXPORT_METHOD(goBack:(nonnull NSNumber *)reactTag)
|
|||||||
|
|
||||||
RCT_EXPORT_METHOD(goForward:(nonnull NSNumber *)reactTag)
|
RCT_EXPORT_METHOD(goForward:(nonnull NSNumber *)reactTag)
|
||||||
{
|
{
|
||||||
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWKWebView *> *viewRegistry) {
|
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCWKWebView *> *viewRegistry) {
|
||||||
RCTWKWebView *view = viewRegistry[reactTag];
|
RNCWKWebView *view = viewRegistry[reactTag];
|
||||||
if (![view isKindOfClass:[RCTWKWebView class]]) {
|
if (![view isKindOfClass:[RNCWKWebView class]]) {
|
||||||
RCTLogError(@"Invalid view returned from registry, expecting RCTWebView, got: %@", view);
|
RCTLogError(@"Invalid view returned from registry, expecting RNCWKWebView, got: %@", view);
|
||||||
} else {
|
} else {
|
||||||
[view goForward];
|
[view goForward];
|
||||||
}
|
}
|
||||||
@ -111,10 +111,10 @@ RCT_EXPORT_METHOD(goForward:(nonnull NSNumber *)reactTag)
|
|||||||
|
|
||||||
RCT_EXPORT_METHOD(reload:(nonnull NSNumber *)reactTag)
|
RCT_EXPORT_METHOD(reload:(nonnull NSNumber *)reactTag)
|
||||||
{
|
{
|
||||||
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWKWebView *> *viewRegistry) {
|
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCWKWebView *> *viewRegistry) {
|
||||||
RCTWKWebView *view = viewRegistry[reactTag];
|
RNCWKWebView *view = viewRegistry[reactTag];
|
||||||
if (![view isKindOfClass:[RCTWKWebView class]]) {
|
if (![view isKindOfClass:[RNCWKWebView class]]) {
|
||||||
RCTLogError(@"Invalid view returned from registry, expecting RCTWebView, got: %@", view);
|
RCTLogError(@"Invalid view returned from registry, expecting RNCWKWebView, got: %@", view);
|
||||||
} else {
|
} else {
|
||||||
[view reload];
|
[view reload];
|
||||||
}
|
}
|
||||||
@ -123,10 +123,10 @@ RCT_EXPORT_METHOD(reload:(nonnull NSNumber *)reactTag)
|
|||||||
|
|
||||||
RCT_EXPORT_METHOD(stopLoading:(nonnull NSNumber *)reactTag)
|
RCT_EXPORT_METHOD(stopLoading:(nonnull NSNumber *)reactTag)
|
||||||
{
|
{
|
||||||
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWKWebView *> *viewRegistry) {
|
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCWKWebView *> *viewRegistry) {
|
||||||
RCTWKWebView *view = viewRegistry[reactTag];
|
RNCWKWebView *view = viewRegistry[reactTag];
|
||||||
if (![view isKindOfClass:[RCTWKWebView class]]) {
|
if (![view isKindOfClass:[RNCWKWebView class]]) {
|
||||||
RCTLogError(@"Invalid view returned from registry, expecting RCTWebView, got: %@", view);
|
RCTLogError(@"Invalid view returned from registry, expecting RNCWKWebView, got: %@", view);
|
||||||
} else {
|
} else {
|
||||||
[view stopLoading];
|
[view stopLoading];
|
||||||
}
|
}
|
||||||
@ -135,7 +135,7 @@ RCT_EXPORT_METHOD(stopLoading:(nonnull NSNumber *)reactTag)
|
|||||||
|
|
||||||
#pragma mark - Exported synchronous methods
|
#pragma mark - Exported synchronous methods
|
||||||
|
|
||||||
- (BOOL) webView:(RCTWKWebView *)webView
|
- (BOOL) webView:(RNCWKWebView *)webView
|
||||||
shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
|
shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
|
||||||
withCallback:(RCTDirectEventBlock)callback
|
withCallback:(RCTDirectEventBlock)callback
|
||||||
{
|
{
|
@ -7,10 +7,10 @@
|
|||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
E914DBF6214474710071092B /* RCTUIWebViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = E914DBF3214474710071092B /* RCTUIWebViewManager.m */; };
|
E914DBF6214474710071092B /* RNCUIWebViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = E914DBF3214474710071092B /* RNCUIWebViewManager.m */; };
|
||||||
E914DBF7214474710071092B /* RCTUIWebView.m in Sources */ = {isa = PBXBuildFile; fileRef = E914DBF4214474710071092B /* RCTUIWebView.m */; };
|
E914DBF7214474710071092B /* RNCUIWebView.m in Sources */ = {isa = PBXBuildFile; fileRef = E914DBF4214474710071092B /* RNCUIWebView.m */; };
|
||||||
E91B351D21446E6C00F9801F /* RCTWKWebViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = E91B351B21446E6C00F9801F /* RCTWKWebViewManager.m */; };
|
E91B351D21446E6C00F9801F /* RNCWKWebViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = E91B351B21446E6C00F9801F /* RNCWKWebViewManager.m */; };
|
||||||
E91B351E21446E6C00F9801F /* RCTWKWebView.m in Sources */ = {isa = PBXBuildFile; fileRef = E91B351C21446E6C00F9801F /* RCTWKWebView.m */; };
|
E91B351E21446E6C00F9801F /* RNCWKWebView.m in Sources */ = {isa = PBXBuildFile; fileRef = E91B351C21446E6C00F9801F /* RNCWKWebView.m */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXCopyFilesBuildPhase section */
|
/* Begin PBXCopyFilesBuildPhase section */
|
||||||
@ -26,15 +26,15 @@
|
|||||||
/* End PBXCopyFilesBuildPhase section */
|
/* End PBXCopyFilesBuildPhase section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
134814201AA4EA6300B7C361 /* libRCTWebView.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTWebView.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
134814201AA4EA6300B7C361 /* libRNCWebView.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNCWebView.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
E914DBF2214474710071092B /* RCTUIWebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTUIWebView.h; sourceTree = "<group>"; };
|
E914DBF2214474710071092B /* RNCUIWebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNCUIWebView.h; sourceTree = "<group>"; };
|
||||||
E914DBF3214474710071092B /* RCTUIWebViewManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTUIWebViewManager.m; sourceTree = "<group>"; };
|
E914DBF3214474710071092B /* RNCUIWebViewManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNCUIWebViewManager.m; sourceTree = "<group>"; };
|
||||||
E914DBF4214474710071092B /* RCTUIWebView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTUIWebView.m; sourceTree = "<group>"; };
|
E914DBF4214474710071092B /* RNCUIWebView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNCUIWebView.m; sourceTree = "<group>"; };
|
||||||
E914DBF5214474710071092B /* RCTUIWebViewManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTUIWebViewManager.h; sourceTree = "<group>"; };
|
E914DBF5214474710071092B /* RNCUIWebViewManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNCUIWebViewManager.h; sourceTree = "<group>"; };
|
||||||
E91B351921446E6C00F9801F /* RCTWKWebViewManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTWKWebViewManager.h; sourceTree = "<group>"; };
|
E91B351921446E6C00F9801F /* RNCWKWebViewManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNCWKWebViewManager.h; sourceTree = "<group>"; };
|
||||||
E91B351A21446E6C00F9801F /* RCTWKWebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTWKWebView.h; sourceTree = "<group>"; };
|
E91B351A21446E6C00F9801F /* RNCWKWebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNCWKWebView.h; sourceTree = "<group>"; };
|
||||||
E91B351B21446E6C00F9801F /* RCTWKWebViewManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTWKWebViewManager.m; sourceTree = "<group>"; };
|
E91B351B21446E6C00F9801F /* RNCWKWebViewManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNCWKWebViewManager.m; sourceTree = "<group>"; };
|
||||||
E91B351C21446E6C00F9801F /* RCTWKWebView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTWKWebView.m; sourceTree = "<group>"; };
|
E91B351C21446E6C00F9801F /* RNCWKWebView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNCWKWebView.m; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@ -51,7 +51,7 @@
|
|||||||
134814211AA4EA7D00B7C361 /* Products */ = {
|
134814211AA4EA7D00B7C361 /* Products */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
134814201AA4EA6300B7C361 /* libRCTWebView.a */,
|
134814201AA4EA6300B7C361 /* libRNCWebView.a */,
|
||||||
);
|
);
|
||||||
name = Products;
|
name = Products;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -59,14 +59,14 @@
|
|||||||
58B511D21A9E6C8500147676 = {
|
58B511D21A9E6C8500147676 = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
E914DBF2214474710071092B /* RCTUIWebView.h */,
|
E914DBF2214474710071092B /* RNCUIWebView.h */,
|
||||||
E914DBF4214474710071092B /* RCTUIWebView.m */,
|
E914DBF4214474710071092B /* RNCUIWebView.m */,
|
||||||
E914DBF5214474710071092B /* RCTUIWebViewManager.h */,
|
E914DBF5214474710071092B /* RNCUIWebViewManager.h */,
|
||||||
E914DBF3214474710071092B /* RCTUIWebViewManager.m */,
|
E914DBF3214474710071092B /* RNCUIWebViewManager.m */,
|
||||||
E91B351A21446E6C00F9801F /* RCTWKWebView.h */,
|
E91B351A21446E6C00F9801F /* RNCWKWebView.h */,
|
||||||
E91B351C21446E6C00F9801F /* RCTWKWebView.m */,
|
E91B351C21446E6C00F9801F /* RNCWKWebView.m */,
|
||||||
E91B351921446E6C00F9801F /* RCTWKWebViewManager.h */,
|
E91B351921446E6C00F9801F /* RNCWKWebViewManager.h */,
|
||||||
E91B351B21446E6C00F9801F /* RCTWKWebViewManager.m */,
|
E91B351B21446E6C00F9801F /* RNCWKWebViewManager.m */,
|
||||||
134814211AA4EA7D00B7C361 /* Products */,
|
134814211AA4EA7D00B7C361 /* Products */,
|
||||||
);
|
);
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -74,9 +74,9 @@
|
|||||||
/* End PBXGroup section */
|
/* End PBXGroup section */
|
||||||
|
|
||||||
/* Begin PBXNativeTarget section */
|
/* Begin PBXNativeTarget section */
|
||||||
58B511DA1A9E6C8500147676 /* RCTWebView */ = {
|
58B511DA1A9E6C8500147676 /* RNCWebView */ = {
|
||||||
isa = PBXNativeTarget;
|
isa = PBXNativeTarget;
|
||||||
buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RCTWebView" */;
|
buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNCWebView" */;
|
||||||
buildPhases = (
|
buildPhases = (
|
||||||
58B511D71A9E6C8500147676 /* Sources */,
|
58B511D71A9E6C8500147676 /* Sources */,
|
||||||
58B511D81A9E6C8500147676 /* Frameworks */,
|
58B511D81A9E6C8500147676 /* Frameworks */,
|
||||||
@ -86,9 +86,9 @@
|
|||||||
);
|
);
|
||||||
dependencies = (
|
dependencies = (
|
||||||
);
|
);
|
||||||
name = RCTWebView;
|
name = RNCWebView;
|
||||||
productName = RCTDataManager;
|
productName = RCTDataManager;
|
||||||
productReference = 134814201AA4EA6300B7C361 /* libRCTWebView.a */;
|
productReference = 134814201AA4EA6300B7C361 /* libRNCWebView.a */;
|
||||||
productType = "com.apple.product-type.library.static";
|
productType = "com.apple.product-type.library.static";
|
||||||
};
|
};
|
||||||
/* End PBXNativeTarget section */
|
/* End PBXNativeTarget section */
|
||||||
@ -105,7 +105,7 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RCTWebView" */;
|
buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNCWebView" */;
|
||||||
compatibilityVersion = "Xcode 3.2";
|
compatibilityVersion = "Xcode 3.2";
|
||||||
developmentRegion = English;
|
developmentRegion = English;
|
||||||
hasScannedForEncodings = 0;
|
hasScannedForEncodings = 0;
|
||||||
@ -117,7 +117,7 @@
|
|||||||
projectDirPath = "";
|
projectDirPath = "";
|
||||||
projectRoot = "";
|
projectRoot = "";
|
||||||
targets = (
|
targets = (
|
||||||
58B511DA1A9E6C8500147676 /* RCTWebView */,
|
58B511DA1A9E6C8500147676 /* RNCWebView */,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
/* End PBXProject section */
|
/* End PBXProject section */
|
||||||
@ -127,10 +127,10 @@
|
|||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
E91B351D21446E6C00F9801F /* RCTWKWebViewManager.m in Sources */,
|
E91B351D21446E6C00F9801F /* RNCWKWebViewManager.m in Sources */,
|
||||||
E914DBF7214474710071092B /* RCTUIWebView.m in Sources */,
|
E914DBF7214474710071092B /* RNCUIWebView.m in Sources */,
|
||||||
E914DBF6214474710071092B /* RCTUIWebViewManager.m in Sources */,
|
E914DBF6214474710071092B /* RNCUIWebViewManager.m in Sources */,
|
||||||
E91B351E21446E6C00F9801F /* RCTWKWebView.m in Sources */,
|
E91B351E21446E6C00F9801F /* RNCWKWebView.m in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@ -229,7 +229,7 @@
|
|||||||
);
|
);
|
||||||
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
||||||
OTHER_LDFLAGS = "-ObjC";
|
OTHER_LDFLAGS = "-ObjC";
|
||||||
PRODUCT_NAME = RCTWebView;
|
PRODUCT_NAME = RNCWebView;
|
||||||
SKIP_INSTALL = YES;
|
SKIP_INSTALL = YES;
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
@ -245,7 +245,7 @@
|
|||||||
);
|
);
|
||||||
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
||||||
OTHER_LDFLAGS = "-ObjC";
|
OTHER_LDFLAGS = "-ObjC";
|
||||||
PRODUCT_NAME = RCTWebView;
|
PRODUCT_NAME = RNCWebView;
|
||||||
SKIP_INSTALL = YES;
|
SKIP_INSTALL = YES;
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
@ -253,7 +253,7 @@
|
|||||||
/* End XCBuildConfiguration section */
|
/* End XCBuildConfiguration section */
|
||||||
|
|
||||||
/* Begin XCConfigurationList section */
|
/* Begin XCConfigurationList section */
|
||||||
58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RCTWebView" */ = {
|
58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNCWebView" */ = {
|
||||||
isa = XCConfigurationList;
|
isa = XCConfigurationList;
|
||||||
buildConfigurations = (
|
buildConfigurations = (
|
||||||
58B511ED1A9E6C8500147676 /* Debug */,
|
58B511ED1A9E6C8500147676 /* Debug */,
|
||||||
@ -262,7 +262,7 @@
|
|||||||
defaultConfigurationIsVisible = 0;
|
defaultConfigurationIsVisible = 0;
|
||||||
defaultConfigurationName = Release;
|
defaultConfigurationName = Release;
|
||||||
};
|
};
|
||||||
58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RCTWebView" */ = {
|
58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNCWebView" */ = {
|
||||||
isa = XCConfigurationList;
|
isa = XCConfigurationList;
|
||||||
buildConfigurations = (
|
buildConfigurations = (
|
||||||
58B511F01A9E6C8500147676 /* Debug */,
|
58B511F01A9E6C8500147676 /* Debug */,
|
@ -3,7 +3,6 @@
|
|||||||
<Workspace
|
<Workspace
|
||||||
version = "1.0">
|
version = "1.0">
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "group:RCTWebView.xcodeproj">
|
location = "group:RNCWebView.xcodeproj">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
</Workspace>
|
</Workspace>
|
||||||
|
|
@ -15,9 +15,9 @@ import { requireNativeComponent } from 'react-native';
|
|||||||
|
|
||||||
import type {DataDetectorTypes} from './WebViewTypes';
|
import type {DataDetectorTypes} from './WebViewTypes';
|
||||||
|
|
||||||
const RCTWKWebView = requireNativeComponent('RCTWKWebView');
|
const RNCWKWebView = requireNativeComponent('RNCWKWebView');
|
||||||
|
|
||||||
type RCTWKWebViewProps = $ReadOnly<{|
|
type RNCWKWebViewProps = $ReadOnly<{|
|
||||||
allowsInlineMediaPlayback?: ?boolean,
|
allowsInlineMediaPlayback?: ?boolean,
|
||||||
mediaPlaybackRequiresUserAction?: ?boolean,
|
mediaPlaybackRequiresUserAction?: ?boolean,
|
||||||
dataDetectorTypes?:
|
dataDetectorTypes?:
|
||||||
@ -25,21 +25,21 @@ type RCTWKWebViewProps = $ReadOnly<{|
|
|||||||
| $ReadOnlyArray<DataDetectorTypes>,
|
| $ReadOnlyArray<DataDetectorTypes>,
|
||||||
|}>;
|
|}>;
|
||||||
|
|
||||||
class WKWebView extends React.Component<RCTWKWebViewProps> {
|
class WKWebView extends React.Component<RNCWKWebViewProps> {
|
||||||
componentWillReceiveProps(nextProps: RCTWKWebViewProps) {
|
componentWillReceiveProps(nextProps: RNCWKWebViewProps) {
|
||||||
this.showRedboxOnPropChanges(nextProps, 'allowsInlineMediaPlayback');
|
this.showRedboxOnPropChanges(nextProps, 'allowsInlineMediaPlayback');
|
||||||
this.showRedboxOnPropChanges(nextProps, 'mediaPlaybackRequiresUserAction');
|
this.showRedboxOnPropChanges(nextProps, 'mediaPlaybackRequiresUserAction');
|
||||||
this.showRedboxOnPropChanges(nextProps, 'dataDetectorTypes');
|
this.showRedboxOnPropChanges(nextProps, 'dataDetectorTypes');
|
||||||
}
|
}
|
||||||
|
|
||||||
showRedboxOnPropChanges(nextProps: RCTWKWebViewProps, propName: string) {
|
showRedboxOnPropChanges(nextProps: RNCWKWebViewProps, propName: string) {
|
||||||
if (this.props[propName] !== nextProps[propName]) {
|
if (this.props[propName] !== nextProps[propName]) {
|
||||||
console.error(`Changes to property ${propName} do nothing after the initial render.`);
|
console.error(`Changes to property ${propName} do nothing after the initial render.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return <RCTWKWebView {...this.props} />;
|
return <RNCWKWebView {...this.props} />;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,11 +51,10 @@ function processDecelerationRate(decelerationRate) {
|
|||||||
return decelerationRate;
|
return decelerationRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
const RCTUIWebViewManager = NativeModules.UIWebViewManager;
|
const RNCUIWebViewManager = NativeModules.RNCUIWebViewManager;
|
||||||
const RCTWKWebViewManager = NativeModules.WKWebViewManager;
|
const RNCWKWebViewManager = NativeModules.RNCWKWebViewManager;
|
||||||
|
|
||||||
const BGWASH = 'rgba(255,255,255,0.8)';
|
const BGWASH = 'rgba(255,255,255,0.8)';
|
||||||
const RCT_WEBVIEW_REF = 'webview';
|
|
||||||
|
|
||||||
const WebViewState = keyMirror({
|
const WebViewState = keyMirror({
|
||||||
IDLE: null,
|
IDLE: null,
|
||||||
@ -143,6 +142,8 @@ class WebView extends React.Component<WebViewSharedProps, State> {
|
|||||||
startInLoadingState: true,
|
startInLoadingState: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
webViewRef = React.createRef();
|
||||||
|
|
||||||
UNSAFE_componentWillMount() {
|
UNSAFE_componentWillMount() {
|
||||||
if (this.props.startInLoadingState) {
|
if (this.props.startInLoadingState) {
|
||||||
this.setState({ viewState: WebViewState.LOADING });
|
this.setState({ viewState: WebViewState.LOADING });
|
||||||
@ -181,7 +182,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
|
|||||||
);
|
);
|
||||||
} else if (this.state.viewState !== WebViewState.IDLE) {
|
} else if (this.state.viewState !== WebViewState.IDLE) {
|
||||||
console.error(
|
console.error(
|
||||||
'RCTWebView invalid state encountered: ' + this.state.viewState,
|
'RNCWebView invalid state encountered: ' + this.state.viewState,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,9 +200,9 @@ class WebView extends React.Component<WebViewSharedProps, State> {
|
|||||||
let viewManager = nativeConfig.viewManager;
|
let viewManager = nativeConfig.viewManager;
|
||||||
|
|
||||||
if (this.props.useWebKit) {
|
if (this.props.useWebKit) {
|
||||||
viewManager = viewManager || RCTWKWebViewManager;
|
viewManager = viewManager || RNCWKWebViewManager;
|
||||||
} else {
|
} else {
|
||||||
viewManager = viewManager || RCTUIWebViewManager;
|
viewManager = viewManager || RNCUIWebViewManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
const compiledWhitelist = [
|
const compiledWhitelist = [
|
||||||
@ -247,14 +248,14 @@ class WebView extends React.Component<WebViewSharedProps, State> {
|
|||||||
let NativeWebView = nativeConfig.component;
|
let NativeWebView = nativeConfig.component;
|
||||||
|
|
||||||
if (this.props.useWebKit) {
|
if (this.props.useWebKit) {
|
||||||
NativeWebView = NativeWebView || RCTWKWebView;
|
NativeWebView = NativeWebView || RNCWKWebView;
|
||||||
} else {
|
} else {
|
||||||
NativeWebView = NativeWebView || RCTWebView;
|
NativeWebView = NativeWebView || RNCUIWebView;
|
||||||
}
|
}
|
||||||
|
|
||||||
const webView = (
|
const webView = (
|
||||||
<NativeWebView
|
<NativeWebView
|
||||||
ref={RCT_WEBVIEW_REF}
|
ref={this.webViewRef}
|
||||||
key="webViewKey"
|
key="webViewKey"
|
||||||
style={webViewStyles}
|
style={webViewStyles}
|
||||||
source={resolveAssetSource(source)}
|
source={resolveAssetSource(source)}
|
||||||
@ -292,10 +293,10 @@ class WebView extends React.Component<WebViewSharedProps, State> {
|
|||||||
|
|
||||||
_getCommands() {
|
_getCommands() {
|
||||||
if (!this.props.useWebKit) {
|
if (!this.props.useWebKit) {
|
||||||
return UIManager.RCTWebView.Commands;
|
return UIManager.RNCUIWebView.Commands;
|
||||||
}
|
}
|
||||||
|
|
||||||
return UIManager.RCTWKWebView.Commands;
|
return UIManager.RNCWKWebView.Commands;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -389,7 +390,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
|
|||||||
* Returns the native `WebView` node.
|
* Returns the native `WebView` node.
|
||||||
*/
|
*/
|
||||||
getWebViewHandle = () => {
|
getWebViewHandle = () => {
|
||||||
return ReactNative.findNodeHandle(this.refs[RCT_WEBVIEW_REF]);
|
return ReactNative.findNodeHandle(this.webViewRef.current);
|
||||||
};
|
};
|
||||||
|
|
||||||
_onLoadingStart = (event: WebViewNavigationEvent) => {
|
_onLoadingStart = (event: WebViewNavigationEvent) => {
|
||||||
@ -451,8 +452,8 @@ class WebView extends React.Component<WebViewSharedProps, State> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const RCTWebView = requireNativeComponent('RCTWebView');
|
const RNCUIWebView = requireNativeComponent('RNCUIWebView');
|
||||||
const RCTWKWebView = requireNativeComponent('RCTWKWebView');
|
const RNCWKWebView = requireNativeComponent('RNCWKWebView');
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user