├── .expo-shared
└── assets.json
├── .gitignore
├── App.js
├── app.json
├── assets
├── adaptive-icon.png
├── favicon.png
├── icon.png
└── splash.png
├── babel.config.js
├── package.json
└── yarn.lock
/.expo-shared/assets.json:
--------------------------------------------------------------------------------
1 | {
2 | "12bb71342c6255bbf50437ec8f4441c083f47cdb74bd89160c15e4f43e52a1cb": true,
3 | "40b842e832070c58deac6aa9e08fa459302ee3f9da492c7e77d93d2fbf4a56fd": true
4 | }
5 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | .expo/
3 | npm-debug.*
4 | *.jks
5 | *.p8
6 | *.p12
7 | *.key
8 | *.mobileprovision
9 | *.orig.*
10 | web-build/
11 |
12 | # macOS
13 | .DS_Store
14 |
--------------------------------------------------------------------------------
/App.js:
--------------------------------------------------------------------------------
1 | import React, { useState, useEffect } from 'react';
2 | import { Text, View, StyleSheet, Button } from 'react-native';
3 | import { BarCodeScanner } from 'expo-barcode-scanner';
4 |
5 | export default function App() {
6 | const [hasPermission, setHasPermission] = useState(null);
7 | const [scanned, setScanned] = useState(false);
8 | const [text, setText] = useState('Not yet scanned')
9 |
10 | const askForCameraPermission = () => {
11 | (async () => {
12 | const { status } = await BarCodeScanner.requestPermissionsAsync();
13 | setHasPermission(status === 'granted');
14 | })()
15 | }
16 |
17 | // Request Camera Permission
18 | useEffect(() => {
19 | askForCameraPermission();
20 | }, []);
21 |
22 | // What happens when we scan the bar code
23 | const handleBarCodeScanned = ({ type, data }) => {
24 | setScanned(true);
25 | setText(data)
26 | console.log('Type: ' + type + '\nData: ' + data)
27 | };
28 |
29 | // Check permissions and return the screens
30 | if (hasPermission === null) {
31 | return (
32 |
33 | Requesting for camera permission
34 | )
35 | }
36 | if (hasPermission === false) {
37 | return (
38 |
39 | No access to camera
40 | )
42 | }
43 |
44 | // Return the View
45 | return (
46 |
47 |
48 |
51 |
52 | {text}
53 |
54 | {scanned &&
56 | );
57 | }
58 |
59 | const styles = StyleSheet.create({
60 | container: {
61 | flex: 1,
62 | backgroundColor: '#fff',
63 | alignItems: 'center',
64 | justifyContent: 'center',
65 | },
66 | maintext: {
67 | fontSize: 16,
68 | margin: 20,
69 | },
70 | barcodebox: {
71 | alignItems: 'center',
72 | justifyContent: 'center',
73 | height: 300,
74 | width: 300,
75 | overflow: 'hidden',
76 | borderRadius: 30,
77 | backgroundColor: 'tomato'
78 | }
79 | });
80 |
--------------------------------------------------------------------------------
/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "expo": {
3 | "name": "BarCodeApp",
4 | "slug": "BarCodeApp",
5 | "version": "1.0.0",
6 | "orientation": "portrait",
7 | "icon": "./assets/icon.png",
8 | "splash": {
9 | "image": "./assets/splash.png",
10 | "resizeMode": "contain",
11 | "backgroundColor": "#ffffff"
12 | },
13 | "updates": {
14 | "fallbackToCacheTimeout": 0
15 | },
16 | "assetBundlePatterns": [
17 | "**/*"
18 | ],
19 | "ios": {
20 | "supportsTablet": true
21 | },
22 | "android": {
23 | "adaptiveIcon": {
24 | "foregroundImage": "./assets/adaptive-icon.png",
25 | "backgroundColor": "#FFFFFF"
26 | }
27 | },
28 | "web": {
29 | "favicon": "./assets/favicon.png"
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/assets/adaptive-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/indently/BarCodeApp/6738465d53db2630b2cf954ee5c05054e6ec2ee0/assets/adaptive-icon.png
--------------------------------------------------------------------------------
/assets/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/indently/BarCodeApp/6738465d53db2630b2cf954ee5c05054e6ec2ee0/assets/favicon.png
--------------------------------------------------------------------------------
/assets/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/indently/BarCodeApp/6738465d53db2630b2cf954ee5c05054e6ec2ee0/assets/icon.png
--------------------------------------------------------------------------------
/assets/splash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/indently/BarCodeApp/6738465d53db2630b2cf954ee5c05054e6ec2ee0/assets/splash.png
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = function(api) {
2 | api.cache(true);
3 | return {
4 | presets: ['babel-preset-expo'],
5 | };
6 | };
7 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "main": "node_modules/expo/AppEntry.js",
3 | "scripts": {
4 | "start": "expo start",
5 | "android": "expo start --android",
6 | "ios": "expo start --ios",
7 | "web": "expo start --web",
8 | "eject": "expo eject"
9 | },
10 | "dependencies": {
11 | "expo": "~42.0.0",
12 | "expo-barcode-scanner": "~10.2.2",
13 | "expo-status-bar": "~1.0.4",
14 | "react": "16.13.1",
15 | "react-dom": "16.13.1",
16 | "react-native": "https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz",
17 | "react-native-web": "~0.13.12"
18 | },
19 | "devDependencies": {
20 | "@babel/core": "^7.9.0"
21 | },
22 | "private": true
23 | }
24 |
--------------------------------------------------------------------------------