Bluesky app fork with some witchin' additions 馃挮 witchsky.app
bluesky fork client
at main 42 lines 1.4 kB view raw
1import {Share} from 'react-native' 2// import * as Sharing from 'expo-sharing' 3import {setStringAsync} from 'expo-clipboard' 4import {t} from '@lingui/core/macro' 5 6import * as Toast from '#/view/com/util/Toast' 7import {IS_ANDROID, IS_IOS} from '#/env' 8 9/** 10 * This function shares a URL using the native Share API if available, or copies it to the clipboard 11 * and displays a toast message if not (mostly on web) 12 * @param {string} url - A string representing the URL that needs to be shared or copied to the 13 * clipboard. 14 */ 15export async function shareUrl(url: string) { 16 if (IS_ANDROID) { 17 await Share.share({message: url}) 18 } else if (IS_IOS) { 19 await Share.share({url}) 20 } else { 21 // React Native Share is not supported by web. Web Share API 22 // has increasing but not full support, so default to clipboard 23 setStringAsync(url) 24 Toast.show(t`Copied to clipboard`, 'clipboard-check') 25 } 26} 27 28/** 29 * This function shares a text using the native Share API if available, or copies it to the clipboard 30 * and displays a toast message if not (mostly on web) 31 * 32 * @param {string} text - A string representing the text that needs to be shared or copied to the 33 * clipboard. 34 */ 35export async function shareText(text: string) { 36 if (IS_ANDROID || IS_IOS) { 37 await Share.share({message: text}) 38 } else { 39 await setStringAsync(text) 40 Toast.show(t`Copied to clipboard`, 'clipboard-check') 41 } 42}