From a0e95158d58300026f847e44957314ea84e8bd4f Mon Sep 17 00:00:00 2001 From: Andriy Zherdiy Date: Sun, 2 Dec 2018 02:13:56 +0200 Subject: [PATCH 1/4] Added possibility to set animation type. Added possibility to set auto focus. Fixed input state after reopen --- index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 6026e8e..697cc08 100644 --- a/index.js +++ b/index.js @@ -16,14 +16,17 @@ class DialogInput extends React.Component{ let textProps = this.props.textInputProps || null; let modalStyleProps = this.props.modalStyle || {}; let dialogStyleProps = this.props.dialogStyle || {}; + let animationType = this.props.animationType || 'fade'; var cancelText = this.props.cancelText || 'Cancel'; var submitText = this.props.submitText || 'Submit'; cancelText = (Platform.OS === 'ios')? cancelText:cancelText.toUpperCase(); submitText = (Platform.OS === 'ios')? submitText:submitText.toUpperCase(); + this.setState({inputModal:this.props.value || ''}); + return( { @@ -43,7 +46,8 @@ class DialogInput extends React.Component{ underlineColorAndroid='transparent' placeholder={hintInput} onChangeText={(inputModal) => this.setState({inputModal})} - value={this.state.inputModal} + value={this.state.inputModal} + autoFocus={(textProps && textProps.autoFocus===false)?false:true} /> From 5b8ca8d0d5d8e13ab65443cd3213922172273165 Mon Sep 17 00:00:00 2001 From: Andriy Zherdiy Date: Sun, 2 Dec 2018 02:19:55 +0200 Subject: [PATCH 2/4] Fixed input state after reopen --- index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 697cc08..c81f096 100644 --- a/index.js +++ b/index.js @@ -9,6 +9,11 @@ class DialogInput extends React.Component{ inputModal: props.value || '' } } + + componentDidMount() { + this.setState({inputModal:this.props.value || ''}); + } + render(){ let title = this.props.title || ''; let hintInput = this.props.hintInput || ''; @@ -22,8 +27,6 @@ class DialogInput extends React.Component{ cancelText = (Platform.OS === 'ios')? cancelText:cancelText.toUpperCase(); submitText = (Platform.OS === 'ios')? submitText:submitText.toUpperCase(); - this.setState({inputModal:this.props.value || ''}); - return( Date: Sun, 2 Dec 2018 03:11:10 +0200 Subject: [PATCH 3/4] Fixed input state after reopen --- index.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index c81f096..9d231b1 100644 --- a/index.js +++ b/index.js @@ -10,10 +10,15 @@ class DialogInput extends React.Component{ } } - componentDidMount() { + onOpen() { this.setState({inputModal:this.props.value || ''}); } + onClose() { + this.props.closeDialog(); + this.setState({inputModal:''}); + } + render(){ let title = this.props.title || ''; let hintInput = this.props.hintInput || ''; @@ -32,9 +37,8 @@ class DialogInput extends React.Component{ animationType={animationType} transparent={true} visible={this.props.isDialogVisible} - onRequestClose={() => { - this.props.closeDialog(); - }}> + onOpen={() => {this.onOpen();}} + onRequestClose={() => {this.onClose();}}> @@ -55,9 +59,7 @@ class DialogInput extends React.Component{ { - this.props.closeDialog(); - }}> + onPress={() => {this.onClose();}}> {cancelText} From 71a25d9a2658ddc8bcde291329f5b2fdef2afab2 Mon Sep 17 00:00:00 2001 From: Andriy Zherdiy Date: Sun, 2 Dec 2018 03:18:52 +0200 Subject: [PATCH 4/4] Fixed input state after reopen --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 9d231b1..71effc0 100644 --- a/index.js +++ b/index.js @@ -10,7 +10,7 @@ class DialogInput extends React.Component{ } } - onOpen() { + onShow() { this.setState({inputModal:this.props.value || ''}); } @@ -37,7 +37,7 @@ class DialogInput extends React.Component{ animationType={animationType} transparent={true} visible={this.props.isDialogVisible} - onOpen={() => {this.onOpen();}} + onShow={() => {this.onShow();}} onRequestClose={() => {this.onClose();}}>