Improvement open TX modal
This commit is contained in:
parent
41ea294b80
commit
b405510db3
11 changed files with 341 additions and 18 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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({
|
||||
|
|
|
|||
67
src/js/controllers/tx.js
Normal file
67
src/js/controllers/tx.js
Normal file
|
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}]);
|
||||
|
||||
;
|
||||
|
|
|
|||
|
|
@ -511,7 +511,6 @@ angular
|
|||
});
|
||||
})
|
||||
.run(function($rootScope, $state, $log, uriHandler, isCordova, profileService, $timeout, nodeWebkit, uxLanguage, animationService) {
|
||||
FastClick.attach(document.body);
|
||||
|
||||
uxLanguage.init();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue