diff --git a/src/components/ImageMethodDialog.vue b/src/components/ImageMethodDialog.vue
index f3938740..2648e420 100644
--- a/src/components/ImageMethodDialog.vue
+++ b/src/components/ImageMethodDialog.vue
@@ -119,12 +119,21 @@
playsinline
muted
>
-
+
+
+
+
track.stop());
+ this.cameraStream = null;
+ }
+
+ // Start new stream with updated facing mode
+ await this.startCameraPreview();
+ }
+ }
+
private createBlobURL(blob: Blob): string {
return URL.createObjectURL(blob);
}
diff --git a/src/services/PlatformService.ts b/src/services/PlatformService.ts
index 574b1a3a..3076a605 100644
--- a/src/services/PlatformService.ts
+++ b/src/services/PlatformService.ts
@@ -26,6 +26,8 @@ export interface PlatformCapabilities {
hasFileDownload: boolean;
/** Whether the platform requires special file handling instructions */
needsFileHandlingInstructions: boolean;
+ /** Whether the platform is a native app (Capacitor, Electron, etc.) */
+ isNativeApp: boolean;
}
/**
@@ -92,6 +94,12 @@ export interface PlatformService {
*/
pickImage(): Promise;
+ /**
+ * Rotates the camera between front and back cameras.
+ * @returns Promise that resolves when the camera is rotated
+ */
+ rotateCamera(): Promise;
+
/**
* Handles deep link URLs for the application.
* @param url - The deep link URL to handle
diff --git a/src/services/platforms/CapacitorPlatformService.ts b/src/services/platforms/CapacitorPlatformService.ts
index ee8f2f82..1294fe5c 100644
--- a/src/services/platforms/CapacitorPlatformService.ts
+++ b/src/services/platforms/CapacitorPlatformService.ts
@@ -4,7 +4,7 @@ import {
PlatformCapabilities,
} from "../PlatformService";
import { Filesystem, Directory, Encoding } from "@capacitor/filesystem";
-import { Camera, CameraResultType, CameraSource } from "@capacitor/camera";
+import { Camera, CameraResultType, CameraSource, CameraDirection } from "@capacitor/camera";
import { Share } from "@capacitor/share";
import { logger } from "../../utils/logger";
@@ -16,6 +16,9 @@ import { logger } from "../../utils/logger";
* - Platform-specific features
*/
export class CapacitorPlatformService implements PlatformService {
+ /** Current camera direction */
+ private currentDirection: CameraDirection = 'BACK';
+
/**
* Gets the capabilities of the Capacitor platform
* @returns Platform capabilities object
@@ -28,6 +31,7 @@ export class CapacitorPlatformService implements PlatformService {
isIOS: /iPad|iPhone|iPod/.test(navigator.userAgent),
hasFileDownload: false,
needsFileHandlingInstructions: true,
+ isNativeApp: true,
};
}
@@ -401,6 +405,7 @@ export class CapacitorPlatformService implements PlatformService {
allowEditing: true,
resultType: CameraResultType.Base64,
source: CameraSource.Camera,
+ direction: this.currentDirection,
});
const blob = await this.processImageData(image.base64String);
@@ -466,6 +471,15 @@ export class CapacitorPlatformService implements PlatformService {
return new Blob(byteArrays, { type: "image/jpeg" });
}
+ /**
+ * Rotates the camera between front and back cameras.
+ * @returns Promise that resolves when the camera is rotated
+ */
+ async rotateCamera(): Promise {
+ this.currentDirection = this.currentDirection === 'BACK' ? 'FRONT' : 'BACK';
+ logger.debug(`Camera rotated to ${this.currentDirection} camera`);
+ }
+
/**
* Handles deep link URLs for the application.
* Note: Capacitor handles deep links automatically.