diff options
| author | Adam Soltys <[email protected]> | 2023-06-06 16:57:00 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-06-06 16:57:00 -0700 |
| commit | 4a1dca452d6e03656c1b892c6afdaf2b92e0858d (patch) | |
| tree | b947b5be491229546d5cf40f718222be4d816277 | |
| parent | 916f9715b29003cac421518363316b69b2d860a7 (diff) | |
| download | coinos-ui-4a1dca452d6e03656c1b892c6afdaf2b92e0858d.tar.gz coinos-ui-4a1dca452d6e03656c1b892c6afdaf2b92e0858d.zip | |
restore scanner
| -rw-r--r-- | src/routes/(app)/scan/+page.svelte | 44 |
1 files changed, 14 insertions, 30 deletions
diff --git a/src/routes/(app)/scan/+page.svelte b/src/routes/(app)/scan/+page.svelte index bcdecf1a..8c5ea0a5 100644 --- a/src/routes/(app)/scan/+page.svelte +++ b/src/routes/(app)/scan/+page.svelte @@ -1,41 +1,19 @@ <script> import { Icon } from '$comp'; - // import QrScanner from 'qr-scanner'; - - import { Html5QrcodeScanner } from 'html5-qrcode'; + import QrScanner from 'qr-scanner'; import { onMount, onDestroy } from 'svelte'; import { back } from '$lib/utils'; import { goto } from '$app/navigation'; let scanner, vid; onMount(() => { - // scanner = new QrScanner(vid, ({ data }) => scanner.stop() || goto(`/send/${encodeURI(data)}`), { - // highlightScanRegion: true, - // highlightCodeOutline: true - // }); - // scanner.start(); - - let html5QrcodeScanner = new Html5QrcodeScanner( - 'reader', - { fps: 10, qrbox: { width: 250, height: 250 } }, - /* verbose= */ false - ); - html5QrcodeScanner.render(onScanSuccess, onScanFailure); + scanner = new QrScanner(vid, ({ data }) => scanner.stop() || goto(`/send/${encodeURI(data)}`), { + highlightScanRegion: true, + highlightCodeOutline: true + }); + scanner.start(); }); -let yeah; - function onScanSuccess(decodedText, decodedResult) { - // handle the scanned code as you like, for example: - console.log(`Code matched = ${decodedText}`, decodedResult); - yeah = true; - } - - function onScanFailure(error) { - // handle scan failure, usually better to ignore and keep scanning. - // for example: - //console.warn(`Code scan error = ${error}`); - } - onDestroy(() => scanner?.stop()); </script> @@ -43,8 +21,14 @@ let yeah; <Icon icon="arrow-left" style="w-10" /> </button> -{#if yeah}TRUE{/if} -<div id="reader" width="600px"></div> +<div class="flex w-full mb-4 px-4"> + <div class="bg-black mx-auto rounded-3xl"> + <video + bind:this={vid} + class="border-4 rounded-3xl border-black md:max-w-[600px] !max-h-[80vh] !min-w-[300px]" + /> + </div> +</div> <div class="flex w-full mb-4"> <button class="mx-auto border rounded-full px-6 py-2 font-bold hover:opacity-80" on:click={back}> |
