Displaying the amount.

This commit is contained in:
Brendon Duncan 2018-08-01 17:17:34 +12:00
commit 38c3f2fb70
3 changed files with 45 additions and 16 deletions

View file

@ -4,33 +4,37 @@ angular
.module('copayApp.controllers') .module('copayApp.controllers')
.controller('reviewController', reviewController); .controller('reviewController', reviewController);
function reviewController(configService, $log, $scope,) { function reviewController(configService, $log, $scope, txFormatService) {
var vm = this; var vm = this;
vm.primaryAmount = '0'; vm.primaryAmount = '';
vm.primaryCurrency = ''; vm.primaryCurrency = '';
vm.secondaryAmount = ''; vm.secondaryAmount = '';
vm.secondaryCurrency = ''; vm.secondaryCurrency = '';
var config;
var amount = { var coin = '';
crypto: { //var config = null;
quantity: 0, var satoshis = null;
currency: ''
}, //var priceDisplayIsFiat = true;
fiat: null
};
var priceDisplayIsFiat = true;
$scope.$on("$ionicView.beforeEnter", onBeforeEnter); $scope.$on("$ionicView.beforeEnter", onBeforeEnter);
function onBeforeEnter(event, data) { function onBeforeEnter(event, data) {
amount.crypto.quantity = data.stateParams.toAmount; satoshis = parseInt(data.stateParams.amount, 10);
coin = data.stateParams.coin;
updateAmount();
/*
//amount.crypto.quantity = ;
amount.crypto.currency = data.stateParams.coin.toUpperCase(); amount.crypto.currency = data.stateParams.coin.toUpperCase();
console.log('cryptoAmount', cryptoAmount); console.log('crypto:', JSON.stringify(amount.crypto));
//vm.amount = cryptoAmount.toFixed(8); //vm.amount = cryptoAmount.toFixed(8);
console.log('vm.amount:', vm.amount); console.log('vm.amount:', vm.amount);
@ -48,6 +52,31 @@ function reviewController(configService, $log, $scope,) {
priceDisplayIsFiat = config.wallet.settings.priceDisplay === 'fiat'; priceDisplayIsFiat = config.wallet.settings.priceDisplay === 'fiat';
} }
}); });
*/
}
function updateAmount() {
if (typeof satoshis !== 'number') {
return;
}
var amountStr = txFormatService.formatAmountStr(coin, satoshis);
var amountParts = amountStr.split(' ');
vm.primaryAmount = amountParts[0];
vm.primaryCurrency = amountParts[1];
txFormatService.formatAlternativeStr(coin, satoshis, function(v) {
if (!v) {
vm.secondaryAmount = '';
vm.secondaryCurrency = '';
return;
}
vm.secondaryAmount = vm.primaryAmount;
vm.secondaryCurrency = vm.primaryCurrency;
var fiatParts = v.split(' ');
vm.primaryAmount = fiatParts[0];
vm.primaryCurrency = fiatParts[1];
});
} }
} }

View file

@ -317,7 +317,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
} }
}) })
.state('tabs.send.review', { .state('tabs.send.review', {
url: '/review/:coin/:fromWalletId/:toAmount/:useSendMax', url: '/review/:coin/:fromWalletId/:amount/:useSendMax',
views: { views: {
'tab-send@tabs': { 'tab-send@tabs': {
controller: 'reviewController', controller: 'reviewController',

View file

@ -11,8 +11,8 @@
ng-init="memoExpanded = false"> ng-init="memoExpanded = false">
<div class="header"> <div class="header">
<div class="content" translate> <div class="content" translate>
<p class="large">13.98 USD</p> <p class="large"><amount value="vm.primaryAmount" currency="vm.primaryCurrency"></amount></p>
<p>0.014 BCH</p> <p ng-show="vm.secondaryAmount"><amount value="vm.secondaryAmount" currency="vm.secondaryCurrency"></p>
</div> </div>
</div> </div>