From 8c8fb6fe7da3f91a471e978fc44476a733a145fa Mon Sep 17 00:00:00 2001 From: Jose Olarte III Date: Fri, 2 May 2025 21:28:46 +0800 Subject: [PATCH] De-coupled web and mobile scanners --- src/views/ContactQRScanShowView.vue | 40 ++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/src/views/ContactQRScanShowView.vue b/src/views/ContactQRScanShowView.vue index c1bb9823..6a39410d 100644 --- a/src/views/ContactQRScanShowView.vue +++ b/src/views/ContactQRScanShowView.vue @@ -83,12 +83,20 @@ >
- Start Scanning - + +
{{ error }} @@ -96,6 +104,14 @@ permissions. + + + @@ -104,9 +120,11 @@ import { AxiosError } from "axios"; import QRCodeVue3 from "qr-code-generator-vue3"; import { Component, Vue } from "vue-facing-decorator"; import { useClipboard } from "@vueuse/core"; +import { Capacitor } from "@capacitor/core"; import QuickNav from "../components/QuickNav.vue"; import UserNameDialog from "../components/UserNameDialog.vue"; +import QRScannerDialog from "../components/QRScanner/QRScannerDialog.vue"; import { NotificationIface } from "../constants/app"; import { db, retrieveSettingsForActiveAccount } from "../db/index"; import { Contact } from "../db/tables/contacts"; @@ -137,6 +155,7 @@ interface IUserNameDialog { QRCodeVue3, QuickNav, UserNameDialog, + QRScannerDialog, }, }) export default class ContactQRScanShow extends Vue { @@ -151,6 +170,8 @@ export default class ContactQRScanShow extends Vue { qrValue = ""; isScanning = false; error: string | null = null; + showScannerDialog = false; + isNativePlatform = Capacitor.isNativePlatform(); ETHR_DID_PREFIX = ETHR_DID_PREFIX; @@ -251,7 +272,13 @@ export default class ContactQRScanShow extends Vue { } } - // Add scan listener + // Show the scanner dialog for web + if (!this.isNativePlatform) { + this.showScannerDialog = true; + return; + } + + // For native platforms, use the scanner service scanner.addListener({ onScan: this.onScanDetect, onError: this.onScanError, @@ -574,6 +601,11 @@ export default class ContactQRScanShow extends Vue { }); } + closeScannerDialog() { + this.showScannerDialog = false; + this.isScanning = false; + } + // Lifecycle hooks mounted() { this.isMounted = true;