mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-23 20:01:01 +08:00
Implement returnKeyType/returnKeyLabel on Android
Summary:
This PR implements [`returnKeyType`](http://facebook.github.io/react-native/docs/textinput.html#returnkeytype) on Android.
It is implemented with [`EditText.setImeOptions()`](http://developer.android.com/reference/android/widget/TextView.html#setImeOptions(int)) that allows us to specify options on an input, in this case change the return button icon. To be noted that it is also possible to specify a string instead of an icon with [`EditText.setImeActionLabel()`](http://developer.android.com/reference/android/widget/TextView.html#setImeActionLabel(java.lang.CharSequence, int)) while being 2 different things I added both of these behaviors in this PR since it was mostly at the same place/component.
**Problems encountered :**
- All the `ReactEditText`s were set to `IME_ACTION_DONE` by default ([reference](a2157dbbe0/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java (L78))). I'm not sure
Closes https://github.com/facebook/react-native/pull/6905
Differential Revision: D3264755
Pulled By: dmmiller
fb-gh-sync-id: 4a090e31b620a245847c06ba1895cfea02e88d0f
fbshipit-source-id: 4a090e31b620a245847c06ba1895cfea02e88d0f
This commit is contained in:
committed by
Facebook Github Bot 2
parent
02af7b57d0
commit
dd8caf4cf2
@@ -120,6 +120,7 @@ var TextInput = React.createClass({
|
||||
* Determines which keyboard to open, e.g.`numeric`.
|
||||
*
|
||||
* The following values work across platforms:
|
||||
*
|
||||
* - default
|
||||
* - numeric
|
||||
* - email-address
|
||||
@@ -150,22 +151,54 @@ var TextInput = React.createClass({
|
||||
'dark',
|
||||
]),
|
||||
/**
|
||||
* Determines how the return key should look.
|
||||
* @platform ios
|
||||
* Determines how the return key should look. On Android you can also use
|
||||
* `returnKeyLabel`.
|
||||
*
|
||||
* The following values work across platforms:
|
||||
*
|
||||
* - done
|
||||
* - go
|
||||
* - next
|
||||
* - search
|
||||
* - send
|
||||
*
|
||||
* The following values work on Android only:
|
||||
*
|
||||
* - none
|
||||
* - previous
|
||||
*
|
||||
* The following values work on iOS only:
|
||||
*
|
||||
* - default
|
||||
* - emergency-call
|
||||
* - google
|
||||
* - join
|
||||
* - route
|
||||
* - yahoo
|
||||
*/
|
||||
returnKeyType: PropTypes.oneOf([
|
||||
'default',
|
||||
// Cross-platform
|
||||
'done',
|
||||
'go',
|
||||
'google',
|
||||
'join',
|
||||
'next',
|
||||
'route',
|
||||
'search',
|
||||
'send',
|
||||
'yahoo',
|
||||
'done',
|
||||
// Android-only
|
||||
'none',
|
||||
'previous',
|
||||
// iOS-only
|
||||
'default',
|
||||
'emergency-call',
|
||||
'google',
|
||||
'join',
|
||||
'route',
|
||||
'yahoo',
|
||||
]),
|
||||
/**
|
||||
* Sets the return key to the label. Use it instead of `returnKeyType`.
|
||||
* @platform android
|
||||
*/
|
||||
returnKeyLabel: PropTypes.string,
|
||||
/**
|
||||
* Limits the maximum number of characters that can be entered. Use this
|
||||
* instead of implementing the logic in JS to avoid flicker.
|
||||
@@ -531,6 +564,8 @@ var TextInput = React.createClass({
|
||||
children={children}
|
||||
editable={this.props.editable}
|
||||
selectTextOnFocus={this.props.selectTextOnFocus}
|
||||
returnKeyType={this.props.returnKeyType}
|
||||
returnKeyLabel={this.props.returnKeyLabel}
|
||||
/>;
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user