Shapeshift refactor / Empty case / CSS

This commit is contained in:
Sebastiaan Pasma 2018-07-31 15:03:20 +02:00
commit 281b969fc3
No known key found for this signature in database
GPG key ID: 9A2B0C8B95A1D26F
9 changed files with 230 additions and 181 deletions

View file

@ -1,10 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('shapeshiftController', function($scope, $interval, profileService, walletService, popupService, lodash, $ionicNavBarDelegate) {
var vm = this;
//vm.buyBitcion = buyBitcoin;
angular.module('copayApp.controllers').controller('shapeshiftController', function($scope, $state, $interval, profileService, walletService, popupService, lodash, $ionicNavBarDelegate) {
var walletsBtc = [];
var walletsBch = [];
@ -19,59 +15,51 @@ angular.module('copayApp.controllers').controller('shapeshiftController', functi
}
function showToWallets() {
$scope.toWallets = $scope.fromWallet.coin == 'btc' ? walletsBch : walletsBtc;
$scope.toWallets = $scope.fromWallet.coin === 'btc' ? walletsBch : walletsBtc;
$scope.onToWalletSelect($scope.toWallets[0]);
$scope.singleToWallet = $scope.toWallets.length == 1;
$scope.singleToWallet = $scope.toWallets.length === 1;
}
function buyBitcoin() {
console.log('buyBitcoin()');
}
$scope.buyBitcoin = buyBitcoin;
$scope.onFromWalletSelect = function(wallet) {
$scope.fromWallet = wallet;
showToWallets();
generateAddress(wallet, function(addr) {
$scope.fromWalletAddress = addr;
});
};
$scope.onToWalletSelect = function(wallet) {
$scope.toWallet = wallet;
generateAddress(wallet, function(addr) {
$scope.toWalletAddress = addr;
});
}
// $scope.onFromWalletSelect = function(wallet) {
// $scope.fromWallet = wallet;
// showToWallets();
// generateAddress(wallet, function(addr) {
// $scope.fromWalletAddress = addr;
// });
// };
//
// $scope.onToWalletSelect = function(wallet) {
// $scope.toWallet = wallet;
// generateAddress(wallet, function(addr) {
// $scope.toWalletAddress = addr;
// });
// };
$scope.$on("$ionicView.beforeEnter", function(event, data) {
console.log('beforeEnter()');
walletsBtc = profileService.getWallets({coin: 'btc'});
walletsBch = profileService.getWallets({coin: 'bch'});
$scope.fromWallets = lodash.filter(walletsBtc.concat(walletsBch), function(w) {
return w.status.balance.availableAmount > 0;
});
console.log('Checking wallets.');
if ($scope.fromWallets.length == 0) {
// Need to go to new origin screen here, with parameters
var params = {
thirdParty: {
id: 'shapeshift'
}
};
console.log('Asking for transition');
$state.transitionTo('tabs.send', params);
return
}
$scope.onFromWalletSelect($scope.fromWallets[0]);
$scope.onToWalletSelect($scope.toWallets[0]);
$scope.singleFromWallet = $scope.fromWallets.length == 1;
$scope.singleToWallet = $scope.toWallets.length == 1;
if ($scope.fromWallets.length === 0) {
// return
// } else {
// $scope.onFromWalletSelect($scope.fromWallets[0]);
}
// $scope.onToWalletSelect($scope.toWallets[0]);
$scope.singleFromWallet = $scope.fromWallets.length === 1;
// $scope.singleToWallet = $scope.toWallets.length == 1;
$scope.fromWalletSelectorTitle = 'From';
$scope.toWalletSelectorTitle = 'To';
$scope.showFromWallets = false;
$scope.showToWallets = false;
$scope.walletsWithFunds = profileService.getWallets({onlyComplete: true, hasFunds: true});
console.log($scope.walletsWithFunds);
$scope.wallets = profileService.getWallets({onlyComplete: true});
$scope.hasWallets = !lodash.isEmpty($scope.wallets);
});
$scope.$on("$ionicView.enter", function(event, data) {
@ -80,9 +68,33 @@ angular.module('copayApp.controllers').controller('shapeshiftController', functi
$scope.showFromWalletSelector = function() {
$scope.showFromWallets = true;
}
};
$scope.showToWalletSelector = function() {
$scope.showToWallets = true;
};
// This could probably be enhanced refactoring the routes abstract states
$scope.createWallet = function() {
$state.go('tabs.home').then(function() {
$state.go('tabs.add.create-personal');
});
};
$scope.buyBitcoin = function() {
$state.go('tabs.home').then(function() {
$state.go('tabs.buyandsell');
});
};
$scope.shapeshift = function() {
var params = {
thirdParty: {
id: 'shapeshift'
}
};
$state.go('tabs.home').then(function() {
$state.transitionTo('tabs.send', params);
});
}
});

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('sendFlowController', function($scope, $rootScope, $state, $stateParams, $log, $ionicHistory, configService, gettextCatalog, profileService) {
angular.module('copayApp.controllers').controller('walletSelectorController', function($scope, $rootScope, $state, $stateParams, $log, $ionicHistory, configService, gettextCatalog, profileService) {
$scope.$on("$ionicView.beforeEnter", function(event, data) {
var config = configService.getSync().wallet.settings;

View file

@ -299,7 +299,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
url: '/wallet-to-wallet',
views: {
'tab-send@tabs': {
controller: 'sendFlowController',
controller: 'walletSelectorController',
templateUrl: 'views/wallet-origin-destination.html'
}
}
@ -308,7 +308,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
url: '/origin/:thirdParty/:amount/:toAddress/:toWalletId/:coin',
views: {
'tab-send@tabs': {
controller: 'sendFlowController',
controller: 'walletSelectorController',
templateUrl: 'views/wallet-origin-destination.html',
}
}
@ -317,7 +317,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
url: '/destination/:thirdParty/:amount/:fromWalletId',
views: {
'tab-send@tabs': {
controller: 'sendFlowController',
controller: 'walletSelectorController',
templateUrl: 'views/wallet-origin-destination.html',
}
}

View file

@ -18,3 +18,42 @@
.absolute-center{
@include absolute-center();
}
@mixin empty-case() {
padding-top: 5vh;
text-align: center;
.item {
border-style: none;
}
& > .title {
font-size: 20px;
color: $v-dark-gray;
margin: 20px 10px;
}
& > .subtitle {
font-size: 1rem;
line-height: 1.5em;
font-weight: 300;
color: #6F6F70;
margin: 20px 1em 2.5em;
}
.big-icon-svg {
.bg.green {
padding: 0 10px;
box-shadow: none;
}
}
.buttons {
margin-top: 18px;
.button {
font-weight: bold;
font-size: 19px;
}
}
.button-first-contact img {
height: 19px;
width: 19px;
margin-right: 6px;
vertical-align: sub;
}
}

View file

@ -0,0 +1,14 @@
#shapeshift {
.empty-case {
@include empty-case();
}
.button-shapeshift {
@extend %button-standard;
@include button-style(#243F5D, #FFF, #606060, #FFF, #FFF);
@include button-clear(#FFF);
@include button-outline(#C1C1C1);
border: 0px;
@include button-shadow();
}
}

View file

@ -133,42 +133,7 @@
padding-left: 30px;
}
.sendTip {
padding-top: 5vh;
text-align: center;
.item {
border-style: none;
}
& > .title {
font-size: 20px;
color: $v-dark-gray;
margin: 20px 10px;
}
& > .subtitle {
font-size: 1rem;
line-height: 1.5em;
font-weight: 300;
color: #6F6F70;
margin: 20px 1em 2.5em;
}
.big-icon-svg {
.bg.green {
padding: 0 10px;
box-shadow: none;
}
}
.buttons {
margin-top: 18px;
.button {
font-weight: bold;
font-size: 19px;
}
}
.button-first-contact img {
height: 19px;
width: 19px;
margin-right: 6px;
vertical-align: sub;
}
@include empty-case();
}
.item-heading {
line-height: 16px;

View file

@ -14,6 +14,7 @@
@import "walletBalance";
@import "walletDetails";
@import "advancedSettings";
@import "shapeshift";
@import "bitpayCard";
@import "bitpayCardIntro";
@import "buyandsell";