Skip to content

Commit

Permalink
WIP: iOS WKWebView
Browse files Browse the repository at this point in the history
  • Loading branch information
jamonholmgren committed Sep 8, 2018
1 parent ba49125 commit 26d2f5c
Show file tree
Hide file tree
Showing 9 changed files with 567 additions and 9 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# React Native WebView - a Modern, Cross-Platform WebView for React Native

**React Native WebView** is a modern, well-supported, and cross-platform (even Windows!) WebView for React Native. It is intended to be a replacement for the built-in WebView (which may be [removed from core](https://github.com/react-native-community/discussions-and-proposals/pull/3)).
**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 (which will be [removed from core](https://github.com/react-native-community/discussions-and-proposals/pull/3)).

## Platforms Supported

Expand Down Expand Up @@ -49,6 +49,10 @@ Simply install React Native WebView and then use it in place of the core WebView

_Guide coming soon_

### Contributor Notes

* I'm currently shimming `ViewAccessibility`, `deprecatedPropType`, and `DeprecatedViewPropTypes` because I'm building my test app for React Native 0.56.0. If I upgrade to a version that exports these and we agree to only support that version going forward, then I'll remove them and pull in from React Native core. You can find these shims in `./js/shims`.

## Maintainers

* [Jamon Holmgren](https://github.com/jamonholmgren) ([Twitter](https://twitter.com/jamonholmgren)) from [Infinite Red](https://infinite.red/react-native)
Expand Down
36 changes: 36 additions & 0 deletions js/WKWebView.ios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow
* @providesModule WKWebView
*/

import React from 'react';

import { requireNativeComponent } from 'react-native';

const RCTWKWebView = requireNativeComponent('RCTWKWebView');

class WKWebView extends React.Component {
componentWillReceiveProps(nextProps) {
this.showRedboxOnPropChanges(nextProps, 'allowsInlineMediaPlayback');
this.showRedboxOnPropChanges(nextProps, 'mediaPlaybackRequiresUserAction');
this.showRedboxOnPropChanges(nextProps, 'dataDetectorTypes');
}

showRedboxOnPropChanges(nextProps, propName) {
if (this.props[propName] !== nextProps[propName]) {
console.error(`Changes to property ${propName} do nothing after the initial render.`);
}
}

render() {
return <RCTWKWebView {...this.props} />;
}
}

module.exports = WKWebView;
3 changes: 2 additions & 1 deletion js/WebView.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import {
requireNativeComponent
} from 'react-native';

import deprecatedPropType from 'deprecated-prop-type';
import deprecatedPropType from './shims/deprecatedPropType';
import DeprecatedViewPropTypes from './shims/DeprecatedViewPropTypes'
import keyMirror from 'fbjs/lib/keyMirror';

import WebViewShared from './WebViewShared';
Expand Down
8 changes: 4 additions & 4 deletions js/WebView.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
Text,
UIManager,
View,
ViewPropTypes,
requireNativeComponent,
NativeModules,
Image
Expand All @@ -31,7 +30,8 @@ import {
import invariant from 'fbjs/lib/invariant';
import keyMirror from 'fbjs/lib/keyMirror';

import deprecatedPropType from 'deprecated-prop-type';
import deprecatedPropType from './shims/deprecatedPropType';
import DeprecatedViewPropTypes from './shims/DeprecatedViewPropTypes'

import WebViewShared from './WebViewShared';

Expand All @@ -47,8 +47,8 @@ function processDecelerationRate(decelerationRate) {
return decelerationRate;
}


const RNCWebViewManager = NativeModules.WebViewManager;
const RCTWebViewManager = NativeModules.WebViewManager;
const RCTWKWebViewManager = NativeModules.WKWebViewManager;

const BGWASH = 'rgba(255,255,255,0.8)';
const RCT_WEBVIEW_REF = 'webview';
Expand Down
Loading

0 comments on commit 26d2f5c

Please sign in to comment.