add old scanner for windows platform
This commit is contained in:
parent
f6245652d9
commit
8627e60103
7 changed files with 121 additions and 62 deletions
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.directives')
|
||||
.directive('qrScanner', function($state, $rootScope, $log, $ionicHistory) {
|
||||
.directive('qrScanner', function($state, $rootScope, $log, $ionicHistory, platformInfo, scannerService) {
|
||||
|
||||
return {
|
||||
restrict: 'E',
|
||||
|
|
@ -9,26 +9,49 @@ angular.module('copayApp.directives')
|
|||
onScan: "&"
|
||||
},
|
||||
replace: true,
|
||||
template: '<a on-tap="openScanner()" nav-transition="none"><i class="icon ion-qr-scanner"></i></a>',
|
||||
template: '<a on-tap="chooseScanner()" nav-transition="none"><i class="icon ion-qr-scanner"></i></a>',
|
||||
link: function(scope, el, attrs) {
|
||||
|
||||
scope.chooseScanner = function() {
|
||||
var isWindowsPhoneApp = platformInfo.isWP && platformInfo.isCordova;
|
||||
|
||||
if (!isWindowsPhoneApp) {
|
||||
scope.openScanner();
|
||||
return;
|
||||
}
|
||||
|
||||
scannerService.useOldScanner(function(err, contents) {
|
||||
if (err) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
return;
|
||||
}
|
||||
scope.onScan({
|
||||
data: contents
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
scope.openScanner = function() {
|
||||
$log.debug('Opening scanner by directive...');
|
||||
$ionicHistory.nextViewOptions({
|
||||
disableAnimate: true
|
||||
});
|
||||
$state.go('scanner', { passthroughMode: 1 });
|
||||
$state.go('scanner', {
|
||||
passthroughMode: 1
|
||||
});
|
||||
};
|
||||
|
||||
var afterEnter = $rootScope.$on('$ionicView.afterEnter', function() {
|
||||
if($rootScope.scanResult) {
|
||||
scope.onScan({ data: $rootScope.scanResult });
|
||||
if ($rootScope.scanResult) {
|
||||
scope.onScan({
|
||||
data: $rootScope.scanResult
|
||||
});
|
||||
$rootScope.scanResult = null;
|
||||
}
|
||||
});
|
||||
|
||||
// Destroy event
|
||||
scope.$on('$destroy', function(){
|
||||
scope.$on('$destroy', function() {
|
||||
afterEnter();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue