change fee on the confirm view

This commit is contained in:
Gabriel Bazán 2017-05-16 14:21:33 -03:00
commit bfa7e47da5
6 changed files with 48 additions and 21 deletions

View file

@ -20,7 +20,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
toAmount = data.stateParams.toAmount; toAmount = data.stateParams.toAmount;
cachedSendMax = {}; cachedSendMax = {};
$scope.showFeeFiat = false;
$scope.showAddress = false; $scope.showAddress = false;
$scope.useSendMax = data.stateParams.useSendMax == 'true' ? true : false; $scope.useSendMax = data.stateParams.useSendMax == 'true' ? true : false;
$scope.recipientType = data.stateParams.recipientType || null; $scope.recipientType = data.stateParams.recipientType || null;
@ -44,10 +43,17 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$scope.feeLevel = feeService.feeOpts[feeLevel]; $scope.feeLevel = feeService.feeOpts[feeLevel];
$scope.network = (new bitcore.Address($scope.toAddress)).network.name; $scope.network = (new bitcore.Address($scope.toAddress)).network.name;
resetValues(); resetValues();
setwallets(); if (!$scope.wallet) setwallets();
else useSelectedWallet();
applyButtonText(); applyButtonText();
}); });
function useSelectedWallet() {
if (!$scope.useSendMax) displayValues();
$scope.onWalletSelect($scope.wallet);
}
function applyButtonText(multisig) { function applyButtonText(multisig) {
$scope.buttonText = $scope.isCordova ? gettextCatalog.getString('Slide') + ' ' : gettextCatalog.getString('Click') + ' '; $scope.buttonText = $scope.isCordova ? gettextCatalog.getString('Slide') + ' ' : gettextCatalog.getString('Click') + ' ';
@ -95,7 +101,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
} }
if (++index == $scope.wallets.length) { if (++index == $scope.wallets.length) {
if (!lodash.isEmpty(filteredWallets)) { if (!lodash.isEmpty(filteredWallets)) {
$scope.wallets = lodash.clone(filteredWallets); $scope.wallets = lodash.clone(filteredWallets);
if ($scope.useSendMax) { if ($scope.useSendMax) {
@ -133,10 +138,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
}); });
}; };
$scope.toggleFeeValue = function() {
$scope.showFeeFiat = !$scope.showFeeFiat;
};
$scope.toggleAddress = function() { $scope.toggleAddress = function() {
$scope.showAddress = !$scope.showAddress; $scope.showAddress = !$scope.showAddress;
}; };
@ -163,8 +164,8 @@ angular.module('copayApp.controllers').controller('confirmController', function(
}; };
function resetValues() { function resetValues() {
$scope.displayAmount = $scope.displayUnit = $scope.fee = $scope.alternativeAmountStr = $scope.insufficientFunds = $scope.noMatchingWallet = null; $scope.displayAmount = $scope.displayUnit = $scope.fee = $scope.feeFiat = $scope.feePercent = $scope.alternativeAmountStr = $scope.insufficientFunds = $scope.noMatchingWallet = null;
$scope.showFeeFiat = $scope.showAddress = false; $scope.showAddress = false;
}; };
$scope.getSendMaxInfo = function() { $scope.getSendMaxInfo = function() {
@ -255,10 +256,14 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$scope.displayAmount = getDisplayAmount($scope.amountStr); $scope.displayAmount = getDisplayAmount($scope.amountStr);
$scope.displayUnit = getDisplayUnit($scope.amountStr); $scope.displayUnit = getDisplayUnit($scope.amountStr);
$scope.fee = txFormatService.formatAmountStr(data.fee); $scope.fee = txFormatService.formatAmountStr(data.fee);
txFormatService.formatAlternativeStr(data.fee, function(v) {
$scope.feeFiat = v;
});
toAmount = parseFloat((data.amount * satToUnit).toFixed(unitDecimals)); toAmount = parseFloat((data.amount * satToUnit).toFixed(unitDecimals));
txFormatService.formatAlternativeStr(data.amount, function(v) { txFormatService.formatAlternativeStr(data.amount, function(v) {
$scope.alternativeAmountStr = v; $scope.alternativeAmountStr = v;
}); });
$scope.feePercent = (data.fee * 100 / (data.amount + data.fee)).toFixed(2);
$timeout(function() { $timeout(function() {
$scope.$apply(); $scope.$apply();
}); });
@ -347,7 +352,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
var stop; var stop;
$scope.wallet = wallet; $scope.wallet = wallet;
$scope.fee = $scope.txp = null; $scope.fee = $scope.txp = null;
if (stop) { if (stop) {
$timeout.cancel(stop); $timeout.cancel(stop);
stop = null; stop = null;
@ -385,6 +389,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$scope.feeFiat = v; $scope.feeFiat = v;
}); });
$scope.txp = txp; $scope.txp = txp;
$scope.feePercent = (txp.fee * 100 / (txp.amount + txp.fee)).toFixed(2);
$timeout(function() { $timeout(function() {
$scope.$apply(); $scope.$apply();
}); });
@ -576,4 +581,10 @@ angular.module('copayApp.controllers').controller('confirmController', function(
if (err) return setSendError(err); if (err) return setSendError(err);
}, onSendStatusChange); }, onSendStatusChange);
}; };
$scope.chooseFeeLevel = function() {
cachedTxp = {};
$state.go('tabs.send.confirm.fee');
};
}); });

View file

@ -12,6 +12,7 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
$scope.wallets = profileService.getWallets({ $scope.wallets = profileService.getWallets({
onlyComplete: true onlyComplete: true
}); });
console.log($scope.wallets);
$scope.hasWallets = lodash.isEmpty($scope.wallets) ? false : true; $scope.hasWallets = lodash.isEmpty($scope.wallets) ? false : true;
}; };
@ -158,6 +159,7 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
return popupService.showAlert(err); return popupService.showAlert(err);
} }
$log.debug('Got toAddress:' + addr + ' | ' + item.name); $log.debug('Got toAddress:' + addr + ' | ' + item.name);
console.log(item);
return $state.transitionTo('tabs.send.amount', { return $state.transitionTo('tabs.send.amount', {
recipientType: item.recipientType, recipientType: item.recipientType,
toAddress: addr, toAddress: addr,

View file

@ -295,6 +295,15 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
paypro: null paypro: null
} }
}) })
.state('tabs.send.confirm.fee', {
url: '/fee',
views: {
'tab-send@tabs': {
controller: 'preferencesFeeController',
templateUrl: 'views/preferencesFee.html'
}
}
})
.state('tabs.send.addressbook', { .state('tabs.send.addressbook', {
url: '/addressbook/add/:fromSendTab/:addressbookEntry', url: '/addressbook/add/:fromSendTab/:addressbookEntry',
views: { views: {

View file

@ -1,6 +1,12 @@
#view-confirm { #view-confirm {
background-color: #ffffff; background-color: #ffffff;
@extend .deflash-blue; @extend .deflash-blue;
.item-note {
float: none;
.fee-percent {
display: inline-block;
}
}
.icon-amazon { .icon-amazon {
background-image: url("../img/icon-amazon.svg"); background-image: url("../img/icon-amazon.svg");
} }

View file

@ -142,10 +142,6 @@
padding: .2rem 0; padding: .2rem 0;
margin-bottom: 5px; margin-bottom: 5px;
~ .bp-arrow-right {
top: 14px;
}
> i { > i {
padding: 0; padding: 0;
position: static; position: static;

View file

@ -48,7 +48,7 @@
</span> </span>
<div class="wallet" ng-if="recipientType == 'wallet'"> <div class="wallet" ng-if="recipientType == 'wallet'">
<i class="icon big-icon-svg"> <i class="icon big-icon-svg">
<img src="img/icon-wallet.svg" ng-style="{'background-color': toColor}" class="bg"/> <img src="img/icon-wallet.svg" ng-class="{'wallet-background-color-default': !toColor}" ng-style="{'background-color': toColor}" class="bg"/>
</i> </i>
<div copy-to-clipboard="toAddress" class="ellipsis"> <div copy-to-clipboard="toAddress" class="ellipsis">
<contact ng-if="!toName" address="{{toAddress}}"></contact> <contact ng-if="!toName" address="{{toAddress}}"></contact>
@ -77,18 +77,21 @@
</div> </div>
<i class="icon bp-arrow-right"></i> <i class="icon bp-arrow-right"></i>
</a> </a>
<a class="item single-line item-icon-right" ng-if="!insufficientFunds && !noMatchingWallet" ng-click="showDescriptionPopup()"> <div class="item item-icon-right" ng-if="!insufficientFunds && !noMatchingWallet" ng-click="chooseFeeLevel()">
<span class="label">{{'Fee' | translate}}: {{feeLevel | translate}}</span>
<span class="m10l">{{fee || '...'}}</span>
<span class="item-note m10l">
<span>{{feeFiat || '...'}}&nbsp;<span class="fee-percent" ng-if="feePercent" translate>- {{feePercent}} % of the transaction</span></span>
</span>
<i class="icon bp-arrow-right"></i>
</div>
<a class="item item-icon-right" ng-if="!insufficientFunds && !noMatchingWallet" ng-click="showDescriptionPopup()">
<span class="label" translate>Add Memo</span> <span class="label" translate>Add Memo</span>
<span class="item-note m10l"> <span class="item-note m10l">
{{description}} {{description}}
</span> </span>
<i class="icon bp-arrow-right"></i> <i class="icon bp-arrow-right"></i>
</a> </a>
<div class="item single-line toggle" ng-if="!insufficientFunds && !noMatchingWallet">
<span class="label">{{'Fee' | translate}}: {{feeLevel | translate}}</span>
<span ng-if="!showFeeFiat" class="item-note" ng-click="toggleFeeValue()">{{fee || '...'}}</span>
<span ng-if="showFeeFiat" class="item-note" ng-click="toggleFeeValue()">{{feeFiat || '...'}}</span>
</div>
<div class="text-center" ng-show="noMatchingWallet"> <div class="text-center" ng-show="noMatchingWallet">
<span class="badge badge-energized" translate>No wallets available</span> <span class="badge badge-energized" translate>No wallets available</span>
</div> </div>