diff --git a/src/js/controllers/copayers.js b/src/js/controllers/copayers.js index bbcf069c2..4e74a3862 100644 --- a/src/js/controllers/copayers.js +++ b/src/js/controllers/copayers.js @@ -1,8 +1,9 @@ 'use strict'; angular.module('copayApp.controllers').controller('copayersController', - function($scope, $log, $timeout, $stateParams, $state, $rootScope, $ionicHistory, appConfigService, lodash, profileService, walletService, popupService, bwcError, platformInfo, gettextCatalog, ongoingProcess) { + function($scope, $log, $timeout, $stateParams, $state, $rootScope, $ionicHistory, appConfigService, lodash, profileService, walletService, popupService, bwcError, platformInfo, gettextCatalog, ongoingProcess, pushNotificationsService) { + var listener; var appName = appConfigService.userVisibleName; var appUrl = appConfigService.url; @@ -10,13 +11,15 @@ angular.module('copayApp.controllers').controller('copayersController', $scope.$on("$ionicView.beforeEnter", function(event, data) { $scope.wallet = profileService.getWallet(data.stateParams.walletId); updateWallet(); - }); + $scope.shareIcon = platformInfo.isIOS ? 'iOS' : 'Android'; + + listener = $rootScope.$on('bwsEvent', function(e, walletId, type, n) { + if ($scope.wallet && walletId == $scope.wallet.id && type == ('NewCopayer' || 'WalletComplete')) + updateWalletDebounced(); + }); + }); - var listener = $rootScope.$on('bwsEvent', function() { - updateWallet(); - }); - - $scope.$on('$destroy', function() { + $scope.$on("$ionicView.leave", function(event, data) { listener(); }); @@ -35,12 +38,19 @@ angular.module('copayApp.controllers').controller('copayersController', if (status.wallet.status == 'complete') { $scope.wallet.openWallet(function(err, status) { if (err) $log.error(err); - $scope.goHome(); + $scope.clearNextView(); + $state.go('tabs.home').then(function() { + $state.transitionTo('tabs.wallet', { + walletId: $scope.wallet.credentials.walletId + }); + }); }); } }); }; + var updateWalletDebounced = lodash.debounce(updateWallet, 5000, true); + $scope.showDeletePopup = function() { var title = gettextCatalog.getString('Confirm'); var msg = gettextCatalog.getString('Are you sure you want to cancel and delete this wallet?'); @@ -56,7 +66,9 @@ angular.module('copayApp.controllers').controller('copayersController', if (err) { popupService.showAlert(gettextCatalog.getString('Error'), err.message || err); } else { - $scope.goHome(); + pushNotificationsService.unsubscribe($scope.wallet); + $scope.clearNextView(); + $state.go('tabs.home'); } }); }; @@ -81,9 +93,13 @@ angular.module('copayApp.controllers').controller('copayersController', } }; - $scope.goHome = function() { - $state.go('tabs.home'); - $ionicHistory.clearHistory(); + $scope.clearNextView = function() { + listener(); // remove listener + $ionicHistory.nextViewOptions({ + disableAnimate: true, + historyRoot: true + }); + $ionicHistory.clearHistory(); }; }); diff --git a/src/js/controllers/customAmount.js b/src/js/controllers/customAmount.js index b3040977e..9a2b46f6c 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, configService, profileService, walletService, popupService) { +angular.module('copayApp.controllers').controller('customAmountController', function($scope, $ionicHistory, txFormatService, platformInfo, configService, profileService, walletService, popupService) { var showErrorAndBack = function(title, msg) { popupService.showAlert(title, msg, function() { @@ -15,6 +15,8 @@ angular.module('copayApp.controllers').controller('customAmountController', func showErrorAndBack('Error', 'No wallet selected'); return; } + + $scope.showShareButton = platformInfo.isCordova ? (platformInfo.isIOS ? 'iOS' : 'Android') : null; $scope.wallet = profileService.getWallet(walletId); @@ -57,6 +59,12 @@ angular.module('copayApp.controllers').controller('customAmountController', func $ionicHistory.goBack(-2); }; + $scope.shareAddress = function() { + if (!platformInfo.isCordova) return; + var data = 'bitcoin:' + $scope.address + '?amount=' + $scope.amountBtc; + window.plugins.socialsharing.share(data, null, null, null); + } + $scope.copyToClipboard = function() { return 'bitcoin:' + $scope.address + '?amount=' + $scope.amountBtc; }; diff --git a/src/js/controllers/tab-receive.js b/src/js/controllers/tab-receive.js index c51b4133d..4a56d565b 100644 --- a/src/js/controllers/tab-receive.js +++ b/src/js/controllers/tab-receive.js @@ -98,6 +98,8 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi var selectedWallet = checkSelectedWallet($scope.wallet, $scope.wallets); $scope.onWalletSelect(selectedWallet); + $scope.showShareButton = platformInfo.isCordova ? (platformInfo.isIOS ? 'iOS' : 'Android') : null; + listeners = [ $rootScope.$on('bwsEvent', function(e, walletId, type, n) { // Update current address @@ -132,8 +134,8 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi $scope.showWallets = true; }; - $scope.copyToClipboard = function() { - if ($scope.isCordova) return 'bitcoin:' + $scope.addr; - else return $scope.addr; + $scope.shareAddress = function() { + if (!$scope.isCordova) return; + window.plugins.socialsharing.share('bitcoin:' + $scope.addr, null, null, null); } }); diff --git a/src/js/directives/copyToClipboard.js b/src/js/directives/copyToClipboard.js index a06b2743d..5de40f23e 100644 --- a/src/js/directives/copyToClipboard.js +++ b/src/js/directives/copyToClipboard.js @@ -21,18 +21,18 @@ angular.module('copayApp.directives') if (!data) return; if (isCordova) { - window.plugins.socialsharing.share(data, null, null, null); + cordova.plugins.clipboard.copy(data); } else if (isNW) { nodeWebkitService.writeToClipboard(data); - scope.$apply(function() { - ionicToast.show(msg, 'bottom', false, 1000); - }); } else if (clipboard.supported) { clipboard.copyText(data); - scope.$apply(function() { - ionicToast.show(msg, 'bottom', false, 1000); - }); + } else { + // No supported + return; } + scope.$apply(function() { + ionicToast.show(msg, 'bottom', false, 1000); + }); }); } } diff --git a/src/sass/variables.scss b/src/sass/variables.scss index d91baa647..5481aace9 100644 --- a/src/sass/variables.scss +++ b/src/sass/variables.scss @@ -24,6 +24,7 @@ $v-text-accent-color: #647ce8 !default; $v-success-color: #13e5b6 !default; $v-warning-color: #ffa500 !default; +$v-error-color: #ef473a !default; $v-wallet-color-map: ( 0: (color: #dd4b39, name: 'Cinnabar'), diff --git a/src/sass/views/copayers.scss b/src/sass/views/copayers.scss index 2f3458a4e..6dabb8758 100644 --- a/src/sass/views/copayers.scss +++ b/src/sass/views/copayers.scss @@ -1,13 +1,37 @@ -.copayers-secret { - text-align: center; - font-size: 12px; - margin: 10px; - white-space: -moz-pre-wrap !important; - white-space: -pre-wrap; - white-space: -o-pre-wrap; - white-space: pre-wrap; - word-wrap: break-word; - white-space: -webkit-pre-wrap; - word-break: break-all; - white-space: normal; +#copayers-invitation { + @extend .deflash-blue; + .button-share { + color: #fff; + box-shadow: none; + border-color: transparent; + background: transparent; + padding: 0 10px; + .icon:before { + font-size: 26px; + } + } + .button-cancel { + margin-top: 15px; + background: transparent; + border: none; + font-size: 12px; + color: $v-error-color; + i.icon { + vertical-align: middle; + padding-left: 5px; + } + } + .copayers-secret { + text-align: center; + font-size: 12px; + margin: 10px; + white-space: -moz-pre-wrap !important; + white-space: -pre-wrap; + white-space: -o-pre-wrap; + white-space: pre-wrap; + word-wrap: break-word; + white-space: -webkit-pre-wrap; + word-break: break-all; + white-space: normal; + } } diff --git a/src/sass/views/custom-amount.scss b/src/sass/views/custom-amount.scss index 245734a09..3576e56a0 100644 --- a/src/sass/views/custom-amount.scss +++ b/src/sass/views/custom-amount.scss @@ -3,6 +3,16 @@ $item-lateral-padding: 20px; $item-vertical-padding: 10px; $item-label-color: #6C6C6E; + .button-share { + color: #fff; + box-shadow: none; + border-color: transparent; + background: transparent; + padding: 0 10px; + .icon:before { + font-size: 26px; + } + } .address { background: #fff; overflow: auto; @@ -39,6 +49,11 @@ padding-right: $item-lateral-padding; } + .item-note { + width: 75%; + text-align: right; + } + .label { font-size: 14px; color: $item-label-color; diff --git a/src/sass/views/tab-receive.scss b/src/sass/views/tab-receive.scss index f573744ee..c013ef4f5 100644 --- a/src/sass/views/tab-receive.scss +++ b/src/sass/views/tab-receive.scss @@ -1,5 +1,33 @@ #tab-receive { @extend .deflash-blue; + .button-share { + color: #fff; + box-shadow: none; + border-color: transparent; + background: transparent; + padding: 0 10px; + .icon:before { + font-size: 26px; + } + } + .button-request { + margin-top: 10px; + background: transparent; + border: none; + font-size: 12px; + color: $v-text-accent-color; + i.icon { + vertical-align: middle; + padding-left: 5px; + } + } + .button-address { + margin-top: 10px; + background: transparent; + border: none; + font-size: 12px; + color: $v-text-accent-color; + } .address { background: #fff; overflow: auto; @@ -21,9 +49,6 @@ margin-top: 5%; font-size: 13px; } - .request-button { - padding-top: 20px; - } } .incomplete { .title { diff --git a/www/views/copayers.html b/www/views/copayers.html index a3b4ff52c..c575d0e0b 100644 --- a/www/views/copayers.html +++ b/www/views/copayers.html @@ -1,19 +1,23 @@ - + {{wallet.name}} -
-
+
Share this invitation with your copayers
@@ -29,11 +33,8 @@ {{secret || ('Loading...'|translate)}}
-
diff --git a/www/views/customAmount.html b/www/views/customAmount.html index 3aead822c..902671d63 100644 --- a/www/views/customAmount.html +++ b/www/views/customAmount.html @@ -1,11 +1,20 @@ + + + {{'Custom Amount' | translate}} - @@ -15,7 +24,7 @@
-
+
Address {{address}} diff --git a/www/views/tab-receive.html b/www/views/tab-receive.html index 3612ec51c..fb335c420 100644 --- a/www/views/tab-receive.html +++ b/www/views/tab-receive.html @@ -1,6 +1,15 @@ {{'Receive' | translate}} + + +
@@ -19,7 +28,7 @@
-
+
-
- +
+ +
+
+