feat(lightbox): add Share image menu item on web

Adds a Share image entry above Download image in the web lightbox menu.
Uses the Web Share API when available, falls back to clipboard copy with a toast.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
vineyardbovines
2026-04-21 12:54:26 -04:00
parent 60896acdc8
commit 7dea2bd0d4
+32
View File
@@ -18,6 +18,7 @@ import {
} from '#/alf'
import {Button} from '#/components/Button'
import {Backdrop} from '#/components/Dialog'
import {ArrowOutOfBox_Stroke2_Corner0_Rounded as ShareIcon} from '#/components/icons/ArrowOutOfBox'
import {
ChevronLeft_Stroke2_Corner0_Rounded as ChevronLeftIcon,
ChevronRight_Stroke2_Corner0_Rounded as ChevronRightIcon,
@@ -265,6 +266,37 @@ function LightboxGallery({
</Menu.Trigger>
<Menu.Outer>
<Menu.Group>
<Menu.Item
label={_(msg`Share image`)}
onPress={async () => {
const url = img.uri
if (
typeof navigator !== 'undefined' &&
'share' in navigator &&
navigator.share
) {
try {
await navigator.share({url})
} catch {
// User cancelled or share failed; no-op
}
} else if (
typeof navigator !== 'undefined' &&
navigator.clipboard
) {
try {
await navigator.clipboard.writeText(url)
Toast.show(_(msg`Link copied to clipboard`))
} catch {
Toast.show(_(msg`Failed to copy link`), {type: 'error'})
}
}
}}>
<Menu.ItemText>
<Trans>Share image</Trans>
</Menu.ItemText>
<Menu.ItemIcon icon={ShareIcon} position="right" />
</Menu.Item>
<Menu.Item
label={_(msg`Download image`)}
onPress={() => {