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) {
|
function onBeforeEnter(event, data) {
|
||||||
if (data.direction == "back") {
|
if (data.direction == "back") {
|
||||||
sendFlowService.popState();
|
sendFlowService.state.pop();
|
||||||
}
|
}
|
||||||
console.log('amount onBeforeEnter after back sendflow ', sendFlowService.state);
|
|
||||||
|
|
||||||
initCurrencies();
|
initCurrencies();
|
||||||
|
|
||||||
passthroughParams = sendFlowService.getStateClone();
|
passthroughParams = sendFlowService.state.getClone();
|
||||||
|
|
||||||
|
console.log('amount onBeforeEnter after back sendflow ', passthroughParams);
|
||||||
|
|
||||||
vm.fromWalletId = passthroughParams.fromWalletId;
|
vm.fromWalletId = passthroughParams.fromWalletId;
|
||||||
vm.toWalletId = passthroughParams.toWalletId;
|
vm.toWalletId = passthroughParams.toWalletId;
|
||||||
|
|
@ -214,7 +215,7 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
|
||||||
}
|
}
|
||||||
|
|
||||||
function goBack() {
|
function goBack() {
|
||||||
$ionicHistory.goBack();
|
sendFlowService.router.goBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
function paste(value) {
|
function paste(value) {
|
||||||
|
|
@ -467,11 +468,10 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
|
||||||
confirmData.thirdParty = vm.thirdParty;
|
confirmData.thirdParty = vm.thirdParty;
|
||||||
}
|
}
|
||||||
|
|
||||||
sendFlowService.pushState(confirmData);
|
|
||||||
if (!confirmData.fromWalletId) {
|
if (!confirmData.fromWalletId) {
|
||||||
$state.transitionTo('tabs.paymentRequest.confirm', confirmData);
|
$state.transitionTo('tabs.paymentRequest.confirm', confirmData);
|
||||||
} else {
|
} else {
|
||||||
$state.transitionTo('tabs.send.review', confirmData);
|
sendFlowService.goNext(confirmData);
|
||||||
$scope.useSendMax = null;
|
$scope.useSendMax = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ function reviewController(addressbookService, bitcoinCashJsService, bitcore, bit
|
||||||
function onBeforeEnter(event, data) {
|
function onBeforeEnter(event, data) {
|
||||||
console.log('walletSelector onBeforeEnter sendflow ', sendFlowService.state);
|
console.log('walletSelector onBeforeEnter sendflow ', sendFlowService.state);
|
||||||
defaults = configService.getDefaults();
|
defaults = configService.getDefaults();
|
||||||
sendFlowData = sendFlowService.getStateClone();
|
sendFlowData = sendFlowService.state.getClone();
|
||||||
originWalletId = sendFlowData.fromWalletId;
|
originWalletId = sendFlowData.fromWalletId;
|
||||||
satoshis = parseInt(sendFlowData.amount, 10);
|
satoshis = parseInt(sendFlowData.amount, 10);
|
||||||
toAddress = sendFlowData.toAddress;
|
toAddress = sendFlowData.toAddress;
|
||||||
|
|
@ -403,7 +403,7 @@ function reviewController(addressbookService, bitcoinCashJsService, bitcore, bit
|
||||||
}
|
}
|
||||||
|
|
||||||
function goBack() {
|
function goBack() {
|
||||||
$ionicHistory.goBack();
|
sendFlowService.router.goBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleDestinationAsAddress(address, originCoin) {
|
function handleDestinationAsAddress(address, originCoin) {
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
|
||||||
|
|
||||||
$scope.$on("$ionicView.enter", function(event, data) {
|
$scope.$on("$ionicView.enter", function(event, data) {
|
||||||
|
|
||||||
var stateParams = sendFlowService.getStateClone();
|
var stateParams = sendFlowService.state.getClone();
|
||||||
$scope.fromWallet = profileService.getWallet(stateParams.fromWalletId);
|
$scope.fromWallet = profileService.getWallet(stateParams.fromWalletId);
|
||||||
|
|
||||||
clipboardService.readFromClipboard(function(text) {
|
clipboardService.readFromClipboard(function(text) {
|
||||||
|
|
@ -60,10 +60,13 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.findContact = function(search) {
|
$scope.findContact = function(search) {
|
||||||
|
sendFlowService.start({
|
||||||
if (incomingData.redir(search)) {
|
data: search
|
||||||
return;
|
});
|
||||||
}
|
return;
|
||||||
|
//if (incomingData.redir(search)) {
|
||||||
|
//return;
|
||||||
|
//}
|
||||||
|
|
||||||
if (!search || search.length < 1) {
|
if (!search || search.length < 1) {
|
||||||
$scope.list = originalList;
|
$scope.list = originalList;
|
||||||
|
|
@ -184,26 +187,26 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
|
||||||
|
|
||||||
$log.debug('Got toAddress:' + toAddress + ' | ' + item.name);
|
$log.debug('Got toAddress:' + toAddress + ' | ' + item.name);
|
||||||
|
|
||||||
var stateParams = sendFlowService.getStateClone();
|
var stateParams = sendFlowService.state.getClone();
|
||||||
stateParams.toAddress = toAddress,
|
stateParams.toAddress = toAddress,
|
||||||
stateParams.coin = item.coin;
|
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');
|
$state.transitionTo('tabs.send.origin');
|
||||||
} else {
|
} else {
|
||||||
$state.transitionTo('tabs.send.amount');
|
$state.transitionTo('tabs.send.amount');
|
||||||
}
|
}*/
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.startWalletToWalletTransfer = function() {
|
$scope.startWalletToWalletTransfer = function() {
|
||||||
console.log('startWalletToWalletTransfer()');
|
console.log('startWalletToWalletTransfer()');
|
||||||
var params = sendFlowService.getStateClone();
|
var params = sendFlowService.state.getClone();
|
||||||
sendFlowService.pushState(params);
|
sendFlowService.goNext({
|
||||||
$state.transitionTo('tabs.send.wallet-to-wallet', {
|
isWalletTransfer: true,
|
||||||
fromWalletId: sendFlowService.fromWalletId
|
fromWalletId: params.fromWalletId
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -238,7 +241,7 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
|
||||||
});
|
});
|
||||||
|
|
||||||
if (data.direction == "back") {
|
if (data.direction == "back") {
|
||||||
sendFlowService.clear();
|
sendFlowService.state.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'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 fromWalletId = '';
|
||||||
var priceDisplayAsFiat = false;
|
var priceDisplayAsFiat = false;
|
||||||
|
|
@ -12,31 +12,22 @@ angular.module('copayApp.controllers').controller('walletSelectorController', fu
|
||||||
|
|
||||||
function onBeforeEnter(event, data) {
|
function onBeforeEnter(event, data) {
|
||||||
if (data.direction == "back") {
|
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;
|
var config = configService.getSync().wallet.settings;
|
||||||
priceDisplayAsFiat = config.priceDisplay === 'fiat';
|
priceDisplayAsFiat = config.priceDisplay === 'fiat';
|
||||||
unitDecimals = config.unitDecimals;
|
unitDecimals = config.unitDecimals;
|
||||||
unitsFromSatoshis = 1 / config.unitToSatoshi;
|
unitsFromSatoshis = 1 / config.unitToSatoshi;
|
||||||
|
|
||||||
switch($state.current.name) {
|
if ($scope.params.isWalletTransfer) {
|
||||||
case 'tabs.send.wallet-to-wallet':
|
$scope.sendFlowTitle = gettextCatalog.getString('Transfer between wallets');
|
||||||
$scope.sendFlowTitle = gettextCatalog.getString('Transfer between wallets');
|
} else if (!$scope.params.thirdParty) {
|
||||||
break;
|
$scope.sendFlowTitle = gettextCatalog.getString('Send');
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.coin = false; // Wallets to show (for destination screen or contacts)
|
$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() {
|
function handleThirdPartyIfShapeshift() {
|
||||||
console.log($scope.thirdParty, $scope.coin);
|
console.log($scope.thirdParty, $scope.coin);
|
||||||
if ($scope.thirdParty.id === 'shapeshift' && $scope.type === 'destination') { // Shapeshift wants to know the
|
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) {
|
$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
|
if ($scope.type === 'origin') { // we're on the origin screen, set wallet to send from
|
||||||
params.fromWalletId = wallet.id;
|
params.fromWalletId = wallet.id;
|
||||||
} else { // we're on the destination screen, set wallet to send to
|
} else { // we're on the destination screen, set wallet to send to
|
||||||
params.toWalletId = wallet.id;
|
params.toWalletId = wallet.id;
|
||||||
}
|
}
|
||||||
sendFlowService.pushState(params);
|
sendFlowService.goNext(params);
|
||||||
var nextStep = getNextStep(params);
|
|
||||||
console.log('walletSelector nextStep', nextStep);
|
|
||||||
$state.transitionTo(nextStep, $scope.params);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.goBack = function() {
|
$scope.goBack = function() {
|
||||||
$ionicHistory.goBack();
|
sendFlowService.router.goBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -6,9 +6,12 @@ angular
|
||||||
.module('copayApp.services')
|
.module('copayApp.services')
|
||||||
.factory('sendFlowRouterService', sendFlowRouterService);
|
.factory('sendFlowRouterService', sendFlowRouterService);
|
||||||
|
|
||||||
function sendFlowRouterService($state, $ionicHistory) {
|
function sendFlowRouterService(
|
||||||
|
sendFlowStateService
|
||||||
|
, $state, $ionicHistory
|
||||||
|
) {
|
||||||
|
|
||||||
var router = {
|
var service = {
|
||||||
// A separate state variable so we can ensure it is cleared of everything,
|
// A separate state variable so we can ensure it is cleared of everything,
|
||||||
// even other properties added that this service does not know about. (such as "coin")
|
// even other properties added that this service does not know about. (such as "coin")
|
||||||
|
|
||||||
|
|
@ -18,26 +21,41 @@ angular
|
||||||
goBack: goBack,
|
goBack: goBack,
|
||||||
};
|
};
|
||||||
|
|
||||||
return router;
|
return service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function start() {
|
function start() {
|
||||||
$ionicHistory.clearHistory();
|
if ($state.current.name != 'tabs.send') {
|
||||||
$state.go('tabs.send');
|
$state.go('tabs.home').then(function () {
|
||||||
|
$ionicHistory.clearHistory();
|
||||||
|
$state.go('tabs.send');
|
||||||
|
goNext();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
goNext();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function goNext(state) {
|
function goNext() {
|
||||||
|
var state = sendFlowStateService.state;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Strategy
|
* Strategy
|
||||||
* Clean the history & and go to the send tab.
|
|
||||||
*/
|
*/
|
||||||
// need to complete here
|
if (!state.fromWalletId && (state.isWalletTransfer || (state.toWalletId || state.toAddress))) {
|
||||||
|
$state.transitionTo('tabs.send.origin');
|
||||||
|
} else if (state.fromWalletId && !state.toWalletId && !state.toAddress) {
|
||||||
|
$state.transitionTo('tabs.send.destination');
|
||||||
|
} else if (state.fromWalletId && (state.toWalletId || state.toAddress) && !state.amount) {
|
||||||
|
$state.transitionTo('tabs.send.amount');
|
||||||
|
} else if (state.fromWalletId && (state.toWalletId || state.toAddress) && state.amount) {
|
||||||
|
$state.transitionTo('tabs.send.review');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function goBack() {
|
function goBack() {
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ angular
|
||||||
|
|
||||||
function init(params) {
|
function init(params) {
|
||||||
clear();
|
clear();
|
||||||
map(params);
|
push(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
function clear() {
|
function clear() {
|
||||||
|
|
|
||||||
|
|
@ -10,17 +10,19 @@ angular
|
||||||
sendFlowStateService, sendFlowRouterService
|
sendFlowStateService, sendFlowRouterService
|
||||||
, bitcoinUriService, payproService
|
, bitcoinUriService, payproService
|
||||||
, popupService
|
, popupService
|
||||||
|
, $state
|
||||||
) {
|
) {
|
||||||
|
|
||||||
var service = {
|
var service = {
|
||||||
// A separate state variable so we can ensure it is cleared of everything,
|
// A separate state variable so we can ensure it is cleared of everything,
|
||||||
// even other properties added that this service does not know about. (such as "coin")
|
// even other properties added that this service does not know about. (such as "coin")
|
||||||
|
state: sendFlowStateService,
|
||||||
|
router: sendFlowRouterService,
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
start: start,
|
start: start,
|
||||||
goNext: goNext,
|
goNext: goNext,
|
||||||
goBack: goBack,
|
goBack: goBack
|
||||||
getStateClone: getStateClone
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return service;
|
return service;
|
||||||
|
|
@ -37,7 +39,9 @@ angular
|
||||||
|
|
||||||
if (res.isValid) {
|
if (res.isValid) {
|
||||||
|
|
||||||
// If BIP70
|
/**
|
||||||
|
* If BIP70
|
||||||
|
*/
|
||||||
if (res.url) {
|
if (res.url) {
|
||||||
var url = res.url;
|
var url = res.url;
|
||||||
var coin = res.coin || '';
|
var coin = res.coin || '';
|
||||||
|
|
@ -79,14 +83,18 @@ angular
|
||||||
verified: true
|
verified: true
|
||||||
};
|
};
|
||||||
|
|
||||||
// Fill in params
|
/**
|
||||||
|
* Fill in params
|
||||||
|
*/
|
||||||
params.amount = thirdPartyData.amount,
|
params.amount = thirdPartyData.amount,
|
||||||
params.toAddress = thirdPartyData.toAddress,
|
params.toAddress = thirdPartyData.toAddress,
|
||||||
params.coin = coin,
|
params.coin = coin,
|
||||||
params.thirdParty = thirdPartyData
|
params.thirdParty = thirdPartyData
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolve
|
/**
|
||||||
|
* Resolve
|
||||||
|
*/
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -94,9 +102,10 @@ angular
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init the state if params is defined
|
/**
|
||||||
|
* Init the state if params is defined
|
||||||
|
*/
|
||||||
sendFlowStateService.init(params);
|
sendFlowStateService.init(params);
|
||||||
console.log(params);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -106,23 +115,32 @@ angular
|
||||||
}
|
}
|
||||||
|
|
||||||
function goNext(state) {
|
function goNext(state) {
|
||||||
// Push the new state
|
/**
|
||||||
|
* Save the current route before leaving
|
||||||
|
*/
|
||||||
|
state.route = $state.current.name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Push the new state
|
||||||
|
*/
|
||||||
sendFlowStateService.push(state);
|
sendFlowStateService.push(state);
|
||||||
|
|
||||||
// Go next
|
/**
|
||||||
sendFlowRouterService.goNext(state);
|
* Go next
|
||||||
|
*/
|
||||||
|
sendFlowRouterService.goNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
function goBack() {
|
function goBack() {
|
||||||
// Pop the current state
|
/**
|
||||||
sendFlowStateService.pop();
|
* Pop the current state
|
||||||
|
*/
|
||||||
|
sendFlowStateService.pop();
|
||||||
|
|
||||||
// Go back
|
/**
|
||||||
sendFlowRouterService.goBack();
|
* Go back
|
||||||
}
|
*/
|
||||||
|
sendFlowRouterService.goBack();
|
||||||
function getStateClone () {
|
|
||||||
return sendFlowStateService.getClone();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue