Message button (#660)

* Remove touchable opacity when scrolling messages
* Tap on disable messages closes keyboard
* Unify vibration
* Vibrate only on Android
This commit is contained in:
Diego Mello 2019-02-27 11:47:15 -03:00 committed by GitHub
parent f3ddf60a57
commit 8c1b57eb26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 11890 additions and 131 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import {
Alert, Clipboard, Vibration, Share
} from 'react-native';
import { Alert, Clipboard, Share } from 'react-native';
import { connect } from 'react-redux';
import ActionSheet from 'react-native-action-sheet';
import * as moment from 'moment';
@ -17,6 +15,7 @@ import {
toggleStarRequest as toggleStarRequestAction
} from '../actions/messages';
import { showToast } from '../utils/info';
import { vibrate } from '../utils/vibration';
import RocketChat from '../lib/rocketchat';
import I18n from '../i18n';
@ -126,7 +125,7 @@ export default class MessageActions extends React.Component {
}
setTimeout(() => {
this.showActionSheet();
Vibration.vibrate(50);
vibrate();
});
}

View File

@ -1,7 +1,7 @@
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import {
View, Text, ViewPropTypes, Image as ImageRN
View, Text, ViewPropTypes, Image as ImageRN, TouchableWithoutFeedback
} from 'react-native';
import Icon from 'react-native-vector-icons/MaterialIcons';
import moment from 'moment';
@ -199,7 +199,7 @@ export default class Message extends PureComponent {
if (header) {
return (
<User
onPress={this._onPress}
onPress={this.onPress}
timeFormat={timeFormat}
username={(useRealName && author.name) || author.username}
alias={alias}
@ -348,22 +348,17 @@ export default class Message extends PureComponent {
editing, style, header, archived, onLongPress, reactionsModal, closeReactions, msg, ts, reactions, author, user, timeFormat, customEmojis, baseUrl
} = this.props;
const accessibilityLabel = I18n.t('Message_accessibility', { user: author.username, time: moment(ts).format(timeFormat), message: msg });
const disabled = this.isInfoMessage() || this.hasError() || archived;
return (
<View style={styles.root}>
{this.renderError()}
<LongPressGestureHandler
onHandlerStateChange={({ nativeEvent }) => nativeEvent.state === State.ACTIVE && onLongPress()}
>
<RectButton
enabled={!(this.isInfoMessage() || this.hasError() || archived)}
style={[styles.container, header && styles.marginBottom]}
<TouchableWithoutFeedback
onLongPress={!disabled && onLongPress}
onPress={this.onPress}
activeOpacity={0.8}
underlayColor='#e1e5e8'
>
<View
style={[styles.message, editing && styles.editing, style]}
style={[styles.container, header && styles.marginBottom, editing && styles.editing, style]}
accessibilityLabel={accessibilityLabel}
>
<View style={styles.flex}>
@ -399,8 +394,7 @@ export default class Message extends PureComponent {
: null
}
</View>
</RectButton>
</LongPressGestureHandler>
</TouchableWithoutFeedback>
</View>
);
}

View File

@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Vibration, ViewPropTypes } from 'react-native';
import { ViewPropTypes } from 'react-native';
import { connect } from 'react-redux';
import equal from 'deep-equal';
@ -10,6 +10,7 @@ import {
toggleReactionPicker as toggleReactionPickerAction,
replyBroadcast as replyBroadcastAction
} from '../../actions/messages';
import { vibrate } from '../../utils/vibration';
@connect(state => ({
baseUrl: state.settings.Site_Url || state.server ? state.server.server : '',
@ -119,7 +120,7 @@ export default class MessageContainer extends React.Component {
onReactionLongPress = () => {
this.setState({ reactionsModal: true });
Vibration.vibrate(50);
vibrate();
}
get timeFormat() {

View File

@ -6,8 +6,12 @@ export default StyleSheet.create({
},
container: {
paddingVertical: 5,
flexDirection: 'row',
width: '100%'
width: '100%',
paddingLeft: 10,
paddingRight: 15,
flexDirection: 'column',
transform: [{ scaleY: -1 }],
flex: 1
},
messageContent: {
flex: 1,
@ -23,13 +27,6 @@ export default StyleSheet.create({
flexDirection: 'row',
flex: 1
},
message: {
paddingLeft: 10,
paddingRight: 15,
flexDirection: 'column',
transform: [{ scaleY: -1 }],
flex: 1
},
textInfo: {
fontStyle: 'italic',
color: '#a0a0a0',

11
app/utils/vibration.js Normal file
View File

@ -0,0 +1,11 @@
import { Vibration } from 'react-native';
import { isAndroid } from './deviceInfo';
const vibrate = () => {
if (isAndroid) {
Vibration.vibrate(30);
}
};
export { vibrate };

View File

@ -1,8 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import {
FlatList, View, Vibration
} from 'react-native';
import { FlatList, View } from 'react-native';
import ActionSheet from 'react-native-action-sheet';
import { connect } from 'react-redux';
import SafeAreaView from 'react-native-safe-area-view';
@ -18,6 +16,7 @@ import database from '../../lib/realm';
import { showToast } from '../../utils/info';
import log from '../../utils/log';
import { isAndroid } from '../../utils/deviceInfo';
import { vibrate } from '../../utils/vibration';
import I18n from '../../i18n';
import SearchBox from '../../containers/SearchBox';
import protectedFunction from '../../lib/methods/helpers/protectedFunction';
@ -184,7 +183,7 @@ export default class RoomMembersView extends LoggedView {
this.actionSheetOptions.push(I18n.t('Mute'));
}
this.setState({ userLongPressed: user });
Vibration.vibrate(50);
vibrate();
this.showActionSheet();
}