This commit is contained in:
Javier 2016-07-25 11:23:05 -03:00
parent 16363562b1
commit f6f9e5d7fc
4 changed files with 28 additions and 22 deletions

View File

@ -6,7 +6,7 @@
</a>
</div>
<h1 class="title ellipsis" translate>Enter amount</h1>
<div class="right-small m5r" ng-click="toggleAlternative()">
<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>
@ -16,9 +16,9 @@
<div ng-show="!specificAmount">
<div class="send-amount row" ng-style="{'background-color':index.backgroundColor}">
<div class="size-48" ng-show="!showAlternativeAmount">{{amount}}</div>
<div class="size-21 text-light" ng-show="!showAlternativeAmount">{{amountResult}} {{alternativeIsoCode}}</div>
<div class="size-21 text-light" ng-show="!showAlternativeAmount">{{globalResult}} {{amountResult}} {{alternativeIsoCode}}</div>
<div class="size-48" ng-show="showAlternativeAmount">${{alternativeAmount}}</div>
<div class="size-21 text-light" ng-show="showAlternativeAmount">{{alternativeResult}} {{unitName}}</div>
<div class="size-21 text-light" ng-show="showAlternativeAmount">{{globalResult}} {{alternativeResult}} {{unitName}}</div>
</div>
<div class="button-content text-center size-10 df">
@ -55,7 +55,7 @@
<div class="columns">
<button class="round expand m0"
ng-style="{'background-color':index.backgroundColor}"
ng-disabled="alternativeResult == 0 && amountResult == 0"
ng-disabled="alternativeResult <= 0 && amountResult <= 0"
ng-click="finish()"
ng-show="!specificAmount">
<span translate ng-show="!address">Ok</span>

View File

@ -303,16 +303,9 @@
</button>
</div>
<div class="small-12 columns" ng-show="home.addr">
<button class="button expand small round m10b" ng-click="openCustomAmountModal(home.addr)"
<button class="button expand small round m10b" ng-click="openAmountModal(home.addr)"
ng-style="{'background-color':index.backgroundColor}"
ng-disabled="home.generatingAddress"
ng-show="!index.isCordova">
<span translate>Request a specific amount</span>
</button>
<button class="button expand small round m10b" ng-click="openInputAmountModal(home.addr)"
ng-style="{'background-color':index.backgroundColor}"
ng-disabled="home.generatingAddress"
ng-show="index.isCordova">
ng-disabled="home.generatingAddress">
<span translate>Request a specific amount</span>
</button>
</div>
@ -432,8 +425,8 @@
<input type="amount" readonly="true" ng-show="showAlternative" id="alternative" ng-disabled="!home.isRateAvailable || home.lockAmount" name="alternative" ng-attr-placeholder="{{'Amount in'|translate}} {{ home.alternativeName }}" ng-model="_alternative" required autocomplete="off" ng-focus="openInputAmountModal()" ignore-mouse-wheel>
</div>
<div ng-if="!index.isCordova">
<input type="text" ng-show="!showAlternative" id="amount" ng-disabled="home.lockAmount" name="amount" ng-attr-placeholder="{{'Amount in'|translate}} {{home.unitName}}" ng-model="_amount" valid-amount required autocomplete="off" ignore-mouse-wheel>
<input type="text" ng-show="showAlternative" id="alternative" ng-disabled="!home.isRateAvailable || home.lockAmount" name="alternative" ng-attr-placeholder="{{'Amount in'|translate}} {{ home.alternativeName }}" ng-model="_alternative" required autocomplete="off" ignore-mouse-wheel>
<input type="number" ng-show="!showAlternative" id="amount" ng-disabled="home.lockAmount" name="amount" ng-attr-placeholder="{{'Amount in'|translate}} {{home.unitName}}" ng-model="_amount" valid-amount required autocomplete="off" ignore-mouse-wheel>
<input type="number" ng-show="showAlternative" id="alternative" ng-disabled="!home.isRateAvailable || home.lockAmount" name="alternative" ng-attr-placeholder="{{'Amount in'|translate}} {{ home.alternativeName }}" ng-model="_alternative" required autocomplete="off" ignore-mouse-wheel>
</div>
<a class="postfix button" ng-show="!showAlternative" ng-style="{'background-color':index.backgroundColor}" ng-click="showAlternative = !showAlternative">{{home.unitName}}</a>
<a class="postfix button black" ng-show="showAlternative" ng-click="showAlternative = !showAlternative">{{home.alternativeIsoCode}}</a>

View File

@ -37,15 +37,19 @@ angular.module('copayApp.controllers').controller('inputAmountController', funct
amount = format($scope.alternativeAmount);
$scope.amountResult = isOperator(lodash.last(amount)) ? evaluate(amount.slice(0, -1)) : evaluate(amount);
}
$scope.globalResult = null;
};
$scope.pushDigit = function(digit) {
var amount = $scope.showAlternativeAmount ? $scope.alternativeAmount.toString() : $scope.amount.toString();
if (amount.length >= 10) return;
if (amount == '0' && digit == 0) return;
var val = amount ? amount + digit : digit;
processAmount(val);
if (amount.length >= 20) return;
if (amount == '0') {
if (digit == 0) return;
processAmount(digit);
return;
}
processAmount(amount + digit);
};
$scope.pushOperator = function(operator) {
@ -93,6 +97,7 @@ angular.module('copayApp.controllers').controller('inputAmountController', funct
function resetAmount() {
$scope.amount = $scope.alternativeAmount = $scope.alternativeResult = $scope.amountResult = 0;
$scope.globalResult = null;
};
function processAmount(val) {
@ -116,6 +121,7 @@ angular.module('copayApp.controllers').controller('inputAmountController', funct
if (lodash.isNumber(result)) {
$scope.amount = $scope.alternativeAmount = val;
$scope.globalResult = result + ' =';
$scope.amountResult = toFiat(result);
$scope.alternativeResult = fromFiat(result);
}
@ -168,10 +174,10 @@ angular.module('copayApp.controllers').controller('inputAmountController', funct
$scope.specificAmountBtc = (amountSat * satToBtc).toFixed(8);
}
$scope.specificAmount = amount;
$scope.specificAlternativeAmount = alternativeAmount;
$scope.specificAmount = amount.toFixed(2);
$scope.specificAlternativeAmount = alternativeAmount.toFixed(2);
} else {
self.setAmount(amount, alternativeAmount, $scope.showAlternativeAmount);
self.setAmount(amount.toFixed(2), alternativeAmount.toFixed(2), $scope.showAlternativeAmount);
$scope.cancel();
}
};

View File

@ -557,6 +557,13 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
});
};
$scope.openAmountModal = function(address) {
if (isCordova)
$scope.openInputAmountModal(address);
else
$scope.openCustomAmountModal(address);
};
$scope.openInputAmountModal = function(addr) {
var fc = profileService.focusedClient;
$scope.color = fc.backgroundColor;