diff --git a/src/js/controllers/activity.js b/src/js/controllers/activity.js index 304e5b62b..dbf2f5ada 100644 --- a/src/js/controllers/activity.js +++ b/src/js/controllers/activity.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('activityController', - function($timeout, $scope, $log, $ionicModal, lodash, txpModalService, profileService, walletService, ongoingProcess, popupService, gettextCatalog) { + function($timeout, $scope, $log, $ionicModal, lodash, txpModalService, profileService, walletService, ongoingProcess, popupService, gettextCatalog, $state) { $scope.openTxpModal = txpModalService.open; $scope.fetchingNotifications = true; @@ -66,11 +66,9 @@ angular.module('copayApp.controllers').controller('activityController', $scope.wallet = wallet; $scope.btx = lodash.cloneDeep(tx); - $ionicModal.fromTemplateUrl('views/modals/tx-details.html', { - scope: $scope - }).then(function(modal) { - $scope.txDetailsModal = modal; - $scope.txDetailsModal.show(); + $state.transitionTo('tabs.wallet.tx-details', { + txid: $scope.btx.txid, + walletId: $scope.walletId }); walletService.getTxNote(wallet, n.txid, function(err, note) { diff --git a/src/js/controllers/modals/txDetails.js b/src/js/controllers/modals/txDetails.js index 9d0386fc3..ea2cb431a 100644 --- a/src/js/controllers/modals/txDetails.js +++ b/src/js/controllers/modals/txDetails.js @@ -1,38 +1,55 @@ 'use strict'; -angular.module('copayApp.controllers').controller('txDetailsController', function($log, $timeout, $scope, $filter, $stateParams, ongoingProcess, walletService, lodash, gettextCatalog, profileService, configService, txFormatService, externalLinkService, popupService) { +angular.module('copayApp.controllers').controller('txDetailsController', function($log, $timeout, $ionicHistory, $scope, $filter, $stateParams, ongoingProcess, walletService, lodash, gettextCatalog, profileService, configService, txFormatService, externalLinkService, popupService) { var config = configService.getSync(); var configWallet = config.wallet; var walletSettings = configWallet.settings; - var wallet; + var wallet = profileService.getWallet($stateParams.walletId); + + $scope.wallet = wallet; $scope.title = gettextCatalog.getString('Transaction'); $scope.init = function() { - wallet = $scope.wallet; $scope.alternativeIsoCode = walletSettings.alternativeIsoCode; $scope.color = wallet.color; $scope.copayerId = wallet.credentials.copayerId; $scope.isShared = wallet.credentials.n > 1; - $scope.btx.feeLevel = walletSettings.feeLevel; + walletService.getTx(wallet, $stateParams.txid, function(err, tx) { + if (err) { + $log.warn('Could not get tx'); + $ionicHistory.goBack(); + return; + } + $scope.btx = tx; + $scope.btx.feeLevel = walletSettings.feeLevel; + if ($scope.btx.action != 'invalid') { + if ($scope.btx.action == 'sent') $scope.title = gettextCatalog.getString('Sent Funds'); + if ($scope.btx.action == 'received') $scope.title = gettextCatalog.getString('Received Funds'); + if ($scope.btx.action == 'moved') $scope.title = gettextCatalog.getString('Moved Funds'); + } - if ($scope.btx.action != 'invalid') { - if ($scope.btx.action == 'sent') $scope.title = gettextCatalog.getString('Sent Funds'); - if ($scope.btx.action == 'received') $scope.title = gettextCatalog.getString('Received Funds'); - if ($scope.btx.action == 'moved') $scope.title = gettextCatalog.getString('Moved Funds'); - } + $scope.displayAmount = getDisplayAmount($scope.btx.amountStr); + $scope.displayUnit = getDisplayUnit($scope.btx.amountStr); - updateMemo(); - initActionList(); - getAlternativeAmount(); + updateMemo(); + initActionList(); + }); }; + function getDisplayAmount(amountStr) { + return amountStr.split(' ')[0]; + } + + function getDisplayUnit(amountStr) { + return amountStr.split(' ')[1]; + } + function updateMemo() { walletService.getTxNote(wallet, $scope.btx.txid, function(err, note) { if (err) { $log.warn('Could not fetch transaction note: ' + err); return; } - if (!note) return; $scope.btx.note = note; @@ -49,7 +66,7 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio }); }); }); - }; + } function initActionList() { $scope.actionList = []; @@ -83,10 +100,13 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio time: $scope.btx.time, description: actionDescriptions['broadcasted'], }); - }; + } $scope.showCommentPopup = function() { var opts = {}; + if ($scope.btx.message) { + opts.defaultText = $scope.btx.message; + } if ($scope.btx.note && $scope.btx.note.body) opts.defaultText = $scope.btx.note.body; popupService.showPrompt(wallet.name, gettextCatalog.getString('Memo'), opts, function(text) { @@ -114,27 +134,12 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio }); }; - var getAlternativeAmount = function() { - var satToBtc = 1 / 100000000; - - wallet.getFiatRate({ - code: $scope.alternativeIsoCode, - ts: $scope.btx.time * 1000 - }, function(err, res) { - if (err) { - $log.debug('Could not get historic rate'); - return; - } - if (res && res.rate) { - var alternativeAmountBtc = ($scope.btx.amount * satToBtc).toFixed(8); - $scope.rateDate = res.fetchedOn; - $scope.rateStr = res.rate + ' ' + $scope.alternativeIsoCode; - $scope.alternativeAmountStr = $filter('formatFiatAmount')(alternativeAmountBtc * res.rate) + ' ' + $scope.alternativeIsoCode; - $timeout(function() { - $scope.$apply(); - }); - } - }); + $scope.viewOnBlockchain = function() { + var btx = $scope.btx; + var url = 'https://' + ($scope.getShortNetworkName() == 'test' ? 'test-' : '') + 'insight.bitpay.com/tx/' + btx.txid; + var title = 'View Transaction on Insight'; + var message = 'Would you like to view this transaction on the Insight blockchain explorer?'; + $scope.openExternalLink(url, true, title, message, 'Open Insight', 'Go back'); }; $scope.openExternalLink = function(url, optIn, title, message, okText, cancelText) { @@ -149,4 +154,6 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio $scope.cancel = function() { $scope.txDetailsModal.hide(); }; + + $scope.init(); }); diff --git a/src/js/controllers/tab-home.js b/src/js/controllers/tab-home.js index 0773f68af..8d1f3963a 100644 --- a/src/js/controllers/tab-home.js +++ b/src/js/controllers/tab-home.js @@ -68,11 +68,9 @@ angular.module('copayApp.controllers').controller('tabHomeController', $scope.wallet = wallet; $scope.btx = lodash.cloneDeep(tx); - $ionicModal.fromTemplateUrl('views/modals/tx-details.html', { - scope: $scope - }).then(function(modal) { - $scope.txDetailsModal = modal; - $scope.txDetailsModal.show(); + $state.transitionTo('tabs.wallet.tx-details', { + txid: $scope.btx.txid, + walletId: $scope.walletId }); walletService.getTxNote(wallet, n.txid, function(err, note) { diff --git a/src/js/controllers/walletDetails.js b/src/js/controllers/walletDetails.js index 9f839a600..6fd7a8b30 100644 --- a/src/js/controllers/walletDetails.js +++ b/src/js/controllers/walletDetails.js @@ -86,17 +86,15 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun $scope.close = function() { $scope.searchModal.hide(); - } + }; }; $scope.openTxModal = function(btx) { $scope.btx = lodash.cloneDeep(btx); $scope.walletId = $scope.wallet.id; - $ionicModal.fromTemplateUrl('views/modals/tx-details.html', { - scope: $scope - }).then(function(modal) { - $scope.txDetailsModal = modal; - $scope.txDetailsModal.show(); + $state.transitionTo('tabs.wallet.tx-details', { + txid: $scope.btx.txid, + walletId: $scope.walletId }); }; diff --git a/src/js/routes.js b/src/js/routes.js index 844634b40..e7017cc41 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -177,6 +177,15 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr } } }) + .state('tabs.wallet.tx-details', { + url: '/tx-details/:txid', + views: { + 'tab-home@tabs': { + controller: 'txDetailsController', + templateUrl: 'views/modals/tx-details.html' + } + } + }) /* * @@ -847,7 +856,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr * */ - .state('tabs.bitpayCardIntro', { + .state('tabs.bitpayCardIntro', { url: '/bitpay-card-intro/:secret/:email/:otp', views: { 'tab-home@tabs': { diff --git a/src/sass/views/includes/txp-details.scss b/src/sass/views/includes/txp-details.scss index dc3ec8817..5bb8fd467 100644 --- a/src/sass/views/includes/txp-details.scss +++ b/src/sass/views/includes/txp-details.scss @@ -24,6 +24,10 @@ img { margin-right: 1rem; } + + span { + text-transform: capitalize; + } } .amount-label{ line-height: 30px; @@ -191,7 +195,7 @@ } > div { - border: 3px solid #09C286; + border: 3px solid #13e5b6; border-radius: 50%; display: flex; height: 26px; @@ -201,7 +205,7 @@ justify-content: center; font-weight: 600; vertical-align: middle; - color: #09C286; + color: #13e5b6; &.rejected { background: #E15061; @@ -231,4 +235,10 @@ color: $item-label-color; padding: 1rem 2rem; } + + .view-on-blockchain-btn { + background: #e8e7e7; + color: rgba(58, 58, 58, .6); + margin-bottom: 1.5rem; + } } diff --git a/www/img/icon-broadcasted.svg b/www/img/icon-broadcasted.svg new file mode 100644 index 000000000..766957c73 --- /dev/null +++ b/www/img/icon-broadcasted.svg @@ -0,0 +1,17 @@ + + + + Group + Created with Sketch. + + + + + + + + + + + + \ No newline at end of file diff --git a/www/img/icon-check-circled.svg b/www/img/icon-check-circled.svg new file mode 100644 index 000000000..17027dd45 --- /dev/null +++ b/www/img/icon-check-circled.svg @@ -0,0 +1,17 @@ + + + + Group + Created with Sketch. + + + + + + + + + + + + \ No newline at end of file diff --git a/www/views/modals/tx-details.html b/www/views/modals/tx-details.html index f23cd902c..208943149 100644 --- a/www/views/modals/tx-details.html +++ b/www/views/modals/tx-details.html @@ -1,178 +1,90 @@ - - - -
+ + + {{title}} -
-
+ + + + -
-
- - - - - -
- {{btx.amountStr}} -
- -
- - {{alternativeAmountStr}} - - - {{rateStr}} ({{rateDate | amDateFormat:'MM/DD/YYYY HH:mm a'}}) - -
-
- -
-
- Sent from - {{wallet.credentials.walletName}} -
- -
- -
-
- -
- Received Funds -
- -
- Moved Funds -
- -
- - -
-
-
-
- -
- - {{btx.merchant.domain}} - {{btx.merchant.domain}} - - - {{btx.labelTo}} - - +
+
+ + {{btx.action | translate}} +
+
+
{{displayAmount}} {{displayUnit}}
+
{{btx.alternativeAmountStr}}
- -
- {{'Recipients'|translate}} - [ {{btx.recipientCount}} ] - - - -
- -
-
- - -
- - View transaction on the blockchain -
- -
-
- {{'Date'|translate}} - - - -
-
- {{'Created by'|translate}} {{btx.creatorName}} - - - -
-
- -
- {{'Fee'|translate}}: {{btx.feeStr}} - - - Unconfirmed - - - {{btx.confirmations}} - - - {{btx.safeConfirmed}} - - Confirmations - -
- -
- {{'Description'|translate}} - - {{btx.message}} - -
- -
- {{'Merchant message'|translate}} - - {{btx.merchant.pr.pd.memo}} - -
- -
- - This transaction has become invalid; possibly due to a double spend attempt. - -
- -
- {{'Memo'|translate}} - - - - - {{btx.note.body}} -
- Edited by {{btx.note.editedByName}}, - -
-
-
- -
-
Timeline
-
-
-
- {{actionList.length - $index}} +
+
+ To + + + +
+ + {{toName}}
-
-
{{a.description}}
+ +
+
+ From + To +
+ + + +
{{wallet.name}}
+
+
+ + Memo + + {{btx.note.body || btx.message}} + + + +
+ Fee + + {{btx.feeStr}} + +
+ +
+
Timeline
+
+
+
+
!
+ +
+ {{actionList.length - $index}} +
+
+
- {{a.by}} - +
+
+ + + - +