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

View file

@ -270,6 +270,24 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
} }
} }
}) })
.state('tabs.send.origin', {
url: '/origin/:thirdParty/:amount/:toAddress/:toWalletId',
views: {
'tab-send@tabs': {
controller: 'sendFlowController',
templateUrl: 'views/wallet-origin-destination.html',
}
}
})
.state('tabs.send.destination', {
url: '/destination/:fromWalletId/:thirdParty/:amount',
views: {
'tab-send@tabs': {
controller: 'sendFlowController',
templateUrl: 'views/wallet-origin-destination.html',
}
}
})
.state('tabs.settings', { .state('tabs.settings', {
url: '/settings', url: '/settings',
views: { views: {
@ -299,7 +317,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
url: '/wallet-to-wallet', url: '/wallet-to-wallet',
views: { views: {
'tab-send@tabs': { 'tab-send@tabs': {
controller: 'walletToWalletController', controller: 'sendFlowController',
templateUrl: 'views/wallet-to-wallet-transfer.html' templateUrl: 'views/wallet-to-wallet-transfer.html'
} }
} }
@ -1273,7 +1291,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
if (screen.width < 768 && platformInfo.isCordova) if (screen.width < 768 && platformInfo.isCordova)
screen.lockOrientation('portrait'); screen.lockOrientation('portrait');
if (ionic.Platform.isAndroid() && StatusBar) { if (ionic.Platform.isAndroid() && platformInfo.isCordova && StatusBar) {
StatusBar.backgroundColorByHexString('#000000'); StatusBar.backgroundColorByHexString('#000000');
} }

View file

@ -83,7 +83,7 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
// Timeout is required to enable the "Back" button // Timeout is required to enable the "Back" button
$timeout(function() { $timeout(function() {
if (amount) { if (amount) {
$state.transitionTo('tabs.send.confirm', { $state.transitionTo('tabs.send.origin', {
toAmount: amount, toAmount: amount,
toAddress: addr, toAddress: addr,
displayAddress: originalAddress ? originalAddress : addr, displayAddress: originalAddress ? originalAddress : addr,
@ -102,8 +102,10 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
params['minShapeshiftAmount'] = shapeshiftData.minAmount; params['minShapeshiftAmount'] = shapeshiftData.minAmount;
params['maxShapeshiftAmount'] = shapeshiftData.maxAmount; params['maxShapeshiftAmount'] = shapeshiftData.maxAmount;
params['shapeshiftOrderId'] = shapeshiftData.orderId; params['shapeshiftOrderId'] = shapeshiftData.orderId;
$state.transitionTo('tabs.send.amount', params);
} else {
$state.transitionTo('tabs.send.origin', params);
} }
$state.transitionTo('tabs.send.amount', params);
} }
}, 100); }, 100);
} }

View file

@ -8,7 +8,7 @@
@import "tab-receive"; @import "tab-receive";
@import "tab-scan"; @import "tab-scan";
@import "tab-send"; @import "tab-send";
@import "wallet-to-wallet-transfer"; @import "wallet-origin-destination";
@import "tab-settings"; @import "tab-settings";
@import "wallet-colors"; @import "wallet-colors";
@import "walletBalance"; @import "walletBalance";

View file

@ -1,4 +1,4 @@
#wallet-to-wallet-transfer { #wallet-origin-destination {
.header--request { .header--request {
padding: 30px 24px; padding: 30px 24px;
width: 100%; width: 100%;

View file

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

View file

@ -1,4 +1,4 @@
<ion-view id="wallet-to-wallet-transfer" show-tabs> <ion-view id="wallet-origin-destination" show-tabs>
<ion-nav-bar class="bar-royal"> <ion-nav-bar class="bar-royal">
<ion-nav-title>{{'Wallet to wallet transfer' | translate}}</ion-nav-title> <ion-nav-title>{{'Wallet to wallet transfer' | translate}}</ion-nav-title>
</ion-nav-bar> </ion-nav-bar>
@ -6,7 +6,7 @@
<div class="header--request" ng-if="isPaymentRequest"> <div class="header--request" ng-if="isPaymentRequest">
<div class="header--request__title" translate>Paying</div> <div class="header--request__title" translate>Paying</div>
<div class="header--request__amount" translate>$37.42 USD</div> <div class="header--request__amount" translate>$37.42 USD</div>
<div class="header--request__amount-alt" translate>0.04580000 BCH</div> <div class="header--request__amount-alt" translate>0.04580000 BCH {{requestAmount}}</div>
</div> </div>
<div class="wallets-header"> <div class="wallets-header">
<div class="title"> <div class="title">