Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: sahir/react-native-barcode-reader
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.0
Choose a base ref
...
head repository: sahir/react-native-barcode-reader
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 12 commits
  • 8 files changed
  • 3 contributors

Commits on Sep 26, 2017

  1. https://github.com/lwansbrough/react-native-camera/issues/476

    🚀 WIP : We receive multiple (~10x) same barcode in a single camera
    capture.
    sahir committed Sep 26, 2017

    Verified

    This commit was signed with the committer’s verified signature.
    erikmd Erik Martin-Dorel
    Copy the full SHA
    f427536 View commit details
  2. Copy the full SHA
    e42cae2 View commit details
  3. Copy the full SHA
    23bf2e2 View commit details

Commits on Oct 10, 2017

  1. Update README.md

    GarimaMathur07 authored Oct 10, 2017
    Copy the full SHA
    57fbe02 View commit details
  2. Update README.md

    sahir authored Oct 10, 2017
    Copy the full SHA
    a7355a4 View commit details

Commits on Mar 27, 2018

  1. remove private for npm publish

    sahir committed Mar 27, 2018
    Copy the full SHA
    658c8f5 View commit details
  2. Merge pull request #8 from sahir/SS_barcodeReader

    remove private for npm publish
    sahir authored Mar 27, 2018
    Copy the full SHA
    6b2e779 View commit details

Commits on Jan 16, 2019

  1. Update README.md

    sahir authored Jan 16, 2019
    Copy the full SHA
    fbcf6cd View commit details

Commits on Nov 8, 2019

  1. Update Utility.js

    sahir authored Nov 8, 2019
    Copy the full SHA
    0f754ac View commit details

Commits on Nov 27, 2019

  1. Create blank.yml

    sahir authored Nov 27, 2019
    Copy the full SHA
    bf0ca30 View commit details

Commits on Aug 10, 2020

  1. Update README.md

    sahir authored Aug 10, 2020
    Copy the full SHA
    3c06f23 View commit details

Commits on Apr 2, 2021

  1. Create codeql-analysis.yml

    sahir authored Apr 2, 2021
    Copy the full SHA
    efaead9 View commit details
Showing with 114 additions and 33 deletions.
  1. +3 −0 .eslintrc
  2. +17 −0 .github/workflows/blank.yml
  3. +67 −0 .github/workflows/codeql-analysis.yml
  4. +7 −1 README.md
  5. +1 −1 android/app/src/main/java/com/barcodereader/MainApplication.java
  6. +1 −1 package.json
  7. +18 −25 src/ScannerScene.js
  8. +0 −5 src/Utility.js
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "rallycoding"
}
17 changes: 17 additions & 0 deletions .github/workflows/blank.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: CI

on: [push]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Run a one-line script
run: echo Hello, world!
- name: Run a multi-line script
run: |
echo Add other actions to build,
echo test, and deploy your project.
67 changes: 67 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '26 23 * * 6'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
language: [ 'java', 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -2,17 +2,23 @@

A simple Barcode Reader Screen implemented with [react-native-camera](https://github.com/lwansbrough/react-native-camera).

https://github.com/sahir/react-native-camera/tree/barcode-finder

# barcode-reader

![barcode-reader](https://github.com/sahir/react-native-barcode-reader/blob/master/screenshots/barcode-reader.jpeg)

## npm publish

https://www.npmjs.com/package/rn-barcode-reader

## Install

**Install library**

`npm install --save barcode-reader`

**Link native librarie `react-native-camera`**
**Link native library `react-native-camera`**

```
which rnpm || npm install -g rnpm
Original file line number Diff line number Diff line change
@@ -39,4 +39,4 @@ public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "barcode-reader",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
@@ -14,6 +13,7 @@
"devDependencies": {
"babel-jest": "21.0.2",
"babel-preset-react-native": "4.0.0",
"eslint-config-rallycoding": "^3.2.0",
"jest": "21.1.0",
"react-test-renderer": "16.0.0-alpha.12"
},
43 changes: 18 additions & 25 deletions src/ScannerScene.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from 'react';
import { Image, StatusBar, StyleSheet, TouchableOpacity, View, AppRegistry, Text, Button } from 'react-native';
import React, { Component } from 'react';
import { View, AppRegistry, Text, Button } from 'react-native';
import Camera from 'react-native-camera';
import Utility from './Utility';


export default class ScannerScene extends React.Component {
constructor(props) {
export default class ScannerScene extends Component {
constructor(props) {
super(props);
this.camera = null;
this.barcodeCodes = [];

this.state = {
camera: {
aspect: Camera.constants.Aspect.fill,
@@ -21,18 +21,15 @@ export default class ScannerScene extends React.Component {
}

onBarCodeRead(scanResult) {
console.warn('onBarCodeRead');
const code = scanResult.data;
if (Utility.isValidBarcode(code)) {
console.warn('valid');
console.warn(code);
} else {
Alert.alert('error', 'invalid Barcode', [
{
text: 'rescan barcode',
}
]);
console.warn(scanResult.type);
console.warn(scanResult.data);
if (scanResult.data != null) {
if (!this.barcodeCodes.includes(scanResult.data)) {
this.barcodeCodes.push(scanResult.data);
console.warn('onBarCodeRead call');
}
}
return;
}

render() {
@@ -60,14 +57,10 @@ export default class ScannerScene extends React.Component {
onBarCodeRead={this.onBarCodeRead.bind(this)}
/>
<View style={[styles.overlay, styles.topOverlay]}>
<Text style={styles.scanScreenMessage}>
Please scan the barcode.
</Text>
<Text style={styles.scanScreenMessage}>Please scan the barcode.</Text>
</View>
<View style={[styles.overlay, styles.bottomOverlay]}>
<Button style={styles.enterBarcodeManualButton}
title='Enter Barcode'>
</Button>
<Button style={styles.enterBarcodeManualButton} title="Enter Barcode" />
</View>
</View>
);
@@ -113,10 +106,10 @@ export default class ScannerScene extends React.Component {
color: 'white',
textAlign: 'center',
alignItems: 'center',
justifyContent: 'center'
justifyContent: 'center'
}
};
}
}

AppRegistry.registerComponent('barcode-reader', () => ScannerScene)
AppRegistry.registerComponent('barcode-reader', () => ScannerScene);
5 changes: 0 additions & 5 deletions src/Utility.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
//
// Copyright © 2017-Present, Punchh, Inc.
// All rights reserved.
//

export default class Utility {
static isValidBarcode(barcode) {
const regex = '[0-9]';