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> <h4 class="title m10l" translate>QR Code</h4>
<ul class="no-bullet size-14 m0"> <ul class="no-bullet size-14 m0">
<li class="line-b p10 oh text-center"> <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"> <div class="m10t text-center" ng-show="isCordova">
<span class="button outline dark-gray tiny round" <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> <i class="fi-share"></i>
<span translate>Share address</span> <span translate>Share address</span>
</span> </span>
@ -91,7 +91,7 @@
<li class="line-b p10 oh"> <li class="line-b p10 oh">
<span class="text-gray" translate>Address</span>: <span class="text-gray" translate>Address</span>:
<span class="right"> <span class="right">
<span class="text-gray enable_text_select">{{address}}</span> <span class="text-gray enable_text_select">{{addr}}</span>
</span> </span>
</li> </li>
<li class="line-b p10 oh"> <li class="line-b p10 oh">

View File

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

View File

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