mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
at offline-indicator 24 lines 870 B view raw
1import {isIOS, isAndroid} from 'platform/detection' 2// import * as Sharing from 'expo-sharing' 3import Clipboard from '@react-native-clipboard/clipboard' 4import * as Toast from '../view/com/util/Toast' 5import {Share} from 'react-native' 6 7/** 8 * This function shares a URL using the native Share API if available, or copies it to the clipboard 9 * and displays a toast message if not (mostly on web) 10 * @param {string} url - A string representing the URL that needs to be shared or copied to the 11 * clipboard. 12 */ 13export async function shareUrl(url: string) { 14 if (isAndroid) { 15 Share.share({message: url}) 16 } else if (isIOS) { 17 Share.share({url}) 18 } else { 19 // React Native Share is not supported by web. Web Share API 20 // has increasing but not full support, so default to clipboard 21 Clipboard.setString(url) 22 Toast.show('Copied to clipboard') 23 } 24}