Skip to content

Commit

Permalink
WebView: Allow to change textZoom on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
nvbn committed Oct 9, 2017
1 parent bf36983 commit d437dde
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Libraries/Components/WebView/WebView.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ class WebView extends React.Component {
* @platform android
*/
urlPrefixesForDefaultIntent: PropTypes.arrayOf(PropTypes.string),

/**
* Text zoom of the page in percent, used on Android only. The default is 100.
* @platform android
*/
textZoom: PropTypes.number,
};

static defaultProps = {
Expand Down Expand Up @@ -318,6 +324,7 @@ class WebView extends React.Component {
mixedContentMode={this.props.mixedContentMode}
saveFormDataDisabled={this.props.saveFormDataDisabled}
urlPrefixesForDefaultIntent={this.props.urlPrefixesForDefaultIntent}
textZoom={this.props.textZoom}
{...nativeConfig.props}
/>;

Expand Down
8 changes: 7 additions & 1 deletion Libraries/Components/WebView/WebView.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ class WebView extends React.Component {
'always',
'compatibility'
]),

/**
* Override the native component used to render the WebView. Enables a custom native
* WebView which uses the same JavaScript as the original WebView.
Expand All @@ -398,6 +398,12 @@ class WebView extends React.Component {
*/
viewManager: PropTypes.object,
}),

/**
* Text zoom of the page in percent, used on Android only. The default is 100.
* @platform android
*/
textZoom: PropTypes.number,
};

static defaultProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,11 @@ public void setUrlPrefixesForDefaultIntent(
}
}

@ReactProp(name = "textZoom")
public void setTextZoom(WebView view, int textZoom) {
view.getSettings().setTextZoom(textZoom);
}

@Override
protected void addEventEmitters(ThemedReactContext reactContext, WebView view) {
// Do not register default touch emitter and let WebView implementation handle touches
Expand Down

0 comments on commit d437dde

Please sign in to comment.