react-native-camera-kit icon indicating copy to clipboard operation
react-native-camera-kit copied to clipboard

CameraType = > back,front not working

Open ahmad6242 opened this issue 2 years ago • 2 comments

Issue Description

CameraType => back, front does not make any effect on which camera is opening. unless i use cameraFlipImage={require('path/to/image')}, when i click on this image only then the camera is switched.

How can i use this Prop CameraType ? Please guide

Steps to Reproduce / Code Snippets / Screenshots

 <Modal animationType="slide" transparent={true} visible={this.state.modalAttendance.modal} onRequestClose={() => this.state.modalAttendance.toggleModal()} >
                    <View style={{ flex: 1 }}>
                        <CameraScreen
                            cameraFlipImage={require('../assets/menu/qr.png')}
                            hideControls={false}
                            cameraType={CameraType.Front}//CameraType.Back
                            // Barcode props
                            scanBarcode={this.state.modalAttendance.scanning}
                            // onReadCode={(event) => Alert.alert('QR code found')} // optional
                            onReadCode={(event) => {
                                let data = event.nativeEvent.codeStringValue
                                if (this.state.modalAttendance.scanning) {
                                    this.setState({ modalAttendance: { ...this.state.modalAttendance, scanning: !this.state.modalAttendance.scanning } }, () => this.onBarCodeRead(data))
                                }
                            }
                            }
                            showFrame={true} // (default false) optional, show frame with transparent layer (qr code or barcode will be read on this area ONLY), start animation for scanner,that stoped when find any code. Frame always at center of the screen
                            laserColor={themeColors.danger2} // (default red) optional, color of laser in scanner frame
                            frameColor={themeColors.warning2} // (default white) optional, color of border of scanner frame
                        />
                    </View>
</Modal>

Environment

  • "@react-navigation/native": "^6.0.13",
  • React Native version: 0.70.3
  • Platform(s) (iOS, Android, or both?): Only tested on 'Android' yet
  • Device info (Simulator/Device? OS version? Debug/Release?): 'Simulator (PIXEL 5 API 31) debug mode'

ahmad6242 avatar Oct 14 '22 08:10 ahmad6242

Hello, I have the same issue. I've tried as in the docs but it doesn't do anything.

image

robertcoroianu avatar Oct 17 '22 10:10 robertcoroianu

@robertcoroianu I have fixed it by changing some code

node_modules\react-native-camera-kit\dist\CameraScreen.js

cameraType: props.CameraType || CameraType.Front,

image

COPY PASTE this function in the file

 componentDidUpdate(prevProps, prevState) {
        if (this.state.cameraType != this.props.cameraType && this.props.cameraType) {
            this.setState({ cameraType: this.props.cameraType })
        }
    }

image

ahmad6242 avatar Oct 18 '22 05:10 ahmad6242

Should be fixed in #545

scarlac avatar Jun 12 '23 00:06 scarlac

Still not fixed in the library.

Used the Code from @ahmad6242 works perfectly. Thanks @ahmad6242

EducoreAPK avatar Nov 20 '23 08:11 EducoreAPK