andreluisjunqueira / react-native-document-scanner-android

Document scanner android, feature live detection, auto-capture, perspective correction :vibration_mode: :camera: -- :trophy:
MIT License
82 stars 32 forks source link

Black Screen issue #17

Closed SwagatRanjit84 closed 5 years ago

SwagatRanjit84 commented 5 years ago

I have build and run the project successfully. But its showing black screen and there is no camera or anything that reflects document scanner. Is this library uncompleted? I have a doubt on it.

App.js code

/**

import React, {Component} from 'react'; import {PermissionsAndroid, Platform, StyleSheet, Text, View} from 'react-native'; import DocumentScanner from 'react-native-documentscanner-android';

import Camera from 'react-native-camera'; const width = '100%'; const height = '100%';

export default class App extends Component {

componentDidMount() {
    async function requestCameraPermission() {
        console.log("requestCameraPermission")
        try {
            const granted = await PermissionsAndroid.request(
                PermissionsAndroid.PERMISSIONS.CAMERA,
                {
                    'title': 'Cool Photo App Camera Permission',
                    'message': 'Cool Photo App needs access to your camera ' +
                    'so you can take awesome pictures.'
                }
            )
            if (granted === PermissionsAndroid.RESULTS.GRANTED) {
                console.log("You can STORE the camera")
            } else {
                console.log("storage permission denied")
            }
        }catch(e){
            console.log(e)
        }
        try {
            const granted = await PermissionsAndroid.request(
                PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
                {
                    'title': 'Cool Photo App Camera Permission',
                    'message': 'Cool Photo App needs access to your camera ' +
                    'so you can take awesome pictures.'
                }
            )
            if (granted === PermissionsAndroid.RESULTS.GRANTED) {
                console.log("You can write storage")
            } else {
                console.log("storage permission denied")
            }
        }catch(e){
            console.log(e)
        }
    }
    requestCameraPermission();
}

render() { return (

{ console.log(data.path) }} enableTorch={false} detectionCountBeforeCapture={5} />
);

} } const styles = StyleSheet.create({ container: { flex: 1, width: '100%', height: '100%', backgroundColor: '#fff' } });

andreluisjunqueira commented 5 years ago

Have you tried to pass flex: 1 to style component ?

<DocumentScanner
style={{ 
   flex: 1, <------- Try it 
   width: width,  
   height: height, 
   backgroundColor: '#fff'
 }}
onPictureTaken={data =>{
console.log(data.path)
}}
enableTorch={false}
detectionCountBeforeCapture={5}
/>
SwagatRanjit84 commented 5 years ago

@andreluisjunqueira I have made it working cheers to this library.

MahmoudElmoghazy commented 5 years ago

@SwagatRanjit84 Can you tell us how it works cause i have black screen

acgollapalli commented 5 years ago

@SwagatRanjit84 How did you get this to work?

SwagatRanjit84 commented 5 years ago

@MahmoudElmoghazy @AGollapalli It worked on react native version 0.57.8, after adding implementation 'com.android.support:support-v4:27.1.1' implementation 'com.android.support:appcompat-v7:27.0.2' implementation 'com.android.support:design:27.1.0' in android/app/build.gradle.

M-Moghazy commented 5 years ago

@SwagatRanjit84 Not working can you give us more info please

M-Moghazy commented 5 years ago

This working for me

"react": "^16.8.1", "react-native": "^0.58.4", "react-native-documentscanner-android": "git+https://github.com/thongdn/react-native-documentscanner-android.git#develop",