Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Libraries/Modal/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ class Modal extends React.Component {
* - `none` appears without an animation
*/
animationType: PropTypes.oneOf(['none', 'slide', 'fade']),
/**
* The `softInputMode` prop controls soft input mode for the modal window.
*
* - `unspecified` The system will try to pick a mode, `resize` or `pan`.
* - `resize` Window is resized when an input method is shown. This mode is ignored if the window is fullscreen.
* - `pan` Window is panned to ensure the current input focus is visible.
* - `nothing` Window is neither resized nor panned when an input method is shown.
* @platform android
*/
softInputMode: PropTypes.oneOf(['unspecified', 'resize', 'pan', 'nothing']),
/**
* The `transparent` prop determines whether your modal will fill the entire view. Setting this to `true` will render the modal over a transparent background.
*/
Expand Down Expand Up @@ -132,6 +142,7 @@ class Modal extends React.Component {
static defaultProps = {
visible: true,
hardwareAccelerated: false,
softInputMode: 'resize',
};

static contextTypes = {
Expand Down Expand Up @@ -165,6 +176,7 @@ class Modal extends React.Component {
return (
<RCTModalHostView
animationType={animationType}
softInputMode={this.props.softInputMode}
transparent={this.props.transparent}
hardwareAccelerated={this.props.hardwareAccelerated}
onRequestClose={this.props.onRequestClose}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ public void setAnimationType(ReactModalHostView view, String animationType) {
view.setAnimationType(animationType);
}

@ReactProp(name = "softInputMode")
public void setSoftInputMode(ReactModalHostView view, String softInputMode) {
view.setSoftInputMode(softInputMode);
}

@ReactProp(name = "transparent")
public void setTransparent(ReactModalHostView view, boolean transparent) {
view.setTransparent(transparent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public interface OnRequestCloseListener {
private @Nullable Dialog mDialog;
private boolean mTransparent;
private String mAnimationType;
private String mSoftInputMode;
private boolean mHardwareAccelerated;
// Set this flag to true if changing a particular property on the view requires a new Dialog to
// be created. For instance, animation does since it affects Dialog creation through the theme
Expand Down Expand Up @@ -154,6 +155,10 @@ protected void setAnimationType(String animationType) {
mPropertyRequiresNewDialog = true;
}

protected void setSoftInputMode(String softInputMode) {
mSoftInputMode = softInputMode;
}

protected void setHardwareAccelerated(boolean hardwareAccelerated) {
mHardwareAccelerated = hardwareAccelerated;
mPropertyRequiresNewDialog = true;
Expand Down Expand Up @@ -242,7 +247,6 @@ public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
}
});

mDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
if (mHardwareAccelerated) {
mDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
}
Expand Down Expand Up @@ -278,6 +282,18 @@ private void updateProperties() {
WindowManager.LayoutParams.FLAG_DIM_BEHIND,
WindowManager.LayoutParams.FLAG_DIM_BEHIND);
}

switch (mSoftInputMode) {
case "resize":
mDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
break;
case "pan":
mDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
break;
case "nothing":
mDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
break;
}
}

/**
Expand Down