-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,57 @@ | ||
import { useCodeScanner } from 'react-native-vision-camera' | ||
import { StyleSheet, Text } from 'react-native' | ||
Check failure Code scanning / ESLint Replace ·StyleSheet,·Text·}·from·'react-native' with StyleSheet,·Text}·from·'react-native'; Error
Replace ·StyleSheet,·Text·}·from·'react-native' with StyleSheet,·Text}·from·'react-native';
|
||
import { SafeAreaView } from 'react-native-safe-area-context'; | ||
Check failure Code scanning / ESLint Replace ·SafeAreaView· with SafeAreaView Error
Replace ·SafeAreaView· with SafeAreaView
|
||
import { Camera, useCameraDevice, useCameraFormat, useCodeScanner, useCameraPermission } from 'react-native-vision-camera' | ||
Check failure Code scanning / ESLint Replace ·Camera,·useCameraDevice,·useCameraFormat,·useCodeScanner,·useCameraPermission·}·from·'react-native-vision-camera' with ⏎··Camera,⏎··useCameraDevice,⏎··useCameraFormat,⏎··useCodeScanner,⏎··useCameraPermission,⏎}·from·'react-native-vision-camera'; Error
Replace ·Camera,·useCameraDevice,·useCameraFormat,·useCodeScanner,·useCameraPermission·}·from·'react-native-vision-camera' with ⏎··Camera,⏎··useCameraDevice,⏎··useCameraFormat,⏎··useCodeScanner,⏎··useCameraPermission,⏎}·from·'react-native-vision-camera';
|
||
import { getProduct } from '../../service/apiCall'; | ||
Check failure Code scanning / ESLint Replace ·getProduct· with getProduct Error
Replace ·getProduct· with getProduct
|
||
|
||
const codeScanner = useCodeScanner({ | ||
codeTypes: ['qr', 'ean-13'], | ||
onCodeScanned: (codes) => { | ||
console.log(`Scanned ${codes.length} codes!`) | ||
} | ||
}) | ||
export const Imager = () => { | ||
const {hasPermission, requestPermission} = useCameraPermission(); | ||
|
||
Check failure Code scanning / ESLint Delete ·· Error
Delete ··
|
||
requestPermission(); | ||
|
||
const codeScanner = useCodeScanner({ | ||
codeTypes: ['qr', 'ean-13'], | ||
onCodeScanned: (codes) => { | ||
Check failure Code scanning / ESLint Replace (codes) with codes Error
Replace (codes) with codes
|
||
codes.forEach(code => { | ||
if(code.type == 'ean-13') getProduct(code.value).then(result => console.log(`Product found : ${result.name}`)/* call another page */); | ||
Check failure Code scanning / ESLint Replace (code.type·==·'ean-13')·getProduct(code.value).then(result·=>·console.log(Product·found·:·${result.name})/*·call·another·page·*/ with ·(code.type·==·'ean-13')⏎··········getProduct(code.value).then(⏎············result·=>⏎··············console.log(⏎················Product·found·:·${result.name},⏎··············)·/*·call·another·page·*/,⏎·········· Error
Replace (code.type·==·'ean-13')·getProduct(code.value).then(result·=>·console.log(Product·found·:·${result.name})/\*·call·another·page·\*/ with ·(code.type·==·'ean-13')⏎··········getProduct(code.value).then(⏎············result·=>⏎··············console.log(⏎················Product·found·:·${result.name},⏎··············)·/\*·call·another·page·\*/,⏎··········
Check warning Code scanning / ESLint require the use of `===` and `!==` Warning
Expected '===' and instead saw '=='.
|
||
}); | ||
} | ||
Check failure Code scanning / ESLint Insert , Error
Insert ,
|
||
}); | ||
|
||
const device = useCameraDevice('back', { | ||
physicalDevices: [ | ||
'ultra-wide-angle-camera', | ||
'wide-angle-camera', | ||
'telephoto-camera' | ||
Check failure Code scanning / ESLint Insert , Error
Insert ,
|
||
] | ||
Check failure Code scanning / ESLint Insert , Error
Insert ,
|
||
}); | ||
|
||
return <Camera {...props} codeScanner={codeScanner} /> | ||
if(!device) return <NoCameraDeviceError /> | ||
Check failure Code scanning / ESLint Replace (!device)·return·<NoCameraDeviceError··/> with ·(!device)·return·<NoCameraDeviceError·/>; Error
Replace (!device)·return·<NoCameraDeviceError··/> with ·(!device)·return·<NoCameraDeviceError·/>;
Check warning Code scanning / ESLint Disallow missing React when using JSX Warning
'React' must be in scope when using JSX
Check failure Code scanning / ESLint Disallow undeclared variables in JSX Error
'NoCameraDeviceError' is not defined.
|
||
else | ||
{ | ||
Check failure Code scanning / ESLint Delete ⏎· Error
Delete ⏎·
|
||
const format = useCameraFormat(device, [ | ||
Check failure Code scanning / ESLint enforces the Rules of Hooks Error
React Hook "useCameraFormat" is called conditionally. React Hooks must be called in the exact same order in every component render.
|
||
{ videoAspectRatio: 3/4 }, | ||
Check failure Code scanning / ESLint Replace ·videoAspectRatio:·3/4· with videoAspectRatio:·3·/·4 Error
Replace ·videoAspectRatio:·3/4· with videoAspectRatio:·3·/·4
|
||
{ fps: 120 }, | ||
Check failure Code scanning / ESLint Replace ·fps:·120· with fps:·120 Error
Replace ·fps:·120· with fps:·120
|
||
{ videoStabilizationMode: 'cinematic-extended'} | ||
Check failure Code scanning / ESLint Replace ·videoStabilizationMode:·'cinematic-extended'} with videoStabilizationMode:·'cinematic-extended'}, Error
Replace ·videoStabilizationMode:·'cinematic-extended'} with videoStabilizationMode:·'cinematic-extended'},
|
||
]); | ||
|
||
if(hasPermission) | ||
{ | ||
Check failure Code scanning / ESLint Replace (hasPermission)⏎··· with ·(hasPermission) Error
Replace (hasPermission)⏎··· with ·(hasPermission)
|
||
return ( | ||
<Camera | ||
style={StyleSheet.absoluteFill} | ||
device={device} | ||
format={format} | ||
codeScanner={codeScanner} | ||
isActive={true} /> | ||
Check warning Code scanning / ESLint Disallow missing React when using JSX Warning
'React' must be in scope when using JSX
Check failure Code scanning / ESLint Insert ⏎······· Error
Insert ⏎·······
|
||
); | ||
} | ||
else | ||
{ | ||
Check failure Code scanning / ESLint Replace ⏎····else⏎··· with ·else Error
Replace ⏎····else⏎··· with ·else
|
||
return( | ||
Check failure Code scanning / ESLint Insert · Error
Insert ·
|
||
<SafeAreaView> | ||
Check warning Code scanning / ESLint Disallow missing React when using JSX Warning
'React' must be in scope when using JSX
|
||
<Text style={{color: 'black'}}>No permission granted for the Camera</Text> | ||
Check warning Code scanning / ESLint Disallow missing React when using JSX Warning
'React' must be in scope when using JSX
Check failure Code scanning / ESLint Replace No·permission·granted·for·the·Camera with ⏎············No·permission·granted·for·the·Camera⏎·········· Error
Replace No·permission·granted·for·the·Camera with ⏎············No·permission·granted·for·the·Camera⏎··········
|
||
</SafeAreaView> | ||
); | ||
} | ||
} | ||
}; | ||
Check failure Code scanning / ESLint Insert ⏎ Error
Insert ⏎
|