You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
99 lines
2.7 KiB
99 lines
2.7 KiB
import { PlatformServiceFactory } from "./PlatformServiceFactory";
|
|
import { PlatformService } from "./PlatformService";
|
|
import { logger } from "@/utils/logger";
|
|
|
|
/**
|
|
* QR Navigation Service
|
|
*
|
|
* Handles platform-specific routing logic for QR scanning operations.
|
|
* Removes coupling between views and routing logic by centralizing
|
|
* navigation decisions based on platform capabilities.
|
|
*
|
|
* @author Matthew Raymer
|
|
*/
|
|
export class QRNavigationService {
|
|
private static instance: QRNavigationService | null = null;
|
|
private platformService: PlatformService;
|
|
|
|
private constructor() {
|
|
this.platformService = PlatformServiceFactory.getInstance();
|
|
}
|
|
|
|
/**
|
|
* Get singleton instance of QRNavigationService
|
|
*/
|
|
public static getInstance(): QRNavigationService {
|
|
if (!QRNavigationService.instance) {
|
|
QRNavigationService.instance = new QRNavigationService();
|
|
}
|
|
return QRNavigationService.instance;
|
|
}
|
|
|
|
/**
|
|
* Get the appropriate QR scanner route based on platform
|
|
*
|
|
* @returns Object with route name and parameters for QR scanning
|
|
*/
|
|
public getQRScannerRoute(): {
|
|
name: string;
|
|
params?: Record<string, string | number>;
|
|
} {
|
|
const isCapacitor = this.platformService.isCapacitor();
|
|
|
|
logger.debug("QR Navigation - Platform detection:", {
|
|
isCapacitor,
|
|
platform: this.platformService.getCapabilities(),
|
|
});
|
|
|
|
if (isCapacitor) {
|
|
// Use native scanner on mobile platforms
|
|
return { name: "contact-qr-scan-full" };
|
|
} else {
|
|
// Use web scanner on other platforms
|
|
return { name: "contact-qr" };
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get the appropriate QR display route based on platform
|
|
*
|
|
* @returns Object with route name and parameters for QR display
|
|
*/
|
|
public getQRDisplayRoute(): {
|
|
name: string;
|
|
params?: Record<string, string | number>;
|
|
} {
|
|
const isCapacitor = this.platformService.isCapacitor();
|
|
|
|
logger.debug("QR Navigation - Display route detection:", {
|
|
isCapacitor,
|
|
platform: this.platformService.getCapabilities(),
|
|
});
|
|
|
|
if (isCapacitor) {
|
|
// Use dedicated display view on mobile
|
|
return { name: "contact-qr-scan-show" };
|
|
} else {
|
|
// Use combined view on web
|
|
return { name: "contact-qr" };
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Check if native QR scanning is available on current platform
|
|
*
|
|
* @returns true if native scanning is available, false otherwise
|
|
*/
|
|
public isNativeScanningAvailable(): boolean {
|
|
return this.platformService.isCapacitor();
|
|
}
|
|
|
|
/**
|
|
* Get platform capabilities for QR operations
|
|
*
|
|
* @returns Platform capabilities object
|
|
*/
|
|
public getPlatformCapabilities() {
|
|
return this.platformService.getCapabilities();
|
|
}
|
|
}
|
|
|