|
@@ -5,16 +5,16 @@
|
5
|
5
|
* LICENSE file in the root directory of this source tree.
|
6
|
6
|
*/
|
7
|
7
|
|
8
|
|
-#import "RCTWKWebViewManager.h"
|
|
8
|
+#import "RNCWKWebViewManager.h"
|
9
|
9
|
|
10
|
10
|
#import <React/RCTUIManager.h>
|
11
|
11
|
#import <React/RCTDefines.h>
|
12
|
|
-#import "RCTWKWebView.h"
|
|
12
|
+#import "RNCWKWebView.h"
|
13
|
13
|
|
14
|
|
-@interface RCTWKWebViewManager () <RCTWKWebViewDelegate>
|
|
14
|
+@interface RNCWKWebViewManager () <RNCWKWebViewDelegate>
|
15
|
15
|
@end
|
16
|
16
|
|
17
|
|
-@implementation RCTWKWebViewManager
|
|
17
|
+@implementation RNCWKWebViewManager
|
18
|
18
|
{
|
19
|
19
|
NSConditionLock *_shouldStartLoadLock;
|
20
|
20
|
BOOL _shouldStartLoad;
|
|
@@ -24,7 +24,7 @@ RCT_EXPORT_MODULE()
|
24
|
24
|
|
25
|
25
|
- (UIView *)view
|
26
|
26
|
{
|
27
|
|
- RCTWKWebView *webView = [RCTWKWebView new];
|
|
27
|
+ RNCWKWebView *webView = [RNCWKWebView new];
|
28
|
28
|
webView.delegate = self;
|
29
|
29
|
return webView;
|
30
|
30
|
}
|
|
@@ -51,34 +51,34 @@ RCT_EXPORT_VIEW_PROPERTY(onMessage, RCTDirectEventBlock)
|
51
|
51
|
|
52
|
52
|
RCT_EXPORT_METHOD(postMessage:(nonnull NSNumber *)reactTag message:(NSString *)message)
|
53
|
53
|
{
|
54
|
|
- [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWKWebView *> *viewRegistry) {
|
55
|
|
- RCTWKWebView *view = viewRegistry[reactTag];
|
56
|
|
- if (![view isKindOfClass:[RCTWKWebView class]]) {
|
57
|
|
- RCTLogError(@"Invalid view returned from registry, expecting RCTWebView, got: %@", view);
|
|
54
|
+ [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCWKWebView *> *viewRegistry) {
|
|
55
|
+ RNCWKWebView *view = viewRegistry[reactTag];
|
|
56
|
+ if (![view isKindOfClass:[RNCWKWebView class]]) {
|
|
57
|
+ RCTLogError(@"Invalid view returned from registry, expecting RNCWKWebView, got: %@", view);
|
58
|
58
|
} else {
|
59
|
59
|
[view postMessage:message];
|
60
|
60
|
}
|
61
|
61
|
}];
|
62
|
62
|
}
|
63
|
63
|
|
64
|
|
-RCT_CUSTOM_VIEW_PROPERTY(bounces, BOOL, RCTWKWebView) {
|
|
64
|
+RCT_CUSTOM_VIEW_PROPERTY(bounces, BOOL, RNCWKWebView) {
|
65
|
65
|
view.bounces = json == nil ? true : [RCTConvert BOOL: json];
|
66
|
66
|
}
|
67
|
67
|
|
68
|
|
-RCT_CUSTOM_VIEW_PROPERTY(scrollEnabled, BOOL, RCTWKWebView) {
|
|
68
|
+RCT_CUSTOM_VIEW_PROPERTY(scrollEnabled, BOOL, RNCWKWebView) {
|
69
|
69
|
view.scrollEnabled = json == nil ? true : [RCTConvert BOOL: json];
|
70
|
70
|
}
|
71
|
71
|
|
72
|
|
-RCT_CUSTOM_VIEW_PROPERTY(decelerationRate, CGFloat, RCTWKWebView) {
|
|
72
|
+RCT_CUSTOM_VIEW_PROPERTY(decelerationRate, CGFloat, RNCWKWebView) {
|
73
|
73
|
view.decelerationRate = json == nil ? UIScrollViewDecelerationRateNormal : [RCTConvert CGFloat: json];
|
74
|
74
|
}
|
75
|
75
|
|
76
|
76
|
RCT_EXPORT_METHOD(injectJavaScript:(nonnull NSNumber *)reactTag script:(NSString *)script)
|
77
|
77
|
{
|
78
|
|
- [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWKWebView *> *viewRegistry) {
|
79
|
|
- RCTWKWebView *view = viewRegistry[reactTag];
|
80
|
|
- if (![view isKindOfClass:[RCTWKWebView class]]) {
|
81
|
|
- RCTLogError(@"Invalid view returned from registry, expecting RCTWebView, got: %@", view);
|
|
78
|
+ [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCWKWebView *> *viewRegistry) {
|
|
79
|
+ RNCWKWebView *view = viewRegistry[reactTag];
|
|
80
|
+ if (![view isKindOfClass:[RNCWKWebView class]]) {
|
|
81
|
+ RCTLogError(@"Invalid view returned from registry, expecting RNCWKWebView, got: %@", view);
|
82
|
82
|
} else {
|
83
|
83
|
[view injectJavaScript:script];
|
84
|
84
|
}
|
|
@@ -87,10 +87,10 @@ RCT_EXPORT_METHOD(injectJavaScript:(nonnull NSNumber *)reactTag script:(NSString
|
87
|
87
|
|
88
|
88
|
RCT_EXPORT_METHOD(goBack:(nonnull NSNumber *)reactTag)
|
89
|
89
|
{
|
90
|
|
- [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWKWebView *> *viewRegistry) {
|
91
|
|
- RCTWKWebView *view = viewRegistry[reactTag];
|
92
|
|
- if (![view isKindOfClass:[RCTWKWebView class]]) {
|
93
|
|
- RCTLogError(@"Invalid view returned from registry, expecting RCTWebView, got: %@", view);
|
|
90
|
+ [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCWKWebView *> *viewRegistry) {
|
|
91
|
+ RNCWKWebView *view = viewRegistry[reactTag];
|
|
92
|
+ if (![view isKindOfClass:[RNCWKWebView class]]) {
|
|
93
|
+ RCTLogError(@"Invalid view returned from registry, expecting RNCWKWebView, got: %@", view);
|
94
|
94
|
} else {
|
95
|
95
|
[view goBack];
|
96
|
96
|
}
|
|
@@ -99,10 +99,10 @@ RCT_EXPORT_METHOD(goBack:(nonnull NSNumber *)reactTag)
|
99
|
99
|
|
100
|
100
|
RCT_EXPORT_METHOD(goForward:(nonnull NSNumber *)reactTag)
|
101
|
101
|
{
|
102
|
|
- [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWKWebView *> *viewRegistry) {
|
103
|
|
- RCTWKWebView *view = viewRegistry[reactTag];
|
104
|
|
- if (![view isKindOfClass:[RCTWKWebView class]]) {
|
105
|
|
- RCTLogError(@"Invalid view returned from registry, expecting RCTWebView, got: %@", view);
|
|
102
|
+ [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCWKWebView *> *viewRegistry) {
|
|
103
|
+ RNCWKWebView *view = viewRegistry[reactTag];
|
|
104
|
+ if (![view isKindOfClass:[RNCWKWebView class]]) {
|
|
105
|
+ RCTLogError(@"Invalid view returned from registry, expecting RNCWKWebView, got: %@", view);
|
106
|
106
|
} else {
|
107
|
107
|
[view goForward];
|
108
|
108
|
}
|
|
@@ -111,10 +111,10 @@ RCT_EXPORT_METHOD(goForward:(nonnull NSNumber *)reactTag)
|
111
|
111
|
|
112
|
112
|
RCT_EXPORT_METHOD(reload:(nonnull NSNumber *)reactTag)
|
113
|
113
|
{
|
114
|
|
- [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWKWebView *> *viewRegistry) {
|
115
|
|
- RCTWKWebView *view = viewRegistry[reactTag];
|
116
|
|
- if (![view isKindOfClass:[RCTWKWebView class]]) {
|
117
|
|
- RCTLogError(@"Invalid view returned from registry, expecting RCTWebView, got: %@", view);
|
|
114
|
+ [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCWKWebView *> *viewRegistry) {
|
|
115
|
+ RNCWKWebView *view = viewRegistry[reactTag];
|
|
116
|
+ if (![view isKindOfClass:[RNCWKWebView class]]) {
|
|
117
|
+ RCTLogError(@"Invalid view returned from registry, expecting RNCWKWebView, got: %@", view);
|
118
|
118
|
} else {
|
119
|
119
|
[view reload];
|
120
|
120
|
}
|
|
@@ -123,10 +123,10 @@ RCT_EXPORT_METHOD(reload:(nonnull NSNumber *)reactTag)
|
123
|
123
|
|
124
|
124
|
RCT_EXPORT_METHOD(stopLoading:(nonnull NSNumber *)reactTag)
|
125
|
125
|
{
|
126
|
|
- [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWKWebView *> *viewRegistry) {
|
127
|
|
- RCTWKWebView *view = viewRegistry[reactTag];
|
128
|
|
- if (![view isKindOfClass:[RCTWKWebView class]]) {
|
129
|
|
- RCTLogError(@"Invalid view returned from registry, expecting RCTWebView, got: %@", view);
|
|
126
|
+ [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCWKWebView *> *viewRegistry) {
|
|
127
|
+ RNCWKWebView *view = viewRegistry[reactTag];
|
|
128
|
+ if (![view isKindOfClass:[RNCWKWebView class]]) {
|
|
129
|
+ RCTLogError(@"Invalid view returned from registry, expecting RNCWKWebView, got: %@", view);
|
130
|
130
|
} else {
|
131
|
131
|
[view stopLoading];
|
132
|
132
|
}
|
|
@@ -135,7 +135,7 @@ RCT_EXPORT_METHOD(stopLoading:(nonnull NSNumber *)reactTag)
|
135
|
135
|
|
136
|
136
|
#pragma mark - Exported synchronous methods
|
137
|
137
|
|
138
|
|
-- (BOOL) webView:(RCTWKWebView *)webView
|
|
138
|
+- (BOOL) webView:(RNCWKWebView *)webView
|
139
|
139
|
shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
|
140
|
140
|
withCallback:(RCTDirectEventBlock)callback
|
141
|
141
|
{
|