[IMPROVEMENT] Hold URL to copy (#1684)
This commit is contained in:
parent
4a63cb01e2
commit
91518a1bc4
|
@ -0,0 +1,8 @@
|
|||
export class Client { }
|
||||
|
||||
export default {
|
||||
bugsnag: () => '',
|
||||
leaveBreadcrumb: () => '',
|
||||
notify: () => '',
|
||||
loggerConfig: () => ''
|
||||
};
|
|
@ -0,0 +1,3 @@
|
|||
export default {
|
||||
analytics: null
|
||||
};
|
|
@ -27460,6 +27460,7 @@ exports[`Storyshots Message list message 1`] = `
|
|||
Support
|
||||
</Text>
|
||||
<Text
|
||||
onLongPress={[Function]}
|
||||
onPress={[Function]}
|
||||
style={
|
||||
Object {
|
||||
|
@ -27531,6 +27532,7 @@ exports[`Storyshots Message list message 1`] = `
|
|||
|
||||
</Text>
|
||||
<Text
|
||||
onLongPress={[Function]}
|
||||
onPress={[Function]}
|
||||
style={
|
||||
Object {
|
||||
|
@ -27666,6 +27668,7 @@ exports[`Storyshots Message list message 1`] = `
|
|||
|
||||
</Text>
|
||||
<Text
|
||||
onLongPress={[Function]}
|
||||
onPress={[Function]}
|
||||
style={
|
||||
Object {
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Text } from 'react-native';
|
||||
import { Text, Clipboard } from 'react-native';
|
||||
|
||||
import styles from './styles';
|
||||
import { themes } from '../../constants/colors';
|
||||
import openLink from '../../utils/openLink';
|
||||
import { LISTENER } from '../Toast';
|
||||
import EventEmitter from '../../utils/events';
|
||||
import I18n from '../../i18n';
|
||||
|
||||
const Link = React.memo(({
|
||||
children, link, preview, theme
|
||||
|
@ -17,11 +20,16 @@ const Link = React.memo(({
|
|||
};
|
||||
|
||||
const childLength = React.Children.toArray(children).filter(o => o).length;
|
||||
const onLongPress = () => {
|
||||
Clipboard.setString(link);
|
||||
EventEmitter.emit(LISTENER, { message: I18n.t('Copied_to_clipboard') });
|
||||
};
|
||||
|
||||
// if you have a [](https://rocket.chat) render https://rocket.chat
|
||||
return (
|
||||
<Text
|
||||
onPress={preview ? undefined : handlePress}
|
||||
onLongPress={preview ? undefined : onLongPress}
|
||||
style={
|
||||
!preview
|
||||
? { ...styles.link, color: themes[theme].actionTintColor }
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import React from 'react';
|
||||
import { View, Text, StyleSheet } from 'react-native';
|
||||
import {
|
||||
View, Text, StyleSheet, Clipboard
|
||||
} from 'react-native';
|
||||
import PropTypes from 'prop-types';
|
||||
import FastImage from 'react-native-fast-image';
|
||||
import Touchable from 'react-native-platform-touchable';
|
||||
|
@ -10,6 +12,9 @@ import sharedStyles from '../../views/Styles';
|
|||
import { themes } from '../../constants/colors';
|
||||
import { withTheme } from '../../theme';
|
||||
import { withSplit } from '../../split';
|
||||
import { LISTENER } from '../Toast';
|
||||
import EventEmitter from '../../utils/events';
|
||||
import I18n from '../../i18n';
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
button: {
|
||||
|
@ -82,9 +87,15 @@ const Url = React.memo(({
|
|||
|
||||
const onPress = () => openLink(url.url, theme);
|
||||
|
||||
const onLongPress = () => {
|
||||
Clipboard.setString(url.url);
|
||||
EventEmitter.emit(LISTENER, { message: I18n.t('Copied_to_clipboard') });
|
||||
};
|
||||
|
||||
return (
|
||||
<Touchable
|
||||
onPress={onPress}
|
||||
onLongPress={onLongPress}
|
||||
style={[
|
||||
styles.button,
|
||||
index > 0 && styles.marginTop,
|
||||
|
|
Loading…
Reference in New Issue