Removes all Coinbase dependencies from amount view

This commit is contained in:
Gustavo Maximiliano Cortez 2017-01-12 09:58:12 -03:00
parent e42d09574b
commit c3131838ef
No known key found for this signature in database
GPG Key ID: 15EDAD8D9F2EB1AF
5 changed files with 22 additions and 20 deletions

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('amountController', function($scope, $filter, $timeout, $ionicScrollDelegate, $ionicHistory, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService, ongoingProcess, bitpayCardService, popupService, bwcError, payproService, profileService, bitcore, amazonService, glideraService, coinbaseService, appConfigService) { angular.module('copayApp.controllers').controller('amountController', function($scope, $filter, $timeout, $ionicScrollDelegate, $ionicHistory, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService, ongoingProcess, bitpayCardService, popupService, bwcError, payproService, profileService, bitcore, amazonService, glideraService, appConfigService) {
var unitToSatoshi; var unitToSatoshi;
var satToUnit; var satToUnit;
var unitDecimals; var unitDecimals;
@ -20,8 +20,8 @@ angular.module('copayApp.controllers').controller('amountController', function($
$scope.isGlidera = data.stateParams.isGlidera; $scope.isGlidera = data.stateParams.isGlidera;
$scope.glideraAccessToken = data.stateParams.glideraAccessToken; $scope.glideraAccessToken = data.stateParams.glideraAccessToken;
// Coinbase // Go to...
$scope.coinbase = data.stateParams.coinbase; $scope.nextStep = data.stateParams.nextStep;
$scope.cardId = data.stateParams.cardId; $scope.cardId = data.stateParams.cardId;
$scope.showMenu = $ionicHistory.backView() && $ionicHistory.backView().stateName == 'tabs.send'; $scope.showMenu = $ionicHistory.backView() && $ionicHistory.backView().stateName == 'tabs.send';
@ -30,13 +30,13 @@ angular.module('copayApp.controllers').controller('amountController', function($
$scope.toAddress = data.stateParams.toAddress; $scope.toAddress = data.stateParams.toAddress;
$scope.toName = data.stateParams.toName; $scope.toName = data.stateParams.toName;
$scope.toEmail = data.stateParams.toEmail; $scope.toEmail = data.stateParams.toEmail;
$scope.showAlternativeAmount = !!$scope.cardId || !!$scope.isGiftCard || !!$scope.isGlidera || !!$scope.coinbase; $scope.showAlternativeAmount = !!$scope.cardId || !!$scope.isGiftCard || !!$scope.isGlidera || !!$scope.nextStep;
$scope.toColor = data.stateParams.toColor; $scope.toColor = data.stateParams.toColor;
$scope.showSendMax = false; $scope.showSendMax = false;
$scope.customAmount = data.stateParams.customAmount; $scope.customAmount = data.stateParams.customAmount;
if (!$scope.cardId && !$scope.isGiftCard && !$scope.isGlidera && !$scope.coinbase && !data.stateParams.toAddress) { if (!$scope.cardId && !$scope.isGiftCard && !$scope.isGlidera && !$scope.nextStep && !data.stateParams.toAddress) {
$log.error('Bad params at amount') $log.error('Bad params at amount')
throw ('bad params'); throw ('bad params');
} }
@ -357,15 +357,9 @@ angular.module('copayApp.controllers').controller('amountController', function($
isGlidera: $scope.isGlidera, isGlidera: $scope.isGlidera,
glideraAccessToken: $scope.glideraAccessToken glideraAccessToken: $scope.glideraAccessToken
}); });
} else if ($scope.coinbase) { } else if ($scope.nextStep) {
var amountAlternative = $scope.showAlternativeAmount ? _amount : $filter('formatFiatAmount')(toFiat(_amount)); var amountAlternative = $scope.showAlternativeAmount ? _amount : $filter('formatFiatAmount')(toFiat(_amount));
if (amountAlternative < 1) { $state.transitionTo($scope.nextStep, {
popupService.showAlert(gettextCatalog.getString('Error'), 'Amount must be at least 1.00 ' + $scope.alternativeIsoCode);
return;
}
var goTo = 'tabs.buyandsell.coinbase.' + $scope.coinbase;
$state.transitionTo(goTo, {
amount: amountAlternative, amount: amountAlternative,
currency: $scope.alternativeIsoCode currency: $scope.alternativeIsoCode
}); });

View File

@ -15,6 +15,14 @@ angular.module('copayApp.controllers').controller('buyCoinbaseController', funct
$scope.$on("$ionicView.beforeEnter", function(event, data) { $scope.$on("$ionicView.beforeEnter", function(event, data) {
amount = data.stateParams.amount; amount = data.stateParams.amount;
currency = data.stateParams.currency; currency = data.stateParams.currency;
console.log('[buyCoinbase.js:17]',amount, currency); //TODO
if (amount < 1) {
popupService.showAlert('Error', 'Amount must be at least 1.00 ' + currency, function() {
$ionicHistory.goBack();
});
return;
}
$scope.network = coinbaseService.getNetwork(); $scope.network = coinbaseService.getNetwork();
$scope.wallets = profileService.getWallets({ $scope.wallets = profileService.getWallets({

View File

@ -942,7 +942,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
} }
}) })
.state('tabs.buyandsell.coinbase.amount', { .state('tabs.buyandsell.coinbase.amount', {
url: '/amount/:coinbase/:currency', url: '/amount/:nextStep/:currency',
views: { views: {
'tab-home@tabs': { 'tab-home@tabs': {
controller: 'amountController', controller: 'amountController',

View File

@ -1,7 +1,7 @@
<ion-view id="view-amount" hide-tabs> <ion-view id="view-amount" hide-tabs>
<ion-nav-bar class="bar-royal"> <ion-nav-bar class="bar-royal">
<ion-nav-title> <ion-nav-title>
{{coinbase ? (coinbase == 'buy' ? 'Buy bitcoin' : 'Sell bitcoin') : ('Enter Amount' | translate)}} {{'Enter Amount' | translate}}
</ion-nav-title> </ion-nav-title>
<ion-nav-back-button> <ion-nav-back-button>
</ion-nav-back-button> </ion-nav-back-button>
@ -14,7 +14,7 @@
<ion-content scroll="false"> <ion-content scroll="false">
<div ng-if="!customAmount && !isGlidera && !coinbase"> <div ng-if="!customAmount && !isGlidera && !nextStep">
<div class="item item-no-bottom-border recipient-label" translate>Recipient</div> <div class="item item-no-bottom-border recipient-label" translate>Recipient</div>
<div class="item item-text-wrap item-icon-left bitcoin-address" ng-class="{'item-big-icon-left':cardId}"> <div class="item item-text-wrap item-icon-left bitcoin-address" ng-class="{'item-big-icon-left':cardId}">
@ -39,8 +39,8 @@
</div> </div>
</div> </div>
<div ng-class="{'amount-pane-recipient': !customAmount && !isGlidera && !coinbase, <div ng-class="{'amount-pane-recipient': !customAmount && !isGlidera && !nextStep,
'amount-pane-no-recipient': customAmount || isGlidera || coinbase}"> 'amount-pane-no-recipient': customAmount || isGlidera || nextStep}">
<div class="amount-bar oh"> <div class="amount-bar oh">
<div class="title"> <div class="title">

View File

@ -68,13 +68,13 @@
<div class="list card" <div class="list card"
ng-show="accountId"> ng-show="accountId">
<a class="item item-icon-right" <a class="item item-icon-right"
href ui-sref="tabs.buyandsell.coinbase.amount({coinbase: 'buy', currency: currency})"> href ui-sref="tabs.buyandsell.coinbase.amount({nextStep: 'tabs.buyandsell.coinbase.buy', currency: currency})">
<img src="img/buy-bitcoin.svg" alt="buy bitcoin" width="35" class="item-img-buy"> <img src="img/buy-bitcoin.svg" alt="buy bitcoin" width="35" class="item-img-buy">
Buy Bitcoin Buy Bitcoin
<i class="icon bp-arrow-right"></i> <i class="icon bp-arrow-right"></i>
</a> </a>
<a class="item item-icon-right" <a class="item item-icon-right"
href ui-sref="tabs.buyandsell.coinbase.amount({coinbase: 'sell', currency: currency})"> href ui-sref="tabs.buyandsell.coinbase.amount({nextStep: 'tabs.buyandsell.coinbase.sell', currency: currency})">
<img src="img/sell-bitcoin.svg" alt="buy bitcoin" width="35" class="item-img-sell"> <img src="img/sell-bitcoin.svg" alt="buy bitcoin" width="35" class="item-img-sell">
Sell Bitcoin Sell Bitcoin
<i class="icon bp-arrow-right"></i> <i class="icon bp-arrow-right"></i>