Skip to content

Commit

Permalink
Camera issue fix
Browse files Browse the repository at this point in the history
  • Loading branch information
shyambhongle committed Jul 17, 2024
1 parent 8732120 commit 333999f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,5 @@ yarn-error.*
notes.txt

.vscode

android
ios
android/
ios/
22 changes: 8 additions & 14 deletions src/components/common/CameraView.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { Linking, Platform, StyleSheet, Text, View } from 'react-native'
import React, { useEffect, useRef, useState } from 'react'
import {
Camera,
CameraCapturedPicture,
CameraType,
PermissionStatus,
} from 'expo-camera'
import { CameraCapturedPicture, CameraView, PermissionStatus, useCameraPermissions } from 'expo-camera';
import { scaleSize } from 'src/utils/constants/mixins'
import CustomButton from './CustomButton'
import { Colors, Typography } from 'src/utils/constants'
Expand All @@ -16,18 +11,18 @@ interface Props {
takePicture: (metaData: CameraCapturedPicture) => void
}

const CameraView = (props: Props) => {
const [permission, requestPermission] = Camera.useCameraPermissions()
const CameraMainView = (props: Props) => {
const [permission, requestPermission] = useCameraPermissions()
const [loading, setLoading] = useState(false)
const cameraRef = useRef<Camera>(null)
const cameraRef = useRef<CameraView>(null)

useEffect(() => {
requestPermission()
}, [])

const captureImage = async () => {
setLoading(true)
const data = await cameraRef.current.takePictureAsync({skipProcessing:true})
const data = await cameraRef.current.takePictureAsync({ skipProcessing: true })
if (data) {
props.takePicture(data)
} else {
Expand Down Expand Up @@ -55,11 +50,10 @@ const CameraView = (props: Props) => {
</Text>
</>
) : (
<Camera
type={CameraType.back}
<CameraView
facing='back'
style={styles.cameraWrapper}
ref={cameraRef}
ratio="1:1"
/>
)}
</View>
Expand All @@ -75,7 +69,7 @@ const CameraView = (props: Props) => {
)
}

export default CameraView
export default CameraMainView

const styles = StyleSheet.create({
container: {
Expand Down

0 comments on commit 333999f

Please sign in to comment.