aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/scan/+page.svelte
blob: 8c5ea0a5e54caf15a93317c7bea9f8db90148433 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<script>
	import { Icon } from '$comp';
	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();
	});

	onDestroy(() => scanner?.stop());
</script>

<button class="ml-5 md:ml-20 mt-5 md:mt-10 hover:opacity-80" on:click={back}>
	<Icon icon="arrow-left" style="w-10" />
</button>

<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}>
		Cancel
	</button>
</div>

<style>
	video {
		transition: transform 0.3s ease-out;
		transform: scale(1);
	}
</style>