Browse Source

Rename back to RCT

Jamon Holmgren 6 years ago
parent
commit
e9a6c6134f

ios/IRWebView.h → ios/RCTWebView.h View File

@@ -7,7 +7,7 @@
7 7
 
8 8
 #import <React/RCTView.h>
9 9
 
10
-@class IRWebView;
10
+@class RCTWebView;
11 11
 
12 12
 /**
13 13
  * Special scheme used to pass messages to the injectedJavaScript
@@ -17,17 +17,17 @@
17 17
  */
18 18
 extern NSString *const RCTJSNavigationScheme;
19 19
 
20
-@protocol IRWebViewDelegate <NSObject>
20
+@protocol RCTWebViewDelegate <NSObject>
21 21
 
22
-- (BOOL)webView:(IRWebView *)webView
22
+- (BOOL)webView:(RCTWebView *)webView
23 23
 shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
24 24
    withCallback:(RCTDirectEventBlock)callback;
25 25
 
26 26
 @end
27 27
 
28
-@interface IRWebView : RCTView
28
+@interface RCTWebView : RCTView
29 29
 
30
-@property (nonatomic, weak) id<IRWebViewDelegate> delegate;
30
+@property (nonatomic, weak) id<RCTWebViewDelegate> delegate;
31 31
 
32 32
 @property (nonatomic, copy) NSDictionary *source;
33 33
 @property (nonatomic, assign) UIEdgeInsets contentInset;

ios/IRWebView.m → ios/RCTWebView.m View File

@@ -5,7 +5,7 @@
5 5
  * LICENSE file in the root directory of this source tree.
6 6
  */
7 7
 
8
-#import "IRWebView.h"
8
+#import "RCTWebView.h"
9 9
 
10 10
 #import <UIKit/UIKit.h>
11 11
 
@@ -21,7 +21,7 @@ NSString *const RCTJSNavigationScheme = @"react-js-navigation";
21 21
 
22 22
 static NSString *const kPostMessageHost = @"postMessage";
23 23
 
24
-@interface IRWebView () <UIWebViewDelegate, RCTAutoInsetsProtocol>
24
+@interface RCTWebView () <UIWebViewDelegate, RCTAutoInsetsProtocol>
25 25
 
26 26
 @property (nonatomic, copy) RCTDirectEventBlock onLoadingStart;
27 27
 @property (nonatomic, copy) RCTDirectEventBlock onLoadingFinish;
@@ -31,7 +31,7 @@ static NSString *const kPostMessageHost = @"postMessage";
31 31
 
32 32
 @end
33 33
 
34
-@implementation IRWebView
34
+@implementation RCTWebView
35 35
 {
36 36
   UIWebView *_webView;
37 37
   NSString *_injectedJavaScript;

ios/IRWebView.podspec → ios/RCTWebView.podspec View File

@@ -1,18 +1,18 @@
1 1
 
2 2
 Pod::Spec.new do |s|
3
-  s.name         = "IRWebView"
3
+  s.name         = "RCTWebView"
4 4
   s.version      = "1.0.0"
5
-  s.summary      = "IRWebView"
5
+  s.summary      = "RCTWebView"
6 6
   s.description  = <<-DESC
7
-                  IRWebView
7
+                  RCTWebView
8 8
                    DESC
9 9
   s.homepage     = ""
10 10
   s.license      = "MIT"
11 11
   # s.license      = { :type => "MIT", :file => "FILE_LICENSE" }
12 12
   s.author             = { "author" => "author@domain.cn" }
13 13
   s.platform     = :ios, "7.0"
14
-  s.source       = { :git => "https://github.com/author/IRWebView.git", :tag => "master" }
15
-  s.source_files  = "IRWebView/**/*.{h,m}"
14
+  s.source       = { :git => "https://github.com/author/RCTWebView.git", :tag => "master" }
15
+  s.source_files  = "RCTWebView/**/*.{h,m}"
16 16
   s.requires_arc = true
17 17
 
18 18
 

ios/IRWebView.xcodeproj/project.pbxproj → ios/RCTWebView.xcodeproj/project.pbxproj View File

@@ -7,7 +7,7 @@
7 7
 	objects = {
8 8
 
9 9
 /* Begin PBXBuildFile section */
10
-		B3E7B58A1CC2AC0600A0062D /* IRWebView.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* IRWebView.m */; };
10
+		B3E7B58A1CC2AC0600A0062D /* RCTWebView.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* RCTWebView.m */; };
11 11
 /* End PBXBuildFile section */
12 12
 
