Replace WebView with React Native Community WebView (#2340)

This commit is contained in:
Elias Nahum 2018-11-16 13:28:54 -03:00 committed by GitHub
parent 8e97b47425
commit fb51e38733
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 3198 additions and 3078 deletions

View file

@ -2146,6 +2146,41 @@ SOFTWARE.
---
## react-native-webview
This product contains 'react-native-webview' by Facebook.
React Native WebView is a modern, well-supported, and cross-platform WebView for React Native. It is intended to be a replacement for the built-in WebView.
* HOMEPAGE:
* https://github.com/react-native-community/react-native-webview
* LICENSE: MIT
MIT License
Copyright (c) 2015-present, Facebook, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---
## react-native-youtube
This product contains a modified version of 'react-native-youtube' by Param Aggarwal.

View file

@ -212,6 +212,7 @@ dependencies {
implementation project(':react-native-exception-handler')
implementation project(':rn-fetch-blob')
implementation project(':react-native-recyclerview-list')
implementation project(':react-native-webview')
// For animated GIF support
implementation 'com.facebook.fresco:fresco:1.10.0'

View file

@ -19,6 +19,7 @@ import com.RNFetchBlob.RNFetchBlobPackage;
import com.gantix.JailMonkey.JailMonkeyPackage;
import io.tradle.react.LocalAuthPackage;
import com.github.godness84.RNRecyclerViewList.RNRecyclerviewListPackage;
import com.reactnativecommunity.webview.RNCWebViewPackage;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
@ -77,7 +78,8 @@ public class MainApplication extends NavigationApplication implements INotificat
new SharePackage(this),
new KeychainPackage(),
new InitializationPackage(this),
new RNRecyclerviewListPackage()
new RNRecyclerviewListPackage(),
new RNCWebViewPackage()
);
}

View file

@ -41,3 +41,5 @@ include ':react-native-linear-gradient'
project(':react-native-linear-gradient').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-linear-gradient/android')
include ':react-native-recyclerview-list'
project(':react-native-recyclerview-list').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-recyclerview-list/android')
include ':react-native-webview'
project(':react-native-webview').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview/android')

View file

