From dab4d71f697cb376afa80fdeafe916c06a48418b Mon Sep 17 00:00:00 2001 From: Miguel Araujo Perez Date: Tue, 16 Feb 2016 10:29:44 +0100 Subject: [PATCH] Proxy WebView proptypes to simplify --- webview-bridge/index.android.js | 44 +---------------- webview-bridge/index.ios.js | 83 +-------------------------------- 2 files changed, 4 insertions(+), 123 deletions(-) diff --git a/webview-bridge/index.android.js b/webview-bridge/index.android.js index c671151..3efc551 100644 --- a/webview-bridge/index.android.js +++ b/webview-bridge/index.android.js @@ -25,6 +25,7 @@ var { StyleSheet, Text, View, + WebView, requireNativeComponent, PropTypes, DeviceEventEmitter, @@ -47,48 +48,7 @@ var WebViewBridgeState = keyMirror({ var WebViewBridge = React.createClass({ propTypes: { - ...View.propTypes, - renderError: PropTypes.func, - renderLoading: PropTypes.func, - onLoad: PropTypes.func, - onLoadEnd: PropTypes.func, - onLoadStart: PropTypes.func, - onError: PropTypes.func, - url: PropTypes.string, - html: PropTypes.string, - automaticallyAdjustContentInsets: PropTypes.bool, - contentInset: EdgeInsetsPropType, - onNavigationStateChange: PropTypes.func, - startInLoadingState: PropTypes.bool, // force WebView to show loadingView on first load - style: View.propTypes.style, - - /** - * Used on Android only, JS is enabled by default for WebView on iOS - * @platform android - */ - javaScriptEnabled: PropTypes.bool, - - /** - * Used on Android only, controls whether DOM Storage is enabled or not - * @platform android - */ - domStorageEnabled: PropTypes.bool, - - /** - * Sets the JS to be injected when the webpage loads. - */ - injectedJavaScript: PropTypes.string, - - /** - * Sets the user-agent for this WebView. The user-agent can also be set in native using - * WebViewConfig. This prop will overwrite that config. - */ - userAgent: PropTypes.string, - - /** - * Used to locate this view in end-to-end tests. - */ - testID: PropTypes.string, + ...WebView.propTypes, /** * Will be called once the message is being sent from webview diff --git a/webview-bridge/index.ios.js b/webview-bridge/index.ios.js index fb4a961..279fbe2 100644 --- a/webview-bridge/index.ios.js +++ b/webview-bridge/index.ios.js @@ -24,6 +24,7 @@ var { StyleSheet, Text, View, + WebView, requireNativeComponent, PropTypes, UIManager, @@ -94,87 +95,7 @@ var WebViewBridge = React.createClass({ }, propTypes: { - ...View.propTypes, - url: PropTypes.string, - html: PropTypes.string, - /** - * Function that returns a view to show if there's an error. - */ - renderError: PropTypes.func, // view to show if there's an error - /** - * Function that returns a loading indicator. - */ - renderLoading: PropTypes.func, - /** - * Invoked when load finish - */ - onLoad: PropTypes.func, - /** - * Invoked when load either succeeds or fails - */ - onLoadEnd: PropTypes.func, - /** - * Invoked on load start - */ - onLoadStart: PropTypes.func, - /** - * Invoked when load fails - */ - onError: PropTypes.func, - /** - * @platform ios - */ - bounces: PropTypes.bool, - /** - * @platform ios - */ - scrollEnabled: PropTypes.bool, - automaticallyAdjustContentInsets: PropTypes.bool, - contentInset: EdgeInsetsPropType, - onNavigationStateChange: PropTypes.func, - startInLoadingState: PropTypes.bool, // force WebView to show loadingView on first load - style: View.propTypes.style, - - /** - * Used on Android only, JS is enabled by default for WebView on iOS - * @platform android - */ - javaScriptEnabled: PropTypes.bool, - - /** - * Used on Android only, controls whether DOM Storage is enabled or not - * @platform android - */ - domStorageEnabled: PropTypes.bool, - - /** - * Sets the JS to be injected when the webpage loads. - */ - injectedJavaScript: PropTypes.string, - - /** - * Sets whether the webpage scales to fit the view and the user can change the scale. - * @platform ios - */ - scalesPageToFit: PropTypes.bool, - - /** - * Allows custom handling of any webview requests by a JS handler. Return true - * or false from this method to continue loading the request. - * @platform ios - */ - onShouldStartLoadWithRequest: PropTypes.func, - - /** - * Determines whether HTML5 videos play inline or use the native full-screen - * controller. - * default value `false` - * **NOTE** : "In order for video to play inline, not only does this - * property need to be set to true, but the video element in the HTML - * document must also include the webkit-playsinline attribute." - * @platform ios - */ - allowsInlineMediaPlayback: PropTypes.bool, + ...WebView.propTypes, /** * Will be called once the message is being sent from webview