react-native-camera-kit
react-native-camera-kit copied to clipboard
CameraType = > back,front not working
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'
Hello, I have the same issue. I've tried as in the docs but it doesn't do anything.
@robertcoroianu I have fixed it by changing some code
node_modules\react-native-camera-kit\dist\CameraScreen.js
cameraType: props.CameraType || CameraType.Front,
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 })
}
}
Should be fixed in #545
Still not fixed in the library.
Used the Code from @ahmad6242 works perfectly. Thanks @ahmad6242