13 13
 /* Begin PBXCopyFilesBuildPhase section */
@@ -23,9 +23,9 @@
23 23
 /* End PBXCopyFilesBuildPhase section */
24 24
 
25 25
 /* Begin PBXFileReference section */
26
-		134814201AA4EA6300B7C361 /* libIRWebView.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libIRWebView.a; sourceTree = BUILT_PRODUCTS_DIR; };
27
-		B3E7B5881CC2AC0600A0062D /* IRWebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IRWebView.h; sourceTree = "<group>"; };
28
-		B3E7B5891CC2AC0600A0062D /* IRWebView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IRWebView.m; sourceTree = "<group>"; };
26
+		134814201AA4EA6300B7C361 /* libRCTWebView.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTWebView.a; sourceTree = BUILT_PRODUCTS_DIR; };
27
+		B3E7B5881CC2AC0600A0062D /* RCTWebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTWebView.h; sourceTree = "<group>"; };
28
+		B3E7B5891CC2AC0600A0062D /* RCTWebView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTWebView.m; sourceTree = "<group>"; };
29 29
 /* End PBXFileReference section */
30 30
 
31 31
 /* Begin PBXFrameworksBuildPhase section */
@@ -42,7 +42,7 @@
42 42
 		134814211AA4EA7D00B7C361 /* Products */ = {
43 43
 			isa = PBXGroup;
44 44
 			children = (
45
-				134814201AA4EA6300B7C361 /* libIRWebView.a */,
45
+				134814201AA4EA6300B7C361 /* libRCTWebView.a */,
46 46
 			);
47 47
 			name = Products;
48 48
 			sourceTree = "<group>";
@@ -50,8 +50,8 @@
50 50
 		58B511D21A9E6C8500147676 = {
51 51
 			isa = PBXGroup;
52 52
 			children = (
53
-				B3E7B5881CC2AC0600A0062D /* IRWebView.h */,
54
-				B3E7B5891CC2AC0600A0062D /* IRWebView.m */,
53
+				B3E7B5881CC2AC0600A0062D /* RCTWebView.h */,
54
+				B3E7B5891CC2AC0600A0062D /* RCTWebView.m */,
55 55
 				134814211AA4EA7D00B7C361 /* Products */,
56 56
 			);
57 57
 			sourceTree = "<group>";
@@ -59,9 +59,9 @@
59 59
 /* End PBXGroup section */
60 60
 
61 61
 /* Begin PBXNativeTarget section */
62
-		58B511DA1A9E6C8500147676 /* IRWebView */ = {
62
+		58B511DA1A9E6C8500147676 /* RCTWebView */ = {
63 63
 			isa = PBXNativeTarget;
64
-			buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "IRWebView" */;
64
+			buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RCTWebView" */;
65 65
 			buildPhases = (
66 66
 				58B511D71A9E6C8500147676 /* Sources */,
67 67
 				58B511D81A9E6C8500147676 /* Frameworks */,
@@ -71,9 +71,9 @@
71 71
 			);
72 72
 			dependencies = (
73 73
 			);
74
-			name = IRWebView;
74
+			name = RCTWebView;
75 75
 			productName = RCTDataManager;
76
-			productReference = 134814201AA4EA6300B7C361 /* libIRWebView.a */;
76
+			productReference = 134814201AA4EA6300B7C361 /* libRCTWebView.a */;
77 77
 			productType = "com.apple.product-type.library.static";
78 78
 		};
79 79
 /* End PBXNativeTarget section */
@@ -90,7 +90,7 @@
90 90
 					};
91 91
 				};
92 92
 			};
93
-			buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "IRWebView" */;
93
+			buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RCTWebView" */;
94 94
 			compatibilityVersion = "Xcode 3.2";
95 95
 			developmentRegion = English;
96 96
 			hasScannedForEncodings = 0;
@@ -102,7 +102,7 @@
102 102
 			projectDirPath = "";
103 103
 			projectRoot = "";
104 104
 			targets = (
105
-				58B511DA1A9E6C8500147676 /* IRWebView */,
105
+				58B511DA1A9E6C8500147676 /* RCTWebView */,
106 106
 			);
107 107
 		};
108 108
 /* End PBXProject section */
@@ -112,7 +112,7 @@
112 112
 			isa = PBXSourcesBuildPhase;
113 113
 			buildActionMask = 2147483647;
114 114
 			files = (
115
-				B3E7B58A1CC2AC0600A0062D /* IRWebView.m in Sources */,
115
+				B3E7B58A1CC2AC0600A0062D /* RCTWebView.m in Sources */,
116 116
 			);
