[ReactNative] Use strings instead of constants for keyboardDismissMode

This commit is contained in:
Christopher Chedeau 2015-03-03 10:22:29 -08:00
parent 3daaf1741c
commit 46f41c3d4b
3 changed files with 23 additions and 17 deletions

View File

@ -239,7 +239,7 @@ var SearchScreen = React.createClass({
renderRow={this.renderRow} renderRow={this.renderRow}
onEndReached={this.onEndReached} onEndReached={this.onEndReached}
automaticallyAdjustContentInsets={false} automaticallyAdjustContentInsets={false}
keyboardDismissMode={ScrollView.keyboardDismissMode.OnDrag} keyboardDismissMode="onDrag"
keyboardShouldPersistTaps={true} keyboardShouldPersistTaps={true}
showsVerticalScrollIndicator={false} showsVerticalScrollIndicator={false}
/>; />;

View File

@ -30,8 +30,7 @@ var UIExplorerPage = React.createClass({
} else { } else {
ContentWrapper = ScrollView; ContentWrapper = ScrollView;
wrapperProps.keyboardShouldPeristTaps = true; wrapperProps.keyboardShouldPeristTaps = true;
wrapperProps.keyboardDismissMode = wrapperProps.keyboardDismissMode = 'interactive';
ScrollView.keyboardDismissMode.Interactive;
} }
var title = this.props.title ? var title = this.props.title ?
<UIExplorerTitle title={this.props.title} /> : <UIExplorerTitle title={this.props.title} /> :

View File

@ -31,6 +31,12 @@ var PropTypes = React.PropTypes;
var SCROLLVIEW = 'ScrollView'; var SCROLLVIEW = 'ScrollView';
var INNERVIEW = 'InnerScrollView'; var INNERVIEW = 'InnerScrollView';
var keyboardDismissModeConstants = {
'none': RKScrollViewConsts.KeyboardDismissMode.None, // default
'interactive': RKScrollViewConsts.KeyboardDismissMode.Interactive,
'onDrag': RKScrollViewConsts.KeyboardDismissMode.OnDrag,
};
/** /**
* `React` component that wraps platform `RKScrollView` while providing * `React` component that wraps platform `RKScrollView` while providing
* integration with touch locking "responder" system. * integration with touch locking "responder" system.
@ -80,8 +86,8 @@ var INNERVIEW = 'InnerScrollView';
/** /**
* A floating-point number that determines how quickly the scroll view * A floating-point number that determines how quickly the scroll view
* decelerates after the user lifts their finger. Reasonable choices include * decelerates after the user lifts their finger. Reasonable choices include
* `RKScrollView.Constants.DecelerationRate.Normal` (the default) and * - Normal: 0.998 (the default)
* `RKScrollView.Constants.DecelerationRate.Fast`. * - Fast: 0.9
*/ */
decelerationRate: nativePropType(PropTypes.number), decelerationRate: nativePropType(PropTypes.number),
/** /**
@ -91,18 +97,17 @@ var INNERVIEW = 'InnerScrollView';
horizontal: PropTypes.bool, horizontal: PropTypes.bool,
/** /**
* Determines whether the keyboard gets dismissed in response to a drag. * Determines whether the keyboard gets dismissed in response to a drag.
* When `ScrollView.keyboardDismissMode.None` (the default), drags do not * - 'none' (the default), drags do not dismiss the keyboard.
* dismiss the keyboard. When `ScrollView.keyboardDismissMode.OnDrag`, the * - 'onDrag', the keyboard is dismissed when a drag begins.
* keyboard is dismissed when a drag begins. When * - 'interactive', the keyboard is dismissed interactively with the drag
* `ScrollView.keyboardDismissMode.Interactive`, the keyboard is dismissed * and moves in synchrony with the touch; dragging upwards cancels the
* interactively with the drag and moves in synchrony with the touch; * dismissal.
* dragging upwards cancels the dismissal.
*/ */
keyboardDismissMode: nativePropType(PropTypes.oneOf([ keyboardDismissMode: PropTypes.oneOf([
RKScrollViewConsts.KeyboardDismissMode.None, // default 'none', // default
RKScrollViewConsts.KeyboardDismissMode.Interactive, 'interactive',
RKScrollViewConsts.KeyboardDismissMode.OnDrag, 'onDrag',
])), ]),
/** /**
* When false, tapping outside of the focused text input when the keyboard * When false, tapping outside of the focused text input when the keyboard
* is up dismisses the keyboard. When true, the scroll view will not catch * is up dismisses the keyboard. When true, the scroll view will not catch
@ -154,7 +159,6 @@ var INNERVIEW = 'InnerScrollView';
var ScrollView = React.createClass({ var ScrollView = React.createClass({
statics: { statics: {
PropTypes: RKScrollViewPropTypes, PropTypes: RKScrollViewPropTypes,
keyboardDismissMode: RKScrollViewConsts.KeyboardDismissMode,
}, },
propTypes: RKScrollViewPropTypes, propTypes: RKScrollViewPropTypes,
@ -230,6 +234,9 @@ var ScrollView = React.createClass({
this.props, { this.props, {
alwaysBounceHorizontal, alwaysBounceHorizontal,
alwaysBounceVertical, alwaysBounceVertical,
keyboardDismissMode: this.props.keyboardDismissMode ?
keyboardDismissModeConstants[this.props.keyboardDismissMode] :
undefined,
style: [styles.base, this.props.style], style: [styles.base, this.props.style],
onTouchStart: this.scrollResponderHandleTouchStart, onTouchStart: this.scrollResponderHandleTouchStart,
onTouchMove: this.scrollResponderHandleTouchMove, onTouchMove: this.scrollResponderHandleTouchMove,