2022-10-06 08:11:06 +00:00
|
|
|
import Clipboard from '@react-native-community/clipboard';
|
2022-09-26 17:31:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Tries to copy a given text to the clipboard.
|
|
|
|
* Returns true if the action succeeds.
|
|
|
|
*
|
|
|
|
* @param {string} textToCopy - Text to be copied.
|
|
|
|
* @returns {Promise<boolean>}
|
|
|
|
*/
|
2022-10-06 08:11:06 +00:00
|
|
|
export function copyText(textToCopy: string) {
|
2022-09-26 17:31:06 +00:00
|
|
|
try {
|
2022-10-06 08:11:06 +00:00
|
|
|
Clipboard.setString(textToCopy);
|
2022-09-26 17:31:06 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
} catch (e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|