diff --git a/public/views/includes/wallets.html b/public/views/includes/wallets.html index 2e529f61e..ed88f8302 100644 --- a/public/views/includes/wallets.html +++ b/public/views/includes/wallets.html @@ -1,7 +1,7 @@ -
+
- -
+ +
{{wallet.name || wallet.id}} diff --git a/public/views/tab-receive.html b/public/views/tab-receive.html index 8320cb69d..7e338b681 100644 --- a/public/views/tab-receive.html +++ b/public/views/tab-receive.html @@ -54,7 +54,8 @@ Error: {{addrError}} {{addr}}
-
+ + diff --git a/public/views/tab-settings.html b/public/views/tab-settings.html index 7783fad68..4549569dd 100644 --- a/public/views/tab-settings.html +++ b/public/views/tab-settings.html @@ -18,6 +18,7 @@
Preferences
+
diff --git a/src/js/controllers/tab-receive.js b/src/js/controllers/tab-receive.js index 28ede85ad..d46bd1e69 100644 --- a/src/js/controllers/tab-receive.js +++ b/src/js/controllers/tab-receive.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('tabReceiveController', function($scope, $ionicPopover, $timeout, platformInfo, nodeWebkit, walletService, profileService, configService, lodash, gettextCatalog) { +angular.module('copayApp.controllers').controller('tabReceiveController', function($scope, $ionicPopover, $timeout, $log, platformInfo, nodeWebkit, walletService, profileService, configService, lodash, gettextCatalog) { $scope.isCordova = platformInfo.isCordova; @@ -8,43 +8,82 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi $scope.index = 0; $scope.isCordova = platformInfo.isCordova; $scope.isNW = platformInfo.isNW; - $scope.setWallets(); + // $scope.setWallets(); $scope.setAddress(false); - $scope.options = { - loop: false, - effect: 'flip', - speed: 500, - spaceBetween: 100 - } - - $scope.$on("$ionicSlides.sliderInitialized", function(event, data) { - // data.slider is the instance of Swiper - $scope.slider = data.slider; - }); - - $scope.$on("$ionicSlides.slideChangeStart", function(event, data) { - console.log('Slide change is beginning'); - }); - - $scope.$on("$ionicSlides.slideChangeEnd", function(event, data) { - $scope.index = data.slider.activeIndex; - $scope.setAddress(); - }); + // $scope.options = { + // loop: false, + // effect: 'flip', + // speed: 500, + // spaceBetween: 100 + // } + // + // $scope.$on("$ionicSlides.sliderInitialized", function(event, data) { + // // data.slider is the instance of Swiper + // $scope.slider = data.slider; + // }); + // + // $scope.$on("$ionicSlides.slideChangeStart", function(event, data) { + // console.log('Slide change is beginning'); + // }); + // + // $scope.$on("$ionicSlides.slideChangeEnd", function(event, data) { + // $scope.index = data.slider.activeIndex; + // $scope.setAddress(); + // }); } + $scope.copyToClipboard = function(addr, $event) { + + var showPopover = function() { + + $ionicPopover.fromTemplateUrl('views/includes/copyToClipboard.html', { + scope: $scope + }).then(function(popover) { + $scope.popover = popover; + $scope.popover.show($event); + }); + + $scope.close = function() { + $scope.popover.hide(); + } + + $timeout(function() { + $scope.popover.hide(); //close the popover after 0.7 seconds + }, 700); + + $scope.$on('$destroy', function() { + $scope.popover.remove(); + }); + }; + + if ($scope.isCordova) { + window.cordova.plugins.clipboard.copy(addr); + window.plugins.toast.showShortCenter(gettextCatalog.getString('Copied to clipboard')); + } else if ($scope.isNW) { + nodeWebkit.writeToClipboard(addr); + showPopover($event); + } + }; + + $scope.$on('Wallet/Changed', function(event, wallet) { + console.log(wallet); + $log.debug('Wallet changed: ' + wallet.name); + $scope.setAddress(wallet); + }); + $scope.shareAddress = function(addr) { if ($scope.isCordova) { window.plugins.socialsharing.share('bitcoin:' + addr, null, null, null); } }; - $scope.setAddress = function(forceNew) { + $scope.setAddress = function(wallet, forceNew) { + if (!wallet) return; if ($scope.generatingAddress) return; $scope.addr = null; $scope.addrError = null; - var wallet = $scope.wallets[$scope.index]; if (!wallet.isComplete()) { $scope.incomplete = true; $timeout(function() { @@ -55,8 +94,9 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi $scope.incomplete = false; $scope.generatingAddress = true; + $timeout(function() { - walletService.getAddress($scope.wallets[$scope.index], forceNew, function(err, addr) { + walletService.getAddress(wallet, forceNew, function(err, addr) { $scope.generatingAddress = false; if (err) { $scope.addrError = err; diff --git a/src/js/directives/directives.js b/src/js/directives/directives.js index 85bf80267..945511b1e 100644 --- a/src/js/directives/directives.js +++ b/src/js/directives/directives.js @@ -143,25 +143,29 @@ angular.module('copayApp.directives') } } }) - .directive('wallets', function(profileService, lodash) { + .directive('wallets', function(profileService) { return { restrict: 'E', templateUrl: 'views/includes/wallets.html', - scope: {}, + scope: false, link: function(scope, element, attrs) { var opts = {}; opts.onlyComplete = attrs.onlyComplete == 'true' ? true : null; opts.network = attrs.network; opts.n = attrs.n; - scope.wallets = profileService.getWallets(opts); + scope.content = {}; + scope.content.wallets = profileService.getWallets(opts); scope.$on("$ionicSlides.sliderInitialized", function(event, data) { scope.slider = data.slider; + scope.content.index = data.slider.activeIndex; + scope.$emit('Wallet/Changed', scope.content.wallets[scope.content.index]); }); scope.$on("$ionicSlides.slideChangeEnd", function(event, data) { - scope.index = data.slider.activeIndex; + scope.content.index = data.slider.activeIndex; + scope.$emit('Wallet/Changed', scope.content.wallets[scope.content.index]); }); } }