Share profile and post (#499)

This commit is contained in:
Ollie Hsieh 2023-04-20 11:08:30 -07:00 committed by GitHub
parent 74a1910e12
commit 3e78c71018
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 4 deletions

View file

@ -19,6 +19,9 @@ import {toShareUrl} from 'lib/strings/url-helpers'
import {useStores} from 'state/index'
import {usePalette} from 'lib/hooks/usePalette'
import {useTheme} from 'lib/ThemeContext'
import {isAndroid, isIOS} from 'platform/detection'
import Clipboard from '@react-native-clipboard/clipboard'
import * as Toast from '../../util/Toast'
const HITSLOP = {left: 10, top: 10, right: 10, bottom: 10}
const ESTIMATED_MENU_ITEM_HEIGHT = 52
@ -159,7 +162,16 @@ export function PostDropdownBtn({
icon: 'share',
label: 'Share...',
onPress() {
Share.share({url: toShareUrl(itemHref)})
const url = toShareUrl(itemHref)
if (isIOS || isAndroid) {
Share.share({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')
}
},
},
{