117 117
 			runOnlyForDeploymentPostprocessing = 0;
118 118
 		};
@@ -211,7 +211,7 @@
211 211
 				);
212 212
 				LIBRARY_SEARCH_PATHS = "$(inherited)";
213 213
 				OTHER_LDFLAGS = "-ObjC";
214
-				PRODUCT_NAME = IRWebView;
214
+				PRODUCT_NAME = RCTWebView;
215 215
 				SKIP_INSTALL = YES;
216 216
 			};
217 217
 			name = Debug;
@@ -227,7 +227,7 @@
227 227
 				);
228 228
 				LIBRARY_SEARCH_PATHS = "$(inherited)";
229 229
 				OTHER_LDFLAGS = "-ObjC";
230
-				PRODUCT_NAME = IRWebView;
230
+				PRODUCT_NAME = RCTWebView;
231 231
 				SKIP_INSTALL = YES;
232 232
 			};
233 233
 			name = Release;
@@ -235,7 +235,7 @@
235 235
 /* End XCBuildConfiguration section */
236 236
 
237 237
 /* Begin XCConfigurationList section */
238
-		58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "IRWebView" */ = {
238
+		58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RCTWebView" */ = {
239 239
 			isa = XCConfigurationList;
240 240
 			buildConfigurations = (
241 241
 				58B511ED1A9E6C8500147676 /* Debug */,
@@ -244,7 +244,7 @@
244 244
 			defaultConfigurationIsVisible = 0;
245 245
 			defaultConfigurationName = Release;
246 246
 		};
247
-		58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "IRWebView" */ = {
247
+		58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RCTWebView" */ = {
248 248
 			isa = XCConfigurationList;
249 249
 			buildConfigurations = (
250 250
 				58B511F01A9E6C8500147676 /* Debug */,

ios/IRWebView.xcworkspace/contents.xcworkspacedata → ios/RCTWebView.xcworkspace/contents.xcworkspacedata View File

@@ -3,7 +3,7 @@
3 3
 <Workspace
4 4
    version = "1.0">
5 5
    <FileRef
6
-      location = "group:IRWebView.xcodeproj">
6
+      location = "group:RCTWebView.xcodeproj">
7 7
    </FileRef>
8 8
 </Workspace>
9 9
   

ios/IRWebViewManager.h → ios/RCTWebViewManager.h View File

@@ -5,8 +5,8 @@
5 5
  * LICENSE file in the root directory of this source tree.
6 6
  */
7 7
 
8
-#import <React/IRViewManager.h>
8
+#import <React/RCTViewManager.h>
9 9
 
10
-@interface IRWebViewManager : IRViewManager
10
+@interface RCTWebViewManager : RCTViewManager
11 11
 
12 12
 @end

ios/IRWebViewManager.m → ios/RCTWebViewManager.m View File

@@ -5,18 +5,18 @@
5 5
  * LICENSE file in the root directory of this source tree.
6 6
  */
7 7
 
8
-#import "IRWebViewManager.h"
8
+#import "RCTWebViewManager.h"
9 9
 
10 10
 #import "RCTBridge.h"
11 11
 #import "RCTUIManager.h"
12
-#import "IRWebView.h"
12
+#import "RCTWebView.h"
13 13
 #import "UIView+React.h"
14 14
 
15
-@interface IRWebViewManager () <IRWebViewDelegate>
15
+@interface RCTWebViewManager () <RCTWebViewDelegate>
16 16
 
17 17
 @end
18 18
 
19
-@implementation IRWebViewManager
19
+@implementation RCTWebViewManager
20 20
 {
21 21
   NSConditionLock *_shouldStartLoadLock;
22 22
   BOOL _shouldStartLoad;
@@ -26,7 +26,7 @@ RCT_EXPORT_MODULE()
26 26
 
27 27
 - (UIView *)view
28 28
 {
29
-  IRWebView *webView = [IRWebView new];
29
+  RCTWebView *webView = [RCTWebView new];
30 30
   webView.delegate = self;
31 31
   return webView;
32 32
 }
@@ -51,10 +51,10 @@ RCT_REMAP_VIEW_PROPERTY(dataDetectorTypes, _webView.dataDetectorTypes, UIDataDet
51 51
 
52 52
 RCT_EXPORT_METHOD(goBack:(nonnull NSNumber *)reactTag)
53 53
 {
54
-  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, IRWebView *> *viewRegistry) {
55
-    IRWebView *view = viewRegistry[reactTag];
56
-    if (![view isKindOfClass:[IRWebView class]]) {
57
-      RCTLogError(@"Invalid view returned from registry, expecting IRWebView, got: %@", view);
54
+  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWebView *> *viewRegistry) {
55
+    RCTWebView *view = viewRegistry[reactTag];
56
+    if (![view isKindOfClass:[RCTWebView class]]) {
57
+      RCTLogError(@"Invalid view returned from registry, expecting RCTWebView, got: %@", view);
58 58
     } else {
59 59
       [view goBack];
60 60
     }
@@ -65,8 +65,8 @@ RCT_EXPORT_METHOD(goForward:(nonnull NSNumber *)reactTag)
65 65
 {
66 66
   [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
67 67
     id view = viewRegistry[reactTag];
68
-    if (![view isKindOfClass:[IRWebView class]]) {
69
-      RCTLogError(@"Invalid view returned from registry, expecting IRWebView, got: %@", view);
68
+    if (![view isKindOfClass:[RCTWebView class]]) {
69
+      RCTLogError(@"Invalid view returned from registry, expecting RCTWebView, got: %@", view);
70 70
     } else {
71 71
       [view goForward];
72 72
     }
@@ -75,10 +75,10 @@ RCT_EXPORT_METHOD(goForward:(nonnull NSNumber *)reactTag)
75 75
 
76 76
 RCT_EXPORT_METHOD(reload:(nonnull NSNumber *)reactTag)
77 77
 {
78
-  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, IRWebView *> *viewRegistry) {
79
-    IRWebView *view = viewRegistry[reactTag];
80
-    if (![view isKindOfClass:[IRWebView class]]) {
81
-      RCTLogError(@"Invalid view returned from registry, expecting IRWebView, got: %@", view);
78
+  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWebView *> *viewRegistry) {
79
+    RCTWebView *view = viewRegistry[reactTag];
80
+    if (![view isKindOfClass:[RCTWebView class]]) {
81
+      RCTLogError(@"Invalid view returned from registry, expecting RCTWebView, got: %@", view);
82 82
     } else {
83 83
       [view reload];
84 84
     }
@@ -87,10 +87,10 @@ RCT_EXPORT_METHOD(reload:(nonnull NSNumber *)reactTag)
87 87
 
88 88
 RCT_EXPORT_METHOD(stopLoading:(nonnull NSNumber *)reactTag)
89 89
 {
90
-  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, IRWebView *> *viewRegistry) {
91
-    IRWebView *view = viewRegistry[reactTag];
92
-    if (![view isKindOfClass:[IRWebView class]]) {
93
-      RCTLogError(@"Invalid view returned from registry, expecting IRWebView, got: %@", view);
90
+  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWebView *> *viewRegistry) {
91
+    RCTWebView *view = viewRegistry[reactTag];
92
+    if (![view isKindOfClass:[RCTWebView class]]) {
93
+      RCTLogError(@"Invalid view returned from registry, expecting RCTWebView, got: %@", view);
94 94
     } else {
95 95
       [view stopLoading];
96 96
     }
@@ -99,10 +99,10 @@ RCT_EXPORT_METHOD(stopLoading:(nonnull NSNumber *)reactTag)
99 99
 
100 100
 RCT_EXPORT_METHOD(postMessage:(nonnull NSNumber *)reactTag message:(NSString *)message)
101 101
 {
102
-  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, IRWebView *> *viewRegistry) {
103
-    IRWebView *view = viewRegistry[reactTag];
104
-    if (![view isKindOfClass:[IRWebView class]]) {
105
-      RCTLogError(@"Invalid view returned from registry, expecting IRWebView, got: %@", view);
102
+  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWebView *> *viewRegistry) {
103
+    RCTWebView *view = viewRegistry[reactTag];
104
+    if (![view isKindOfClass:[RCTWebView class]]) {
105
+      RCTLogError(@"Invalid view returned from registry, expecting RCTWebView, got: %@", view);
106 106
     } else {
107 107
       [view postMessage:message];
108 108
     }
@@ -111,10 +111,10 @@ RCT_EXPORT_METHOD(postMessage:(nonnull NSNumber *)reactTag message:(NSString *)m
111 111
 
112 112
 RCT_EXPORT_METHOD(injectJavaScript:(nonnull NSNumber *)reactTag script:(NSString *)script)
113 113
 {
114
-  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, IRWebView *> *viewRegistry) {
115
-    IRWebView *view = viewRegistry[reactTag];
116
-    if (![view isKindOfClass:[IRWebView class]]) {
117
-      RCTLogError(@"Invalid view returned from registry, expecting IRWebView, got: %@", view);
114
+  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWebView *> *viewRegistry) {
115
+    RCTWebView *view = viewRegistry[reactTag];
116
+    if (![view isKindOfClass:[RCTWebView class]]) {
117
+      RCTLogError(@"Invalid view returned from registry, expecting RCTWebView, got: %@", view);
118 118
     } else {
119 119
       [view injectJavaScript:script];
120 120
     }
@@ -123,7 +123,7 @@ RCT_EXPORT_METHOD(injectJavaScript:(nonnull NSNumber *)reactTag script:(NSString
123 123
 
124 124
 #pragma mark - Exported synchronous methods
125 125
 
126
-- (BOOL)webView:(__unused IRWebView *)webView
126
+- (BOOL)webView:(__unused RCTWebView *)webView
127 127
 shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
128 128
    withCallback:(RCTDirectEventBlock)callback
129 129
 {

+ 0
- 46
ios/fb/RCTWebView.h View File

@@ -1,46 +0,0 @@
1
-// /**
2
-//  * Copyright (c) 2015-present, Facebook, Inc.
3
-//  *
4
-//  * This source code is licensed under the MIT license found in the
5
-//  * LICENSE file in the root directory of this source tree.
6
-//  */
7
-
8
-// #import <React/RCTView.h>
9
-
10
-// @class IRWebView;
11
-
12
-// /**
13
-//  * Special scheme used to pass messages to the injectedJavaScript
14
-//  * code without triggering a page load. Usage:
15
-//  *
16
-//  *   window.location.href = RCTJSNavigationScheme + '://hello'
17
-//  */
18
-// extern NSString *const RCTJSNavigationScheme;
19
-
20
-// @protocol IRWebViewDelegate <NSObject>
21
-
22
-// - (BOOL)webView:(IRWebView *)webView
23
-// shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
24
-//    withCallback:(RCTDirectEventBlock)callback;
25
-
26
-// @end
27
-
28
-// @interface IRWebView : RCTView
29
-
30
-// @property (nonatomic, weak) id<IRWebViewDelegate> delegate;
31
-
32
-// @property (nonatomic, copy) NSDictionary *source;
33
-// @property (nonatomic, assign) UIEdgeInsets contentInset;
34
-// @property (nonatomic, assign) BOOL automaticallyAdjustContentInsets;
35
-// @property (nonatomic, assign) BOOL messagingEnabled;
36
-// @property (nonatomic, copy) NSString *injectedJavaScript;
37
-// @property (nonatomic, assign) BOOL scalesPageToFit;
38
-
39
-// - (void)goForward;
40
-// - (void)goBack;
41
-// - (void)reload;
42
-// - (void)stopLoading;
43
-// - (void)postMessage:(NSString *)message;
44
-// - (void)injectJavaScript:(NSString *)script;
45
-
46
-// @end

+ 0
- 351
ios/fb/RCTWebView.m View File

@@ -1,351 +0,0 @@
1
-// /**
2
-//  * Copyright (c) 2015-present, Facebook, Inc.
3
-//  *
4
-//  * This source code is licensed under the MIT license found in the
5
-//  * LICENSE file in the root directory of this source tree.
6
-//  */
7
-
8
-// #import "IRWebView.h"
9
-
10
-// #import <UIKit/UIKit.h>
11
-
12
-// #import "RCTAutoInsetsProtocol.h"
13
-// #import "RCTConvert.h"
14
-// #import "RCTEventDispatcher.h"
15
-// #import "RCTLog.h"
16
-// #import "RCTUtils.h"
17
-// #import "RCTView.h"
18
-// #import "UIView+React.h"
19
-
20
-// NSString *const RCTJSNavigationScheme = @"react-js-navigation";
21
-
22
-// static NSString *const kPostMessageHost = @"postMessage";
23
-
24
-// @interface IRWebView () <UIWebViewDelegate, RCTAutoInsetsProtocol>
25
-
26
-// @property (nonatomic, copy) RCTDirectEventBlock onLoadingStart;
27
-// @property (nonatomic, copy) RCTDirectEventBlock onLoadingFinish;
28
-// @property (nonatomic, copy) RCTDirectEventBlock onLoadingError;
29
-// @property (nonatomic, copy) RCTDirectEventBlock onShouldStartLoadWithRequest;
30
-// @property (nonatomic, copy) RCTDirectEventBlock onMessage;
31
-
32
-// @end
33
-
34
-// @implementation IRWebView
35
-// {
36
-//   UIWebView *_webView;
37
-//   NSString *_injectedJavaScript;
38
-// }
39
-
40
-// - (void)dealloc
41
-// {
42
-//   _webView.delegate = nil;
43
-// }
44
-
45
-// - (instancetype)initWithFrame:(CGRect)frame
46
-// {
47
-//   if ((self = [super initWithFrame:frame])) {
48
-//     super.backgroundColor = [UIColor clearColor];
49
-//     _automaticallyAdjustContentInsets = YES;
50
-//     _contentInset = UIEdgeInsetsZero;
51
-//     _webView = [[UIWebView alloc] initWithFrame:self.bounds];
52
-//     _webView.delegate = self;
53
-// #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */
54
-//     if ([_webView.scrollView respondsToSelector:@selector(setContentInsetAdjustmentBehavior:)]) {
55
-//       _webView.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
56
-//     }
57
-// #endif
58
-//     [self addSubview:_webView];
59
-//   }
60
-//   return self;
61
-// }
62
-
63
-// RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
64
-
65
-// - (void)goForward
66
-// {
67
-//   [_webView goForward];
68
-// }
69
-
70
-// - (void)goBack
71
-// {
72
-//   [_webView goBack];
73
-// }
74
-
75
-// - (void)reload
76
-// {
77
-//   NSURLRequest *request = [RCTConvert NSURLRequest:self.source];
78
-//   if (request.URL && !_webView.request.URL.absoluteString.length) {
79
-//     [_webView loadRequest:request];
80
-//   }
81
-//   else {
82
-//     [_webView reload];
83
-//   }
84
-// }
85
-
86
-// - (void)stopLoading
87
-// {
88
-//   [_webView stopLoading];
89
-// }
90
-
91
-// - (void)postMessage:(NSString *)message
92
-// {
93
-//   NSDictionary *eventInitDict = @{
94
-//     @"data": message,
95
-//   };
96
-//   NSString *source = [NSString
97
-//     stringWithFormat:@"document.dispatchEvent(new MessageEvent('message', %@));",
98
-//     RCTJSONStringify(eventInitDict, NULL)
99
-//   ];
100
-//   [_webView stringByEvaluatingJavaScriptFromString:source];
101
-// }
102
-
103
-// - (void)injectJavaScript:(NSString *)script
104
-// {
105
-//   [_webView stringByEvaluatingJavaScriptFromString:script];
106
-// }
107
-
108
-// - (void)setSource:(NSDictionary *)source
109
-// {
110
-//   if (![_source isEqualToDictionary:source]) {
111
-//     _source = [source copy];
112
-
113
-//     // Check for a static html source first
114
-//     NSString *html = [RCTConvert NSString:source[@"html"]];
115
-//     if (html) {
116
-//       NSURL *baseURL = [RCTConvert NSURL:source[@"baseUrl"]];
117
-//       if (!baseURL) {
118
-//         baseURL = [NSURL URLWithString:@"about:blank"];
119
-//       }
120
-//       [_webView loadHTMLString:html baseURL:baseURL];
121
-//       return;
122
-//     }
123
-
124
-//     NSURLRequest *request = [RCTConvert NSURLRequest:source];
125
-//     // Because of the way React works, as pages redirect, we actually end up
126
-//     // passing the redirect urls back here, so we ignore them if trying to load
127
-//     // the same url. We'll expose a call to 'reload' to allow a user to load
128
-//     // the existing page.
129
-//     if ([request.URL isEqual:_webView.request.URL]) {
130
-//       return;
131
-//     }
132
-//     if (!request.URL) {
133
-//       // Clear the webview
134
-//       [_webView loadHTMLString:@"" baseURL:nil];
135
-//       return;
136
-//     }
137
-//     [_webView loadRequest:request];
138
-//   }
139
-// }
140
-
141
-// - (void)layoutSubviews
142
-// {
143
-//   [super layoutSubviews];
144
-//   _webView.frame = self.bounds;
145
-// }
146
-
147
-// - (void)setContentInset:(UIEdgeInsets)contentInset
148
-// {
149
-//   _contentInset = contentInset;
150
-//   [RCTView autoAdjustInsetsForView:self
151
-//                     withScrollView:_webView.scrollView
152
-//                       updateOffset:NO];
153
-// }
154
-
155
-// - (void)setScalesPageToFit:(BOOL)scalesPageToFit
156
-// {
157
-//   if (_webView.scalesPageToFit != scalesPageToFit) {
158
-//     _webView.scalesPageToFit = scalesPageToFit;
159
-//     [_webView reload];
160
-//   }
161
-// }
162
-
163
-// - (BOOL)scalesPageToFit
164
-// {
165
-//   return _webView.scalesPageToFit;
166
-// }
167
-
168
-// - (void)setBackgroundColor:(UIColor *)backgroundColor
169
-// {
170
-//   CGFloat alpha = CGColorGetAlpha(backgroundColor.CGColor);
171
-//   self.opaque = _webView.opaque = (alpha == 1.0);
172
-//   _webView.backgroundColor = backgroundColor;
173
-// }
174
-
175
-// - (UIColor *)backgroundColor
176
-// {
177
-//   return _webView.backgroundColor;
178
-// }
179
-
180
-// - (NSMutableDictionary<NSString *, id> *)baseEvent
181
-// {
182
-//   NSMutableDictionary<NSString *, id> *event = [[NSMutableDictionary alloc] initWithDictionary:@{
183
-//     @"url": _webView.request.URL.absoluteString ?: @"",
184
-//     @"loading" : @(_webView.loading),
185
-//     @"title": [_webView stringByEvaluatingJavaScriptFromString:@"document.title"],
186
-//     @"canGoBack": @(_webView.canGoBack),
187
-//     @"canGoForward" : @(_webView.canGoForward),
188
-//   }];
189
-
190
-//   return event;
191
-// }
192
-
193
-// - (void)refreshContentInset
194
-// {
195
-//   [RCTView autoAdjustInsetsForView:self
196
-//                     withScrollView:_webView.scrollView
197
-//                       updateOffset:YES];
198
-// }
199
-
200
-// #pragma mark - UIWebViewDelegate methods
201
-
202
-// - (BOOL)webView:(__unused UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request
203
-//  navigationType:(UIWebViewNavigationType)navigationType
204
-// {
205
-//   BOOL isJSNavigation = [request.URL.scheme isEqualToString:RCTJSNavigationScheme];
206
-
207
-//   static NSDictionary<NSNumber *, NSString *> *navigationTypes;
208
-//   static dispatch_once_t onceToken;
209
-//   dispatch_once(&onceToken, ^{
210
-//     navigationTypes = @{
211
-//       @(UIWebViewNavigationTypeLinkClicked): @"click",
212
-//       @(UIWebViewNavigationTypeFormSubmitted): @"formsubmit",
213
-//       @(UIWebViewNavigationTypeBackForward): @"backforward",
214
-//       @(UIWebViewNavigationTypeReload): @"reload",
215
-//       @(UIWebViewNavigationTypeFormResubmitted): @"formresubmit",
216
-//       @(UIWebViewNavigationTypeOther): @"other",
217
-//     };
218
-//   });
219
-
220
-//   // skip this for the JS Navigation handler
221
-//   if (!isJSNavigation && _onShouldStartLoadWithRequest) {
222
-//     NSMutableDictionary<NSString *, id> *event = [self baseEvent];
223
-//     [event addEntriesFromDictionary: @{
224
-//       @"url": (request.URL).absoluteString,
225
-//       @"navigationType": navigationTypes[@(navigationType)]
226
-//     }];
227
-//     if (![self.delegate webView:self
228
-//       shouldStartLoadForRequest:event
229
-//                    withCallback:_onShouldStartLoadWithRequest]) {
230
-//       return NO;
231
-//     }
232
-//   }
233
-
234
-//   if (_onLoadingStart) {
235
-//     // We have this check to filter out iframe requests and whatnot
236
-//     BOOL isTopFrame = [request.URL isEqual:request.mainDocumentURL];
237
-//     if (isTopFrame) {
238
-//       NSMutableDictionary<NSString *, id> *event = [self baseEvent];
239
-//       [event addEntriesFromDictionary: @{
240
-//         @"url": (request.URL).absoluteString,
241
-//         @"navigationType": navigationTypes[@(navigationType)]
242
-//       }];
243
-//       _onLoadingStart(event);
244
-//     }
245
-//   }
246
-
247
-//   if (isJSNavigation && [request.URL.host isEqualToString:kPostMessageHost]) {
248
-//     NSString *data = request.URL.query;
249
-//     data = [data stringByReplacingOccurrencesOfString:@"+" withString:@" "];
250
-//     data = [data stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
251
-
252
-//     NSMutableDictionary<NSString *, id> *event = [self baseEvent];
253
-//     [event addEntriesFromDictionary: @{
254
-//       @"data": data,
255
-//     }];
256
-
257
-//     NSString *source = @"document.dispatchEvent(new MessageEvent('message:received'));";
258
-
259
-//     [_webView stringByEvaluatingJavaScriptFromString:source];
260
-
261
-//     _onMessage(event);
262
-//   }
263
-
264
-//   // JS Navigation handler
265
-//   return !isJSNavigation;
266
-// }
267
-
268
-// - (void)webView:(__unused UIWebView *)webView didFailLoadWithError:(NSError *)error
269
-// {
270
-//   if (_onLoadingError) {
271
-//     if ([error.domain isEqualToString:NSURLErrorDomain] && error.code == NSURLErrorCancelled) {
272
-//       // NSURLErrorCancelled is reported when a page has a redirect OR if you load
273
-//       // a new URL in the WebView before the previous one came back. We can just
274
-//       // ignore these since they aren't real errors.
275
-//       // http://stackoverflow.com/questions/1024748/how-do-i-fix-nsurlerrordomain-error-999-in-iphone-3-0-os
276
-//       return;
277
-//     }
278
-
279
-//     if ([error.domain isEqualToString:@"WebKitErrorDomain"] && error.code == 102) {
280
-//       // Error code 102 "Frame load interrupted" is raised by the UIWebView if
281
-//       // its delegate returns FALSE from webView:shouldStartLoadWithRequest:navigationType
282
-//       // when the URL is from an http redirect. This is a common pattern when
283
-//       // implementing OAuth with a WebView.
284
-//       return;
285
-//     }
286
-
287
-//     NSMutableDictionary<NSString *, id> *event = [self baseEvent];
288
-//     [event addEntriesFromDictionary:@{
289
-//       @"domain": error.domain,
290
-//       @"code": @(error.code),
291
-//       @"description": error.localizedDescription,
292
-//     }];
293
-//     _onLoadingError(event);
294
-//   }
295
-// }
296
-
297
-// - (void)webViewDidFinishLoad:(UIWebView *)webView
298
-// {
299
-//   if (_messagingEnabled) {
300
-//     #if RCT_DEV
301
-//     // See isNative in lodash
302
-//     NSString *testPostMessageNative = @"String(window.postMessage) === String(Object.hasOwnProperty).replace('hasOwnProperty', 'postMessage')";
303
-//     BOOL postMessageIsNative = [
304
-//       [webView stringByEvaluatingJavaScriptFromString:testPostMessageNative]
305
-//       isEqualToString:@"true"
306
-//     ];
307
-//     if (!postMessageIsNative) {
308
-//       RCTLogError(@"Setting onMessage on a WebView overrides existing values of window.postMessage, but a previous value was defined");
309
-//     }
310
-//     #endif
311
-//     NSString *source = [NSString stringWithFormat:
312
-//       @"(function() {"
313
-//         "window.originalPostMessage = window.postMessage;"
314
-
315
-//         "var messageQueue = [];"
316
-//         "var messagePending = false;"
317
-
318
-//         "function processQueue() {"
319
-//           "if (!messageQueue.length || messagePending) return;"
320
-//           "messagePending = true;"
321
-//           "window.location = '%@://%@?' + encodeURIComponent(messageQueue.shift());"
322
-//         "}"
323
-
324
-//         "window.postMessage = function(data) {"
325
-//           "messageQueue.push(String(data));"
326
-//           "processQueue();"
327
-//         "};"
328
-
329
-//         "document.addEventListener('message:received', function(e) {"
330
-//           "messagePending = false;"
331
-//           "processQueue();"
332
-//         "});"
333
-//       "})();", RCTJSNavigationScheme, kPostMessageHost
334
-//     ];
335
-//     [webView stringByEvaluatingJavaScriptFromString:source];
336
-//   }
337
-//   if (_injectedJavaScript != nil) {
338
-//     NSString *jsEvaluationValue = [webView stringByEvaluatingJavaScriptFromString:_injectedJavaScript];
339
-
340
-//     NSMutableDictionary<NSString *, id> *event = [self baseEvent];
341
-//     event[@"jsEvaluationValue"] = jsEvaluationValue;
342
-
343
-//     _onLoadingFinish(event);
344
-//   }
345
-//   // we only need the final 'finishLoad' call so only fire the event when we're actually done loading.
346
-//   else if (_onLoadingFinish && !webView.loading && ![webView.request.URL.absoluteString isEqualToString:@"about:blank"]) {
347
-//     _onLoadingFinish([self baseEvent]);
348
-//   }
349
-// }
350
-
351
-// @end