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
|
|
@ -72,7 +72,7 @@ angular.module('copayApp.controllers').controller('CreateController',
|
|||
});
|
||||
};
|
||||
|
||||
$scope.$on("$destroy", function () {
|
||||
$rootScope.hideWalletNavigation = false;
|
||||
$scope.$on("$destroy", function () {
|
||||
$rootScope.hideWalletNavigation = false;
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -100,8 +100,8 @@ angular.module('copayApp.controllers').controller('ImportController',
|
|||
};
|
||||
|
||||
|
||||
$scope.$on("$destroy", function () {
|
||||
$rootScope.hideWalletNavigation = false;
|
||||
$scope.$on("$destroy", function () {
|
||||
$rootScope.hideWalletNavigation = false;
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ angular.module('copayApp.controllers').controller('JoinController',
|
|||
}
|
||||
|
||||
|
||||
$scope.$on("$destroy", function () {
|
||||
$rootScope.hideWalletNavigation = false;
|
||||
$scope.$on("$destroy", function () {
|
||||
$rootScope.hideWalletNavigation = false;
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -50,6 +50,17 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
});
|
||||
};
|
||||
|
||||
if (isCordova) {
|
||||
var openScannerCordova = $rootScope.$on('dataScanned', function(event, data) {
|
||||
$scope.sendForm.address.$setViewValue(data);
|
||||
$scope.sendForm.address.$render();
|
||||
});
|
||||
|
||||
$scope.$on('$destroy', function() {
|
||||
openScannerCordova();
|
||||
});
|
||||
}
|
||||
|
||||
$scope.formFocus = function(what) {
|
||||
if (!$scope.isWindowsPhoneApp) return
|
||||
|
||||
|
|
@ -183,17 +194,17 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
var comment = form.comment.$modelValue;
|
||||
var merchantData = $scope._merchantData;
|
||||
var address, amount;
|
||||
if (!merchantData) {
|
||||
if (!merchantData) {
|
||||
address = form.address.$modelValue;
|
||||
amount = parseInt((form.amount.$modelValue * unitToSat).toFixed(0));
|
||||
}
|
||||
|
||||
w.spend({
|
||||
w.spend({
|
||||
merchantData: merchantData,
|
||||
toAddress: address,
|
||||
amountSat: amount,
|
||||
comment: comment,
|
||||
}, function (err, txid, status) {
|
||||
comment: comment,
|
||||
}, function (err, txid, status) {
|
||||
$scope.loading = false;
|
||||
$scope.creatingTX = false;
|
||||
if ($scope.isWindowsPhoneApp)
|
||||
|
|
@ -202,8 +213,8 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
if (err)
|
||||
return $scope.setError(err);
|
||||
txStatus.notify(status);
|
||||
$scope.resetForm();
|
||||
});
|
||||
$scope.resetForm();
|
||||
});
|
||||
}, 1);
|
||||
};
|
||||
|
||||
|
|
@ -299,7 +310,6 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
};
|
||||
|
||||
$scope.openScanner = function() {
|
||||
if (window.cordova) return $scope.scannerIntent();
|
||||
$scope.showScanner = true;
|
||||
|
||||
// Wait a moment until the canvas shows
|
||||
|
|
@ -324,31 +334,6 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
}, 500);
|
||||
};
|
||||
|
||||
$scope.scannerIntent = 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() {
|
||||
$scope.sendForm.address.$setViewValue(result.text);
|
||||
$scope.sendForm.address.$render();
|
||||
});
|
||||
}, 1000);
|
||||
},
|
||||
function onError(error) {
|
||||
$timeout(function() {
|
||||
window.ignoreMobilePause = false;
|
||||
}, 100);
|
||||
alert('Scanning error');
|
||||
});
|
||||
}
|
||||
|
||||
$scope.setTopAmount = function() {
|
||||
var w = $rootScope.wallet;
|
||||
var form = $scope.sendForm;
|
||||
|
|
|
|||
|
|
@ -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