Skip to content

bangslosan/BarcodeView

 
 

Repository files navigation

Appcelerator Titanium :: Barcode View

An Appcelerator Titanium module that creates a view that allows you to scan UPC's using the ZBar Barcode Reader (http://zbar.sourceforge.net/).

I had been playing around with the Acktie Barcode reader and really wanted something that would let me place the view inside of my own page (and not use a modal window). This module allows you to create the barcode view just as you would create a standard Titanium.UI.view and listen for a 'success' callback.

This module will continue to grow and new options will be added in the near future.

Setup

Include the module in your tiapp.xml:


com.mfogg.barcode

Usage

Currently the options you have are limited to what type of barcodes you would like to 'listen' for, but that makes the module pretty simple :)

The types of barcodes available are:

  • EAN2
  • EAN5
  • EAN8
  • UPCE
  • ISBN10
  • UPCA
  • EAN13
  • ISBN13
  • COMPOSITE
  • I25
  • DATABAR
  • DATABAR_EXP
  • CODE39
  • PDF417
  • CODE93
  • CODE128

And they can be used like...


var Barcode = require('com.mfogg.barcode'); // Initialize the Barcode module

// open a single window
var win = Ti.UI.createWindow({backgroundColor:"#eee"});

var allowed_upcs = [ // See list of available barcode types above
  "UPCE",
  "ISBN10",
  "UPCA",
  "EAN13",
  "CODE93",
  "CODE128"
];

var barcodeView = Barcode.createView({
  top: 0,
  height: 320,
  width: 320,
  barcodes: allowed_upcs
});

win.add(barcodeView);
win.open();

  • Note here that the created view (ex. 'barcodeView' above) can have other views added on top of it to act as a camera overlay (exactly how you would a standard Ti.UI.view)

Listeners

Currently, the only event listener enabled is "success" which will fire every time a barcode that fits the types above comes into the view.


barcodeView.addEventListener("success", function(event){
	// event.data == number returned from the scan
	// event.type == type of scan
	
	Ti.API.info("[NEW SCAN] Data: "+event.data);
	Ti.API.info("[NEW SCAN] Type: "+event.type);
});

Known Issues and Future Improvements

  1. Ability to manage the light on/off (on initialize and via function call).
  2. Android support

... anything else :)

Please let me know if you'd like any additions or something isn't working!

License

Do whatever you want, however you want, whenever you want. And if you find a problem on your way, let me know so I can fix it for my own apps too :)

Attributions

About

An Appcelerator Titanium Module that allows you to create a barcode scanner view

Resources

License

Unknown, Unknown licenses found

Licenses found

Unknown
LICENSE
Unknown
LICENSE.txt

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published