routes, renames and flow

This commit is contained in:
Sebastiaan Pasma 2018-07-23 16:58:32 +02:00
commit 3604ee3c3c
No known key found for this signature in database
GPG key ID: 9A2B0C8B95A1D26F
9 changed files with 160 additions and 105 deletions

View file

@ -0,0 +1,69 @@
'use strict';
angular.module('copayApp.controllers').controller('sendFlowController', function($scope, $rootScope, $state, $stateParams, $log, configService, gettextCatalog, profileService) {
var unitToSatoshi;
var satToUnit;
var unitDecimals;
var satToBtc;
$scope.$on("$ionicView.beforeEnter", function(event, data) {
var config = configService.getSync().wallet.settings;
$scope.specificAmount = $scope.specificAlternativeAmount = '';
unitToSatoshi = config.unitToSatoshi;
satToUnit = 1 / unitToSatoshi;
satToBtc = 1 / 100000000;
unitDecimals = config.unitDecimals;
// in SAT ALWAYS
if ($stateParams.toAmount) {
$scope.requestAmount = (($stateParams.toAmount) * satToUnit).toFixed(unitDecimals);
$scope.isPaymentRequest = true;
}
console.log(data, $stateParams);
$scope.params = $stateParams;
});
$scope.$on("$ionicView.enter", function(event, data) {
console.log(data, $stateParams);
$scope.type = data.stateParams.fromWalletId ? 'destination' : 'origin'; // origin || destination
$scope.coin = false; // Wallets to show (for destination screen)
$scope.walletsEmpty = [];
// Show price-header
if ($scope.type === 'origin') {
$scope.headerTitle = gettextCatalog.getString('Choose a wallet to send from');
$scope.walletsEmpty = profileService.getWallets({coin: $scope.coin, hasNoFunds: true});
} else if ($scope.type === 'destination') {
$scope.fromWallet = profileService.getWallet(data.stateParams.fromWalletId);
$scope.coin = $scope.fromWallet.coin;
$scope.headerTitle = gettextCatalog.getString('Choose a wallet to send to');
}
if (!$scope.coin || $scope.coin === 'bch') {
$scope.walletsBch = profileService.getWallets({coin: 'bch', hasFunds: $scope.type==='origin'});
}
if (!$scope.coin || $scope.coin === 'btc') {
$scope.walletsBtc = profileService.getWallets({coin: 'btc', hasFunds: $scope.type === 'origin'});
}
configService.whenAvailable(function(config) {
$scope.selectedPriceDisplay = config.wallet.settings.priceDisplay;
});
});
$scope.useWallet = function(wallet) {
if ($scope.type === 'origin') {
$scope.params['fromWalletId'] = wallet.id;
$state.transitionTo('tabs.send.destination', $scope.params);
} else {
$scope.params['toWalletId'] = wallet.id;
$state.transitionTo('tabs.send.amount', $scope.params);
}
};
});

View file

@ -54,42 +54,42 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
updateList();
});
});
var wallets;
var walletsBch;
var walletsBtc;
var walletToWalletFrom = false;
$scope.onWalletSelect = function(wallet) {
if (!$scope.walletToWalletFrom) {
$scope.walletToWalletFrom = wallet;
if (wallet.coin === 'bch') {
$scope.showWalletsBch = true;
} else if (wallet.coin === 'btc') {
$scope.showWalletsBtc = true;
}
$scope.walletSelectorTitleTo = gettextCatalog.getString('Send to');
} else {
$ionicLoading.show();
walletService.getAddress(wallet, true, function(err, addr) {
$ionicLoading.hide();
return $state.transitionTo('tabs.send.amount', {
displayAddress: $scope.walletToWalletFrom.coin === 'bch' ? bitcoinCashJsService.translateAddresses(addr).cashaddr : addr,
recipientType: 'wallet',
fromWalletId: $scope.walletToWalletFrom.id,
toAddress: addr,
coin: $scope.walletToWalletFrom.coin
});
});
}
};
$scope.showWalletSelector = function() {
$scope.walletToWalletFrom = false;
$scope.walletSelectorTitleFrom = gettextCatalog.getString('Send from');
$scope.showWallets = true;
};
//
// var wallets;
// var walletsBch;
// var walletsBtc;
// var walletToWalletFrom = false;
//
// $scope.onWalletSelect = function(wallet) {
// if (!$scope.walletToWalletFrom) {
// $scope.walletToWalletFrom = wallet;
// if (wallet.coin === 'bch') {
// $scope.showWalletsBch = true;
// } else if (wallet.coin === 'btc') {
// $scope.showWalletsBtc = true;
// }
// $scope.walletSelectorTitleTo = gettextCatalog.getString('Send to');
// } else {
// $ionicLoading.show();
// walletService.getAddress(wallet, true, function(err, addr) {
// $ionicLoading.hide();
// return $state.transitionTo('tabs.send.amount', {
// displayAddress: $scope.walletToWalletFrom.coin === 'bch' ? bitcoinCashJsService.translateAddresses(addr).cashaddr : addr,
// recipientType: 'wallet',
// fromWalletId: $scope.walletToWalletFrom.id,
// toAddress: addr,
// coin: $scope.walletToWalletFrom.coin
// });
// });
//
// }
// };
//
// $scope.showWalletSelector = function() {
// $scope.walletToWalletFrom = false;
// $scope.walletSelectorTitleFrom = gettextCatalog.getString('Send from');
// $scope.showWallets = true;
// };
$scope.findContact = function(search) {
@ -133,7 +133,6 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
};
var updateHasFunds = function() {
$scope.hasFunds = false;
var index = 0;
lodash.each($scope.wallets, function(w) {

View file

@ -1,33 +0,0 @@
'use strict';
angular.module('copayApp.controllers').controller('walletToWalletController', function($scope, $rootScope, $log, configService, gettextCatalog, profileService) {
$scope.$on("$ionicView.enter", function(event, data) {
$scope.type = 'origin'; // origin || destination
$scope.coin = false; // Wallets to show (for destination screen)
$scope.walletsEmpty = [];
$scope.isPaymentRequest = true; // Show price-header
if ($scope.type === 'origin') {
$scope.headerTitle = gettextCatalog.getString('Choose a wallet to send from');
$scope.walletsEmpty = profileService.getWallets({coin: $scope.coin, hasNoFunds: true});
} else if ($scope.type === 'destination') {
$scope.headerTitle = gettextCatalog.getString('Choose a wallet to send to');
}
if (!$scope.coin || $scope.coin === 'bch') {
$scope.walletsBch = profileService.getWallets({coin: 'bch', hasFunds: $scope.type==='origin'});
}
if (!$scope.coin || $scope.coin === 'btc') {
$scope.walletsBtc = profileService.getWallets({coin: 'btc', hasFunds: $scope.type === 'origin'});
}
configService.whenAvailable(function(config) {
$scope.selectedPriceDisplay = config.wallet.settings.priceDisplay;
});
});
$scope.useWallet = function(wallet) {
// Do something with selected wallet
};
});