second step enhancement
This commit is contained in:
parent
d864b35513
commit
162fd685e5
7 changed files with 101 additions and 84 deletions
|
|
@ -68,13 +68,14 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
|
|||
|
||||
function onBeforeEnter(event, data) {
|
||||
if (data.direction == "back") {
|
||||
sendFlowService.popState();
|
||||
sendFlowService.state.pop();
|
||||
}
|
||||
console.log('amount onBeforeEnter after back sendflow ', sendFlowService.state);
|
||||
|
||||
initCurrencies();
|
||||
|
||||
passthroughParams = sendFlowService.getStateClone();
|
||||
passthroughParams = sendFlowService.state.getClone();
|
||||
|
||||
console.log('amount onBeforeEnter after back sendflow ', passthroughParams);
|
||||
|
||||
vm.fromWalletId = passthroughParams.fromWalletId;
|
||||
vm.toWalletId = passthroughParams.toWalletId;
|
||||
|
|
@ -214,7 +215,7 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
|
|||
}
|
||||
|
||||
function goBack() {
|
||||
$ionicHistory.goBack();
|
||||
sendFlowService.router.goBack();
|
||||
}
|
||||
|
||||
function paste(value) {
|
||||
|
|
@ -467,11 +468,10 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
|
|||
confirmData.thirdParty = vm.thirdParty;
|
||||
}
|
||||
|
||||
sendFlowService.pushState(confirmData);
|
||||
if (!confirmData.fromWalletId) {
|
||||
$state.transitionTo('tabs.paymentRequest.confirm', confirmData);
|
||||
} else {
|
||||
$state.transitionTo('tabs.send.review', confirmData);
|
||||
sendFlowService.goNext(confirmData);
|
||||
$scope.useSendMax = null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ function reviewController(addressbookService, bitcoinCashJsService, bitcore, bit
|
|||
function onBeforeEnter(event, data) {
|
||||
console.log('walletSelector onBeforeEnter sendflow ', sendFlowService.state);
|
||||
defaults = configService.getDefaults();
|
||||
sendFlowData = sendFlowService.getStateClone();
|
||||
sendFlowData = sendFlowService.state.getClone();
|
||||
originWalletId = sendFlowData.fromWalletId;
|
||||
satoshis = parseInt(sendFlowData.amount, 10);
|
||||
toAddress = sendFlowData.toAddress;
|
||||
|
|
@ -403,7 +403,7 @@ function reviewController(addressbookService, bitcoinCashJsService, bitcore, bit
|
|||
}
|
||||
|
||||
function goBack() {
|
||||
$ionicHistory.goBack();
|
||||
sendFlowService.router.goBack();
|
||||
}
|
||||
|
||||
function handleDestinationAsAddress(address, originCoin) {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
|
|||
|
||||
$scope.$on("$ionicView.enter", function(event, data) {
|
||||
|
||||
var stateParams = sendFlowService.getStateClone();
|
||||
var stateParams = sendFlowService.state.getClone();
|
||||
$scope.fromWallet = profileService.getWallet(stateParams.fromWalletId);
|
||||
|
||||
clipboardService.readFromClipboard(function(text) {
|
||||
|
|
@ -60,10 +60,13 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
|
|||
});
|
||||
|
||||
$scope.findContact = function(search) {
|
||||
|
||||
if (incomingData.redir(search)) {
|
||||
return;
|
||||
}
|
||||
sendFlowService.start({
|
||||
data: search
|
||||
});
|
||||
return;
|
||||
//if (incomingData.redir(search)) {
|
||||
//return;
|
||||
//}
|
||||
|
||||
if (!search || search.length < 1) {
|
||||
$scope.list = originalList;
|
||||
|
|
@ -184,26 +187,26 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
|
|||
|
||||
$log.debug('Got toAddress:' + toAddress + ' | ' + item.name);
|
||||
|
||||
var stateParams = sendFlowService.getStateClone();
|
||||
var stateParams = sendFlowService.state.getClone();
|
||||
stateParams.toAddress = toAddress,
|
||||
stateParams.coin = item.coin;
|
||||
sendFlowService.pushState(stateParams);
|
||||
sendFlowService.goNext(stateParams);
|
||||
|
||||
if (!stateParams.fromWalletId) { // If we have no toAddress or fromWallet
|
||||
/*if (!stateParams.fromWalletId) { // If we have no toAddress or fromWallet
|
||||
$state.transitionTo('tabs.send.origin');
|
||||
} else {
|
||||
$state.transitionTo('tabs.send.amount');
|
||||
}
|
||||
}*/
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
$scope.startWalletToWalletTransfer = function() {
|
||||
console.log('startWalletToWalletTransfer()');
|
||||
var params = sendFlowService.getStateClone();
|
||||
sendFlowService.pushState(params);
|
||||
$state.transitionTo('tabs.send.wallet-to-wallet', {
|
||||
fromWalletId: sendFlowService.fromWalletId
|
||||
var params = sendFlowService.state.getClone();
|
||||
sendFlowService.goNext({
|
||||
isWalletTransfer: true,
|
||||
fromWalletId: params.fromWalletId
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -238,7 +241,7 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
|
|||
});
|
||||
|
||||
if (data.direction == "back") {
|
||||
sendFlowService.clear();
|
||||
sendFlowService.state.clear();
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('walletSelectorController', function($scope, $rootScope, $state, $log, $ionicHistory, sendFlowService, configService, gettextCatalog, profileService, txFormatService) {
|
||||
angular.module('copayApp.controllers').controller('walletSelectorController', function($scope, $state, sendFlowService, configService, gettextCatalog, profileService, txFormatService) {
|
||||
|
||||
var fromWalletId = '';
|
||||
var priceDisplayAsFiat = false;
|
||||
|
|
@ -12,31 +12,22 @@ angular.module('copayApp.controllers').controller('walletSelectorController', fu
|
|||
|
||||
function onBeforeEnter(event, data) {
|
||||
if (data.direction == "back") {
|
||||
sendFlowService.popState();
|
||||
sendFlowService.state.pop();
|
||||
}
|
||||
console.log('walletSelector onBeforeEnter after back sendflow', sendFlowService.state);
|
||||
|
||||
$scope.params = sendFlowService.getStateClone();
|
||||
$scope.params = sendFlowService.state.getClone();
|
||||
|
||||
console.log('walletSelector onBeforeEnter after back sendflow', $scope.params);
|
||||
|
||||
var config = configService.getSync().wallet.settings;
|
||||
priceDisplayAsFiat = config.priceDisplay === 'fiat';
|
||||
unitDecimals = config.unitDecimals;
|
||||
unitsFromSatoshis = 1 / config.unitToSatoshi;
|
||||
|
||||
switch($state.current.name) {
|
||||
case 'tabs.send.wallet-to-wallet':
|
||||
$scope.sendFlowTitle = gettextCatalog.getString('Transfer between wallets');
|
||||
break;
|
||||
case 'tabs.send.destination':
|
||||
if ($scope.params.fromWalletId && !$scope.params.thirdParty) {
|
||||
$scope.sendFlowTitle = gettextCatalog.getString('Transfer between wallets');
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (!$scope.params.thirdParty) {
|
||||
$scope.sendFlowTitle = gettextCatalog.getString('Send');
|
||||
}
|
||||
// nop
|
||||
if ($scope.params.isWalletTransfer) {
|
||||
$scope.sendFlowTitle = gettextCatalog.getString('Transfer between wallets');
|
||||
} else if (!$scope.params.thirdParty) {
|
||||
$scope.sendFlowTitle = gettextCatalog.getString('Send');
|
||||
}
|
||||
|
||||
$scope.coin = false; // Wallets to show (for destination screen or contacts)
|
||||
|
|
@ -105,16 +96,6 @@ angular.module('copayApp.controllers').controller('walletSelectorController', fu
|
|||
}
|
||||
}
|
||||
|
||||
function getNextStep(params) {
|
||||
if (!params.toWalletId && !params.toAddress) { // If we have no toAddress or fromWallet
|
||||
return 'tabs.send.destination';
|
||||
} else if (!params.amount) { // If we have no amount
|
||||
return 'tabs.send.amount';
|
||||
} else { // If we do have them
|
||||
return 'tabs.send.review';
|
||||
}
|
||||
}
|
||||
|
||||
function handleThirdPartyIfShapeshift() {
|
||||
console.log($scope.thirdParty, $scope.coin);
|
||||
if ($scope.thirdParty.id === 'shapeshift' && $scope.type === 'destination') { // Shapeshift wants to know the
|
||||
|
|
@ -192,20 +173,17 @@ angular.module('copayApp.controllers').controller('walletSelectorController', fu
|
|||
|
||||
|
||||
$scope.useWallet = function(wallet) {
|
||||
var params = sendFlowService.getStateClone();
|
||||
var params = sendFlowService.state.getClone();
|
||||
if ($scope.type === 'origin') { // we're on the origin screen, set wallet to send from
|
||||
params.fromWalletId = wallet.id;
|
||||
} else { // we're on the destination screen, set wallet to send to
|
||||
params.toWalletId = wallet.id;
|
||||
}
|
||||
sendFlowService.pushState(params);
|
||||
var nextStep = getNextStep(params);
|
||||
console.log('walletSelector nextStep', nextStep);
|
||||
$state.transitionTo(nextStep, $scope.params);
|
||||
sendFlowService.goNext(params);
|
||||
};
|
||||
|
||||
$scope.goBack = function() {
|
||||
$ionicHistory.goBack();
|
||||
sendFlowService.router.goBack();
|
||||
}
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue