feat(scan): create Scan tab and scannerService, implement QRScanner and controls
This commit is contained in:
parent
ceac7c2c2b
commit
f901c95f67
13 changed files with 393 additions and 23 deletions
45
src/js/controllers/tab-scan.js
Normal file
45
src/js/controllers/tab-scan.js
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('tabScanController', function($scope, $log, $timeout, scannerService, incomingData) {
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function() {
|
||||
$log.debug('Preparing to display available controls.');
|
||||
var capabilities = scannerService.getCapabilities();
|
||||
$scope.canEnableLight = capabilities.canEnableLight;
|
||||
$scope.canChangeCamera = capabilities.canChangeCamera;
|
||||
});
|
||||
|
||||
$scope.$on("$ionicView.afterEnter", function() {
|
||||
scannerService.activate(function(){
|
||||
scannerService.scan(function(err, contents){
|
||||
if(err){
|
||||
$log.debug('Scan canceled.');
|
||||
} else {
|
||||
incomingData.redir(contents);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
$scope.$on("$ionicView.afterLeave", function() {
|
||||
scannerService.deactivate();
|
||||
});
|
||||
|
||||
$scope.toggleLight = function(){
|
||||
scannerService.toggleLight(function(lightEnabled){
|
||||
$scope.lightActive = lightEnabled;
|
||||
$scope.$apply();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.toggleCamera = function(){
|
||||
$scope.cameraToggleActive = true;
|
||||
scannerService.toggleCamera(function(status){
|
||||
// (a short delay for the user to see the visual feedback)
|
||||
$timeout(function(){
|
||||
$scope.cameraToggleActive = false;
|
||||
$log.debug('Camera toggle control deactivated.');
|
||||
}, 200);
|
||||
});
|
||||
};
|
||||
|
||||
});
|
||||
|
|
@ -97,12 +97,6 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
|
|||
});
|
||||
};
|
||||
|
||||
$scope.onQrCodeScanned = function(data) {
|
||||
if (!incomingData.redir(data)) {
|
||||
popupService.showAlert(null, gettextCatalog.getString('Invalid data'));
|
||||
}
|
||||
};
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
$scope.formData = {
|
||||
search: null
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue