Unverified Commit 91518a1b authored by Sarthak Pranesh's avatar Sarthak Pranesh Committed by GitHub
Browse files

[IMPROVEMENT] Hold URL to copy (#1684)

parent 4a63cb01
export class Client { }
export default {
bugsnag: () => '',
leaveBreadcrumb: () => '',
notify: () => '',
loggerConfig: () => ''
};
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 {
......
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 }
......
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,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment