-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
82 additions
and
22 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ | |
"type": "module", | ||
"dependencies": { | ||
"@tauri-apps/api": "^1.5.6", | ||
"qr-scanner": "^1.4.2", | ||
"qrcode": "^1.5.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,68 @@ | ||
<script lang="ts"> | ||
import { goto } from '$app/navigation'; | ||
import Button from '$lib/components/Button.svelte'; | ||
import ChevronLeft from '$lib/components/icons/ChevronLeft.svelte'; | ||
import { onMount } from 'svelte'; | ||
import QrScanner from 'qr-scanner'; | ||
let hashCode: string | undefined; | ||
let videoSource: HTMLVideoElement | null = null; | ||
let loading = false; | ||
let qrScanner: QrScanner | null = null; | ||
onMount(() => { | ||
navigator.permissions.query({ name: 'camera' as PermissionName }).then((permission) => { | ||
if (permission.state === 'denied') { | ||
goto('/transfers'); | ||
} | ||
loading = true; | ||
navigator.mediaDevices | ||
.getUserMedia({ | ||
audio: false, | ||
video: true | ||
}) | ||
.then((stream) => { | ||
if (!videoSource) return; | ||
videoSource.srcObject = stream; | ||
videoSource.play(); | ||
loading = false; | ||
qrScanner = new QrScanner( | ||
videoSource, | ||
(result) => { | ||
goto('/transfers/recieve/confirm?hash=' + result); | ||
}, | ||
{ | ||
highlightCodeOutline: true, | ||
highlightScanRegion: true | ||
} | ||
); | ||
qrScanner.start(); | ||
}); | ||
}); | ||
return () => { | ||
if (qrScanner) { | ||
qrScanner.stop(); | ||
} | ||
}; | ||
}); | ||
</script> | ||
|
||
<header class="my-2 flex flex-row justify-between px-4 py-2"> | ||
<header class="absolute top-0 z-50 my-2 flex flex-row justify-between px-4 py-2"> | ||
<button | ||
on:click={() => { | ||
goto('/transfers'); | ||
}} | ||
class="flex flex-row items-center gap-5" | ||
> | ||
<ChevronLeft class="h-6 w-6 stroke-black" /> | ||
<span class="text-lg font-medium">Back</span> | ||
<ChevronLeft class="h-6 w-6 stroke-white" /> | ||
<span class="text-lg font-medium text-white">Back</span> | ||
</button> | ||
</header> | ||
|
||
<h2 class="w-full text-center text-gray-modern-200">Temporary Page</h2> | ||
|
||
<div class="mx-12 my-48 flex flex-col items-center justify-center gap-2"> | ||
<span class="w-full text-xs text-gray-modern-600">Enter Hash Code</span> | ||
<input | ||
bind:value={hashCode} | ||
class="w-full rounded-lg border-2 border-gray-modern-200 p-2" | ||
type="text" | ||
/> | ||
<Button | ||
on:click={() => { | ||
goto('/transfers/recieve/confirm?hash=' + hashCode); | ||
}} | ||
class="w-full ">Connect</Button | ||
> | ||
</div> | ||
<video class="absolute inset-0 z-0 h-full bg-black object-contain" bind:this={videoSource}> | ||
<track kind="captions" /> | ||
</video> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters