Wallet to wallet flow

This commit is contained in:
Sebastiaan Pasma 2018-07-12 15:25:11 +02:00
commit 2e6ae9770e
No known key found for this signature in database
GPG key ID: 9A2B0C8B95A1D26F
4 changed files with 52 additions and 11 deletions

View file

@ -4,6 +4,8 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
var clipboardHasAddress = false;
var clipboardHasContent = false;
var originalList;
$scope.displayBalanceAsFiat = true;
$scope.walletSelectorTitleForce = true;
$scope.addContact = function() {
$state.go('tabs.settings').then(function() {
@ -50,22 +52,25 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
});
});
var wallets;
var walletsBch;
var walletsBtc;
var walletToWalletFrom = false;
var walletToWalletTo = false;
$scope.onWalletSelect = function(wallet) {
if (!$scope.walletToWalletFrom) {
$scope.walletToWalletFrom = wallet;
$scope.walletSelectorTitle = gettextCatalog.getString('Send to');
$timeout(function(){
$scope.showWallets = true;
}, 200);
if (wallet.coin === 'bch') {
$scope.showWalletsBch = true;
} else if (wallet.coin === 'btc') {
$scope.showWalletsBtc = true;
}
$scope.walletSelectorTitleTo = gettextCatalog.getString('Send to');
} else {
$scope.walletToWalletTo = wallet;
walletService.getAddress($scope.walletToWalletFrom, true, function(err, addr) {
walletService.getAddress(wallet, true, function(err, addr) {
return $state.transitionTo('tabs.send.amount', {
displayAddress: $scope.walletToWalletFrom.coin === 'bch' ? bitcoinCashJsService.translateAddresses(addr).cashaddr : addr,
recipientType: 'wallet',
fromWalletId: $scope.walletToWalletFrom.walletId,
toAddress: addr,
coin: $scope.walletToWalletFrom.coin
@ -77,7 +82,7 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
$scope.showWalletSelector = function() {
$scope.walletToWalletFrom = false;
$scope.walletSelectorTitle = gettextCatalog.getString('Send from');
$scope.walletSelectorTitleFrom = gettextCatalog.getString('Send from');
$scope.showWallets = true;
};
@ -107,6 +112,14 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
$scope.wallets = profileService.getWallets({
onlyComplete: true
});
$scope.walletsBch = profileService.getWallets({
onlyComplete: true,
coin: 'bch'
});
$scope.walletsBtc = profileService.getWallets({
onlyComplete: true,
coin: 'btc'
});
$scope.hasWallets = lodash.isEmpty($scope.wallets) ? false : true;
};
@ -234,11 +247,19 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
};
$scope.$on("$ionicView.beforeEnter", function(event, data) {
$scope.showWalletsBch = $scope.showWalletsBtc = $scope.showWallets = false;
$scope.checkingBalance = true;
$scope.formData = {
search: null
};
originalList = [];
hasWallets();
configService.whenAvailable(function(_config) {
$scope.displayBalanceAsFiat = _config.wallet.settings.priceDisplay === 'fiat';
config = _config;
});
});
});

View file

@ -8,6 +8,7 @@ angular.module('copayApp.directives')
transclude: true,
scope: {
title: '=walletSelectorTitle',
forceTitle: '=walletSelectorForceTitle',
show: '=walletSelectorShow',
wallets: '=walletSelectorWallets',
selectedWallet: '=walletSelectorSelectedWallet',
@ -15,6 +16,7 @@ angular.module('copayApp.directives')
displayBalanceAsFiat : '=walletSelectorDisplayBalanceAsFiat'
},
link: function(scope, element, attrs) {
console.log(scope, element, attrs);
scope.hide = function() {
scope.show = false;
};

View file

@ -5,7 +5,7 @@
ng-init="wallet.coin == 'btc' ? walletsBtc.push(wallet) : walletsBch.push(wallet)">
</span>
<div class="header" ng-if="!walletsBtc[0] || !walletsBch[0]">{{title}}</div>
<div class="header" ng-if="(!walletsBtc[0] || !walletsBch[0]) || forceTitle === true">{{title}}</div>
<div class="subheader" ng-if="walletsBch[0] && walletsBtc[0]">
<div translate>Bitcoin Cash (BCH)</div>

View file

@ -115,11 +115,29 @@
</div>
</ion-content>
<wallet-selector
wallet-selector-title="walletSelectorTitle"
wallet-selector-title="walletSelectorTitleFrom"
wallet-selector-force-title="walletSelectorTitleForce"
wallet-selector-wallets="wallets"
wallet-selector-selected-wallet="wallet"
wallet-selector-show="showWallets"
wallet-selector-on-select="onWalletSelect"
wallet-selector-display-balance-as-fiat="displayBalanceAsFiat">
</wallet-selector>
<wallet-selector
wallet-selector-title="walletSelectorTitleTo"
wallet-selector-wallets="walletsBch"
wallet-selector-selected-wallet="wallet"
wallet-selector-show="showWalletsBch"
wallet-selector-on-select="onWalletSelect"
wallet-selector-display-balance-as-fiat="displayBalanceAsFiat">
</wallet-selector>
<wallet-selector
wallet-selector-title="walletSelectorTitleTo"
wallet-selector-wallets="walletsBtc"
wallet-selector-selected-wallet="wallet"
wallet-selector-show="showWalletsBtc"
wallet-selector-on-select="onWalletSelect"
wallet-selector-display-balance-as-fiat="displayBalanceAsFiat">
</wallet-selector>
</ion-view>