feat: add native share support for space invites
This commit is contained in:
@@ -3,7 +3,9 @@
|
||||
import {sleep} from "@welshman/lib"
|
||||
import {request} from "@welshman/net"
|
||||
import {displayRelayUrl, getTagValue, RELAY_INVITE} from "@welshman/util"
|
||||
import {Share} from "@capacitor/share"
|
||||
import LinkRound from "@assets/icons/link-round.svg?dataurl"
|
||||
import NativeShare from "@assets/icons/native-share.svg?dataurl"
|
||||
import Copy from "@assets/icons/copy.svg?dataurl"
|
||||
import Spinner from "@lib/components/Spinner.svelte"
|
||||
import Field from "@lib/components/Field.svelte"
|
||||
@@ -28,6 +30,8 @@
|
||||
|
||||
const copyInvite = () => clip(invite)
|
||||
|
||||
const shareInvite = () => Share.share({url: invite})
|
||||
|
||||
let claim = $state("")
|
||||
let loading = $state(true)
|
||||
|
||||
@@ -74,17 +78,35 @@
|
||||
<p class="center">Oops! It looks like you're not a member of this relay.</p>
|
||||
{:else}
|
||||
<div class="flex flex-col items-center gap-6">
|
||||
<QRCode code={invite} />
|
||||
<div class="w-48">
|
||||
<QRCode code={invite} />
|
||||
</div>
|
||||
<Field>
|
||||
{#snippet input()}
|
||||
<label class="input input-bordered flex w-full items-center gap-2">
|
||||
<Icon icon={LinkRound} />
|
||||
<input bind:value={invite} class="grow" type="text" />
|
||||
<Button onclick={copyInvite}>
|
||||
<Icon icon={Copy} />
|
||||
<div class="flex w-full gap-2">
|
||||
<Button
|
||||
class="input input-bordered flex shrink-0 w-12 items-center justify-center p-0"
|
||||
onclick={shareInvite}
|
||||
>
|
||||
<Icon icon={NativeShare} />
|
||||
</Button>
|
||||
</label>
|
||||
|
||||
<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 info()}
|
||||
<p>
|
||||
This invite link can be used by clicking "Add Space" and pasting it there.
|
||||
|
||||
Reference in New Issue
Block a user