From 552a4c8bcf3c083edcc49922c8b95e18609503c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Wed, 3 May 2017 16:25:27 -0300 Subject: [PATCH 1/7] refactor receive view --- src/js/controllers/addresses.js | 7 - src/js/controllers/customAmount.js | 4 - .../preferencesAdvancedController.js | 8 +- src/js/controllers/tab-receive.js | 125 ++--- src/js/directives/actionSheet.js | 6 +- src/js/directives/copyToClipboard.js | 3 +- src/sass/views/tab-receive.scss | 519 ++---------------- www/views/addresses.html | 4 - www/views/customAmount.html | 8 +- www/views/preferencesAdvanced.html | 4 + www/views/tab-receive.html | 118 ++-- 11 files changed, 134 insertions(+), 672 deletions(-) diff --git a/src/js/controllers/addresses.js b/src/js/controllers/addresses.js index dedcb6824..f0a8a5b9c 100644 --- a/src/js/controllers/addresses.js +++ b/src/js/controllers/addresses.js @@ -114,13 +114,6 @@ angular.module('copayApp.controllers').controller('addressesController', functio }); }; - $scope.requestSpecificAmount = function() { - $state.go('tabs.receive.amount', { - customAmount: true, - toAddress: $stateParams.toAddress - }); - } - $scope.showInformation = function() { $timeout(function() { $scope.showInfo = !$scope.showInfo; diff --git a/src/js/controllers/customAmount.js b/src/js/controllers/customAmount.js index b3c17137f..8aaa5b4dd 100644 --- a/src/js/controllers/customAmount.js +++ b/src/js/controllers/customAmount.js @@ -12,10 +12,6 @@ angular.module('copayApp.controllers').controller('customAmountController', func $scope.altAmountStr = txFormatService.formatAlternativeStr($scope.amount); }); - $scope.shareAddress = function(uri) { - window.plugins.socialsharing.share(uri, null, null, null); - }; - $scope.finish = function() { $ionicHistory.nextViewOptions({ disableAnimate: false diff --git a/src/js/controllers/preferencesAdvancedController.js b/src/js/controllers/preferencesAdvancedController.js index 26c45a26d..0cbb742a0 100644 --- a/src/js/controllers/preferencesAdvancedController.js +++ b/src/js/controllers/preferencesAdvancedController.js @@ -1,11 +1,15 @@ 'use strict'; -angular.module('copayApp.controllers').controller('preferencesAdvancedController', function($scope, $timeout, $stateParams, profileService) { +angular.module('copayApp.controllers').controller('preferencesAdvancedController', function($scope, $timeout, $state, $stateParams, profileService) { var wallet = profileService.getWallet($stateParams.walletId); $scope.network = wallet.network; $scope.wallet = wallet; - + $scope.goToAddresses = function() { + $state.go('tabs.receive.addresses', { + walletId: $stateParams.walletId, + }); + }; $timeout(function() { $scope.$apply(); diff --git a/src/js/controllers/tab-receive.js b/src/js/controllers/tab-receive.js index 5281be998..b36680b9e 100644 --- a/src/js/controllers/tab-receive.js +++ b/src/js/controllers/tab-receive.js @@ -5,13 +5,12 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi var listeners = []; $scope.isCordova = platformInfo.isCordova; $scope.isNW = platformInfo.isNW; - $scope.walletAddrs = {}; - $scope.shareAddress = function(addr) { - if ($scope.generatingAddress) return; - if ($scope.isCordova) { - window.plugins.socialsharing.share('bitcoin:' + addr, null, null, null); - } + $scope.requestSpecificAmount = function() { + $state.go('tabs.receive.amount', { + customAmount: true, + toAddress: $scope.addr + }); }; $scope.setAddress = function(forceNew) { @@ -27,19 +26,12 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi } $scope.addr = addr; - if ($scope.walletAddrs[$scope.wallet.id]) $scope.walletAddrs[$scope.wallet.id] = addr; $timeout(function() { $scope.$apply(); }, 10); }); }; - $scope.loadAddresses = function(wallet, index) { - walletService.getAddress(wallet, false, function(err, addr) { - $scope.walletAddrs[wallet.id] = addr; - }); - } - $scope.goCopayers = function() { $ionicHistory.removeBackView(); $ionicHistory.nextViewOptions({ @@ -53,13 +45,6 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi }, 100); }; - $scope.showAddresses = function() { - $state.go('tabs.receive.addresses', { - walletId: $scope.wallet.credentials.walletId, - toAddress: $scope.addr - }); - }; - $scope.openBackupNeededModal = function() { $ionicModal.fromTemplateUrl('views/includes/backupNeededPopup.html', { scope: $scope, @@ -88,56 +73,13 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi }); }; - $scope.setWallet = function(index) { - $scope.wallet = $scope.wallets[index]; - $scope.walletIndex = index; - if ($scope.walletAddrs[$scope.wallet.id].addr) $scope.addr = $scope.walletAddrs[$scope.walletIndex].addr; - else $scope.setAddress(false); - } - - $scope.isActive = function(index) { - return $scope.wallets[index] == $scope.wallet; - } - - $scope.walletPosition = function(index) { - if (index == $scope.walletIndex) return 'current'; - if (index < $scope.walletIndex) return 'prev'; - if (index > $scope.walletIndex) return 'next'; - } - - - $scope.$on('Wallet/Changed', function(event, wallet) { - if (!wallet) { - $log.debug('No wallet provided'); - return; - } - if (wallet == $scope.wallet) { - $log.debug('No change in wallet'); - return; - } - $scope.wallet = wallet; - $log.debug('Wallet changed: ' + wallet.name); - - $scope.walletIndex = lodash.findIndex($scope.wallets, function(wallet) { - return wallet.id == $scope.wallet.id; - }); - - if (!$scope.walletAddrs[wallet.id]) $scope.setAddress(false); - else $scope.addr = $scope.walletAddrs[wallet.id]; - - $timeout(function() { - $scope.$apply(); - }, 100); - - }); - - $scope.updateCurrentWallet = function() { - walletService.getStatus($scope.wallet, {}, function(err, status) { + $scope.updateCurrentWallet = function(wallet) { + walletService.getStatus(wallet, {}, function(err, status) { if (err) { return popupService.showAlert(bwcError.msg(err, gettextCatalog.getString('Could not update wallet'))); } $timeout(function() { - $scope.wallet = profileService.getWallet($scope.wallet.id); + $scope.wallet = profileService.getWallet(wallet.id); $scope.wallet.status = status; $scope.setAddress(); $scope.$apply(); @@ -157,40 +99,55 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi $scope.showReceiveAddressFromHardware = function() { var wallet = $scope.wallet; if (wallet.isPrivKeyExternal() && wallet.credentials.hwInfo) { - walletService.showReceiveAddressFromHardware(wallet, $scope.addr, function(){}); + walletService.showReceiveAddressFromHardware(wallet, $scope.addr, function() {}); } }; $scope.$on("$ionicView.beforeEnter", function(event, data) { $scope.wallets = profileService.getWallets(); - - lodash.each($scope.wallets, function(wallet, index) { - $scope.loadAddresses(wallet); - }); + $scope.singleWallet = $scope.wallets.length == 1; listeners = [ $rootScope.$on('bwsEvent', function(e, walletId, type, n) { // Update current address - if ($scope.wallet && walletId == $scope.wallet.id) $scope.updateCurrentWallet(); + if ($scope.wallet && walletId == $scope.wallet.id) $scope.updateCurrentWallet($scope.wallet); }) - ]; + ]; - // Update current wallet - if ($scope.wallet) { - var w = lodash.find($scope.wallets, function(w) { - return w.id == $scope.wallet.id; - }); - if (w) $scope.updateCurrentWallet(); - else if (screen.width > 700 && screen.height > 700 && $scope.wallets[0]) { - $scope.setWallet(0) - $scope.walletPosition(0); - } - } + if (!$scope.wallets[0]) return; + if (!$scope.wallet) return $scope.init(); + + var w = lodash.find($scope.wallets, function(w) { + return w.id == $scope.wallet.id; + }); + if (w) $scope.updateCurrentWallet($scope.wallet); + else $scope.init(); }); + $scope.init = function() { + $scope.wallet = $scope.wallets[0]; + $scope.updateCurrentWallet($scope.wallet); + $scope.showWalletSelector(); + }; + $scope.$on("$ionicView.leave", function(event, data) { lodash.each(listeners, function(x) { x(); }); }); + + $scope.onWalletSelect = function(wallet) { + $scope.updateCurrentWallet(wallet); + }; + + $scope.showWalletSelector = function() { + if ($scope.singleWallet) return; + $scope.walletSelectorTitle = gettextCatalog.getString('Address from'); + $scope.showWallets = true; + }; + + $scope.copyToClipboard = function() { + if ($scope.isCordova) return 'bitcoin:' + $scope.addr; + else return $scope.addr; + } }); diff --git a/src/js/directives/actionSheet.js b/src/js/directives/actionSheet.js index 6ea5cb292..734b7f2b3 100644 --- a/src/js/directives/actionSheet.js +++ b/src/js/directives/actionSheet.js @@ -11,8 +11,10 @@ angular.module('copayApp.directives') }, link: function(scope, element, attrs) { scope.$watch('show', function() { - if(scope.show) { - $timeout(function() { scope.revealMenu = true; }, 100); + if (scope.show) { + $timeout(function() { + scope.revealMenu = true; + }, 100); } else { scope.revealMenu = false; } diff --git a/src/js/directives/copyToClipboard.js b/src/js/directives/copyToClipboard.js index 4c8b791d6..a06b2743d 100644 --- a/src/js/directives/copyToClipboard.js +++ b/src/js/directives/copyToClipboard.js @@ -21,8 +21,7 @@ angular.module('copayApp.directives') if (!data) return; if (isCordova) { - window.cordova.plugins.clipboard.copy(data); - window.plugins.toast.showShortCenter(msg); + window.plugins.socialsharing.share(data, null, null, null); } else if (isNW) { nodeWebkitService.writeToClipboard(data); scope.$apply(function() { diff --git a/src/sass/views/tab-receive.scss b/src/sass/views/tab-receive.scss index 09831a149..45a998940 100644 --- a/src/sass/views/tab-receive.scss +++ b/src/sass/views/tab-receive.scss @@ -1,512 +1,55 @@ #tab-receive { - @extend .deflash-blue; - ion-header-bar { - button { - i { - color:#fff; - font-size: 1.1rem; - } - } - } - .border-top { - border-top:1px solid rgb(228,228,228); - } - .scroll { - height:100%; - } - #address { + .address { background: #fff; - height: 66vh; - display: flex; - align-items: center; - justify-content: center; - position: relative; - flex-flow: column; - @media(max-height: 600px) { - height: 68vh; - } - @media(max-height: 600px) and (-webkit-device-pixel-ratio: 2) { - height: 64vh; - } - @media(max-width: 320px) { - height: 62vh; + height: 65vh; + @media(max-height: 600px) and (max-width: 320px) { + height: 70vh; + .button { + min-height: 50px; + } } &-info { height: 100%; display: flex; flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - @media(max-width: 320px) { - height: auto; + .address-label { + margin-top: 5%; + font-size: 13px; } - } - article { - flex:1; - width: 100%; - } - #bit-address { - width: 100%; - margin-top: auto; - position: absolute; - bottom: 0; - min-height: 40px; - #next-address { - color:$v-light-gray; + .qr { + position: relative; + top: 15%; + } + .backup { + background-color: orange; + color: #fff; + position: absolute; + z-index: 2; + i { + padding: 10px; + } + } + .request-button { + padding-top: 20px; } } .incomplete { - padding: 50px; - height: 352px; + height: 100%; .title { - padding: 20px; + margin-top: 10%; font-size: 25px; color: #444; + text-align: center; } .subtitle { padding: 20px; color: #444; + margin-top: 20%; + text-align: center; } .button { - } - } - .item { - border: none; - font-size: .8rem; - z-index: 0; - i { - font-size: 1.3rem; - } - } - #qr-options { - .item { - font-size:.7rem; - @media(min-width:350px) { - font-size:.9rem; - } - @media(min-width:450px) { - font-size:1rem; - } - } - } - .bit-address { - font-size: .8rem; - // left:10%; - cursor: pointer; - cursor: hand; - position: absolute; - transition: all .15s ease; - width:100%; - height: 100%; - z-index: 0; - position: absolute; - top:50%; - &, &.next { - left:100%; - -webkit-transform: translate(100%, -40%); - transform: translate(100%, -40%); - } - &.next, &.prev { - z-index:2; - } - &.current, - &.prev { - left:50%; - } - &.current { - -webkit-transform: translate(-50%, -40%); - transform: translate(-50%, -40%); - z-index: 3; - } - &.prev { - -webkit-transform: translate(-150%, -40%); - transform: translate(-150%, -40%); - } - .item { - white-space: nowrap; - padding-top: 5px; - padding-bottom: 5px; - font-size: .7rem; - @media(min-width:350px) { - font-size:.9rem; - } - @media(min-width:450px) { - font-size:1rem; - } - &.item-icon-left { - @media(max-width: 320px) { - padding-left: 48px; - text-overflow: initial; - } - } - color:$v-light-gray; - } - } - .qr { - padding: 15vh 0 4vh; - align-self: center; - margin-top: auto; - height: 220px; - position: relative; - justify-content: center; - flex: 1; - z-index: 1; - @media(max-width: 320px) { - height: 260px; - margin-top: -50px; - } - div { - transition: all .4s ease; - &.current, - &.prev, - &.next { - position: absolute; - top:50%; - } - &.current, - &.prev { - left:50%; - } - &.current { - -webkit-transform: translate(-50%, -40%); - transform: translate(-50%, -40%); - } - &.prev { - -webkit-transform: translate(-150%, -40%); - transform: translate(-150%, -40%); - } - &.next { - left:100%; - -webkit-transform: translate(100%, -40%); - transform: translate(100%, -40%); - } - } - .overlay { - position: absolute; - width: 220px; - height: 100%; - background-color: rgba(255,255,255,0.8); - button { - width: 100%; - top: 50%; - -webkit-transform: translateY(-50%); - transform: translateY(-50%); - } - } - @media(max-height: 700px) { - padding: 10vh 0 4vh; - } - div { - display: flex; - justify-content: center; - align-items: center; - position: relative; - min-height: 220px; - } - } - #qr-options { - justify-content: center; - align-self: flex-end; - .item{ - i{left:25px;} - } - } - .backup { - background-color: orange; - color: #fff; - position: absolute; - top: 0; - left:0; - z-index: 2; - i { - padding: 10px; - } - } - @media (max-height: 600px) { - & { - .qr { - padding:6vh 0 0; - div { - -webkit-transform: scale(.7); - transform: scale(.7); - } - } - } - } - } - #wallets { - position: relative; - &:before { - content: ""; - display: inline-block; - width: 0; - height: 0; - border-style: solid; - border-width: 0 20px 20px 20px; - border-color: transparent transparent rgb(242,242,242) transparent; - top: -9px; - position: absolute; - left: 50%; - -webkit-transform: translateX(-50%); - transform: translateX(-50%); - z-index: 4; - } - } - #first-time-tip { - background: rgba(30, 49, 134, 1); - background: -moz-linear-gradient(top, rgba(30, 49, 134, 1) 0%, rgba(30, 49, 134, 0) 88%, rgba(30, 49, 134, 0) 100%); - background: -webkit-gradient(left top, left bottom, color-stop(0%, rgba(30, 49, 134, 1)), color-stop(88%, rgba(30, 49, 134, 0)), color-stop(100%, rgba(30, 49, 134, 0))); - background: -webkit-linear-gradient(top, rgba(30, 49, 134, 1) 0%, rgba(30, 49, 134, 0) 88%, rgba(30, 49, 134, 0) 100%); - background: -o-linear-gradient(top, rgba(30, 49, 134, 1) 0%, rgba(30, 49, 134, 0) 88%, rgba(30, 49, 134, 0) 100%); - background: -ms-linear-gradient(top, rgba(30, 49, 134, 1) 0%, rgba(30, 49, 134, 0) 88%, rgba(30, 49, 134, 0) 100%); - background: linear-gradient(to bottom, rgba(30, 49, 134, 1) 0%, rgba(30, 49, 134, 0) 88%, rgba(30, 49, 134, 0) 100%); - position: absolute; - top: 0; - left: 0; - width: 100%; - height: 100%; - opacity: 0; - animation-name: fadeIn; - animation-iteration-count: 1; - animation-timing-function: ease-in; - animation-duration: .4s; - animation-delay: 2s; - animation-fill-mode: forwards; - z-index: 10; - text-align: center; - color: #fff; - padding-top: 3rem; - .close { - top: .5rem; - right: 1rem; - position: absolute; - font-size: 1.5rem; - opacity: .5; - } - h3 { - color: #fff; - margin-bottom:1rem; - } - } - .receive-tab-bitcoin-icon { - border-right: 1px solid rgb(228, 228, 228); - padding-right: 10px; - } - #wallets { - #sidebar-wallet{ - display: none; - } - } - .wallets { - position: relative; - height: calc(27vh - 62px); - z-index: 5; - .slides { - .swiper-container { - position: absolute; - left: 50%; - top: 50%; - -webkit-transform: translate(-50%, -50%); - transform: translate(-50%, -50%); - max-width: 450px; - .swiper-wrapper { - height: auto; - top: 10%; - position:relative; - @media(max-height: 600px) { - padding-top:.2rem - } - @media(min-height: 900px) { - top:30%; - } - } - .swiper-slide { - text-align: center; - .card{ - margin-top: 1vh; - display: inline-block; - width:80%; - @media(min-height: 1000px) and (max-width: 699px) { - .item { - padding: 2vh 3vw 2vh 3vw; - } - } - } - @media(max-width: 500px) { - &-next { - left:-25%; - } - &-prev { - left:25%; - } - } - } - @media (max-height: 600px) { - & { - -webkit-transform: translate(-50%, -58%); - transform: translate(-50%, -58%); - } - } - } - } - } - @media(min-width: 700px) and (min-height: 700px) { - .wallets { - display: none; - } - #address { - float:left; - height:100%; - width:calc(100% - 410px); - @media(max-width: 1000px){ - width:65%; - } - &-info { - height: 100%; - } - #qr-options { - .item{ - font-size:1rem; - } - } - .qr { - height: 70%; - div { - opacity: 0; - transition: none; - &.current { - opacity: 1; - } - } - } - .bit-address { - opacity: 0; - transition: none; - &.current { - opacity: 1; - } - } - .backup, - #bit-address { - left:0; - } - #bit-address { - height: 10%; - padding: 1vh; - .bit-address { - .item{ - top: 40%; - -webkit-transform: translateY(-40%); - transform: translateY(-40%); - font-size:1rem; - } - } - } - } - #wallets { - float:left; - width:35%; - height: 100%; - display: flex; - flex-direction: column; - overflow: visible; - max-width: 410px; - @media(max-height: 600px) { - padding-top:.55rem; - } - @media(max-width: 1000px) { - max-width: none; - } - #sidebar-wallet { - display: block; - } - .list { - height: 100%;overflow: visible; - } - #wallet-list { - position: absolute; - width: 110%; - overflow-y: auto; - height: 100%; - left: -6%; - } - .wallet { - &.current { - position: relative; - .card { - opacity: 1; - -webkit-transform: scale(1); - transform: scale(1); - } - &:before { - right: 93%; - top: 50%; - border: solid transparent; - content: " "; - height: 0; - width: 0; - position: absolute; - pointer-events: none; - border-right-color: #f2f2f2; - border-width: 20px; - margin-top: -20px; - } - } - } - .card { - max-width: 350px; - box-shadow: 0 1px 36px rgba(0, 0, 0, 0.07); - padding:0; - border-radius: 6px; - padding:2px; - width: 80%; - position: relative; - margin: 1.5rem auto 0; - position: relative; - opacity: .5; - -webkit-transform:scale(.85); - transform:scale(.85); - transition:transform .2s ease; - .item { - padding: 6% 10% 6% 8%; - span { - clear: both; - width: 100%; - display: inline-block; - &.wallet-name { - font-size:16px; - width: 79%; - white-space: nowrap; - text-overflow: ellipsis; - overflow: hidden; - font-weight: 600; - } - &.wallet-number { - visibility: hidden; - } - &.visible { - visibility: visible !important; - } - } - .big-icon-svg { - padding: 0; - & > .bg { - padding:.3rem; - width: 40px; - height:40px; - } - } - } + margin-top: 20%; } } } } -@keyframes fadeIn { - 0% { - opacity: 0; - } - 100% { - opacity: 1; - } -} diff --git a/www/views/addresses.html b/www/views/addresses.html index cafa1bf42..155cb044c 100644 --- a/www/views/addresses.html +++ b/www/views/addresses.html @@ -34,10 +34,6 @@
Scan addresses for funds
-
- Request Specific amount - -
View All Addresses diff --git a/www/views/customAmount.html b/www/views/customAmount.html index 0e250ad47..07e6f2d91 100644 --- a/www/views/customAmount.html +++ b/www/views/customAmount.html @@ -12,14 +12,8 @@ -
+
-
diff --git a/www/views/preferencesAdvanced.html b/www/views/preferencesAdvanced.html index 8547bfcec..a50c8f596 100644 --- a/www/views/preferencesAdvanced.html +++ b/www/views/preferencesAdvanced.html @@ -13,6 +13,10 @@ Wallet Information + + Wallet Addresses + + Export Wallet diff --git a/www/views/tab-receive.html b/www/views/tab-receive.html index 644af8e0f..d3687d024 100644 --- a/www/views/tab-receive.html +++ b/www/views/tab-receive.html @@ -6,25 +6,8 @@
No Wallet
-
-
-
-
-
- ... -
-
-
-
-
-
- - ... -
-
-
-
-
+
+
Incomplete wallet @@ -32,72 +15,63 @@
All signing devices must be added to this multisig wallet before bitcoin addresses can be created.
-
- -
-
-
-
-
- - address not yet available -
-
+
-
+
Wallet not backed up
-
- - - - -
-
-
-
- - Share -
-
-
-
-
- - {{walletAddrs[wallet.id]}} - address not available - -
-
-
-
-
-
-
+
+ + From e76924cb749a4f17d0550458cc721b125f59719e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Wed, 3 May 2017 17:08:18 -0300 Subject: [PATCH 2/7] move addresses view to settings --- src/js/controllers/addresses.js | 10 +++++++++- src/js/controllers/preferencesAdvancedController.js | 2 +- src/js/controllers/tab-receive.js | 4 ++-- src/js/routes.js | 8 ++++---- www/views/addresses.html | 2 +- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/js/controllers/addresses.js b/src/js/controllers/addresses.js index f0a8a5b9c..5f765a8c0 100644 --- a/src/js/controllers/addresses.js +++ b/src/js/controllers/addresses.js @@ -130,8 +130,16 @@ angular.module('copayApp.controllers').controller('addressesController', functio $scope.scan = function() { walletService.startScan($scope.wallet); + $ionicHistory.nextViewOptions({ + disableAnimate: true, + historyRoot: true + }); $ionicHistory.clearHistory(); - $state.go('tabs.home'); + $state.go('tabs.home').then(function() { + $state.transitionTo('tabs.wallet', { + walletId: $scope.wallet.credentials.walletId + }); + }); }; $scope.sendByEmail = function() { diff --git a/src/js/controllers/preferencesAdvancedController.js b/src/js/controllers/preferencesAdvancedController.js index 0cbb742a0..c49c6e9e5 100644 --- a/src/js/controllers/preferencesAdvancedController.js +++ b/src/js/controllers/preferencesAdvancedController.js @@ -6,7 +6,7 @@ angular.module('copayApp.controllers').controller('preferencesAdvancedController $scope.wallet = wallet; $scope.goToAddresses = function() { - $state.go('tabs.receive.addresses', { + $state.go('tabs.settings.addresses', { walletId: $stateParams.walletId, }); }; diff --git a/src/js/controllers/tab-receive.js b/src/js/controllers/tab-receive.js index b36680b9e..d86851bf2 100644 --- a/src/js/controllers/tab-receive.js +++ b/src/js/controllers/tab-receive.js @@ -13,11 +13,11 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi }); }; - $scope.setAddress = function(forceNew) { + $scope.setAddress = function() { if (!$scope.wallet || $scope.generatingAddress || !$scope.wallet.isComplete()) return; $scope.addr = null; $scope.generatingAddress = true; - walletService.getAddress($scope.wallet, forceNew, function(err, addr) { + walletService.getAddress($scope.wallet, false, function(err, addr) { $scope.generatingAddress = false; if (err) { diff --git a/src/js/routes.js b/src/js/routes.js index e55d65401..1fa783a6c 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -655,19 +655,19 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr * */ - .state('tabs.receive.addresses', { + .state('tabs.settings.addresses', { url: '/addresses/:walletId/:toAddress', views: { - 'tab-receive@tabs': { + 'tab-settings@tabs': { controller: 'addressesController', templateUrl: 'views/addresses.html' } } }) - .state('tabs.receive.allAddresses', { + .state('tabs.settings.allAddresses', { url: '/allAddresses/:walletId', views: { - 'tab-receive@tabs': { + 'tab-settings@tabs': { controller: 'addressesController', templateUrl: 'views/allAddresses.html' } diff --git a/www/views/addresses.html b/www/views/addresses.html index 155cb044c..5f2748221 100644 --- a/www/views/addresses.html +++ b/www/views/addresses.html @@ -1,4 +1,4 @@ - + {{'Wallet Addresses' | translate}} From dbc49e9ce0dbbf5132b6134ce2aad5f7d1d294d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Thu, 4 May 2017 12:13:55 -0300 Subject: [PATCH 3/7] remove slider directive and replace sliders in paperwallet view --- src/js/controllers/paperWallet.js | 23 +++++++++-------------- src/js/controllers/tab-receive.js | 1 - src/js/directives/directives.js | 19 ------------------- www/views/includes/wallets.html | 18 ------------------ www/views/paperWallet.html | 30 ++++++++++++++++++++++++++++-- 5 files changed, 37 insertions(+), 54 deletions(-) delete mode 100644 www/views/includes/wallets.html diff --git a/src/js/controllers/paperWallet.js b/src/js/controllers/paperWallet.js index 5d9be8376..ee613f574 100644 --- a/src/js/controllers/paperWallet.js +++ b/src/js/controllers/paperWallet.js @@ -101,21 +101,15 @@ angular.module('copayApp.controllers').controller('paperWalletController', $state.go('tabs.home'); }; - $scope.$on('Wallet/Changed', function(event, wallet) { - if (!wallet) { - $log.debug('No wallet provided'); - return; - } - if (wallet == $scope.wallet) { - $log.debug('No change in wallet'); - return; - } + $scope.onWalletSelect = function(wallet) { $scope.wallet = wallet; - $log.debug('Wallet changed: ' + wallet.name); - $timeout(function() { - $scope.$apply(); - }); - }); + }; + + $scope.showWalletSelector = function() { + if ($scope.singleWallet) return; + $scope.walletSelectorTitle = gettextCatalog.getString('Transfer to'); + $scope.showWallets = true; + }; $scope.$on("$ionicView.beforeEnter", function(event, data) { $scope.scannedKey = (data.stateParams && data.stateParams.privateKey) ? data.stateParams.privateKey : null; @@ -127,6 +121,7 @@ angular.module('copayApp.controllers').controller('paperWalletController', onlyComplete: true, network: 'livenet', }); + $scope.singleWallet = $scope.wallets.length == 1; if (!$scope.wallets || !$scope.wallets.length) { $scope.noMatchingWallet = true; diff --git a/src/js/controllers/tab-receive.js b/src/js/controllers/tab-receive.js index d86851bf2..b32f2fbef 100644 --- a/src/js/controllers/tab-receive.js +++ b/src/js/controllers/tab-receive.js @@ -127,7 +127,6 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi $scope.init = function() { $scope.wallet = $scope.wallets[0]; $scope.updateCurrentWallet($scope.wallet); - $scope.showWalletSelector(); }; $scope.$on("$ionicView.leave", function(event, data) { diff --git a/src/js/directives/directives.js b/src/js/directives/directives.js index 8e9022236..ed59564b7 100644 --- a/src/js/directives/directives.js +++ b/src/js/directives/directives.js @@ -143,23 +143,4 @@ angular.module('copayApp.directives') }); } } - }) - .directive('wallets', function($log, profileService, walletService, lodash) { - return { - restrict: 'E', - templateUrl: 'views/includes/wallets.html', - scope: { - wallets: '=wallets' - }, - link: function(scope, element, attrs) { - scope.$on("$ionicSlides.sliderInitialized", function(event, data) { - scope.slider = data.slider; - scope.$emit('Wallet/Changed', scope.wallets ? scope.wallets[0] : null); - }); - - scope.$on("$ionicSlides.slideChangeStart", function(event, data) { - scope.$emit('Wallet/Changed', scope.wallets ? scope.wallets[data.slider.activeIndex] : null); - }); - } - } }); diff --git a/www/views/includes/wallets.html b/www/views/includes/wallets.html deleted file mode 100644 index 4fa2cc894..000000000 --- a/www/views/includes/wallets.html +++ /dev/null @@ -1,18 +0,0 @@ -
- - -
-
- - - - {{wallet.name || wallet.id}} - - {{wallet.status.availableBalanceStr}} - - [Balance Hidden] -
-
-
-
-
diff --git a/www/views/paperWallet.html b/www/views/paperWallet.html index ee9393ba7..81b84ba41 100644 --- a/www/views/paperWallet.html +++ b/www/views/paperWallet.html @@ -18,10 +18,29 @@
...
-
Funds will be transferred to: - {{wallet.walletAlias || wallet.name}} +
+
@@ -34,4 +53,11 @@ Funds transferred + + From 813d89a1394ebaf56c03fd0fb76b2ec8e54c631a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Thu, 4 May 2017 14:45:21 -0300 Subject: [PATCH 4/7] add wallet information to custom amount and addresses view --- src/js/controllers/amount.js | 4 +++- src/js/controllers/customAmount.js | 3 ++- src/js/controllers/tab-receive.js | 1 + src/js/routes.js | 4 ++-- www/views/addresses.html | 6 +----- www/views/customAmount.html | 1 + 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/js/controllers/amount.js b/src/js/controllers/amount.js index aad224372..cd9bf9429 100644 --- a/src/js/controllers/amount.js +++ b/src/js/controllers/amount.js @@ -22,7 +22,7 @@ angular.module('copayApp.controllers').controller('amountController', function($ $scope.currency = data.stateParams.currency; $scope.forceCurrency = data.stateParams.forceCurrency; - $scope.showMenu = $ionicHistory.backView() && ($ionicHistory.backView().stateName == 'tabs.send' || + $scope.showMenu = $ionicHistory.backView() && ($ionicHistory.backView().stateName == 'tabs.send' || $ionicHistory.backView().stateName == 'tabs.bitpayCard'); $scope.recipientType = data.stateParams.recipientType || null; $scope.toAddress = data.stateParams.toAddress; @@ -30,6 +30,7 @@ angular.module('copayApp.controllers').controller('amountController', function($ $scope.toEmail = data.stateParams.toEmail; $scope.showAlternativeAmount = !!$scope.nextStep; $scope.toColor = data.stateParams.toColor; + $scope.walletId = data.stateParams.walletId; $scope.showSendMax = false; $scope.customAmount = data.stateParams.customAmount; @@ -236,6 +237,7 @@ angular.module('copayApp.controllers').controller('amountController', function($ var amount = $scope.showAlternativeAmount ? fromFiat(_amount) : _amount; if ($scope.customAmount) { $state.transitionTo('tabs.receive.customAmount', { + walletId: $scope.walletId, toAmount: (amount * unitToSatoshi).toFixed(0), toAddress: $scope.toAddress }); diff --git a/src/js/controllers/customAmount.js b/src/js/controllers/customAmount.js index 8aaa5b4dd..0f81cb1cb 100644 --- a/src/js/controllers/customAmount.js +++ b/src/js/controllers/customAmount.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('customAmountController', function($rootScope, $scope, $stateParams, $ionicHistory, txFormatService, platformInfo) { +angular.module('copayApp.controllers').controller('customAmountController', function($rootScope, $scope, $stateParams, $ionicHistory, txFormatService, platformInfo, profileService) { $scope.$on("$ionicView.beforeEnter", function(event, data) { var satToBtc = 1 / 100000000; @@ -10,6 +10,7 @@ angular.module('copayApp.controllers').controller('customAmountController', func $scope.amountBtc = ($scope.amount * satToBtc).toFixed(8); $scope.amountStr = txFormatService.formatAmountStr($scope.amount); $scope.altAmountStr = txFormatService.formatAlternativeStr($scope.amount); + $scope.wallet = profileService.getWallet($stateParams.walletId); }); $scope.finish = function() { diff --git a/src/js/controllers/tab-receive.js b/src/js/controllers/tab-receive.js index b32f2fbef..6953f7b1f 100644 --- a/src/js/controllers/tab-receive.js +++ b/src/js/controllers/tab-receive.js @@ -8,6 +8,7 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi $scope.requestSpecificAmount = function() { $state.go('tabs.receive.amount', { + walletId: $scope.wallet.credentials.walletId, customAmount: true, toAddress: $scope.addr }); diff --git a/src/js/routes.js b/src/js/routes.js index 1fa783a6c..ac5889e1f 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -681,7 +681,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr */ .state('tabs.receive.amount', { - url: '/amount/:customAmount/:toAddress', + url: '/amount/:walletId/:customAmount/:toAddress', views: { 'tab-receive@tabs': { controller: 'amountController', @@ -690,7 +690,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr } }) .state('tabs.receive.customAmount', { - url: '/customAmount/:toAmount/:toAddress', + url: '/customAmount/:walletId/:toAmount/:toAddress', views: { 'tab-receive@tabs': { controller: 'customAmountController', diff --git a/www/views/addresses.html b/www/views/addresses.html index 5f2748221..6701b33b4 100644 --- a/www/views/addresses.html +++ b/www/views/addresses.html @@ -11,11 +11,7 @@ - +
diff --git a/www/views/customAmount.html b/www/views/customAmount.html index 07e6f2d91..f7a8c5379 100644 --- a/www/views/customAmount.html +++ b/www/views/customAmount.html @@ -12,6 +12,7 @@ +
From a3ff528ca7f5e8217f6999d334041667fedc6eaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Thu, 4 May 2017 14:56:37 -0300 Subject: [PATCH 5/7] wording --- www/views/customAmount.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/views/customAmount.html b/www/views/customAmount.html index f7a8c5379..f4e1ece3c 100644 --- a/www/views/customAmount.html +++ b/www/views/customAmount.html @@ -7,7 +7,7 @@ From de15b45b798ef95ae701c2f412f5b2150a5887bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Thu, 4 May 2017 18:30:39 -0300 Subject: [PATCH 6/7] routes fix --- src/js/controllers/addresses.js | 2 +- www/views/customAmount.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/controllers/addresses.js b/src/js/controllers/addresses.js index 5f765a8c0..f0525a517 100644 --- a/src/js/controllers/addresses.js +++ b/src/js/controllers/addresses.js @@ -109,7 +109,7 @@ angular.module('copayApp.controllers').controller('addressesController', functio }; $scope.viewAllAddresses = function() { - $state.go('tabs.receive.allAddresses', { + $state.go('tabs.settings.allAddresses', { walletId: $scope.wallet.id }); }; diff --git a/www/views/customAmount.html b/www/views/customAmount.html index f4e1ece3c..ac205dc74 100644 --- a/www/views/customAmount.html +++ b/www/views/customAmount.html @@ -7,7 +7,7 @@ From 6ed0c978c1d2e0195392d4e71e4d947400e2c425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Mon, 8 May 2017 10:35:12 -0300 Subject: [PATCH 7/7] fixing sass --- www/views/customAmount.html | 2 +- www/views/tab-receive.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/www/views/customAmount.html b/www/views/customAmount.html index ac205dc74..7208f02e2 100644 --- a/www/views/customAmount.html +++ b/www/views/customAmount.html @@ -12,7 +12,7 @@ -
+
diff --git a/www/views/tab-receive.html b/www/views/tab-receive.html index d3687d024..6881b4477 100644 --- a/www/views/tab-receive.html +++ b/www/views/tab-receive.html @@ -45,7 +45,7 @@
-
+