apply to request specific amount
This commit is contained in:
parent
01c7c8ff42
commit
87595f54e5
7 changed files with 120 additions and 255 deletions
|
|
@ -1,88 +0,0 @@
|
||||||
<ion-modal-view ng-controller="customAmountController">
|
|
||||||
<ion-header-bar align-title="center" class="tab-bar" ng-style="{'background-color':color}">
|
|
||||||
<div class="left-small">
|
|
||||||
<a ng-click="cancel()" class="p10">
|
|
||||||
<span class="text-close" translate>Close</span>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<h1 class="title ellipsis" translate>Request a specific amount</h1>
|
|
||||||
</ion-header-bar>
|
|
||||||
|
|
||||||
<ion-content ng-style="{'background-color': '#f6f7f9'}">
|
|
||||||
<div class="modal-content fix-modals-touch">
|
|
||||||
<div class="m20b" ng-show="customizedAmountBtc">
|
|
||||||
<h4 class="title m0" 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=' + customizedAmountBtc}}"></qrcode>
|
|
||||||
<div class="m10t text-center" ng-show="isCordova">
|
|
||||||
<span class="button outline dark-gray tiny round"
|
|
||||||
ng-click="shareAddress('bitcoin:' + addr + '?amount=' + customizedAmountBtc)">
|
|
||||||
<i class="fi-share"></i>
|
|
||||||
<span translate>Share address</span>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h4 class="title m0" translate>Details</h4>
|
|
||||||
<ul class="no-bullet size-14 m0">
|
|
||||||
<li class="line-b p10 oh">
|
|
||||||
<span class="text-gray" translate>Address</span>:
|
|
||||||
<span class="right">
|
|
||||||
<span class="text-gray enable_text_select">{{addr}}</span>
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
<li class="line-b p10 oh">
|
|
||||||
<span class="text-gray" translate>Amount</span>:
|
|
||||||
<span class="right">
|
|
||||||
{{customizedAmountUnit}}
|
|
||||||
<span class="label gray radius">{{customizedAlternativeUnit}}</span>
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div ng-show="!customizedAmountBtc" class="row m20t">
|
|
||||||
<div class="large-12 large-centered columns">
|
|
||||||
<form name="amountForm" ng-submit="submitForm(amountForm)" novalidate>
|
|
||||||
<div class="right" ng-hide="amountForm.amount.$pristine && !amountForm.amount.$modelValue ">
|
|
||||||
<span class="has-error right size-12" ng-if="amountForm.amount.$invalid">
|
|
||||||
<i class="icon-close-circle size-14"></i>
|
|
||||||
<span clas="vm" translate>Not valid</span>
|
|
||||||
</span>
|
|
||||||
<small class="text-primary right" ng-if="!amountForm.amount.$invalid">
|
|
||||||
<i class="icon-checkmark-circle size-14"></i>
|
|
||||||
</small>
|
|
||||||
</div>
|
|
||||||
<div ng-show="!showAlternative">
|
|
||||||
<label for="amount">
|
|
||||||
<span translate>Amount</span>
|
|
||||||
</label>
|
|
||||||
<div class="input">
|
|
||||||
<input type="number" id="amount" name="amount" ng-attr-placeholder="{{'Amount in'|translate}} {{unitName}}" ignore-mouse-wheel
|
|
||||||
ng-model="_customAmount" ng-minlength="0.00000001" ng-maxlength="10000000000" valid-amount required autocomplete="off">
|
|
||||||
<input type="number" id="alternative" name="alternative" ng-model="_customAlternative" style="display:none">
|
|
||||||
<a class="postfix button" ng-style="{'background-color':color}" ng-click="toggleAlternative()">{{unitName}}</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div ng-show="showAlternative">
|
|
||||||
<label for="alternative"><span translate>Amount</span> [{{ alternativeIsoCode }}]
|
|
||||||
</label>
|
|
||||||
<div class="input">
|
|
||||||
<input type="number" id="alternative" name="alternative" ng-attr-placeholder="{{'Amount in'|translate}} {{alternativeName}}" ignore-mouse-wheel
|
|
||||||
ng-model="_customAlternative" required autocomplete="off" required>
|
|
||||||
<input type="number" id="amount" name="amount" ng-model="_customAmount" style="display:none">
|
|
||||||
<a class="postfix button black" ng-click="toggleAlternative()"> {{ alternativeIsoCode }}</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button type="submit" class="button black round expand" ng-disabled="amountForm.$invalid" ng-style="{'background-color':color}" translate>
|
|
||||||
Generate QR Code
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</ion-content>
|
|
||||||
</ion-view-modal>
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<ion-modal-view ng-controller="inputAmountController" ng-init=init()>
|
<ion-modal-view ng-controller="inputAmountController" ng-style="{'background-color':'#F6F7F9'}" ng-init=init()>
|
||||||
<ion-header-bar align-title="center" class="tab-bar" ng-style="{'background-color':color}">
|
<ion-header-bar align-title="center" class="tab-bar" ng-style="{'background-color':color}">
|
||||||
<div class="left-small">
|
<div class="left-small">
|
||||||
<a ng-click="cancel()" class="p10">
|
<a ng-click="cancel()" class="p10">
|
||||||
|
|
@ -12,42 +12,77 @@
|
||||||
</div>
|
</div>
|
||||||
</ion-header-bar>
|
</ion-header-bar>
|
||||||
|
|
||||||
<div class="content" ng-style="{'background-color':'#E4E8EC'}">
|
<ion-content>
|
||||||
<div class="send-amount row" ng-style="{'background-color':index.backgroundColor}">
|
<div ng-show="!specificAmount">
|
||||||
<div class="size-48" ng-show="!showAlternativeAmount">{{amount}}</div>
|
<div class="send-amount row" ng-style="{'background-color':index.backgroundColor}">
|
||||||
<div class="size-21 text-light" ng-show="!showAlternativeAmount">{{amountResult}} {{alternativeIsoCode}}</div>
|
<div class="size-48" ng-show="!showAlternativeAmount">{{amount}}</div>
|
||||||
<div class="size-48" ng-show="showAlternativeAmount">${{alternativeAmount}}</div>
|
<div class="size-21 text-light" ng-show="!showAlternativeAmount">{{amountResult}} {{alternativeIsoCode}}</div>
|
||||||
<div class="size-21 text-light" ng-show="showAlternativeAmount">{{alternativeResult}} {{unitName}}</div>
|
<div class="size-48" ng-show="showAlternativeAmount">${{alternativeAmount}}</div>
|
||||||
|
<div class="size-21 text-light" ng-show="showAlternativeAmount">{{alternativeResult}} {{unitName}}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="button-content text-center size-10 df">
|
||||||
|
<button class="button button-amount expand button-stable" ng-click="pushOperator('x')">x</button>
|
||||||
|
<button class="button expand button-stable" ng-click="pushOperator('/')">/</button>
|
||||||
|
<button class="button expand button-stable" ng-click="pushOperator('+')">+</button>
|
||||||
|
<button class="button expand button-stable" ng-click="pushOperator('-')">-</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="m10b">
|
||||||
|
<div class="button-content text-center df">
|
||||||
|
<button class="button expand button-light" ng-click="pushDigit('1')">1</button>
|
||||||
|
<button class="button expand button-light" ng-click="pushDigit('2')">2</button>
|
||||||
|
<button class="button expand button-light" ng-click="pushDigit('3')">3</button>
|
||||||
|
</div>
|
||||||
|
<div class="button-content text-center df">
|
||||||
|
<button class="button expand button-light" ng-click="pushDigit('4')">4</button>
|
||||||
|
<button class="button expand button-light" ng-click="pushDigit('5')">5</button>
|
||||||
|
<button class="button expand button-light" ng-click="pushDigit('6')">6</button>
|
||||||
|
</div>
|
||||||
|
<div class="button-content text-center df">
|
||||||
|
<button class="button expand button-light" ng-click="pushDigit('7')">7</button>
|
||||||
|
<button class="button expand button-light" ng-click="pushDigit('8')">8</button>
|
||||||
|
<button class="button expand button-light" ng-click="pushDigit('9')">9</button>
|
||||||
|
</div>
|
||||||
|
<div class="button-content text-center df">
|
||||||
|
<button class="button expand button-light" ng-click="pushDigit('.')">.</button>
|
||||||
|
<button class="button expand button-light" ng-click="pushDigit('0')">0</button>
|
||||||
|
<button class="button expand button-light" ng-click="removeDigit()"><</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="button-content text-center size-10 df">
|
<div class="modal-content m20b" ng-show="specificAmount">
|
||||||
<button class="button expand button-stable" ng-click="pushOperator('x')">x</button>
|
<h4 class="title m10l" translate>QR Code</h4>
|
||||||
<button class="button expand button-stable" ng-click="pushOperator('/')">/</button>
|
<ul class="no-bullet size-14 m0">
|
||||||
<button class="button expand button-stable" ng-click="pushOperator('+')">+</button>
|
<li class="line-b p10 oh text-center">
|
||||||
<button class="button expand button-stable" ng-click="pushOperator('-')">-</button>
|
<qrcode size="220" data="bitcoin:{{addr + '?amount=' + index.customizedAmountBtc}}"></qrcode>
|
||||||
</div>
|
<div class="m10t text-center" ng-show="isCordova">
|
||||||
|
<span class="button outline dark-gray tiny round"
|
||||||
|
ng-click="shareAddress('bitcoin:' + addr + '?amount=' + index.customizedAmountBtc)">
|
||||||
|
<i class="fi-share"></i>
|
||||||
|
<span translate>Share address</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
<div class="m10b">
|
<h4 class="title m10l" translate>Details</h4>
|
||||||
<div class="button-content text-center df">
|
<ul class="no-bullet size-14 m0">
|
||||||
<button class="button expand button-light" ng-click="pushDigit('1')">1</button>
|
<li class="line-b p10 oh">
|
||||||
<button class="button expand button-light" ng-click="pushDigit('2')">2</button>
|
<span class="text-gray" translate>Address</span>:
|
||||||
<button class="button expand button-light" ng-click="pushDigit('3')">3</button>
|
<span class="right">
|
||||||
</div>
|
<span class="text-gray enable_text_select">{{address}}</span>
|
||||||
<div class="button-content text-center df">
|
</span>
|
||||||
<button class="button expand button-light" ng-click="pushDigit('4')">4</button>
|
</li>
|
||||||
<button class="button expand button-light" ng-click="pushDigit('5')">5</button>
|
<li class="line-b p10 oh">
|
||||||
<button class="button expand button-light" ng-click="pushDigit('6')">6</button>
|
<span class="text-gray" translate>Amount</span>:
|
||||||
</div>
|
<span class="right">
|
||||||
<div class="button-content text-center df">
|
{{specificAmount}} {{unitName}}
|
||||||
<button class="button expand button-light" ng-click="pushDigit('7')">7</button>
|
<span class="label gray radius">{{specificAlternativeAmount}} {{alternativeIsoCode}}</span>
|
||||||
<button class="button expand button-light" ng-click="pushDigit('8')">8</button>
|
</span>
|
||||||
<button class="button expand button-light" ng-click="pushDigit('9')">9</button>
|
</li>
|
||||||
</div>
|
</ul>
|
||||||
<div class="button-content text-center df">
|
|
||||||
<button class="button expand button-light" ng-click="pushDigit('.')">.</button>
|
|
||||||
<button class="button expand button-light" ng-click="pushDigit('0')">0</button>
|
|
||||||
<button class="button expand button-light" ng-click="removeDigit()"><i class="icon ion-backspace-outline"></i></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row p20t">
|
<div class="row p20t">
|
||||||
|
|
@ -55,9 +90,18 @@
|
||||||
<button class="round expand m0"
|
<button class="round expand m0"
|
||||||
ng-style="{'background-color':index.backgroundColor}"
|
ng-style="{'background-color':index.backgroundColor}"
|
||||||
ng-disabled="alternativeResult == 0 && amountResult == 0"
|
ng-disabled="alternativeResult == 0 && amountResult == 0"
|
||||||
ng-click="save()"
|
ng-click="finish()"
|
||||||
translate>Save</button>
|
ng-show="!specificAmount">
|
||||||
|
<span translate ng-show="!address">Ok</span>
|
||||||
|
<span translate ng-show="address">Generate QR Code</span>
|
||||||
|
</button>
|
||||||
|
<button class="round expand m0"
|
||||||
|
ng-style="{'background-color':index.backgroundColor}"
|
||||||
|
ng-click="init()"
|
||||||
|
ng-show="specificAmount">
|
||||||
|
<span translate>Cancel</span>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</ion-content>
|
||||||
</ion-modal-view>
|
</ion-modal-view>
|
||||||
|
|
|
||||||
|
|
@ -303,9 +303,9 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="small-12 columns" ng-show="home.addr">
|
<div class="small-12 columns" ng-show="home.addr">
|
||||||
<button class="button expand small round m10b" ng-click="home.openCustomizedAmountModal(home.addr)"
|
<button class="button expand small round m10b" ng-click="openInputAmountModal(home.addr)"
|
||||||
ng-style="{'background-color':index.backgroundColor}"
|
ng-style="{'background-color':index.backgroundColor}"
|
||||||
ng-disabled="home.generatingAddress">
|
ng-disabled="home.generatingAddress">
|
||||||
<span translate>Request a specific amount</span>
|
<span translate>Request a specific amount</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -407,11 +407,11 @@
|
||||||
<div class="row" ng-init="home.hideAlternative()">
|
<div class="row" ng-init="home.hideAlternative()">
|
||||||
<div class="large-12 medium-12 columns">
|
<div class="large-12 medium-12 columns">
|
||||||
<div class="right" ng-hide="sendForm.amount.$pristine && !sendForm.amount.$modelValue ">
|
<div class="right" ng-hide="sendForm.amount.$pristine && !sendForm.amount.$modelValue ">
|
||||||
<span class="has-error right size-12" ng-if="sendForm.amount.$invalid">
|
<span class="has-error right size-12" ng-show="sendForm.amount.$invalid">
|
||||||
<i class="icon-close-circle size-14"></i>
|
<i class="icon-close-circle size-14"></i>
|
||||||
<span clas="vm" translate>Not valid</span>
|
<span clas="vm" translate>Not valid</span>
|
||||||
</span>
|
</span>
|
||||||
<small class="text-primary right" ng-if="!sendForm.amount.$invalid && !sendForm.alternative.$invalid">
|
<small class="text-primary right" ng-show="!sendForm.amount.$invalid && !sendForm.alternative.$invalid">
|
||||||
<i class="icon-checkmark-circle size-14"></i>
|
<i class="icon-checkmark-circle size-14"></i>
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -107,17 +107,7 @@
|
||||||
border: 1px solid #E9E9EC;
|
border: 1px solid #E9E9EC;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button.button-balanced:hover {
|
.button-amount {
|
||||||
background-color: #b2b2b2;
|
|
||||||
border: 1px solid #E9E9EC;
|
|
||||||
}
|
|
||||||
|
|
||||||
.button.button-balanced:active {
|
|
||||||
background-color: #ababab;
|
|
||||||
border: 1px solid #E9E9EC;
|
|
||||||
}
|
|
||||||
|
|
||||||
.button {
|
|
||||||
text-transform: none;
|
text-transform: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,79 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('customAmountController', function($scope, $timeout, $filter, platformInfo, rateService) {
|
|
||||||
var self = $scope.self;
|
|
||||||
|
|
||||||
$scope.unitName = self.unitName;
|
|
||||||
$scope.alternativeAmount = self.alternativeAmount;
|
|
||||||
$scope.alternativeName = self.alternativeName;
|
|
||||||
$scope.alternativeIsoCode = self.alternativeIsoCode;
|
|
||||||
$scope.isRateAvailable = self.isRateAvailable;
|
|
||||||
$scope.unitToSatoshi = self.unitToSatoshi;
|
|
||||||
$scope.unitDecimals = self.unitDecimals;
|
|
||||||
var satToUnit = 1 / self.unitToSatoshi;
|
|
||||||
$scope.showAlternative = false;
|
|
||||||
$scope.isCordova = platformInfo.isCordova;
|
|
||||||
|
|
||||||
Object.defineProperty($scope,
|
|
||||||
"_customAlternative", {
|
|
||||||
get: function() {
|
|
||||||
return $scope.customAlternative;
|
|
||||||
},
|
|
||||||
set: function(newValue) {
|
|
||||||
$scope.customAlternative = newValue;
|
|
||||||
if (typeof(newValue) === 'number' && $scope.isRateAvailable) {
|
|
||||||
$scope.customAmount = parseFloat((rateService.fromFiat(newValue, $scope.alternativeIsoCode) * satToUnit).toFixed($scope.unitDecimals), 10);
|
|
||||||
} else {
|
|
||||||
$scope.customAmount = null;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
|
|
||||||
Object.defineProperty($scope,
|
|
||||||
"_customAmount", {
|
|
||||||
get: function() {
|
|
||||||
return $scope.customAmount;
|
|
||||||
},
|
|
||||||
set: function(newValue) {
|
|
||||||
$scope.customAmount = newValue;
|
|
||||||
if (typeof(newValue) === 'number' && $scope.isRateAvailable) {
|
|
||||||
$scope.customAlternative = parseFloat((rateService.toFiat(newValue * $scope.unitToSatoshi, $scope.alternativeIsoCode)).toFixed(2), 10);
|
|
||||||
} else {
|
|
||||||
$scope.customAlternative = null;
|
|
||||||
}
|
|
||||||
$scope.alternativeAmount = $scope.customAlternative;
|
|
||||||
},
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
|
|
||||||
$scope.submitForm = function(form) {
|
|
||||||
var satToBtc = 1 / 100000000;
|
|
||||||
var amount = form.amount.$modelValue;
|
|
||||||
var amountSat = parseInt((amount * $scope.unitToSatoshi).toFixed(0));
|
|
||||||
$timeout(function() {
|
|
||||||
$scope.customizedAmountUnit = amount + ' ' + $scope.unitName;
|
|
||||||
$scope.customizedAlternativeUnit = $filter('formatFiatAmount')(form.alternative.$modelValue) + ' ' + $scope.alternativeIsoCode;
|
|
||||||
if ($scope.unitName == 'bits') {
|
|
||||||
amount = (amountSat * satToBtc).toFixed(8);
|
|
||||||
}
|
|
||||||
$scope.customizedAmountBtc = amount;
|
|
||||||
}, 1);
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.toggleAlternative = function() {
|
|
||||||
$scope.showAlternative = !$scope.showAlternative;
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.shareAddress = function(uri) {
|
|
||||||
if (platformInfo.isCordova) {
|
|
||||||
window.plugins.socialsharing.share(uri, null, null, null);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.cancel = function() {
|
|
||||||
$scope.customAmountModal.hide();
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('inputAmountController', function($scope, lodash, configService, go, rateService) {
|
angular.module('copayApp.controllers').controller('inputAmountController', function($rootScope, $scope, lodash, configService, go, rateService) {
|
||||||
var unitToSatoshi;
|
var unitToSatoshi;
|
||||||
var satToUnit;
|
var satToUnit;
|
||||||
var unitDecimals;
|
var unitDecimals;
|
||||||
|
|
@ -10,10 +10,10 @@ angular.module('copayApp.controllers').controller('inputAmountController', funct
|
||||||
var config = configService.getSync().wallet.settings;
|
var config = configService.getSync().wallet.settings;
|
||||||
$scope.unitName = config.unitName;
|
$scope.unitName = config.unitName;
|
||||||
$scope.alternativeIsoCode = config.alternativeIsoCode;
|
$scope.alternativeIsoCode = config.alternativeIsoCode;
|
||||||
|
$scope.specificAmount = $scope.specificAlternativeAmount = null;
|
||||||
unitToSatoshi = config.unitToSatoshi;
|
unitToSatoshi = config.unitToSatoshi;
|
||||||
satToUnit = 1 / unitToSatoshi;
|
satToUnit = 1 / unitToSatoshi;
|
||||||
unitDecimals = config.unitDecimals;
|
unitDecimals = config.unitDecimals;
|
||||||
console.log($scope.showAlternativeAmount);
|
|
||||||
resetAmount();
|
resetAmount();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -23,11 +23,11 @@ angular.module('copayApp.controllers').controller('inputAmountController', funct
|
||||||
|
|
||||||
if ($scope.showAlternativeAmount) {
|
if ($scope.showAlternativeAmount) {
|
||||||
$scope.alternativeAmount = $scope.amountResult;
|
$scope.alternativeAmount = $scope.amountResult;
|
||||||
amount = processFormat($scope.amount);
|
amount = format($scope.amount);
|
||||||
$scope.alternativeResult = isOperator(lodash.last(amount)) ? evaluate(amount.slice(0, -1)) : evaluate(amount);
|
$scope.alternativeResult = isOperator(lodash.last(amount)) ? evaluate(amount.slice(0, -1)) : evaluate(amount);
|
||||||
} else {
|
} else {
|
||||||
$scope.amount = $scope.alternativeResult;
|
$scope.amount = $scope.alternativeResult;
|
||||||
amount = processFormat($scope.alternativeAmount);
|
amount = format($scope.alternativeAmount);
|
||||||
$scope.amountResult = isOperator(lodash.last(amount)) ? evaluate(amount.slice(0, -1)) : evaluate(amount);
|
$scope.amountResult = isOperator(lodash.last(amount)) ? evaluate(amount.slice(0, -1)) : evaluate(amount);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -105,16 +105,24 @@ angular.module('copayApp.controllers').controller('inputAmountController', funct
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var formatedValue = processFormat(val);
|
var formatedValue = format(val);
|
||||||
var result = evaluate(formatedValue);
|
var result = evaluate(formatedValue);
|
||||||
|
|
||||||
if (lodash.isNumber(result)) {
|
if (lodash.isNumber(result)) {
|
||||||
$scope.amount = $scope.alternativeAmount = val;
|
$scope.amount = $scope.alternativeAmount = val;
|
||||||
$scope.alternativeResult = parseFloat((rateService.fromFiat(result, $scope.alternativeIsoCode) * satToUnit).toFixed(unitDecimals), 10);
|
$scope.alternativeResult = fromFiat(result);
|
||||||
$scope.amountResult = parseFloat((rateService.toFiat(result * unitToSatoshi, $scope.alternativeIsoCode)).toFixed(2), 10);
|
$scope.amountResult = toFiat(result);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function fromFiat(val) {
|
||||||
|
return parseFloat((rateService.fromFiat(val, $scope.alternativeIsoCode) * satToUnit).toFixed(unitDecimals), 10);
|
||||||
|
};
|
||||||
|
|
||||||
|
function toFiat(val) {
|
||||||
|
return parseFloat((rateService.toFiat(val * unitToSatoshi, $scope.alternativeIsoCode)).toFixed(2), 10);
|
||||||
|
};
|
||||||
|
|
||||||
function evaluate(val) {
|
function evaluate(val) {
|
||||||
var result;
|
var result;
|
||||||
try {
|
try {
|
||||||
|
|
@ -125,23 +133,27 @@ angular.module('copayApp.controllers').controller('inputAmountController', funct
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
function processFormat(val) {
|
function format(val) {
|
||||||
return val.toString().replace('x', '*');
|
return val.toString().replace('x', '*');
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.save = function() {
|
$scope.finish = function() {
|
||||||
if ($scope.showAlternativeAmount) {
|
var amount = toFiat($scope.alternativeResult);
|
||||||
if ($scope.alternativeResult == 0) return;
|
var alternativeAmount = $scope.showAlternative ? fromFiat(amount) : toFiat(amount);
|
||||||
|
|
||||||
self.showAlternativeAmount = true;
|
if ($scope.address) {
|
||||||
self.setForm(null, $scope.alternativeResult, null);
|
$scope.specificAmount = amount;
|
||||||
|
$scope.specificAlternativeAmount = alternativeAmount;
|
||||||
} else {
|
} else {
|
||||||
if ($scope.amountResult == 0) return;
|
if ($scope.showAlternativeAmount) {
|
||||||
|
self.showAlternative = true;
|
||||||
self.showAlternativeAmount = false;
|
self.setForm(null, alternativeAmount, null);
|
||||||
self.setForm(null, $scope.amountResult, null);
|
} else {
|
||||||
|
self.showAlternative = false;
|
||||||
|
self.setForm(null, amount, null);
|
||||||
|
}
|
||||||
|
$scope.cancel();
|
||||||
}
|
}
|
||||||
$scope.cancel();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.cancel = function() {
|
$scope.cancel = function() {
|
||||||
|
|
|
||||||
|
|
@ -216,21 +216,6 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.openCustomizedAmountModal = function(addr) {
|
|
||||||
var fc = profileService.focusedClient;
|
|
||||||
|
|
||||||
$scope.color = fc.backgroundColor;
|
|
||||||
$scope.self = self;
|
|
||||||
$scope.addr = addr;
|
|
||||||
|
|
||||||
$ionicModal.fromTemplateUrl('views/modals/customized-amount.html', {
|
|
||||||
scope: $scope
|
|
||||||
}).then(function(modal) {
|
|
||||||
$scope.customAmountModal = modal;
|
|
||||||
$scope.customAmountModal.show();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// Send
|
// Send
|
||||||
|
|
||||||
this.resetError = function() {
|
this.resetError = function() {
|
||||||
|
|
@ -544,10 +529,11 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.openInputAmountModal = function() {
|
$scope.openInputAmountModal = function(addr) {
|
||||||
var fc = profileService.focusedClient;
|
var fc = profileService.focusedClient;
|
||||||
$scope.color = fc.backgroundColor;
|
$scope.color = fc.backgroundColor;
|
||||||
$scope.showAlternativeAmount = $scope.showAlternative || null;
|
$scope.showAlternativeAmount = $scope.showAlternative || null;
|
||||||
|
$scope.address = addr || null;
|
||||||
$scope.self = self;
|
$scope.self = self;
|
||||||
|
|
||||||
$ionicModal.fromTemplateUrl('views/modals/inputAmount.html', {
|
$ionicModal.fromTemplateUrl('views/modals/inputAmount.html', {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue