Merge pull request #536 from bluesky-social/ansh/app-558-share-profile-and-post-broken-on-android
[APP-558] Sharing refactor
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import {isNative} from 'platform/detection'
|
||||
// import * as Sharing from 'expo-sharing'
|
||||
import Clipboard from '@react-native-clipboard/clipboard'
|
||||
import * as Toast from '../view/com/util/Toast'
|
||||
import {Share} from 'react-native'
|
||||
|
||||
/**
|
||||
* This function shares a URL using the native Share API if available, or copies it to the clipboard
|
||||
* and displays a toast message if not (mostly on web)
|
||||
* @param {string} url - A string representing the URL that needs to be shared or copied to the
|
||||
* clipboard.
|
||||
*/
|
||||
export async function shareUrl(url: string) {
|
||||
if (isNative) {
|
||||
Share.share({url: url})
|
||||
} else {
|
||||
// React Native Share is not supported by web. Web Share API
|
||||
// has increasing but not full support, so default to clipboard
|
||||
Clipboard.setString(url)
|
||||
Toast.show('Copied to clipboard')
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user