From b405510db3d4f12336ac34929fdcfae56268f1c2 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Tue, 9 Feb 2016 16:48:53 -0500 Subject: [PATCH] Improvement open TX modal --- Gruntfile.js | 1 - public/index.html | 25 ++-- public/views/includes/tx-details.html | 158 ++++++++++++++++++++++++++ public/views/walletHome.html | 16 ++- src/css/main.css | 9 +- src/css/mobile.css | 2 + src/js/controllers/index.js | 7 ++ src/js/controllers/tx.js | 67 +++++++++++ src/js/controllers/walletHome.js | 4 + src/js/directives/directives.js | 69 ++++++++++- src/js/routes.js | 1 - 11 files changed, 341 insertions(+), 18 deletions(-) create mode 100644 public/views/includes/tx-details.html create mode 100644 src/js/controllers/tx.js diff --git a/Gruntfile.js b/Gruntfile.js index f08be00c4..bf463a00b 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -46,7 +46,6 @@ module.exports = function(grunt) { }, angular: { src: [ - 'bower_components/fastclick/lib/fastclick.js', 'bower_components/qrcode-generator/js/qrcode.js', 'bower_components/qrcode-decoder-js/lib/qrcode-decoder.js', 'bower_components/moment/min/moment-with-locales.js', diff --git a/public/index.html b/public/index.html index a385dbe5e..6522699c5 100644 --- a/public/index.html +++ b/public/index.html @@ -3,7 +3,7 @@ - + @@ -14,20 +14,19 @@ -
- -
+
+
+
+
+
+
+ +
- -
-
-
-
+ + + +
+
+
+ sync +

Received

+
+
+ sync +

Sent

+
+
+ sync +

Moved

+
+ +
+ +-{{index.showTx.amountStr}} +
+
+ + {{alternativeAmountStr}} + + + {{rateStr}} ({{rateDate | amDateFormat:'MM/DD/YYYY HH:mm a'}}) + +
+
+
+ - +
+
+ +

Details

+ +
    + +
  • + To + + + {{index.showTx.merchant.domain}} + {{index.showTx.merchant.domain}} + + + {{index.showTx.labelTo}} + + + +
  • + +
  • + Recipients + {{index.showTx.recipientCount}} + + + +
  • + +
    +
    + +
  • + Note + {{index.showTx.message}} +
  • + +
  • + + This transaction has become invalid; possibly due to a double spend attempt. + +
  • + Date + + + + +
  • +
  • + Fee + {{index.showTx.feeStr}} +
  • +
  • + Note + {{index.showTx.message}} +
  • +
  • + Merchant message + + {{index.showTx.merchant.pr.pd.memo}} + +
  • +
  • + Confirmations + + + Unconfirmed + + + {{index.showTx.confirmations}} + + + {{index.showTx.safeConfirmed}} + + + +
  • +
+ +
+

Participants

+
    +
  • + + + + + + {{c.copayerName}} ({{'Me'|translate}}) +
  • +
+
+ +
+
+ +
+
+ +
+
diff --git a/public/views/walletHome.html b/public/views/walletHome.html index 89d0a8005..a2adaac87 100644 --- a/public/views/walletHome.html +++ b/public/views/walletHome.html @@ -199,7 +199,21 @@
diff --git a/src/css/main.css b/src/css/main.css index 3dd261ed8..f03714489 100644 --- a/src/css/main.css +++ b/src/css/main.css @@ -1399,7 +1399,14 @@ input.ng-invalid-match, input.ng-invalid-match:focus { border-top-right-radius: 5px; } -/*******************/ +.txModal { + background: #FFFFFF; + border-radius: 5px; + position: absolute; + width: 100%; + height: 100%; + z-index: 1100; +} .alertModal { background: #FFFFFF; diff --git a/src/css/mobile.css b/src/css/mobile.css index fcdc3af21..e0d5f6cf0 100644 --- a/src/css/mobile.css +++ b/src/css/mobile.css @@ -644,6 +644,8 @@ body.modal-open { .reveal-modal.animated.slideInRight, .reveal-modal.animated.slideOutRight, +.txModal.animated.slideInRight, +.txModal.animated.slideOutRight, .reveal-modal.animated.fadeOutUp, .reveal-modal.animated.slideInUp, .reveal-modal.animated.slideInDown { diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js index d256afeda..a8b33cb97 100644 --- a/src/js/controllers/index.js +++ b/src/js/controllers/index.js @@ -1344,6 +1344,13 @@ angular.module('copayApp.controllers').controller('indexController', function($r }); }); + $rootScope.$on('Local/TxModal', function(event, tx) { + self.showTx = tx; + $timeout(function() { + $rootScope.$apply(); + }); + }); + $rootScope.$on('NewIncomingTx', function() { self.newTx = true; self.updateAll({ diff --git a/src/js/controllers/tx.js b/src/js/controllers/tx.js new file mode 100644 index 000000000..93f70aec9 --- /dev/null +++ b/src/js/controllers/tx.js @@ -0,0 +1,67 @@ +'use strict'; + +angular.module('copayApp.controllers').controller('txController', + function($rootScope, $scope, $timeout, profileService, notification, go, gettext, isCordova, nodeWebkit) { + + var fc = profileService.focusedClient; + this.color = fc.backgroundColor; + this.copayerId = fc.credentials.copayerId; + this.isShared = fc.credentials.n > 1; + + if (isCordova) { + $scope.modalOpening = true; + $timeout(function() { + $scope.modalOpening = false; + }, 300); + } + + this.getAlternativeAmount = function(btx) { +console.log('[tx.js:18]',btx); //TODO + var satToBtc = 1 / 100000000; + fc.getFiatRate({ + code: self.alternativeIsoCode, + ts: btx.time * 1000 + }, function(err, res) { +console.log('[tx.js:24]',res); //TODO + if (err) { + $log.debug('Could not get historic rate'); + return; + } + if (res && res.rate) { + var alternativeAmountBtc = (btx.amount * satToBtc).toFixed(8); + $scope.rateDate = res.fetchedOn; + $scope.rateStr = res.rate + ' ' + self.alternativeIsoCode; + $scope.alternativeAmountStr = $filter('noFractionNumber')(alternativeAmountBtc * res.rate, 2) + ' ' + self.alternativeIsoCode; + $scope.$apply(); + } + }); + }; + + this.getShortNetworkName = function() { + var n = fc.credentials.network; + return n.substring(0, 4); + }; + + this.copyAddress = function(addr) { + if (!addr) return; + if (isCordova) { + window.cordova.plugins.clipboard.copy(addr); + window.plugins.toast.showShortCenter(gettextCatalog.getString('Copied to clipboard')); + } else if (nodeWebkit.isDefined()) { + nodeWebkit.writeToClipboard(addr); + } + }; + + this.cancel = function() { + if (isCordova) { + $scope.modalClosing = true; + $timeout(function() { + $scope.modalClosing = false; + $rootScope.$emit('Local/TxModal', null); + }, 300); + } else { + $rootScope.$emit('Local/TxModal', null); + } + }; + + }); diff --git a/src/js/controllers/walletHome.js b/src/js/controllers/walletHome.js index 7eff987b6..d2f13f912 100644 --- a/src/js/controllers/walletHome.js +++ b/src/js/controllers/walletHome.js @@ -1149,6 +1149,10 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi return this.alternativeIsoCode; }; + this.openNewTxModal = function(tx) { + $rootScope.$emit('Local/TxModal', tx); + }; + this.openTxModal = function(btx) { $rootScope.modalOpened = true; var self = this; diff --git a/src/js/directives/directives.js b/src/js/directives/directives.js index f09f8bd23..3aa66d5b6 100644 --- a/src/js/directives/directives.js +++ b/src/js/directives/directives.js @@ -317,4 +317,71 @@ angular.module('copayApp.directives') replace: true, templateUrl: 'views/includes/available-balance.html' } - }); + }) + .directive('fastClick', [ 'isCordova', '$timeout', function(isCordova, $timeout) { + return { + scope: { someCtrlFn: '&callbackFn'}, + link: function(scope, element, attrs) { + + if (!isCordova) { + element.on('click', function(){ + scope.someCtrlFn(); + console.log('click real'); + }); + } else { + var trackingClick = false; + var targetElement = null; + var touchStartX = 0; + var touchStartY = 0; + var touchBoundary = 10; + + element.on('touchstart', function(event) { + + trackingClick = true; + targetElement = event.target; + touchStartX = event.targetTouches[0].pageX; + touchStartY = event.targetTouches[0].pageY; + + console.log('PRIMER CLICKKKKKK!!'); + + return true; + }); + + element.on('touchend', function(event) { + if (trackingClick) { + scope.someCtrlFn(); + event.preventDefault(); + } + trackingClick = false; + console.log('SOLTANDO EL CLICKKKKKK!!'); + return false; + }); + + element.on('touchmove', function(event) { +console.log('[directives.js:357] MOVING 1', trackingClick); //TODO + if (!trackingClick) { + return true; + } +console.log('[directives.js:361] MOVING 2', trackingClick); //TODO + + // If the touch has moved, cancel the click tracking + if (targetElement !== event.target + || (Math.abs(event.changedTouches[0].pageX - touchStartX) > touchBoundary + || (Math.abs(event.changedTouches[0].pageY - touchStartY) > touchBoundary))) { + trackingClick = false; + targetElement = null; + } + + return true; + }); + + element.on('touchcancel', function() { + trackingClick = false; + targetElement = null; + }); + } + } + } + }]); + +; diff --git a/src/js/routes.js b/src/js/routes.js index 469d7aeb5..1e0fe8283 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -511,7 +511,6 @@ angular }); }) .run(function($rootScope, $state, $log, uriHandler, isCordova, profileService, $timeout, nodeWebkit, uxLanguage, animationService) { - FastClick.attach(document.body); uxLanguage.init();