From 6f236555ddeaa478f91f7742aa652194246a7a6a Mon Sep 17 00:00:00 2001 From: Ramananda Panda Date: Fri, 24 Aug 2018 15:49:20 +0530 Subject: [PATCH 1/3] fixed offfocus out hide keyboard --- index.js | 88 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 45 insertions(+), 43 deletions(-) diff --git a/index.js b/index.js index 0001eea..b5518e7 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ import React from 'react'; -import { StyleSheet, Text, View, Modal, TextInput, TouchableOpacity, +import { StyleSheet, Text, View, Modal, TextInput, TouchableOpacity,TouchableWithoutFeedback,Keyboard, ActivityIndicator, Platform } from 'react-native'; class DialogInput extends React.Component{ @@ -28,50 +28,52 @@ class DialogInput extends React.Component{ onRequestClose={() => { this.props.closeDialog(); }}> - - - - {title} - {this.props.message} - { - if(inputModal.trim()){ - this.setState({inputModal:inputModal,submitDisabled:false}) - }else{ - if(isInputRequired) - this.setState({inputModal:inputModal,submitDisabled:true}) - else - this.setState({inputModal}); - } - }} - /> - - - { - this.props.closeDialog(); - }}> - {cancelText} - - - { - this.props.submitInput(this.state.inputModal); - }}> - {submitText} - + + + + + {title} + {this.props.message} + { + if(inputModal.trim()){ + this.setState({inputModal:inputModal,submitDisabled:false}) + }else{ + if(isInputRequired) + this.setState({inputModal:inputModal,submitDisabled:true}) + else + this.setState({inputModal}); + } + }} + /> + + + { + this.props.closeDialog(); + }}> + {cancelText} + + + { + this.props.submitInput(this.state.inputModal); + }}> + {submitText} + + - + ); } From e5c5c0eae044aa7c2437f61d1864513bf0549818 Mon Sep 17 00:00:00 2001 From: Ramananda Panda Date: Fri, 24 Aug 2018 15:50:10 +0530 Subject: [PATCH 2/3] some visual fixes --- index.js | 91 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 47 insertions(+), 44 deletions(-) diff --git a/index.js b/index.js index b5518e7..b805e64 100644 --- a/index.js +++ b/index.js @@ -29,50 +29,50 @@ class DialogInput extends React.Component{ this.props.closeDialog(); }}> - - - - {title} - {this.props.message} - { - if(inputModal.trim()){ - this.setState({inputModal:inputModal,submitDisabled:false}) - }else{ - if(isInputRequired) - this.setState({inputModal:inputModal,submitDisabled:true}) - else - this.setState({inputModal}); - } - }} - /> - - - { - this.props.closeDialog(); - }}> - {cancelText} - - - { - this.props.submitInput(this.state.inputModal); - }}> - {submitText} - - + + + + {title} + {this.props.message} + { + if(inputModal.trim()){ + this.setState({inputModal:inputModal,submitDisabled:false}) + }else{ + if(isInputRequired) + this.setState({inputModal:inputModal,submitDisabled:true}) + else + this.setState({inputModal}); + } + }} + /> + + + { + this.props.closeDialog(); + }}> + {cancelText} + + + { + this.props.submitInput(this.state.inputModal); + }}> + {submitText} + + ); @@ -87,6 +87,9 @@ const styles = StyleSheet.create({ ...Platform.select({ android:{ backgroundColor: 'rgba(0,0,0,0.62)' + }, + ios:{ + backgroundColor: 'rgba(0,0,0,0.52)' } }), }, @@ -95,7 +98,7 @@ const styles = StyleSheet.create({ marginRight: 30, ...Platform.select({ ios: { - backgroundColor:'rgba(220,220,220, 0.9)', + backgroundColor:'rgba(220,220,220, 0.98)', borderRadius: 10, minWidth: 300, }, @@ -133,7 +136,7 @@ const styles = StyleSheet.create({ }), }, message_modal:{ - fontSize: 16, + fontSize: 14, ...Platform.select({ ios: { textAlign:'center', From 6e33fd85573c728806992b457acf151451a6440b Mon Sep 17 00:00:00 2001 From: Ramananda Panda Date: Fri, 24 Aug 2018 16:25:05 +0530 Subject: [PATCH 3/3] reseting state on closeDialog --- index.js | 94 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 51 insertions(+), 43 deletions(-) diff --git a/index.js b/index.js index b805e64..6d87150 100644 --- a/index.js +++ b/index.js @@ -6,6 +6,12 @@ class DialogInput extends React.Component{ constructor(props){ super(props); this.state = {inputModal:'',submitDisabled:true} + this.baseState = this.state; + } + closeDialog(){ + this.setState(this.baseState,()=>{ + this.props.closeDialog(); + }) } render(){ let title = this.props.title || ''; @@ -19,6 +25,7 @@ class DialogInput extends React.Component{ var isInputRequired = (textProps && textProps.required )|| false; cancelText = (Platform.OS === 'ios')? cancelText:cancelText.toUpperCase(); submitText = (Platform.OS === 'ios')? submitText:submitText.toUpperCase(); + return( { - this.props.closeDialog(); + this.closeDialog(); }}> - - - - {title} - {this.props.message} - { - if(inputModal.trim()){ - this.setState({inputModal:inputModal,submitDisabled:false}) - }else{ - if(isInputRequired) - this.setState({inputModal:inputModal,submitDisabled:true}) - else - this.setState({inputModal}); - } - }} - /> - - - { - this.props.closeDialog(); - }}> - {cancelText} - - - { - this.props.submitInput(this.state.inputModal); - }}> - {submitText} - + + + + {title} + {this.props.message} + { + let trimmedInput = inputModal.trim(); + if(trimmedInput){ + this.setState({inputModal:trimmedInput,submitDisabled:false}) + }else{ + if(isInputRequired) + this.setState({inputModal:trimmedInput,submitDisabled:true}) + else + this.setState({inputModal}); + } + }} + /> + + + { + this.closeDialog(); + }}> + {cancelText} + + + { + this.props.submitInput(this.state.inputModal); + }}> + {submitText} + + - );