Skip to content

Commit b96f6c3

Browse files
Updated camera implementation to work with new version.
1 parent e202d93 commit b96f6c3

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

hooks/useCamera.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// useCamera.ts
22
import { useState, useRef, useEffect } from "react";
3-
import { Camera, CameraType, FlashMode, VideoQuality } from "expo-camera";
3+
import { CameraView, CameraType, FlashMode } from "expo-camera";
44
import {
55
requestCameraPermission,
66
checkCameraPermission,
@@ -24,7 +24,7 @@ type CameraState = {
2424
};
2525

2626
const useCamera = () => {
27-
const cameraRef = useRef(null);
27+
const cameraRef = useRef<CameraView | null>(null);
2828
const [state, setState] = useState<CameraState>({
2929
hasPermission: null,
3030
// Use string literals instead of enum values
@@ -62,11 +62,8 @@ const useCamera = () => {
6262
};
6363

6464
const cycleFlashMode = () => {
65-
setState((prev) => {
66-
//FlashMode
67-
const modes = Object.values("off").filter(
68-
(v) => typeof v === "number"
69-
) as unknown as FlashMode[];
65+
setState((prev) => {3
66+
const modes: FlashMode[] = ["off", "on", "auto", "torch"];
7067
const currentIndex = modes.indexOf(prev.flashMode);
7168
const nextIndex = (currentIndex + 1) % modes.length;
7269
return { ...prev, flashMode: modes[nextIndex] };

0 commit comments

Comments
 (0)