From e79d12fb839b3b92b913da4175dcf0428056f04f Mon Sep 17 00:00:00 2001 From: Sathyanarayana Date: Wed, 24 Oct 2018 15:18:35 +0530 Subject: [PATCH 1/3] Update index.android.js --- webview-bridge/index.android.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/webview-bridge/index.android.js b/webview-bridge/index.android.js index 14e5e263..75adbbc6 100644 --- a/webview-bridge/index.android.js +++ b/webview-bridge/index.android.js @@ -169,6 +169,14 @@ var WebViewBridge = createReactClass({ null ); }, + + stopLoading: function() { + UIManager.dispatchViewManagerCommand( + this.getWebViewBridgeHandle(), + UIManager.RCTWebViewBridge.Commands.stopLoading, + null + ); + }, sendToBridge: function (message: string) { UIManager.dispatchViewManagerCommand( From 682f2992f469a21732a02e4c85954735d0e743d0 Mon Sep 17 00:00:00 2001 From: Sathyanarayana Date: Wed, 24 Oct 2018 15:40:15 +0530 Subject: [PATCH 2/3] Added stopLoading functionality. --- ios/RCTWebViewBridge.h | 1 + ios/RCTWebViewBridge.m | 5 +++++ ios/RCTWebViewBridgeManager.m | 13 +++++++++++++ webview-bridge/index.android.js | 8 ++++++++ webview-bridge/index.ios.js | 9 +++++++++ 5 files changed, 36 insertions(+) diff --git a/ios/RCTWebViewBridge.h b/ios/RCTWebViewBridge.h index c7d34222..a2da007d 100644 --- a/ios/RCTWebViewBridge.h +++ b/ios/RCTWebViewBridge.h @@ -43,6 +43,7 @@ shouldStartLoadForRequest:(NSMutableDictionary *)request - (void)goForward; - (void)goBack; - (void)reload; +- (void)stopLoading; - (void)sendToBridge:(NSString *)message; @end diff --git a/ios/RCTWebViewBridge.m b/ios/RCTWebViewBridge.m index 86ddabc4..5849c11f 100644 --- a/ios/RCTWebViewBridge.m +++ b/ios/RCTWebViewBridge.m @@ -88,6 +88,11 @@ - (void)reload [_webView reload]; } +- (void)stopLoading +{ + [_webView stopLoading]; +} + - (void)sendToBridge:(NSString *)message { //we are warpping the send message in a function to make sure that if diff --git a/ios/RCTWebViewBridgeManager.m b/ios/RCTWebViewBridgeManager.m index 218cca0e..9a96fb32 100644 --- a/ios/RCTWebViewBridgeManager.m +++ b/ios/RCTWebViewBridgeManager.m @@ -61,6 +61,7 @@ - (UIView *)view @"FormSubmitted": @(UIWebViewNavigationTypeFormSubmitted), @"BackForward": @(UIWebViewNavigationTypeBackForward), @"Reload": @(UIWebViewNavigationTypeReload), + @"StopLoading": @(UIWebViewNavigationTypeStopLoading), @"FormResubmitted": @(UIWebViewNavigationTypeFormResubmitted), @"Other": @(UIWebViewNavigationTypeOther) }, @@ -108,6 +109,18 @@ + (BOOL)requiresMainQueueSetup }]; } +RCT_EXPORT_METHOD(stopLoading:(nonnull NSNumber *)reactTag) +{ + [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary *viewRegistry) { + RCTWebViewBridge *view = viewRegistry[reactTag]; + if (![view isKindOfClass:[RCTWebViewBridge class]]) { + RCTLogError(@"Invalid view returned from registry, expecting RCTWebViewBridge, got: %@", view); + } else { + [view stopLoading]; + } + }]; +} + RCT_EXPORT_METHOD(sendToBridge:(nonnull NSNumber *)reactTag value:(NSString*)message) { diff --git a/webview-bridge/index.android.js b/webview-bridge/index.android.js index 75adbbc6..5f9f68a5 100644 --- a/webview-bridge/index.android.js +++ b/webview-bridge/index.android.js @@ -169,6 +169,14 @@ var WebViewBridge = createReactClass({ null ); }, + + stopLoading: function() { + UIManager.dispatchViewManagerCommand( + this.getWebViewBridgeHandle(), + UIManager.RCTWebViewBridge.Commands.stopLoading, + null + ); + }, stopLoading: function() { UIManager.dispatchViewManagerCommand( diff --git a/webview-bridge/index.ios.js b/webview-bridge/index.ios.js index 1aad6b02..f74b3f0d 100644 --- a/webview-bridge/index.ios.js +++ b/webview-bridge/index.ios.js @@ -53,6 +53,7 @@ var NavigationType = { formsubmit: RCTWebViewBridgeManager.NavigationType.FormSubmitted, backforward: RCTWebViewBridgeManager.NavigationType.BackForward, reload: RCTWebViewBridgeManager.NavigationType.Reload, + stopLoading: RCTWebViewBridgeManager.NavigationType.StopLoading, formresubmit: RCTWebViewBridgeManager.NavigationType.FormResubmitted, other: RCTWebViewBridgeManager.NavigationType.Other, }; @@ -231,6 +232,14 @@ var WebViewBridge = createReactClass({ ); }, + stopLoading: function() { + UIManager.dispatchViewManagerCommand( + this.getWebViewBridgeHandle(), + UIManager.RCTWebViewBridge.Commands.stopLoading, + null + ); + }, + sendToBridge: function (message: string) { WebViewBridgeManager.sendToBridge(this.getWebViewBridgeHandle(), message); }, From 56a089cca23889f87bf69feb204ebd45ee9185b4 Mon Sep 17 00:00:00 2001 From: Sathyanarayana Date: Wed, 24 Oct 2018 16:21:29 +0530 Subject: [PATCH 3/3] removed duplicate call --- webview-bridge/index.android.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/webview-bridge/index.android.js b/webview-bridge/index.android.js index 5f9f68a5..8e2ac10e 100644 --- a/webview-bridge/index.android.js +++ b/webview-bridge/index.android.js @@ -170,14 +170,6 @@ var WebViewBridge = createReactClass({ ); }, - stopLoading: function() { - UIManager.dispatchViewManagerCommand( - this.getWebViewBridgeHandle(), - UIManager.RCTWebViewBridge.Commands.stopLoading, - null - ); - }, - stopLoading: function() { UIManager.dispatchViewManagerCommand( this.getWebViewBridgeHandle(),