From wallet details.
This commit is contained in:
parent
38c3f2fb70
commit
0caa3fb92a
2 changed files with 96 additions and 36 deletions
|
|
@ -4,68 +4,116 @@ angular
|
||||||
.module('copayApp.controllers')
|
.module('copayApp.controllers')
|
||||||
.controller('reviewController', reviewController);
|
.controller('reviewController', reviewController);
|
||||||
|
|
||||||
function reviewController(configService, $log, $scope, txFormatService) {
|
function reviewController(configService, gettextCatalog, profileService, $scope, txFormatService) {
|
||||||
var vm = this;
|
var vm = this;
|
||||||
|
|
||||||
|
vm.origin = {
|
||||||
|
balanceAmount: '',
|
||||||
|
balanceCurrency: '',
|
||||||
|
color: '',
|
||||||
|
currency: '',
|
||||||
|
name: '',
|
||||||
|
};
|
||||||
vm.primaryAmount = '';
|
vm.primaryAmount = '';
|
||||||
vm.primaryCurrency = '';
|
vm.primaryCurrency = '';
|
||||||
|
|
||||||
vm.secondaryAmount = '';
|
vm.secondaryAmount = '';
|
||||||
vm.secondaryCurrency = '';
|
vm.secondaryCurrency = '';
|
||||||
|
|
||||||
|
|
||||||
var coin = '';
|
var coin = '';
|
||||||
//var config = null;
|
var originWalletId = '';
|
||||||
|
var priceDisplayIsFiat = true;
|
||||||
var satoshis = null;
|
var satoshis = null;
|
||||||
|
var toAddress = '';
|
||||||
|
var toWalletId = '';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//var priceDisplayIsFiat = true;
|
|
||||||
|
|
||||||
$scope.$on("$ionicView.beforeEnter", onBeforeEnter);
|
$scope.$on("$ionicView.beforeEnter", onBeforeEnter);
|
||||||
|
|
||||||
|
|
||||||
function onBeforeEnter(event, data) {
|
function onBeforeEnter(event, data) {
|
||||||
|
|
||||||
satoshis = parseInt(data.stateParams.amount, 10);
|
|
||||||
coin = data.stateParams.coin;
|
coin = data.stateParams.coin;
|
||||||
|
originWalletId = data.stateParams.fromWalletId;
|
||||||
|
satoshis = parseInt(data.stateParams.amount, 10);
|
||||||
|
toAddress = data.stateParams.toAddress;
|
||||||
|
|
||||||
updateAmount();
|
var originWallet = profileService.getWallet(originWalletId);
|
||||||
|
vm.origin.currency = originWallet.coin.toUpperCase();
|
||||||
|
vm.origin.color = originWallet.color;
|
||||||
/*
|
vm.origin.name = originWallet.name;
|
||||||
//amount.crypto.quantity = ;
|
|
||||||
amount.crypto.currency = data.stateParams.coin.toUpperCase();
|
|
||||||
console.log('crypto:', JSON.stringify(amount.crypto));
|
|
||||||
//vm.amount = cryptoAmount.toFixed(8);
|
|
||||||
console.log('vm.amount:', vm.amount);
|
|
||||||
|
|
||||||
vm.secondaryAmount = amount.crypto.quantity;
|
|
||||||
vm.secondaryCurrency = amount.crypto.currency;
|
|
||||||
|
|
||||||
configService.get(function onConfig(err, configCache) {
|
configService.get(function onConfig(err, configCache) {
|
||||||
if (err) {
|
if (err) {
|
||||||
$log.err('Error getting config.', err);
|
$log.err('Error getting config.', err);
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
console.log('Got config.');
|
console.log('Got config.');
|
||||||
config = configCache;
|
//config = configCache;
|
||||||
// Use this later if have time
|
// Use this later if have time
|
||||||
priceDisplayIsFiat = config.wallet.settings.priceDisplay === 'fiat';
|
priceDisplayIsFiat = configCache.wallet.settings.priceDisplay === 'fiat';
|
||||||
}
|
}
|
||||||
|
updateSendAmounts();
|
||||||
|
getOriginWalletBalance(originWallet);
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateAmount() {
|
function getOriginWalletBalance(originWallet) {
|
||||||
|
console.log('origin wallet error:', originWallet.error);
|
||||||
|
var balanceCryptoAmount = '';
|
||||||
|
var balanceCryptoCurrencyCode = '';
|
||||||
|
var balanceFiatAmount = '';
|
||||||
|
var balanceFiatCurrency = ''
|
||||||
|
|
||||||
|
var originWalletStatus = null;
|
||||||
|
if (originWallet.status.isValid) {
|
||||||
|
originWalletStatus = originWallet.status;
|
||||||
|
} else if (originWallet.cachedStatus.isValid) {
|
||||||
|
originWalletStatus = originWallet.cachedStatus;
|
||||||
|
} else {
|
||||||
|
vm.origin.balanceAmount = '';
|
||||||
|
vm.origin.balanceCurrency = '';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (originWalletStatus) {
|
||||||
|
var cryptoBalanceParts = originWalletStatus.spendableBalanceStr.split(' ');
|
||||||
|
balanceCryptoAmount = cryptoBalanceParts[0];
|
||||||
|
balanceCryptoCurrencyCode = cryptoBalanceParts.length > 1 ? cryptoBalanceParts[1] : '';
|
||||||
|
|
||||||
|
if (originWalletStatus.alternativeBalanceAvailable) {
|
||||||
|
balanceFiatAmount = originWalletStatus.spendableBalanceAlternative;
|
||||||
|
balanceFiatCurrency = originWalletStatus.alternativeIsoCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (priceDisplayIsFiat) {
|
||||||
|
vm.origin.balanceAmount = balanceFiatAmount ? balanceFiatAmount : balanceCryptoAmount;
|
||||||
|
vm.origin.balanceCurrency = balanceFiatAmount ? balanceFiatCurrency : balanceCryptoCurrencyCode;
|
||||||
|
} else {
|
||||||
|
vm.origin.balanceAmount = balanceCryptoAmount;
|
||||||
|
vm.origin.balanceCurrency = balanceCryptoCurrencyCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateSendAmounts() {
|
||||||
if (typeof satoshis !== 'number') {
|
if (typeof satoshis !== 'number') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var cryptoAmount = '';
|
||||||
|
var cryptoCurrencyCode = '';
|
||||||
var amountStr = txFormatService.formatAmountStr(coin, satoshis);
|
var amountStr = txFormatService.formatAmountStr(coin, satoshis);
|
||||||
var amountParts = amountStr.split(' ');
|
if (amountStr) {
|
||||||
vm.primaryAmount = amountParts[0];
|
var amountParts = amountStr.split(' ');
|
||||||
vm.primaryCurrency = amountParts[1];
|
cryptoAmount = amountParts[0];
|
||||||
|
cryptoCurrencyCode = amountParts.length > 1 ? amountParts[1] : '';
|
||||||
|
}
|
||||||
|
// Want to avoid flashing of amount strings so do all formatting after this has returned.
|
||||||
txFormatService.formatAlternativeStr(coin, satoshis, function(v) {
|
txFormatService.formatAlternativeStr(coin, satoshis, function(v) {
|
||||||
if (!v) {
|
if (!v) {
|
||||||
|
vm.primaryAmount = cryptoAmount;
|
||||||
|
vm.primaryCurrency = cryptoCurrencyCode;
|
||||||
vm.secondaryAmount = '';
|
vm.secondaryAmount = '';
|
||||||
vm.secondaryCurrency = '';
|
vm.secondaryCurrency = '';
|
||||||
return;
|
return;
|
||||||
|
|
@ -74,8 +122,20 @@ function reviewController(configService, $log, $scope, txFormatService) {
|
||||||
vm.secondaryCurrency = vm.primaryCurrency;
|
vm.secondaryCurrency = vm.primaryCurrency;
|
||||||
|
|
||||||
var fiatParts = v.split(' ');
|
var fiatParts = v.split(' ');
|
||||||
vm.primaryAmount = fiatParts[0];
|
var fiatAmount = fiatParts[0];
|
||||||
vm.primaryCurrency = fiatParts[1];
|
var fiatCurrency = fiatParts.length > 1 ? fiatParts[1] : '';
|
||||||
|
|
||||||
|
if (priceDisplayIsFiat) {
|
||||||
|
vm.primaryAmount = fiatAmount;
|
||||||
|
vm.primaryCurrency = fiatCurrency;
|
||||||
|
vm.secondaryAmount = cryptoAmount;
|
||||||
|
vm.secondaryCurrency = cryptoCurrencyCode;
|
||||||
|
} else {
|
||||||
|
vm.primaryAmount = cryptoAmount;
|
||||||
|
vm.primaryCurrency = cryptoCurrencyCode;
|
||||||
|
vm.secondaryAmount = fiatAmount;
|
||||||
|
vm.secondaryCurrency = fiatCurrency;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,24 +10,24 @@
|
||||||
<ion-content class="padded-bottom-cta-with-summary bg-neutral"
|
<ion-content class="padded-bottom-cta-with-summary bg-neutral"
|
||||||
ng-init="memoExpanded = false">
|
ng-init="memoExpanded = false">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<div class="content" translate>
|
<div class="content">
|
||||||
<p class="large"><amount value="vm.primaryAmount" currency="vm.primaryCurrency"></amount></p>
|
<p class="large">{{vm.primaryAmount}} {{vm.primaryCurrency}}</amount></p>
|
||||||
<p ng-show="vm.secondaryAmount"><amount value="vm.secondaryAmount" currency="vm.secondaryCurrency"></p>
|
<p ng-show="vm.secondaryAmount">{{vm.secondaryAmount}} {{vm.secondaryCurrency}}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="content-frame negative-top">
|
<div class="content-frame negative-top">
|
||||||
<div class="card card-gutter-compact">
|
<div class="card card-gutter-compact">
|
||||||
<div class="item item-compact">From:</div>
|
<div class="item item-compact" translate>From:</div>
|
||||||
<div class="item item-gutterless item-complex item-avatar">
|
<div class="item item-gutterless item-complex item-avatar">
|
||||||
<div class="item-content item-content-avatar">
|
<div class="item-content item-content-avatar">
|
||||||
<i class="icon big-icon-svg theme-circle theme-circle-services">
|
<i class="icon big-icon-svg theme-circle theme-circle-services">
|
||||||
<div class="bg icon-wallet"
|
<div class="bg icon-wallet"
|
||||||
ng-style="{'background-color': '#eeb640'}"
|
style="background-color: {{vm.origin.color}}"
|
||||||
></div>
|
></div>
|
||||||
</i>
|
</i>
|
||||||
<h2>Personal Wallet <span class="highlight" ng-style="{'color': '#eeb640'}">(BCH)</span></h2>
|
<h2>{{vm.origin.name}} <span class="highlight" ng-style="{'color': '#eeb640'}">({{vm.origin.currency}})</span></h2>
|
||||||
<p>128.67</p>
|
<p ng-show="vm.origin.balanceAmount">{{vm.origin.balanceAmount}} {{vm.origin.balanceCurrency}}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue