From 010f1d03c3bf029cae83aebc9a0866faa530fdf8 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Fri, 13 Feb 2015 18:05:09 -0300 Subject: [PATCH] Display loading spinner on mobile devices --- cordova/build.sh | 3 +++ js/controllers/homeWallet.js | 20 +++++++++++++++++++- js/controllers/send.js | 7 +++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/cordova/build.sh b/cordova/build.sh index 95fa23754..cc4b684ed 100755 --- a/cordova/build.sh +++ b/cordova/build.sh @@ -112,6 +112,9 @@ if [ ! -d $PROJECT ]; then cordova plugin add https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin.git && cordova prepare checkOK + cordova plugin add hu.dpal.phonegap.plugins.spinnerdialog + checkOK + fi if $DBGJS diff --git a/js/controllers/homeWallet.js b/js/controllers/homeWallet.js index a4efbe719..5fd1f22bf 100644 --- a/js/controllers/homeWallet.js +++ b/js/controllers/homeWallet.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('HomeWalletController', function($scope, $rootScope, $timeout, $filter, $modal, rateService, notification, txStatus, identityService) { +angular.module('copayApp.controllers').controller('HomeWalletController', function($scope, $rootScope, $timeout, $filter, $modal, rateService, notification, txStatus, identityService, isCordova) { $scope.openTxModal = function(tx) { var ModalInstanceCtrl = function($scope, $modalInstance) { @@ -9,9 +9,15 @@ angular.module('copayApp.controllers').controller('HomeWalletController', functi $scope.loading = null; $scope.sign = function(ntxid) { + if (isCordova) { + window.plugins.spinnerDialog.show(null, 'Signing transaction...', true); + } $scope.loading = true; $timeout(function() { w.signAndSend(ntxid, function(err, id, status) { + if (isCordova) { + window.plugins.spinnerDialog.hide(); + } $scope.loading = false; if (err) $scope.error = err; @@ -22,9 +28,15 @@ angular.module('copayApp.controllers').controller('HomeWalletController', functi }; $scope.reject = function(ntxid) { + if (isCordova) { + window.plugins.spinnerDialog.show(null, 'Rejecting transaction...', true); + } $scope.loading = true; $timeout(function() { w.reject(ntxid, function(err, status) { + if (isCordova) { + window.plugins.spinnerDialog.hide(); + } $scope.loading = false; if (err) $scope.error = err; @@ -35,9 +47,15 @@ angular.module('copayApp.controllers').controller('HomeWalletController', functi }; $scope.broadcast = function(ntxid) { + if (isCordova) { + window.plugins.spinnerDialog.show(null, 'Sending transaction...', true); + } $scope.loading = true; $timeout(function() { w.issueTx(ntxid, function(err, txid, status) { + if (isCordova) { + window.plugins.spinnerDialog.hide(); + } $scope.loading = false; if (err) $scope.error = err; diff --git a/js/controllers/send.js b/js/controllers/send.js index fa5d49d07..7989d1ac7 100644 --- a/js/controllers/send.js +++ b/js/controllers/send.js @@ -185,6 +185,10 @@ angular.module('copayApp.controllers').controller('SendController', return; } + if (isCordova) { + window.plugins.spinnerDialog.show(null, 'Creating transaction...', true); + } + $scope.loading = true; if ($scope.isWindowsPhoneApp) $rootScope.wpInputFocused = true; @@ -204,6 +208,9 @@ angular.module('copayApp.controllers').controller('SendController', amountSat: amount, comment: comment, }, function (err, txid, status) { + if (isCordova) { + window.plugins.spinnerDialog.hide(); + } $scope.loading = false; if ($scope.isWindowsPhoneApp) $rootScope.wpInputFocused = false;