wallet to wallet case worked out. Also fixed routes and some css

This commit is contained in:
Sebastiaan Pasma 2018-07-24 14:24:22 +02:00
commit fd4adbfb57
No known key found for this signature in database
GPG key ID: 9A2B0C8B95A1D26F
6 changed files with 138 additions and 117 deletions

View file

@ -6,34 +6,34 @@ angular.module('copayApp.controllers').controller('sendFlowController', function
var satToUnit;
var unitDecimals;
var satToBtc;
var nextStep = '';
$scope.$on("$ionicView.beforeEnter", function(event, data) {
var config = configService.getSync().wallet.settings;
$scope.params = $stateParams;
$scope.specificAmount = $scope.specificAlternativeAmount = '';
unitToSatoshi = config.unitToSatoshi;
satToUnit = 1 / unitToSatoshi;
satToBtc = 1 / 100000000;
unitDecimals = config.unitDecimals;
// in SAT ALWAYS
if ($stateParams.toAmount) {
$scope.requestAmount = (($stateParams.toAmount) * satToUnit).toFixed(unitDecimals);
if ($scope.params.amount) {
console.log("is Payment Request", $scope.params.amount);
$scope.requestAmount = (($stateParams.amount) * satToUnit).toFixed(unitDecimals);
$scope.isPaymentRequest = true;
}
console.log(data, $stateParams);
$scope.params = $stateParams;
});
$scope.$on("$ionicView.enter", function(event, data) {
console.log(data, $stateParams);
$scope.type = data.stateParams.fromWalletId ? 'destination' : 'origin'; // origin || destination
$scope.type = data.stateParams && data.stateParams['fromWalletId'] ? 'destination' : 'origin'; // origin || destination
$scope.coin = false; // Wallets to show (for destination screen)
$scope.walletsEmpty = [];
// Show price-header
console.log("current type: "+$scope.type);
if ($scope.type === 'origin') {
$scope.headerTitle = gettextCatalog.getString('Choose a wallet to send from');
$scope.walletsEmpty = profileService.getWallets({coin: $scope.coin, hasNoFunds: true});
@ -57,13 +57,22 @@ angular.module('copayApp.controllers').controller('sendFlowController', function
});
});
function getNextStep() {
if (!$scope.params.toWalletId && !$scope.params.toAddress) {
return 'tabs.send.destination';
} else if (!$scope.params.amount) {
return 'tabs.send.amount';
} else {
return 'tabs.send.confirm';
}
}
$scope.useWallet = function(wallet) {
if ($scope.type === 'origin') {
$scope.params['fromWalletId'] = wallet.id;
$state.transitionTo('tabs.send.destination', $scope.params);
} else {
$scope.params['toWalletId'] = wallet.id;
$state.transitionTo('tabs.send.amount', $scope.params);
}
$state.transitionTo(getNextStep(), $scope.params);
};
});