Scanner button at topbar only for mobile
This commit is contained in:
parent
05e4c2abb8
commit
d0f8583122
8 changed files with 76 additions and 70 deletions
|
|
@ -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.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue