fix customized unit amount - show address

This commit is contained in:
Javier 2016-08-09 15:28:03 -03:00
parent c3e510cc7c
commit cdcc060674
3 changed files with 18 additions and 11 deletions

View File

@ -75,10 +75,10 @@
<h4 class="title m10l" translate>QR Code</h4>
<ul class="no-bullet size-14 m0">
<li class="line-b p10 oh text-center">
<qrcode size="220" data="bitcoin:{{addr + '?amount=' + specificAmount}}"></qrcode>
<qrcode size="220" data="bitcoin:{{addr + '?amount=' + customizedAmountBtc}}"></qrcode>
<div class="m10t text-center" ng-show="isCordova">
<span class="button outline dark-gray tiny round"
ng-click="shareAddress('bitcoin:' + addr + '?amount=' + specificAmount)">
ng-click="shareAddress('bitcoin:' + addr + '?amount=' + customizedAmountBtc)">
<i class="fi-share"></i>
<span translate>Share address</span>
</span>
@ -91,7 +91,7 @@
<li class="line-b p10 oh">
<span class="text-gray" translate>Address</span>:
<span class="right">
<span class="text-gray enable_text_select">{{address}}</span>
<span class="text-gray enable_text_select">{{addr}}</span>
</span>
</li>
<li class="line-b p10 oh">

View File

@ -4,6 +4,7 @@ angular.module('copayApp.controllers').controller('inputAmountController', funct
var unitToSatoshi;
var satToUnit;
var unitDecimals;
var satToBtc;
var self = $scope.self;
var SMALL_FONT_SIZE_LIMIT = 13;
var LENGTH_EXPRESSION_LIMIT = 19;
@ -16,6 +17,7 @@ angular.module('copayApp.controllers').controller('inputAmountController', funct
$scope.isCordova = platformInfo.isCordova;
unitToSatoshi = config.unitToSatoshi;
satToUnit = 1 / unitToSatoshi;
satToBtc = 1 / 100000000;
unitDecimals = config.unitDecimals;
$scope.resetAmount();
$timeout(function() {
@ -138,20 +140,26 @@ angular.module('copayApp.controllers').controller('inputAmountController', funct
};
$scope.finish = function() {
var amount = evaluate(format($scope.amount)).toFixed(unitDecimals);
var alternativeAmount = fromFiat(amount).toFixed(unitDecimals);
var amount = $scope.showAlternativeAmount ? fromFiat(evaluate(format($scope.amount))).toFixed(unitDecimals) : evaluate(format($scope.amount));
var alternativeAmount = $scope.showAlternativeAmount ? evaluate(format($scope.amount)) : toFiat(evaluate(format($scope.amount)));
if (amount % 1 == 0) amount = parseInt(amount);
if ($scope.addr) {
$scope.specificAmount = amount;
$scope.specificAlternativeAmount = $filter('formatFiatAmount')(toFiat(amount));
$scope.specificAmount = profileService.formatAmount(amount * unitToSatoshi, true);
$scope.specificAlternativeAmount = $filter('formatFiatAmount')(alternativeAmount);
if ($scope.unitName == 'bits') {
var amountSat = parseInt((amount * unitToSatoshi).toFixed(0));
amount = (amountSat * satToBtc).toFixed(8);
}
$scope.customizedAmountBtc = amount;
$timeout(function() {
$ionicScrollDelegate.resize();
}, 100);
} else {
self.setAmount(amount, alternativeAmount, $scope.showAlternativeAmount);
self.setAmount(amount, $scope.showAlternativeAmount);
$scope.cancel();
}
};

View File

@ -347,12 +347,11 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
}, 1);
};
this.setAmount = function(amount, alternativeAmount, useAlternativeAmount) {
var amountResult = useAlternativeAmount ? alternativeAmount : amount;
this.setAmount = function(amount, useAlternativeAmount) {
$scope.showAlternative = useAlternativeAmount;
self.fromInputAmount = true;
self.setForm(null, amountResult, null);
self.setForm(null, amount, null);
};
this.submitForm = function() {