diff options
author | Ollie Hsieh <renahlee@outlook.com> | 2023-04-20 11:08:30 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-20 13:08:30 -0500 |
commit | 3e78c7101815985241b2631432a023dc8f70d82e (patch) | |
tree | 8136053915475834cac36e06f7da1188558d4356 /src/view/com/util/forms/DropdownButton.tsx | |
parent | 74a1910e1252e9dd58cde66b0996dea998191277 (diff) | |
download | voidsky-3e78c7101815985241b2631432a023dc8f70d82e.tar.zst |
Share profile and post (#499)
Diffstat (limited to 'src/view/com/util/forms/DropdownButton.tsx')
-rw-r--r-- | src/view/com/util/forms/DropdownButton.tsx | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/view/com/util/forms/DropdownButton.tsx b/src/view/com/util/forms/DropdownButton.tsx index 938c346cd..f21323efb 100644 --- a/src/view/com/util/forms/DropdownButton.tsx +++ b/src/view/com/util/forms/DropdownButton.tsx @@ -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') + } }, }, { |