fix switch with empty values - fix UI - fix BTC format

This commit is contained in:
Javier 2016-08-02 12:44:47 -03:00
parent 7db87cd0a9
commit a17a4438b4
3 changed files with 26 additions and 17 deletions

View File

@ -6,9 +6,9 @@
</a>
</div>
<h1 class="title ellipsis" translate>Enter amount</h1>
<div class="right-small m5r" ng-show="!specificAmount" ng-click="toggleAlternative()">
<a class="postfix" ng-show="showAlternativeAmount">{{alternativeIsoCode}}</a>
<a class="postfix" ng-show="!showAlternativeAmount">{{unitName}}</a>
<div class="buttons m5r m3t" ng-show="!specificAmount" ng-click="toggleAlternative()">
<button class="button black" ng-show="showAlternativeAmount">{{alternativeIsoCode}}</button>
<button class="button" ng-style="{'background-color':color}" ng-show="!showAlternativeAmount">{{unitName}}</button>
</div>
</ion-header-bar>
@ -16,8 +16,8 @@
<div ng-show="!specificAmount">
<div class="send-amount row" ng-style="{'background-color':index.backgroundColor}">
<div class="size-48" ng-class="{'small-font': smallFont}">{{amount || '-'}}</div>
<div class="size-21 text-light" ng-show="!showAlternativeAmount">{{globalResult}} [{{amountResult || 0}} {{alternativeIsoCode}}]</div>
<div class="size-21 text-light" ng-show="showAlternativeAmount">{{globalResult}} [{{alternativeResult || 0}} {{unitName}}]</div>
<div class="size-21 text-light" ng-show="!showAlternativeAmount">{{globalResult}} [{{amountResult || '0.00'}} {{alternativeIsoCode}}]</div>
<div class="size-21 text-light" ng-show="showAlternativeAmount">{{globalResult}} [{{alternativeResult || '0.00'}} {{unitName}}]</div>
</div>
<div class="button-content text-center size-10 df">

View File

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('inputAmountController', function($rootScope, $scope, $filter, platformInfo, lodash, configService, go, rateService) {
angular.module('copayApp.controllers').controller('inputAmountController', function($rootScope, $scope, $filter, profileService, platformInfo, lodash, configService, go, rateService) {
var unitToSatoshi;
var satToUnit;
var unitDecimals;
@ -27,9 +27,12 @@ angular.module('copayApp.controllers').controller('inputAmountController', funct
$scope.toggleAlternative = function() {
$scope.showAlternativeAmount = !$scope.showAlternativeAmount;
if (isExpression($scope.amount)) {
var decimals = $scope.showAlternativeAmount ? 2 : unitDecimals;
$scope.globalResult = '= ' + evaluate(format($scope.amount)).toFixed(decimals);
if ($scope.amount && isExpression($scope.amount)) {
var amount = evaluate(format($scope.amount));
if ($scope.showAlternativeAmount)
$scope.globalResult = '= ' + $filter('formatFiatAmount')(amount);
else
$scope.globalResult = '= ' + profileService.formatAmount(amount * unitToSatoshi, true);
}
};
@ -40,9 +43,9 @@ angular.module('copayApp.controllers').controller('inputAmountController', funct
$scope.pushDigit = function(digit) {
checkFontSize();
if ($scope.amount && $scope.amount.length >= 20) return;
if ($scope.amount && $scope.amount.length >= 19) return;
$scope.amount = $scope.amount + digit;
$scope.amount = ($scope.amount + digit).replace('..', '.');
processAmount($scope.amount);
};
@ -67,11 +70,11 @@ angular.module('copayApp.controllers').controller('inputAmountController', funct
};
function isExpression(val) {
var regex = /^\d+(\.?\d?)+$/;
var regex = /^\.?\d+(\.?\d+)?([\/\-\+\*x]\d?\.?\d+)+$/;
var match = regex.exec(val);
if (match) return false;
return true;
if (match) return true;
return false;
};
$scope.removeDigit = function() {
@ -100,11 +103,13 @@ angular.module('copayApp.controllers').controller('inputAmountController', funct
var result = evaluate(formatedValue);
if (lodash.isNumber(result)) {
var decimals = $scope.showAlternativeAmount ? 2 : unitDecimals;
if ($scope.showAlternativeAmount)
$scope.globalResult = isExpression(val) ? '= ' + $filter('formatFiatAmount')(result) : '';
else
$scope.globalResult = isExpression(val) ? '= ' + profileService.formatAmount(result * unitToSatoshi, true) : '';
$scope.globalResult = isExpression(val) ? '= ' + result.toFixed(decimals) : '';
$scope.amountResult = $filter('formatFiatAmount')(toFiat(result));
$scope.alternativeResult = $filter('formatFiatAmount')(fromFiat(result));
$scope.alternativeResult = profileService.formatAmount(fromFiat(result) * unitToSatoshi, true);
}
};

View File

@ -588,6 +588,10 @@ ul.manage li {
margin-bottom: 10px;
}
.m3t {
margin-top: 3px;
}
.m10t {
margin-top: 10px;
}