feat: add native share support for space invites
This commit is contained in:
parent
016ae86d50
commit
7a7af58f5c
3 changed files with 41 additions and 8 deletions
|
|
@ -55,6 +55,7 @@
|
||||||
"@capacitor/keyboard": "^8.0.0",
|
"@capacitor/keyboard": "^8.0.0",
|
||||||
"@capacitor/preferences": "^8.0.0",
|
"@capacitor/preferences": "^8.0.0",
|
||||||
"@capacitor/push-notifications": "^8.0.0",
|
"@capacitor/push-notifications": "^8.0.0",
|
||||||
|
"@capacitor/share": "^8.0.1",
|
||||||
"@capawesome/capacitor-android-dark-mode-support": "^8.0.0",
|
"@capawesome/capacitor-android-dark-mode-support": "^8.0.0",
|
||||||
"@capawesome/capacitor-badge": "^8.0.0",
|
"@capawesome/capacitor-badge": "^8.0.0",
|
||||||
"@getalby/lightning-tools": "^6.1.0",
|
"@getalby/lightning-tools": "^6.1.0",
|
||||||
|
|
|
||||||
BIN
pnpm-lock.yaml
BIN
pnpm-lock.yaml
Binary file not shown.
|
|
@ -3,7 +3,9 @@
|
||||||
import {sleep} from "@welshman/lib"
|
import {sleep} from "@welshman/lib"
|
||||||
import {request} from "@welshman/net"
|
import {request} from "@welshman/net"
|
||||||
import {displayRelayUrl, getTagValue, RELAY_INVITE} from "@welshman/util"
|
import {displayRelayUrl, getTagValue, RELAY_INVITE} from "@welshman/util"
|
||||||
|
import {Share} from "@capacitor/share"
|
||||||
import LinkRound from "@assets/icons/link-round.svg?dataurl"
|
import LinkRound from "@assets/icons/link-round.svg?dataurl"
|
||||||
|
import Upload from "@assets/icons/upload.svg?dataurl"
|
||||||
import Copy from "@assets/icons/copy.svg?dataurl"
|
import Copy from "@assets/icons/copy.svg?dataurl"
|
||||||
import Spinner from "@lib/components/Spinner.svelte"
|
import Spinner from "@lib/components/Spinner.svelte"
|
||||||
import Field from "@lib/components/Field.svelte"
|
import Field from "@lib/components/Field.svelte"
|
||||||
|
|
@ -27,6 +29,17 @@
|
||||||
const back = () => history.back()
|
const back = () => history.back()
|
||||||
const copyInvite = () => clip(invite)
|
const copyInvite = () => clip(invite)
|
||||||
|
|
||||||
|
const shareInvite = async () => {
|
||||||
|
if (!canShare) return
|
||||||
|
|
||||||
|
try {
|
||||||
|
await Share.share({url: invite})
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let canShare = $state(false)
|
||||||
let claim = $state("")
|
let claim = $state("")
|
||||||
let loading = $state(true)
|
let loading = $state(true)
|
||||||
let invite = $state("")
|
let invite = $state("")
|
||||||
|
|
@ -38,6 +51,13 @@
|
||||||
})
|
})
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
|
try {
|
||||||
|
const {value} = await Share.canShare()
|
||||||
|
canShare = value
|
||||||
|
} catch {
|
||||||
|
canShare = false
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const [[event]] = await Promise.all([
|
const [[event]] = await Promise.all([
|
||||||
request({
|
request({
|
||||||
|
|
@ -76,16 +96,28 @@
|
||||||
<p class="center">Oops! It looks like you're not a member of this relay.</p>
|
<p class="center">Oops! It looks like you're not a member of this relay.</p>
|
||||||
{:else}
|
{:else}
|
||||||
<div class="flex flex-col items-center gap-6">
|
<div class="flex flex-col items-center gap-6">
|
||||||
<QRCode code={invite} />
|
<div class="w-48">
|
||||||
|
<QRCode code={invite} />
|
||||||
|
</div>
|
||||||
<Field>
|
<Field>
|
||||||
{#snippet input()}
|
{#snippet input()}
|
||||||
<label class="input input-bordered flex w-full items-center gap-2">
|
<div class="flex w-full gap-2">
|
||||||
<Icon icon={LinkRound} />
|
{#if canShare}
|
||||||
<input bind:value={invite} class="grow" type="text" />
|
<Button
|
||||||
<Button onclick={copyInvite}>
|
class="input input-bordered flex shrink-0 w-12 items-center justify-center p-0"
|
||||||
<Icon icon={Copy} />
|
onclick={shareInvite}>
|
||||||
</Button>
|
<Icon icon={Upload} />
|
||||||
</label>
|
</Button>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<label class="input input-bordered flex min-w-0 flex-1 items-center gap-2">
|
||||||
|
<Icon icon={LinkRound} class="shrink-0" />
|
||||||
|
<input bind:value={invite} class="min-w-0 flex-1 truncate" type="text" readonly />
|
||||||
|
<Button class="shrink-0" onclick={copyInvite}>
|
||||||
|
<Icon icon={Copy} />
|
||||||
|
</Button>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
{#snippet info()}
|
{#snippet info()}
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue