set send max

This commit is contained in:
Javier 2016-11-23 11:23:19 -03:00
commit 1687669149
11 changed files with 249 additions and 171 deletions

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('amountController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService, ongoingProcess, bitpayCardService, popupService, bwcError, payproService, amazonService, profileService, bitcore, walletService, feeService) { angular.module('copayApp.controllers').controller('amountController', function($scope, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService, ongoingProcess, bitpayCardService, popupService, bwcError, payproService, profileService, bitcore, amazonService) {
var unitToSatoshi; var unitToSatoshi;
var satToUnit; var satToUnit;
var unitDecimals; var unitDecimals;
@ -53,8 +53,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
$timeout(function() { $timeout(function() {
$scope.$apply(); $scope.$apply();
}, 10); });
}); });
var config = configService.getSync().wallet.settings; var config = configService.getSync().wallet.settings;
@ -78,74 +77,22 @@ angular.module('copayApp.controllers').controller('amountController', function($
$timeout(function() { $timeout(function() {
$ionicScrollDelegate.resize(); $ionicScrollDelegate.resize();
}, 10); });
}); });
$scope.getSendMaxInfo = function(wallet) { $scope.showSendMaxSelector = function() {
ongoingProcess.set('gettingFeeLevels', true); $scope.sendMax = true;
feeService.getCurrentFeeValue($scope.network, function(err, fee) {
ongoingProcess.set('gettingFeeLevels', false);
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), err.message);
return;
}
var config = configService.getSync();
ongoingProcess.set('retrivingInputs', true);
walletService.getSendMaxInfo(wallet, {
feePerKb: fee,
excludeUnconfirmedUtxos: !config.wallet.spendUnconfirmed,
returnInputs: true,
}, function(err, resp) {
ongoingProcess.set('retrivingInputs', false);
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), err);
return;
}
if (resp.amount == 0) {
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Not enough funds for fee'));
return;
}
var msg = gettextCatalog.getString("{{fee}} will be deducted for bitcoin networking fees", {
fee: txFormatService.formatAmount(resp.fee) + ' ' + $scope.unitName
});
var warningMsg = verifyExcludedUtxos();
if (!lodash.isEmpty(warningMsg))
msg += '. \n' + warningMsg;
popupService.showConfirm(null, msg, 'Ok', gettextCatalog.getString('Cancel'), function(result) {
if (!result) return;
var amount = (resp.amount * satToUnit).toFixed(0);
$scope.amount = amount;
processAmount(amount);
});
function verifyExcludedUtxos() {
var warningMsg = [];
if (resp.utxosBelowFee > 0) {
warningMsg.push(gettextCatalog.getString("A total of {{amountBelowFeeStr}} were excluded. These funds come from UTXOs smaller than the network fee provided.", {
amountBelowFeeStr: txFormatService.formatAmount(resp.amountBelowFee) + ' ' + $scope.unitName
}));
}
if (resp.utxosAboveMaxSize > 0) {
warningMsg.push(gettextCatalog.getString("A total of {{amountAboveMaxSizeStr}} were excluded. The maximum size allowed for a transaction was exceeded", {
amountAboveMaxSizeStr: txFormatService.formatAmount(resp.amountAboveMaxSize) + ' ' + $scope.unitName
}));
}
return warningMsg.join('\n');
};
});
});
}; };
$scope.showWalletSelector = function() { $scope.setSendMax = function() {
$scope.showWallets = true; $state.transitionTo('tabs.send.confirm', {
isWallet: $scope.isWallet,
toAmount: null,
toAddress: $scope.toAddress,
toName: $scope.toName,
toEmail: $scope.toEmail,
useSendMax: true,
});
}; };
$scope.toggleAlternative = function() { $scope.toggleAlternative = function() {

View file

@ -1,7 +1,9 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $interval, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, gettext, txFormatService, ongoingProcess, $ionicModal, popupService, $ionicHistory, $ionicConfig, payproService, amazonService) { angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $interval, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, gettext, txFormatService, ongoingProcess, $ionicModal, popupService, $ionicHistory, $ionicConfig, payproService, feeService, amazonService) {
var cachedTxp = {}; var cachedTxp = {};
var amountStr;
var toAmount;
var isChromeApp = platformInfo.isChromeApp; var isChromeApp = platformInfo.isChromeApp;
var countDown = null; var countDown = null;
var giftCardAmountUSD; var giftCardAmountUSD;
@ -12,7 +14,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$ionicConfig.views.swipeBackEnabled(false); $ionicConfig.views.swipeBackEnabled(false);
$scope.$on("$ionicView.beforeEnter", function(event, data) { $scope.$on("$ionicView.beforeEnter", function(event, data) {
// Amazon.com Gift Card parameters // Amazon.com Gift Card parameters
$scope.isGiftCard = data.stateParams.isGiftCard; $scope.isGiftCard = data.stateParams.isGiftCard;
giftCardAmountUSD = data.stateParams.giftCardAmountUSD; giftCardAmountUSD = data.stateParams.giftCardAmountUSD;
@ -20,102 +21,175 @@ angular.module('copayApp.controllers').controller('confirmController', function(
giftCardInvoiceTime = data.stateParams.giftCardInvoiceTime; giftCardInvoiceTime = data.stateParams.giftCardInvoiceTime;
giftCardUUID = data.stateParams.giftCardUUID; giftCardUUID = data.stateParams.giftCardUUID;
toAmount = data.stateParams.toAmount;
$scope.isWallet = data.stateParams.isWallet; $scope.isWallet = data.stateParams.isWallet;
$scope.cardId = data.stateParams.cardId; $scope.cardId = data.stateParams.cardId;
$scope.toAmount = data.stateParams.toAmount;
$scope.toAddress = data.stateParams.toAddress; $scope.toAddress = data.stateParams.toAddress;
$scope.toName = data.stateParams.toName; $scope.toName = data.stateParams.toName;
$scope.toEmail = data.stateParams.toEmail; $scope.toEmail = data.stateParams.toEmail;
$scope.description = data.stateParams.description; $scope.description = data.stateParams.description;
$scope.paypro = data.stateParams.paypro; $scope.paypro = data.stateParams.paypro;
$scope.useSendMax = data.stateParams.useSendMax;
$scope.insuffientFunds = false;
$scope.noMatchingWallet = false;
$scope.paymentExpired = { $scope.paymentExpired = {
value: false value: false
}; };
$scope.remainingTimeStr = { $scope.remainingTimeStr = {
value: null value: null
}; };
initConfirm();
});
var initConfirm = function() {
// TODO (URL , etc)
if (!$scope.toAddress || !$scope.toAmount) {
$log.error('Bad params at amount');
throw ('bad params');
}
var config = configService.getSync().wallet; var config = configService.getSync().wallet;
$scope.feeLevel = config.settings && config.settings.feeLevel ? config.settings.feeLevel : 'normal'; $scope.feeLevel = config.settings && config.settings.feeLevel ? config.settings.feeLevel : 'normal';
$scope.toAmount = parseInt($scope.toAmount); $scope.network = (new bitcore.Address($scope.toAddress)).network.name;
$scope.amountStr = txFormatService.formatAmountStr($scope.toAmount);
$scope.displayAmount = getDisplayAmount($scope.amountStr);
$scope.displayUnit = getDisplayUnit($scope.amountStr);
var networkName = (new bitcore.Address($scope.toAddress)).network.name; $scope.wallets = profileService.getWallets({
$scope.network = networkName;
$scope.insuffientFunds = false;
$scope.noMatchingWallet = false;
var wallets = profileService.getWallets({
onlyComplete: true, onlyComplete: true,
network: networkName, network: $scope.network,
n: $scope.isGiftCard ? true : false n: $scope.isGiftCard ? true : false
}); });
if (!wallets || !wallets.length) { if (!$scope.wallets || !$scope.wallets.length) {
$scope.noMatchingWallet = true; $scope.noMatchingWallet = true;
} else {
$scope.wallet = $scope.wallets[0];
} }
if (!$scope.useSendMax) initConfirm();
else $scope.getSendMaxInfo();
});
var initConfirm = function() {
toAmount = parseInt(toAmount);
amountStr = txFormatService.formatAmountStr(toAmount);
$scope.displayAmount = getDisplayAmount(amountStr);
$scope.displayUnit = getDisplayUnit(amountStr);
var filteredWallets = []; var filteredWallets = [];
var index = 0; var index = 0;
var enoughFunds = false; var enoughFunds = false;
lodash.each(wallets, function(w) { lodash.each($scope.wallets, function(w) {
walletService.getStatus(w, {}, function(err, status) { walletService.getStatus(w, {}, function(err, status) {
if (err || !status) { if (err || !status) {
$log.error(err); $log.error(err);
} else { } else {
w.status = status; w.status = status;
if (!status.availableBalanceSat) $log.debug('No balance available in: ' + w.name); if (!status.availableBalanceSat) $log.debug('No balance available in: ' + w.name);
if (status.availableBalanceSat > $scope.toAmount) { if (status.availableBalanceSat > toAmount) {
filteredWallets.push(w); filteredWallets.push(w);
enoughFunds = true; enoughFunds = true;
} }
} }
if (++index == wallets.length) { if (++index == $scope.wallets.length) {
if (!lodash.isEmpty(filteredWallets)) { if (!lodash.isEmpty(filteredWallets)) {
$scope.wallets = lodash.clone(filteredWallets); $scope.wallets = lodash.clone(filteredWallets);
setWallet($scope.wallets[0]); setWallet($scope.wallets[0]);
} else { } else {
if (!enoughFunds) $scope.insuffientFunds = true;
if (!enoughFunds)
$scope.insuffientFunds = true;
$log.warn('No wallet available to make the payment'); $log.warn('No wallet available to make the payment');
$timeout(function() {
$scope.$apply();
});
} }
} }
}); });
}); });
txFormatService.formatAlternativeStr($scope.toAmount, function(v) { txFormatService.formatAlternativeStr(toAmount, function(v) {
$scope.alternativeAmountStr = v; $scope.alternativeAmountStr = v;
}); });
if($scope.paypro) { if ($scope.paypro) _paymentTimeControl($scope.paypro.expires);
_paymentTimeControl($scope.paypro.expires);
}
$timeout(function() { $timeout(function() {
$scope.$apply(); $scope.$apply();
}); });
}; };
$scope.getSendMaxInfo = function() {
ongoingProcess.set('gettingFeeLevels', true);
feeService.getCurrentFeeValue($scope.network, function(err, feePerKb) {
ongoingProcess.set('gettingFeeLevels', false);
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), err.message);
return;
}
var config = configService.getSync().wallet;
var unitName = config.settings.unitName;
var unitToSatoshi = config.settings.unitToSatoshi;
var satToUnit = 1 / unitToSatoshi;
var unitDecimals = config.settings.unitDecimals;
ongoingProcess.set('retrievingInputs', true);
walletService.getSendMaxInfo($scope.wallet, {
feePerKb: feePerKb,
excludeUnconfirmedUtxos: !config.spendUnconfirmed,
returnInputs: true,
}, function(err, resp) {
ongoingProcess.set('retrievingInputs', false);
if (err) {
$scope.insuffientFunds = true;
popupService.showAlert(gettextCatalog.getString('Error'), err);
return;
}
if (resp.amount == 0) {
$scope.insuffientFunds = true;
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Not enough funds for fee'));
return;
}
$scope.sendMaxInfo = {
sendMax: true,
inputs: resp.inputs,
fee: resp.fee,
feePerKb: feePerKb,
};
toAmount = parseFloat((resp.amount * satToUnit).toFixed(unitDecimals));
var msg = gettextCatalog.getString("{{fee}} will be deducted for bitcoin networking fees", {
fee: txFormatService.formatAmount(resp.fee) + ' ' + unitName
});
var warningMsg = verifyExcludedUtxos();
if (!lodash.isEmpty(warningMsg))
msg += '. \n' + warningMsg;
popupService.showConfirm(null, msg, 'Ok', gettextCatalog.getString('Cancel'), function(result) {
if (!result) return;
var amount = txFormatService.formatAmount(resp.amount, true);
$scope.displayAmount = amount;
$scope.displayUnit = unitName;
$scope.fee = txFormatService.formatAmount($scope.sendMaxInfo.fee) + ' ' + unitName;
createTx($scope.wallet, true, function(err, txp) {
if (err) return;
cachedTxp[$scope.wallet.id] = txp;
apply(txp);
});
});
function verifyExcludedUtxos() {
var warningMsg = [];
if (resp.utxosBelowFee > 0) {
warningMsg.push(gettextCatalog.getString("A total of {{amountBelowFeeStr}} were excluded. These funds come from UTXOs smaller than the network fee provided.", {
amountBelowFeeStr: txFormatService.formatAmount(resp.amountBelowFee) + ' ' + unitName
}));
}
if (resp.utxosAboveMaxSize > 0) {
warningMsg.push(gettextCatalog.getString("A total of {{amountAboveMaxSizeStr}} were excluded. The maximum size allowed for a transaction was exceeded", {
amountAboveMaxSizeStr: txFormatService.formatAmount(resp.amountAboveMaxSize) + ' ' + unitName
}));
}
return warningMsg.join('\n');
};
});
});
};
$scope.$on('accepted', function(event) { $scope.$on('accepted', function(event) {
$scope.approve(); $scope.approve();
}); });
@ -134,10 +208,10 @@ angular.module('copayApp.controllers').controller('confirmController', function(
}; };
$scope.onWalletSelect = function(wallet) { $scope.onWalletSelect = function(wallet) {
setWallet(wallet); if (!$scope.useSendMax) setWallet(wallet);
else $scope.getSendMaxInfo();
}; };
$scope.showDescriptionPopup = function() { $scope.showDescriptionPopup = function() {
var message = gettextCatalog.getString('Add description'); var message = gettextCatalog.getString('Add description');
var opts = { var opts = {
@ -154,11 +228,11 @@ angular.module('copayApp.controllers').controller('confirmController', function(
function getDisplayAmount(amountStr) { function getDisplayAmount(amountStr) {
return amountStr.split(' ')[0]; return amountStr.split(' ')[0];
} };
function getDisplayUnit(amountStr) { function getDisplayUnit(amountStr) {
return amountStr.split(' ')[1]; return amountStr.split(' ')[1];
} };
function _paymentTimeControl(expirationTime) { function _paymentTimeControl(expirationTime) {
$scope.paymentExpired.value = false; $scope.paymentExpired.value = false;
@ -180,7 +254,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
var m = Math.floor(totalSecs / 60); var m = Math.floor(totalSecs / 60);
var s = totalSecs % 60; var s = totalSecs % 60;
$scope.remainingTimeStr.value = ('0' + m).slice(-2) + ":" + ('0' + s).slice(-2); $scope.remainingTimeStr.value = ('0' + m).slice(-2) + ":" + ('0' + s).slice(-2);
} };
function setExpiredValues() { function setExpiredValues() {
$scope.paymentExpired.value = true; $scope.paymentExpired.value = true;
@ -189,8 +263,8 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$timeout(function() { $timeout(function() {
$scope.$apply(); $scope.$apply();
}); });
} };
} };
function setWallet(wallet, delayed) { function setWallet(wallet, delayed) {
var stop; var stop;
@ -200,7 +274,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$timeout(function() { $timeout(function() {
$ionicScrollDelegate.resize(); $ionicScrollDelegate.resize();
$scope.$apply(); $scope.$apply();
}, 10); });
if (stop) { if (stop) {
$timeout.cancel(stop); $timeout.cancel(stop);
@ -218,7 +292,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
}); });
}, delayed ? 2000 : 1); }, delayed ? 2000 : 1);
} }
} };
var setSendError = function(msg) { var setSendError = function(msg) {
$scope.sendStatus = ''; $scope.sendStatus = '';
@ -232,17 +306,16 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$scope.fee = txFormatService.formatAmountStr(txp.fee); $scope.fee = txFormatService.formatAmountStr(txp.fee);
$scope.txp = txp; $scope.txp = txp;
$scope.$apply(); $scope.$apply();
} };
var createTx = function(wallet, dryRun, cb) { var createTx = function(wallet, dryRun, cb) {
var config = configService.getSync().wallet; var config = configService.getSync().wallet;
var currentSpendUnconfirmed = config.spendUnconfirmed; var currentSpendUnconfirmed = config.spendUnconfirmed;
var outputs = [];
var paypro = $scope.paypro; var paypro = $scope.paypro;
var toAddress = $scope.toAddress; var toAddress = $scope.toAddress;
var toAmount = $scope.toAmount;
var description = $scope.description; var description = $scope.description;
var unitToSatoshi = config.settings.unitToSatoshi;
var unitDecimals = config.settings.unitDecimals;
// ToDo: use a credential's (or fc's) function for this // ToDo: use a credential's (or fc's) function for this
if (description && !wallet.credentials.sharedEncryptingKey) { if (description && !wallet.credentials.sharedEncryptingKey) {
@ -257,28 +330,29 @@ angular.module('copayApp.controllers').controller('confirmController', function(
return setSendError(msg); return setSendError(msg);
} }
outputs.push({
'toAddress': toAddress,
'amount': toAmount,
'message': description
});
var txp = {}; var txp = {};
var amount;
if ($scope.useSendMax) amount = parseFloat((toAmount * unitToSatoshi));
else amount = toAmount;
// TODO txp.outputs = [{
if (!lodash.isEmpty($scope.sendMaxInfo)) { 'toAddress': toAddress,
txp.sendMax = true; 'amount': amount,
'message': description
}];
if ($scope.sendMaxInfo) {
txp.inputs = $scope.sendMaxInfo.inputs; txp.inputs = $scope.sendMaxInfo.inputs;
txp.fee = $scope.sendMaxInfo.fee; txp.feePerKb = $scope.sendMaxInfo.feePerKb;
} } else
txp.feeLevel = config.settings && config.settings.feeLevel ? config.settings.feeLevel : 'normal';
txp.outputs = outputs;
txp.message = description; txp.message = description;
if(paypro) {
if (paypro) {
txp.payProUrl = paypro.url; txp.payProUrl = paypro.url;
} }
txp.excludeUnconfirmedUtxos = config.spendUnconfirmed ? false : true; txp.excludeUnconfirmedUtxos = !currentSpendUnconfirmed;
txp.feeLevel = config.settings && config.settings.feeLevel ? config.settings.feeLevel : 'normal';
txp.dryRun = dryRun; txp.dryRun = dryRun;
walletService.createTx(wallet, txp, function(err, ctxp) { walletService.createTx(wallet, txp, function(err, ctxp) {
@ -334,7 +408,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
var isCordova = $scope.isCordova; var isCordova = $scope.isCordova;
var bigAmount = parseFloat(txFormatService.formatToUSD(txp.amount)) > 20; var bigAmount = parseFloat(txFormatService.formatToUSD(txp.amount)) > 20;
var message = gettextCatalog.getString('Sending {{amountStr}} from your {{name}} wallet', { var message = gettextCatalog.getString('Sending {{amountStr}} from your {{name}} wallet', {
amountStr: $scope.amountStr, amountStr: amountStr,
name: wallet.name name: wallet.name
}); });
var okText = gettextCatalog.getString('Confirm'); var okText = gettextCatalog.getString('Confirm');
@ -375,7 +449,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
} else if (showName) { } else if (showName) {
$scope.sendStatus = showName; $scope.sendStatus = showName;
} }
} };
$scope.statusChangeHandler = statusChangeHandler; $scope.statusChangeHandler = statusChangeHandler;

View file

@ -0,0 +1,26 @@
'use strict';
angular.module('copayApp.directives')
.directive('sendMaxSelector', function($timeout) {
return {
restrict: 'E',
templateUrl: 'views/includes/sendMaxSelector.html',
transclude: true,
scope: {
show: '=sendMaxSelectorShow',
wallet: '=sendMaxSelectorWallet',
onSelect: '=sendMaxSelectorOnSelect'
},
link: function(scope, element, attrs) {
scope.hide = function() {
scope.show = false;
};
scope.setSendMax = function() {
$timeout(function() {
scope.hide();
}, 100);
scope.onSelect();
};
}
};
});

View file

@ -286,7 +286,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
} }
}) })
.state('tabs.send.confirm', { .state('tabs.send.confirm', {
url: '/confirm/:isWallet/:toAddress/:toName/:toAmount/:toEmail/:description', url: '/confirm/:isWallet/:toAddress/:toName/:toAmount/:toEmail/:description/:useSendMax',
views: { views: {
'tab-send@tabs': { 'tab-send@tabs': {
controller: 'confirmController', controller: 'confirmController',

View file

@ -25,7 +25,7 @@ angular.module('copayApp.services').factory('ongoingProcess', function($log, $ti
'recreating': gettext('Recreating Wallet...'), 'recreating': gettext('Recreating Wallet...'),
'rejectTx': gettext('Rejecting payment proposal'), 'rejectTx': gettext('Rejecting payment proposal'),
'removeTx': gettext('Deleting payment proposal'), 'removeTx': gettext('Deleting payment proposal'),
'retrivingInputs': gettext('Retrieving inputs information'), 'retrievingInputs': gettext('Retrieving inputs information'),
'scanning': gettext('Scanning Wallet funds...'), 'scanning': gettext('Scanning Wallet funds...'),
'sendingTx': gettext('Sending transaction'), 'sendingTx': gettext('Sending transaction'),
'signingTx': gettext('Signing transaction'), 'signingTx': gettext('Signing transaction'),

View file

@ -562,20 +562,13 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
if (lodash.isEmpty(txp) || lodash.isEmpty(wallet)) if (lodash.isEmpty(txp) || lodash.isEmpty(wallet))
return cb('MISSING_PARAMETER'); return cb('MISSING_PARAMETER');
if (txp.sendMax) { wallet.createTxProposal(txp, function(err, createdTxp) {
wallet.createTxProposal(txp, function(err, createdTxp) { if (err) return cb(err);
if (err) return cb(err); else {
else return cb(null, createdTxp); $log.debug('Transaction created');
}); return cb(null, createdTxp);
} else { }
wallet.createTxProposal(txp, function(err, createdTxp) { });
if (err) return cb(err);
else {
$log.debug('Transaction created');
return cb(null, createdTxp);
}
});
}
}; };
root.publishTx = function(wallet, txp, cb) { root.publishTx = function(wallet, txp, cb) {
@ -1086,8 +1079,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
root.getSendMaxInfo = function(wallet, opts, cb) { root.getSendMaxInfo = function(wallet, opts, cb) {
opts = opts || {}; opts = opts || {};
wallet.getSendMaxInfo(opts, function(err, res) { wallet.getSendMaxInfo(opts, function(err, res) {
if (err) return cb(err); return cb(err, res);
return cb(null, res);
}); });
}; };

View file

@ -0,0 +1,21 @@
send-max-selector {
.bp-action-sheet__sheet {
padding-left: 2rem;
padding-right: .75rem;
}
.max-selector {
a.item {
border: none;
padding-top: 20px;
padding-bottom: 20px;
span {
&.item-note {
color: #3A3A3A;
font-family: "Roboto-Light";
}
}
}
}
}

View file

@ -38,6 +38,7 @@
@import "includes/tx-details"; @import "includes/tx-details";
@import "includes/txp-details"; @import "includes/txp-details";
@import "includes/tx-status"; @import "includes/tx-status";
@import "includes/sendMaxSelector";
@import "includes/walletSelector"; @import "includes/walletSelector";
@import "integrations/coinbase"; @import "integrations/coinbase";
@import "integrations/glidera"; @import "integrations/glidera";

View file

@ -5,6 +5,11 @@
</ion-nav-title> </ion-nav-title>
<ion-nav-back-button> <ion-nav-back-button>
</ion-nav-back-button> </ion-nav-back-button>
<ion-nav-buttons side="secondary">
<button class="button back-button" ng-click="showSendMaxSelector()">
<i class="icon ion-ios-more"></i>
</button>
</ion-nav-buttons>
</ion-nav-bar> </ion-nav-bar>
<ion-content scroll="false"> <ion-content scroll="false">
@ -93,10 +98,9 @@
</div> </div>
</div> </div>
</ion-content> </ion-content>
<wallet-selector <send-max-selector
wallet-selector-wallets="wallets" send-max-selector-wallet="wallet"
wallet-selector-selected-wallet="wallet" send-max-selector-show="sendMax"
wallet-selector-show="showWallets" send-max-selector-on-select="setSendMax">
wallet-selector-on-select="getSendMaxInfo"> </send-max-selector>
</wallet-selector>
</ion-view> </ion-view>

View file

@ -12,10 +12,11 @@
<div class="item head"> <div class="item head">
<div class="sending-label"> <div class="sending-label">
<img src="img/icon-tx-sent-outline.svg"> <img src="img/icon-tx-sent-outline.svg">
<span translate>Sending</span> <span translate ng-if="!useSendMax">Sending</span>
<span translate ng-if="useSendMax">Sending maximum amount <i class="icon ion-ios-navigate-outline"></i></span>
</div> </div>
<div class="amount-label"> <div class="amount-label">
<div class="amount">{{displayAmount}} <span class="unit">{{displayUnit}}</span></div> <div class="amount">{{displayAmount || '...'}} <span class="unit">{{displayUnit}}</span></div>
<div class="alternative">{{alternativeAmountStr}}</div> <div class="alternative">{{alternativeAmountStr}}</div>
</div> </div>
</div> </div>
@ -49,12 +50,6 @@
<span ng-if="tx.hasMultiplesOutputs" translate>Multiple recipients</span> --> <span ng-if="tx.hasMultiplesOutputs" translate>Multiple recipients</span> -->
</span> </span>
</div> </div>
<div class="text-center" ng-show="noMatchingWallet">
<span class="badge badge-energized" translate>No wallets available</span>
</div>
<div class="text-center" ng-show="insuffientFunds">
<span class="badge badge-energized" translate>Insufficient funds</span>
</div>
<a class="item item-icon-right" ng-hide="insuffientFunds || noMatchingWallet" ng-click="showWalletSelector()"> <a class="item item-icon-right" ng-hide="insuffientFunds || noMatchingWallet" ng-click="showWalletSelector()">
<span class="label" translate>From</span> <span class="label" translate>From</span>
<div class="wallet"> <div class="wallet">
@ -65,30 +60,36 @@
</div> </div>
<i class="icon bp-arrow-right"></i> <i class="icon bp-arrow-right"></i>
</a> </a>
<a class="item single-line item-icon-right" ng-hide="insuffientFunds || noMatchingWallet" ng-click="showDescriptionPopup()"> <a class="item single-line item-icon-right" ng-if="!insuffientFunds && !noMatchingWallet" ng-click="showDescriptionPopup()">
<span class="label" translate>Add Memo</span> <span class="label" translate>Add Memo</span>
<span class="item-note m10l"> <span class="item-note m10l">
{{description}} {{description}}
</span> </span>
<i class="icon bp-arrow-right"></i> <i class="icon bp-arrow-right"></i>
</a> </a>
<div class="item single-line" ng-hide="insuffientFunds || noMatchingWallet"> <div class="item single-line" ng-if="!insuffientFunds && !noMatchingWallet">
<span class="label" translate>Fee: {{feeLevel}}</span> <span class="label" translate>Fee: {{feeLevel}}</span>
<span class="item-note"> <span class="item-note">
{{fee || '...'}} {{fee || '...'}}
</span> </span>
</div> </div>
<div class="text-center" ng-show="noMatchingWallet">
<span class="badge badge-energized" translate>No wallets available</span>
</div>
<div class="text-center" ng-show="insuffientFunds">
<span class="badge badge-energized" translate>Insufficient funds</span>
</div>
</div> </div>
</div> </div>
</ion-content> </ion-content>
<click-to-accept <click-to-accept
ng-click="approve(statusChangeHandler)" ng-click="approve(statusChangeHandler)"
ng-if="!isCordova && wallets[0]" ng-if="!isCordova && wallets[0] && !insuffientFunds"
click-send-status="sendStatus"> click-send-status="sendStatus">
Click to pay Click to pay
</click-to-accept> </click-to-accept>
<slide-to-accept <slide-to-accept
ng-if="isCordova && wallets[0]" ng-if="isCordova && wallets[0] && !insuffientFunds"
slide-on-confirm="onConfirm()" slide-on-confirm="onConfirm()"
slide-send-status="sendStatus"> slide-send-status="sendStatus">
Slide to pay Slide to pay

View file

@ -0,0 +1,12 @@
<action-sheet action-sheet-show="show" class="max-selector">
<div class="header" translate>Shortcuts</div>
<a class="item item-icon-left item-icon-right" ng-click="setSendMax()">
<i class="icon ion-ios-navigate-outline"></i>
<span translate>Send max amount</span>
<span class="item-note">{{wallet.status.availableBalanceStr}}</span>
<i class="icon ion-ios-arrow-right"></i>
</a>
<div class="button button-block" ng-click="hide()">
<span translate>Cancel</span>
</div>
</action-sheet>