Keyboard dismiss (#219)
* Fix keyboard scroll * * Input resize * Touchable input * keyboard dismiss * Remove unnecessary emoji picker when it's not in use
This commit is contained in:
parent
037caf5e17
commit
153cfecab5
|
@ -12,6 +12,7 @@ export default class MessageBox extends React.PureComponent {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.animatedBottom = new Animated.Value(0);
|
this.animatedBottom = new Animated.Value(0);
|
||||||
|
this.state = { render: false };
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
|
@ -25,6 +26,7 @@ export default class MessageBox extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
show() {
|
show() {
|
||||||
|
this.setState({ render: true });
|
||||||
this.animatedBottom.setValue(0);
|
this.animatedBottom.setValue(0);
|
||||||
Animated.timing(this.animatedBottom, {
|
Animated.timing(this.animatedBottom, {
|
||||||
toValue: 1,
|
toValue: 1,
|
||||||
|
@ -39,6 +41,9 @@ export default class MessageBox extends React.PureComponent {
|
||||||
duration: 300,
|
duration: 300,
|
||||||
useNativeDriver: true
|
useNativeDriver: true
|
||||||
}).start();
|
}).start();
|
||||||
|
setTimeout(() => {
|
||||||
|
this.setState({ render: false });
|
||||||
|
}, 300);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -47,6 +52,10 @@ export default class MessageBox extends React.PureComponent {
|
||||||
outputRange: [0, -this.props.messageboxHeight - 200]
|
outputRange: [0, -this.props.messageboxHeight - 200]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!this.state.render) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Animated.View
|
<Animated.View
|
||||||
style={{
|
style={{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { StyleSheet, Text } from 'react-native';
|
import { StyleSheet, Text, Keyboard } from 'react-native';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
|
@ -23,12 +23,15 @@ export default class Typing extends React.Component {
|
||||||
shouldComponentUpdate(nextProps) {
|
shouldComponentUpdate(nextProps) {
|
||||||
return this.props.usersTyping.join() !== nextProps.usersTyping.join();
|
return this.props.usersTyping.join() !== nextProps.usersTyping.join();
|
||||||
}
|
}
|
||||||
|
onPress = () => {
|
||||||
|
Keyboard.dismiss();
|
||||||
|
}
|
||||||
get usersTyping() {
|
get usersTyping() {
|
||||||
const users = this.props.usersTyping.filter(_username => this.props.username !== _username);
|
const users = this.props.usersTyping.filter(_username => this.props.username !== _username);
|
||||||
return users.length ? `${ users.join(' ,') } ${ users.length > 1 ? 'are' : 'is' } typing` : '';
|
return users.length ? `${ users.join(' ,') } ${ users.length > 1 ? 'are' : 'is' } typing` : '';
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
return (<Text style={styles.typing}>{this.usersTyping}</Text>);
|
return (<Text style={styles.typing} onPress={() => this.onPress()}>{this.usersTyping}</Text>);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { View, TouchableHighlight, Text, TouchableOpacity, Animated } from 'react-native';
|
import { View, TouchableHighlight, Text, TouchableOpacity, Animated, Keyboard } from 'react-native';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import Icon from 'react-native-vector-icons/MaterialIcons';
|
import Icon from 'react-native-vector-icons/MaterialIcons';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
@ -64,6 +64,10 @@ export default class Message extends React.Component {
|
||||||
return this.props.item._updatedAt.toGMTString() !== nextProps.item._updatedAt.toGMTString() || this.props.item.status !== nextProps.item.status;
|
return this.props.item._updatedAt.toGMTString() !== nextProps.item._updatedAt.toGMTString() || this.props.item.status !== nextProps.item.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onPress = () => {
|
||||||
|
Keyboard.dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
onLongPress() {
|
onLongPress() {
|
||||||
const { item } = this.props;
|
const { item } = this.props;
|
||||||
this.props.actionsShow(JSON.parse(JSON.stringify(item)));
|
this.props.actionsShow(JSON.parse(JSON.stringify(item)));
|
||||||
|
@ -181,6 +185,7 @@ export default class Message extends React.Component {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TouchableHighlight
|
<TouchableHighlight
|
||||||
|
onPress={() => this.onPress()}
|
||||||
onLongPress={() => this.onLongPress()}
|
onLongPress={() => this.onLongPress()}
|
||||||
disabled={this.isDeleted() || this.hasError()}
|
disabled={this.isDeleted() || this.hasError()}
|
||||||
underlayColor='#FFFFFF'
|
underlayColor='#FFFFFF'
|
||||||
|
|
|
@ -209,7 +209,7 @@ export default class RoomView extends React.Component {
|
||||||
renderRow={item => this.renderItem(item)}
|
renderRow={item => this.renderItem(item)}
|
||||||
initialListSize={10}
|
initialListSize={10}
|
||||||
keyboardShouldPersistTaps='always'
|
keyboardShouldPersistTaps='always'
|
||||||
keyboardDismissMode='on-drag'
|
keyboardDismissMode='none'
|
||||||
/>
|
/>
|
||||||
</SafeAreaView>
|
</SafeAreaView>
|
||||||
{this.renderFooter()}
|
{this.renderFooter()}
|
||||||
|
|
Loading…
Reference in New Issue