Ref custom amount. Also fixes small screen issue

This commit is contained in:
Gustavo Maximiliano Cortez 2017-05-11 15:43:35 -03:00
commit 1c91420581
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
6 changed files with 170 additions and 71 deletions

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('amountController', function($scope, $filter, $timeout, $ionicScrollDelegate, $ionicHistory, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService, ongoingProcess, popupService, bwcError, payproService, profileService, bitcore, amazonService, nodeWebkitService) {
var _cardId;
var _id;
var unitToSatoshi;
var satToUnit;
var unitDecimals;
@ -17,7 +17,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
$scope.$on("$ionicView.beforeEnter", function(event, data) {
// Go to...
_cardId = data.stateParams.id; // Optional (BitPay Card ID)
_id = data.stateParams.id; // Optional (BitPay Card ID or Wallet ID)
$scope.nextStep = data.stateParams.nextStep;
$scope.currency = data.stateParams.currency;
$scope.forceCurrency = data.stateParams.forceCurrency;
@ -30,11 +30,8 @@ angular.module('copayApp.controllers').controller('amountController', function($
$scope.toEmail = data.stateParams.toEmail;
$scope.showAlternativeAmount = !!$scope.nextStep;
$scope.toColor = data.stateParams.toColor;
$scope.walletId = data.stateParams.walletId;
$scope.showSendMax = false;
$scope.customAmount = data.stateParams.customAmount;
if (!$scope.nextStep && !data.stateParams.toAddress) {
$log.error('Bad params at amount')
throw ('bad params');
@ -228,30 +225,22 @@ angular.module('copayApp.controllers').controller('amountController', function($
if ($scope.nextStep) {
$state.transitionTo($scope.nextStep, {
id: _cardId,
id: _id,
amount: $scope.useSendMax ? null : _amount,
currency: $scope.showAlternativeAmount ? $scope.alternativeIsoCode : $scope.unitName,
useSendMax: $scope.useSendMax
});
} else {
var amount = $scope.showAlternativeAmount ? fromFiat(_amount) : _amount;
if ($scope.customAmount) {
$state.transitionTo('tabs.receive.customAmount', {
walletId: $scope.walletId,
toAmount: (amount * unitToSatoshi).toFixed(0),
toAddress: $scope.toAddress
});
} else {
$state.transitionTo('tabs.send.confirm', {
recipientType: $scope.recipientType,
toAmount: $scope.useSendMax ? null : (amount * unitToSatoshi).toFixed(0),
toAddress: $scope.toAddress,
toName: $scope.toName,
toEmail: $scope.toEmail,
toColor: $scope.toColor,
useSendMax: $scope.useSendMax
});
}
$state.transitionTo('tabs.send.confirm', {
recipientType: $scope.recipientType,
toAmount: $scope.useSendMax ? null : (amount * unitToSatoshi).toFixed(0),
toAddress: $scope.toAddress,
toName: $scope.toName,
toEmail: $scope.toEmail,
toColor: $scope.toColor,
useSendMax: $scope.useSendMax
});
}
$scope.useSendMax = null;
};