Scanner button at topbar only for mobile

This commit is contained in:
Gustavo Maximiliano Cortez 2015-01-15 12:57:18 -03:00 committed by bechi
commit d0f8583122
8 changed files with 76 additions and 70 deletions

View file

@ -1,8 +1,9 @@
'use strict';
angular.module('copayApp.controllers').controller('SidebarController', function($scope, $rootScope, $location, $timeout, identityService, isMobile, go) {
angular.module('copayApp.controllers').controller('SidebarController', function($scope, $rootScope, $location, $timeout, identityService, isMobile, isCordova, go) {
$scope.isMobile = isMobile.any()
$scope.isMobile = isMobile.any();
$scope.isCordova = isCordova;
$scope.menu = [{
'title': 'Home',
@ -46,6 +47,32 @@ angular.module('copayApp.controllers').controller('SidebarController', function(
$scope.setWallets();
};
$scope.openScanner = function() {
window.ignoreMobilePause = true;
cordova.plugins.barcodeScanner.scan(
function onSuccess(result) {
$timeout(function() {
window.ignoreMobilePause = false;
}, 100);
if (result.cancelled) return;
$timeout(function() {
var data = result.text;
$scope.$apply(function() {
$rootScope.$emit('dataScanned', data);
});
}, 1000);
},
function onError(error) {
$timeout(function() {
window.ignoreMobilePause = false;
}, 100);
alert('Scanning error');
}
);
go.send();
};
$scope.init = function() {
// This should be called only once.