@ -8,8 +8,8 @@ import {
InteractionManager,
Text,
View,
WebView,
} from 'react-native';
import {WebView} from 'react-native-webview';
import CookieManager from 'react-native-cookies';
import urlParse from 'url-parse';
@ -26,7 +26,7 @@ const HEADERS = {
'X-Mobile-App': 'mattermost',
};
const postMessageJS = "postMessage(document.body.innerText, '*');";
const postMessageJS = "window.postMessage(document.body.innerText, '*');";
// Used to make sure that OneLogin forms scale appropriately on both platforms.
const oneLoginFormScalingJS = `
@ -161,10 +161,6 @@ class SSO extends PureComponent {
if (parsed.host.includes('.onelogin.com')) {
nextState.jsCode = oneLoginFormScalingJS;
} else if (parsed.host.includes(this.completedUrl)) {
this.webView.setNativeProps({
onMessage: this.onMessage,
});
}
if (Object.keys(nextState).length) {
@ -239,6 +235,7 @@ class SSO extends PureComponent {
renderLoading={this.renderLoading}
injectedJavaScript={jsCode}
onLoadEnd={this.onLoadEnd}
onMessage={this.onMessage}
useWebKit={true}
/>
);

View file

@ -46,6 +46,7 @@
71F30A436B5847DF9D319D15 /* Roboto-BlackItalic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 7F54ABFAE6CE4A6DB11D1ED7 /* Roboto-BlackItalic.ttf */; };
74D116AD208A8D5600CF8A79 /* libRNKeychain.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 74D116AA208A8D3100CF8A79 /* libRNKeychain.a */; };
7F2691A11EE1DC6A007574FE /* libRNNotifications.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7F2691A01EE1DC51007574FE /* libRNNotifications.a */; };
7F26C1CC219C463D00FEB42D /* libRNCWebView.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7F26C1CB219C463300FEB42D /* libRNCWebView.a */; };
7F292A711E8AB73400A450A3 /* SplashScreenResource in Resources */ = {isa = PBXBuildFile; fileRef = 7F292A701E8AB73400A450A3 /* SplashScreenResource */; };
7F292AA61E8ABB1100A450A3 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7F292AA41E8ABB1100A450A3 /* LaunchScreen.xib */; };
7F292AA71E8ABB1100A450A3 /* splash.png in Resources */ = {isa = PBXBuildFile; fileRef = 7F292AA51E8ABB1100A450A3 /* splash.png */; };
@ -405,6 +406,13 @@
remoteGlobalIDString = 134814201AA4EA6300B7C361;
remoteInfo = RNNotifications;
};
7F26C1CA219C463300FEB42D /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 7F26C1C6219C463300FEB42D /* RNCWebView.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 134814201AA4EA6300B7C361;
remoteInfo = RNCWebView;
};
7F43D5BD1F6BF882001FC614 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = A2968536BEC74A4ABBB73BD9 /* RCTYouTube.xcodeproj */;
@ -697,6 +705,7 @@
79CB6EBA24FE4ABFB0C155F0 /* YTPlayerView-iframe-player.html */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "YTPlayerView-iframe-player.html"; path = "../node_modules/react-native-youtube/assets/YTPlayerView-iframe-player.html"; sourceTree = "<group>"; };
7DCC3D826CE640AF8F491692 /* BVLinearGradient.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = BVLinearGradient.xcodeproj; path = "../node_modules/react-native-linear-gradient/BVLinearGradient.xcodeproj"; sourceTree = "<group>"; };
7F26919B1EE1DC51007574FE /* RNNotifications.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RNNotifications.xcodeproj; path = "../node_modules/react-native-notifications/RNNotifications/RNNotifications.xcodeproj"; sourceTree = "<group>"; };
7F26C1C6219C463300FEB42D /* RNCWebView.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RNCWebView.xcodeproj; path = "../node_modules/react-native-webview/ios/RNCWebView.xcodeproj"; sourceTree = "<group>"; };
7F292A701E8AB73400A450A3 /* SplashScreenResource */ = {isa = PBXFileReference; lastKnownFileType = folder; path = SplashScreenResource; sourceTree = "<group>"; };
7F292AA41E8ABB1100A450A3 /* LaunchScreen.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = LaunchScreen.xib; path = SplashScreenResource/LaunchScreen.xib; sourceTree = "<group>"; };
7F292AA51E8ABB1100A450A3 /* splash.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = splash.png; path = SplashScreenResource/splash.png; sourceTree = "<group>"; };
@ -819,6 +828,7 @@
7FDB92B11F706F58006CDFD1 /* libRNImagePicker.a in Frameworks */,
7F5CA9A0208FE3B9004F91CE /* libRNDocumentPicker.a in Frameworks */,
7F43D5DE1F6BF96A001FC614 /* libRCTYouTube.a in Frameworks */,
7F26C1CC219C463D00FEB42D /* libRNCWebView.a in Frameworks */,
7F43D6061F6BF9EB001FC614 /* libPods-Mattermost.a in Frameworks */,
A9B746D2CFA9CEBFB8AE2B5B /* libPods-Mattermost.a in Frameworks */,
5A0920184BD344979BCFCD5C /* libRCTVideo.a in Frameworks */,
@ -1144,6 +1154,14 @@
name = Products;
sourceTree = "<group>";
};
7F26C1C7219C463300FEB42D /* Products */ = {
isa = PBXGroup;
children = (
7F26C1CB219C463300FEB42D /* libRNCWebView.a */,
);
name = Products;
sourceTree = "<group>";
};
7F43D58F1F6BF855001FC614 /* Products */ = {
isa = PBXGroup;
children = (
@ -1319,6 +1337,7 @@
832341AE1AAA6A7D00B99B32 /* Libraries */ = {
isa = PBXGroup;
children = (
7F26C1C6219C463300FEB42D /* RNCWebView.xcodeproj */,
7FF31C0E21330B4200680B75 /* RNFetchBlob.xcodeproj */,
7F5CA956208FE38F004F91CE /* RNDocumentPicker.xcodeproj */,
7F642DE72093530B00F3165E /* RNDeviceInfo.xcodeproj */,
@ -1612,6 +1631,10 @@
ProductGroup = 372E25631F5F0E1800A2BFAB /* Products */;
ProjectRef = 62A58E5E984E4CF1811620B8 /* RNCookieManagerIOS.xcodeproj */;
},
{
ProductGroup = 7F26C1C7219C463300FEB42D /* Products */;
ProjectRef = 7F26C1C6219C463300FEB42D /* RNCWebView.xcodeproj */;
},
{
ProductGroup = 7F642DE82093530B00F3165E /* Products */;
ProjectRef = 7F642DE72093530B00F3165E /* RNDeviceInfo.xcodeproj */;
@ -1952,6 +1975,13 @@
remoteRef = 7F26919F1EE1DC51007574FE /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
7F26C1CB219C463300FEB42D /* libRNCWebView.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRNCWebView.a;
remoteRef = 7F26C1CA219C463300FEB42D /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
7F43D5BE1F6BF882001FC614 /* libRCTYouTube.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
@ -2449,6 +2479,7 @@
"$(SRCROOT)/../node_modules/react-native-safe-area/ios/RNSafeArea",
"$(SRCROOT)/../node_modules/react-native-document-picker/**",
"$(SRCROOT)/../node_modules/react-native-device-info/ios/**",
"$(SRCROOT)../node_modules/react-native-webview/ios",
);
INFOPLIST_FILE = Mattermost/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
@ -2498,6 +2529,7 @@
"$(SRCROOT)/../node_modules/react-native-safe-area/ios/RNSafeArea",
"$(SRCROOT)/../node_modules/react-native-document-picker/**",
"$(SRCROOT)/../node_modules/react-native-device-info/ios/**",
"$(SRCROOT)../node_modules/react-native-webview/ios",
);
INFOPLIST_FILE = Mattermost/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;

6192
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -54,6 +54,7 @@
"react-native-tableview": "2.3.1",
"react-native-vector-icons": "5.0.0",
"react-native-video": "3.2.1",
"react-native-webview": "2.5.0",
"react-native-youtube": "github:enahum/react-native-youtube#3f395b620ae4e05a3f1c6bdeef3a1158e78daadc",
"react-navigation": "2.14.2",
"react-redux": "5.0.7",