Skip to content

Commit

Permalink
fix(ReactWebView): Add ReactWebView
Browse files Browse the repository at this point in the history
ReactWebView provides access to native webview UI components for React Native JavaScript applications.
- PR comments #3 implemented

Fixes #118
  • Loading branch information
ebragge authored and rozele committed May 25, 2016
1 parent 6f358e4 commit 0cd0a51
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
18 changes: 8 additions & 10 deletions ReactNative/Views/Web/ReactWebViewManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,21 @@ public override IReadOnlyDictionary<string, object> CommandsMap
}

/// <summary>
/// Sets flag signaling whether JavaScript is enabled.
/// Sets whether JavaScript is enabled or not.
/// </summary>
/// <param name="view">A webview instance.</param>
/// <param name="enabled"></param>
/// <param name="enabled">A flag signaling whether JavaScript is enabled.</param>
[ReactProp("javaScriptEnabled")]
public void SetJavaScriptEnabled(WebView view, bool enabled)
{
view.Settings.IsJavaScriptEnabled = enabled;
}

/// <summary>
/// Sets flag signaling whether Indexed DB is enabled.
/// Sets whether Indexed DB is enabled or not.
/// </summary>
/// <param name="view">A webview instance.</param>
/// <param name="enabled"></param>
/// <param name="enabled">A flag signaling whether Indexed DB is enabled.</param>
[ReactProp("indexedDbEnabled")]
public void SetIndexedDbEnabled(WebView view, bool enabled)
{
Expand All @@ -76,7 +76,7 @@ public void SetIndexedDbEnabled(WebView view, bool enabled)
/// Sets the JavaScript to be injected when the webpage loads.
/// </summary>
/// <param name="view">A webview instance.</param>
/// <param name="injectedJavaScript"></param>
/// <param name="injectedJavaScript">An injected JavaScript.</param>
[ReactProp("injectedJavaScript")]
public void SetInjectedJavaScript(WebView view, string injectedJavaScript)
{
Expand All @@ -87,7 +87,7 @@ public void SetInjectedJavaScript(WebView view, string injectedJavaScript)
/// Sets webview source.
/// </summary>
/// <param name="view">A webview instance.</param>
/// <param name="source"></param>
/// <param name="source">A source for the webview (either static html or an uri).</param>
[ReactProp("source")]
public void SetSource(WebView view, JObject source)
{
Expand Down Expand Up @@ -137,11 +137,9 @@ public void SetSource(WebView view, JObject source)
var headers = source.Value<JObject>("headers");
if (headers != null)
{
IEnumerator<KeyValuePair<string, JToken>> enumerator = ((JObject)headers).GetEnumerator();
enumerator.Reset();
while (enumerator.MoveNext())
foreach (var header in headers)
{
request.Headers.Append(enumerator.Current.Key, enumerator.Current.Value.Value<string>());
request.Headers.Append(header.Key, header.Value.Value<string>());
}
}

Expand Down
3 changes: 1 addition & 2 deletions js/Components/WebView/WebView.windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ var WebView = React.createClass({

/**
* Used on Android and Windows only, JS is enabled by default for WebView on iOS
* @platform android
* @platform windows
* @platform android, windows
*/
javaScriptEnabled: PropTypes.bool,

Expand Down

0 comments on commit 0cd0a51

Please sign in to comment.