File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11// useCamera.ts
22import { useState , useRef , useEffect } from "react" ;
3- import { Camera , CameraType , FlashMode , VideoQuality } from "expo-camera" ;
3+ import { CameraView , CameraType , FlashMode } from "expo-camera" ;
44import {
55 requestCameraPermission ,
66 checkCameraPermission ,
@@ -24,7 +24,7 @@ type CameraState = {
2424} ;
2525
2626const 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 ] } ;
You can’t perform that action at this time.
0 commit comments