Skip to content

Commit

Permalink
Prop to change supported orientation (#11)
Browse files Browse the repository at this point in the history
* Prop to change supported orientation
  • Loading branch information
mikaello authored and peacechen committed Aug 16, 2017
1 parent f31a3f6 commit 78576a7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class SampleApp extends Component {
<ModalSelector
data={data}
initValue="Select something yummy!"
supportedOrientations={['landscape']}
onChange={(option)=>{ this.setState({textInputValue:option.label})}}>

<TextInput
Expand Down Expand Up @@ -100,4 +101,5 @@ NOTE: Due to breaking changes in React Native, RN < 0.39.0 should pass `flex:1`
* `cancelStyle` (object, optional) style definitions for the cancel element
* `cancelTextStyle` (object, optional) style definitions for the cancel text element
* `disabled` (bool, optional, default false) disable opening of the modal
* `supportedOrientations` (`['portrait', 'landscape']`, optional, default both), orientations the modal support
* `keyboardShouldPersistTaps` (string/bool, optional, default 'always') passed to underlying ScrollView
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const propTypes = {
overlayStyle: rnVersion >= 0.44 ? ViewPropTypes.style : View.propTypes.style,
cancelText: PropTypes.string,
disabled: PropTypes.bool,
supportedOrientations: PropTypes.arrayOf(PropTypes.oneOfType(['portrait', 'landscape', 'portrait-upside-down', 'landscape-left', 'landscape-right'])),
keyboardShouldPersistTaps: PropTypes.oneOfType([PropTypes.string, PropTypes.bool])
};

Expand All @@ -54,6 +55,7 @@ const defaultProps = {
overlayStyle: {},
cancelText: 'cancel',
disabled: false,
supportedOrientations: ['portrait', 'landscape'],
keyboardShouldPersistTaps: 'always'
};

Expand Down Expand Up @@ -171,7 +173,7 @@ export default class ModalSelector extends BaseComponent {
<Modal
transparent={true}
ref="modal"
supportedOrientations={['landscape', 'portrait']}
supportedOrientations={this.props.supportedOrientations}
visible={this.state.modalVisible}
onRequestClose={this.close}
animationType={this.state.animationType}
Expand Down

0 comments on commit 78576a7

Please sign in to comment.