From 04937aa3906bd6ebf8fa1e539d2eae3adf2ed358 Mon Sep 17 00:00:00 2001 From: Carlo Lucadei Date: Wed, 26 Sep 2018 16:19:49 +0200 Subject: [PATCH 01/13] Added support for loadingStyle and loadingSize --- README.md | 2 ++ WKWebView.ios.js | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ac0ae09a..49dcbff3 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,8 @@ Add JavaScript at document end. Since 1.20.0, the implementation has been change - source - startInLoadingState - style +- loadingStyle (optional) +- loadingSize (optional) - url (deprecated) - bounces - onShouldStartLoadWithRequest diff --git a/WKWebView.ios.js b/WKWebView.ios.js index f9a37eb1..52333248 100644 --- a/WKWebView.ios.js +++ b/WKWebView.ios.js @@ -47,9 +47,9 @@ type ErrorEvent = { type Event = Object; -const defaultRenderLoading = () => ( - - +const defaultRenderLoading = (loadingStyle, loadingSize) => ( + + ); const defaultRenderError = (errorDomain, errorCode, errorDesc) => ( @@ -203,6 +203,8 @@ class WKWebView extends React.Component { scalesPageToFit: PropTypes.bool, startInLoadingState: PropTypes.bool, style: ViewPropTypes.style, + loadingStyle?: ViewPropTypes.style, + loadingSize?: "small" | "large", /** * If false injectJavaScript will run both main frame and iframe * @platform ios @@ -281,7 +283,7 @@ class WKWebView extends React.Component { let otherView = null; if (this.state.viewState === WebViewState.LOADING) { - otherView = (this.props.renderLoading || defaultRenderLoading)(); + otherView = (this.props.renderLoading || defaultRenderLoading)(this.props.loadingStyle, this.props.loadingSize); } else if (this.state.viewState === WebViewState.ERROR) { const errorEvent = this.state.lastErrorEvent; invariant( From 5a9555566d2a2b1b88b87442b4a941f8db653a7b Mon Sep 17 00:00:00 2001 From: Carlo Lucadei Date: Wed, 26 Sep 2018 16:23:58 +0200 Subject: [PATCH 02/13] Added support for containerStyle props --- README.md | 1 + WKWebView.ios.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 49dcbff3..4673d23a 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,7 @@ Add JavaScript at document end. Since 1.20.0, the implementation has been change - source - startInLoadingState - style +- containerStyle (optional) - loadingStyle (optional) - loadingSize (optional) - url (deprecated) diff --git a/WKWebView.ios.js b/WKWebView.ios.js index 52333248..651eb104 100644 --- a/WKWebView.ios.js +++ b/WKWebView.ios.js @@ -203,6 +203,7 @@ class WKWebView extends React.Component { scalesPageToFit: PropTypes.bool, startInLoadingState: PropTypes.bool, style: ViewPropTypes.style, + containerStyle?: ViewPropTypes.style, loadingStyle?: ViewPropTypes.style, loadingSize?: "small" | "large", /** @@ -364,7 +365,7 @@ class WKWebView extends React.Component { />; return ( - + {webView} {otherView} From 444783e6a99210b55402e320d8a73dda50988321 Mon Sep 17 00:00:00 2001 From: Carlo Lucadei Date: Wed, 26 Sep 2018 16:24:21 +0200 Subject: [PATCH 03/13] 1.21.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d8bbaa39..5b6db3ec 100644 --- a/package.json +++ b/package.json @@ -77,5 +77,5 @@ "sync-from-example": "cp ./example/node_modules/react-native-wkwebview-reborn/*.js ./;cp -r ./example/node_modules/react-native-wkwebview-reborn/ios ./", "sync-to-example": "cp ./*.js ./example/node_modules/react-native-wkwebview-reborn/;cp -r ./ios ./example/node_modules/react-native-wkwebview-reborn/" }, - "version": "1.21.0" + "version": "1.21.1" } From 4f0c60f27b2d0563ffeae615bfa5bbe56130477c Mon Sep 17 00:00:00 2001 From: Carlo Lucadei Date: Wed, 26 Sep 2018 16:48:35 +0200 Subject: [PATCH 04/13] Fixed props declareation --- WKWebView.ios.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/WKWebView.ios.js b/WKWebView.ios.js index 651eb104..ad0e6b79 100644 --- a/WKWebView.ios.js +++ b/WKWebView.ios.js @@ -203,9 +203,9 @@ class WKWebView extends React.Component { scalesPageToFit: PropTypes.bool, startInLoadingState: PropTypes.bool, style: ViewPropTypes.style, - containerStyle?: ViewPropTypes.style, - loadingStyle?: ViewPropTypes.style, - loadingSize?: "small" | "large", + containerStyle: ViewPropTypes.style, + loadingStyle: ViewPropTypes.style, + loadingSize: null | "small" | "large", /** * If false injectJavaScript will run both main frame and iframe * @platform ios From 61a2f85670f0619f3a30c9e2f1f49e98625a9fa5 Mon Sep 17 00:00:00 2001 From: Carlo Lucadei Date: Wed, 26 Sep 2018 16:48:41 +0200 Subject: [PATCH 05/13] 1.21.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5b6db3ec..2e8103cf 100644 --- a/package.json +++ b/package.json @@ -77,5 +77,5 @@ "sync-from-example": "cp ./example/node_modules/react-native-wkwebview-reborn/*.js ./;cp -r ./example/node_modules/react-native-wkwebview-reborn/ios ./", "sync-to-example": "cp ./*.js ./example/node_modules/react-native-wkwebview-reborn/;cp -r ./ios ./example/node_modules/react-native-wkwebview-reborn/" }, - "version": "1.21.1" + "version": "1.21.2" } From 802fec3e133fe9e26faa0d69914db4e13cbcd6d6 Mon Sep 17 00:00:00 2001 From: Carlo Lucadei Date: Tue, 9 Oct 2018 17:51:25 +0200 Subject: [PATCH 06/13] Fix: handling status code --- ios/RCTWKWebView/RCTWKWebView.m | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ios/RCTWKWebView/RCTWKWebView.m b/ios/RCTWKWebView/RCTWKWebView.m index e1348c81..1be45ef4 100644 --- a/ios/RCTWKWebView/RCTWKWebView.m +++ b/ios/RCTWKWebView/RCTWKWebView.m @@ -619,10 +619,17 @@ - (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNaviga @"status": [NSHTTPURLResponse localizedStringForStatusCode:statusCode], @"statusCode": @(statusCode), }]; - _onNavigationResponse(event); + // check status code + if(statusCode == 200) { + _onNavigationResponse(event); + decisionHandler(WKNavigationResponsePolicyAllow); + } else { + RCTLogError(@"Something wrong, statusCode is %zd!", statusCode); + decisionHandler(WKNavigationResponsePolicyCancel); + } + } else { + decisionHandler(WKNavigationResponsePolicyAllow); } - - decisionHandler(WKNavigationResponsePolicyAllow); } @end From a12c3ec260be70697699a5b6d03ce69b374d1006 Mon Sep 17 00:00:00 2001 From: Carlo Lucadei Date: Tue, 9 Oct 2018 17:55:24 +0200 Subject: [PATCH 07/13] some stuff --- WKWebView.ios.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/WKWebView.ios.js b/WKWebView.ios.js index ad0e6b79..4e70a8ae 100644 --- a/WKWebView.ios.js +++ b/WKWebView.ios.js @@ -297,8 +297,7 @@ class WKWebView extends React.Component { errorEvent.description ); } else if (this.state.viewState !== WebViewState.IDLE) { - console.error( - 'RCTWKWebView invalid state encountered: ' + this.state.loading + console.error('RCTWKWebView invalid state encountered: ' + this.state.loading ); } From 2314f158b077cf8149b857113699ce0370d88ab0 Mon Sep 17 00:00:00 2001 From: Carlo Lucadei Date: Tue, 9 Oct 2018 17:55:52 +0200 Subject: [PATCH 08/13] 1.21.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2e8103cf..f8e54bf7 100644 --- a/package.json +++ b/package.json @@ -77,5 +77,5 @@ "sync-from-example": "cp ./example/node_modules/react-native-wkwebview-reborn/*.js ./;cp -r ./example/node_modules/react-native-wkwebview-reborn/ios ./", "sync-to-example": "cp ./*.js ./example/node_modules/react-native-wkwebview-reborn/;cp -r ./ios ./example/node_modules/react-native-wkwebview-reborn/" }, - "version": "1.21.2" + "version": "1.21.3" } From ddf918157ed6f0cb2beb2ae761eb7b4483908107 Mon Sep 17 00:00:00 2001 From: Carlo Lucadei Date: Tue, 9 Oct 2018 18:04:54 +0200 Subject: [PATCH 09/13] Fix: from RCTLogError to RCTLogWarn when loggin statusCode --- ios/RCTWKWebView/RCTWKWebView.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/RCTWKWebView/RCTWKWebView.m b/ios/RCTWKWebView/RCTWKWebView.m index 1be45ef4..f5c4cfed 100644 --- a/ios/RCTWKWebView/RCTWKWebView.m +++ b/ios/RCTWKWebView/RCTWKWebView.m @@ -624,7 +624,7 @@ - (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNaviga _onNavigationResponse(event); decisionHandler(WKNavigationResponsePolicyAllow); } else { - RCTLogError(@"Something wrong, statusCode is %zd!", statusCode); + RCTLogWarn(@"Something wrong, statusCode is %zd!", statusCode); decisionHandler(WKNavigationResponsePolicyCancel); } } else { From 98530d7616ead92c499039d4c503817bdf3ad909 Mon Sep 17 00:00:00 2001 From: Carlo Lucadei Date: Tue, 9 Oct 2018 18:05:02 +0200 Subject: [PATCH 10/13] 1.21.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f8e54bf7..4fb56d5b 100644 --- a/package.json +++ b/package.json @@ -77,5 +77,5 @@ "sync-from-example": "cp ./example/node_modules/react-native-wkwebview-reborn/*.js ./;cp -r ./example/node_modules/react-native-wkwebview-reborn/ios ./", "sync-to-example": "cp ./*.js ./example/node_modules/react-native-wkwebview-reborn/;cp -r ./ios ./example/node_modules/react-native-wkwebview-reborn/" }, - "version": "1.21.3" + "version": "1.21.4" } From 42df650f1f6f0962ed672660c7b597db353a4cc3 Mon Sep 17 00:00:00 2001 From: Carlo Lucadei Date: Thu, 8 Nov 2018 14:20:25 +0100 Subject: [PATCH 11/13] Fix: handling wrong cast (iOS 11) --- ios/RCTWKWebView/RCTWKWebView.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ios/RCTWKWebView/RCTWKWebView.m b/ios/RCTWKWebView/RCTWKWebView.m index f5c4cfed..6deb49f6 100644 --- a/ios/RCTWKWebView/RCTWKWebView.m +++ b/ios/RCTWKWebView/RCTWKWebView.m @@ -611,8 +611,13 @@ - (void)webViewWebContentProcessDidTerminate:(WKWebView *)webView - (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler { if (_onNavigationResponse) { - NSDictionary *headers = ((NSHTTPURLResponse *)navigationResponse.response).allHeaderFields; - NSInteger statusCode = ((NSHTTPURLResponse *)navigationResponse.response).statusCode; + NSDictionary *headers = @{}; + NSInteger statusCode = 200; + if([navigationResponse.response isKindOfClass:[NSHTTPURLResponse class]]){ + headers = ((NSHTTPURLResponse *)navigationResponse.response).allHeaderFields; + statusCode = ((NSHTTPURLResponse *)navigationResponse.response).statusCode; + } + NSMutableDictionary *event = [self baseEvent]; [event addEntriesFromDictionary:@{ @"headers": headers, From 867feb9f70cafc1de8aad77b65b6b57bfb6be157 Mon Sep 17 00:00:00 2001 From: Carlo Lucadei Date: Thu, 8 Nov 2018 14:21:45 +0100 Subject: [PATCH 12/13] 1.21.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4fb56d5b..df1546e4 100644 --- a/package.json +++ b/package.json @@ -77,5 +77,5 @@ "sync-from-example": "cp ./example/node_modules/react-native-wkwebview-reborn/*.js ./;cp -r ./example/node_modules/react-native-wkwebview-reborn/ios ./", "sync-to-example": "cp ./*.js ./example/node_modules/react-native-wkwebview-reborn/;cp -r ./ios ./example/node_modules/react-native-wkwebview-reborn/" }, - "version": "1.21.4" + "version": "1.21.5" } From 8d9fb522d564c24a5ce52aad8de93ea2399bd389 Mon Sep 17 00:00:00 2001 From: Carlo Lucadei Date: Tue, 8 Jan 2019 09:21:20 +0100 Subject: [PATCH 13/13] 1.23.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5505776b..50ed61f5 100644 --- a/package.json +++ b/package.json @@ -77,5 +77,5 @@ "sync-from-example": "cp ./example/node_modules/react-native-wkwebview-reborn/*.js ./;cp -r ./example/node_modules/react-native-wkwebview-reborn/ios ./", "sync-to-example": "cp ./*.js ./example/node_modules/react-native-wkwebview-reborn/;cp -r ./ios ./example/node_modules/react-native-wkwebview-reborn/" }, - "version": "1.22.0" + "version": "1.23.0" }