Skip to content

Commit

Permalink
feat(components-rn): Input & Textarea 开放 RN 参数, close #3125
Browse files Browse the repository at this point in the history
  • Loading branch information
Manjiz committed May 23, 2019
1 parent 4d12ad9 commit 02d4e3b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
2 changes: 2 additions & 0 deletions packages/taro-components-rn/TCRNExample/example/EXInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default class EXTextinput extends Component {
onConfirm={this.onConfirm}
onInput={this.onInput}
value={this.state.inputValue}
placeholderTextColor="red"
/>

<Textarea
Expand All @@ -45,6 +46,7 @@ export default class EXTextinput extends Component {
height: 30
}}
autoHeight
placeholderTextColor="red"
/>
</View>
)
Expand Down
25 changes: 24 additions & 1 deletion packages/taro-components-rn/src/components/Input/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
TextInputContentSizeChangeEventData,
KeyboardTypeOptions
} from 'react-native'
import { noop } from '../../utils'
import { noop, omit } from '../../utils'
import { InputProps, InputState } from './PropsType'

const keyboardTypeMap: { [key: string]: string } = {
Expand Down Expand Up @@ -214,6 +214,29 @@ class _Input extends React.Component<InputProps, InputState> {
onContentSizeChange={this.onContentSizeChange}
underlineColorAndroid="rgba(0,0,0,0)"
style={[style, _multiline && { height: Math.max(35, this.state.height) }]}
{...omit(this.props, [
'style',
'value',
'type',
'password',
'placeholder',
'disabled',
'maxlength',
'focus',
'confirmType',
'confirmHold',
'cursor',
'selectionStart',
'selectionEnd',
'onInput',
'onFocus',
'onBlur',
'onKeyDown',
'onConfirm',
'_multiline',
'_autoHeight',
'_onLineChange'
])}
/>
)
}
Expand Down
9 changes: 6 additions & 3 deletions packages/taro-components-rn/src/components/Textarea/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@ const _Textarea: React.SFC<TextareaProps> = (props) => {

return (
<Input
_multiline={true}
_autoHeight={autoHeight}
_onLineChange={onLineChange}
{...omit(props, [
'type',
'password',
'confirmType',
'confirmHold',
// props
'autoHeight',
'onLineChange'
])}
_multiline={true}
_autoHeight={autoHeight}
_onLineChange={onLineChange}
/>
)
}
Expand Down

0 comments on commit 02d4e3b

Please sign in to comment.