Merge pull request #2654 from matiu/feat/touchdown

Feat/touchdown
This commit is contained in:
Gustavo Maximiliano Cortez 2015-04-29 09:57:29 -03:00
commit e44780379a
10 changed files with 119 additions and 57 deletions

View file

@ -1,7 +1,6 @@
<div <div class="bottom-bar row collapse">
class="bottom-bar row collapse">
<div class="medium-3 small-3 columns text-center bottombar-item" ng-repeat="item in index.menu"> <div class="medium-3 small-3 columns text-center bottombar-item" ng-repeat="item in index.menu">
<a ng-click="index.setTab(item.link)" ng-class="{'active': index.tab == item.link}"> <a ng-click="index.setTab(item.link)" ng-class="{'active': index.tab == item.link}" id="menu-{{item.link}}">
<i class="size-36 {{item.icon}} db"></i> <i class="size-36 {{item.icon}} db"></i>
<div class="size-10 tu"> <div class="size-10 tu">
{{item.title|translate}} {{item.title|translate}}
@ -11,5 +10,5 @@
</div> </div>
</a> </a>
</div> </div>
</div> </div>

View file

@ -10,7 +10,7 @@
</section> </section>
<section class="right-small" ng-show="!goBackToState"> <section class="right-small" ng-show="!goBackToState">
<a ng-show="!closeToHome && index.isComplete" class="p10" <a id="camera-icon" ng-show="!closeToHome && index.isComplete" class="p10"
ng-click="topbar.openScanner()"><i class="fi-camera size-24"></i></a> ng-click="topbar.openScanner()"><i class="fi-camera size-24"></i></a>
<a ng-show="closeToHome" class="p10 ng-animate-disabled" <a ng-show="closeToHome" class="p10 ng-animate-disabled"
ng-click="topbar.goHome(); closeToHome = null"> ng-click="topbar.goHome(); closeToHome = null">

View file

@ -224,7 +224,7 @@
</div> </div>
<div class="row m20t"> <div class="row m20t">
<div class="large-12 columns"> <div class="large-12 columns">
<button class="button black expand radius" ng-click="home.newAddress()" <button class="button black expand radius" ng-click="home.setNewAddress()"
ng-style="{'background-color':index.backgroundColor}" ng-disabled="home.blockUx || index.isOffline ||home.generatingAddress" translate> ng-style="{'background-color':index.backgroundColor}" ng-disabled="home.blockUx || index.isOffline ||home.generatingAddress" translate>
Generate new address Generate new address
</button> </button>

View file

@ -275,7 +275,6 @@ a.missing-copayers {
.sidebar li { .sidebar li {
overflow: hidden; overflow: hidden;
padding: 1rem 0.7rem;
border-bottom: 1px solid #f1f3f5; border-bottom: 1px solid #f1f3f5;
} }
@ -327,15 +326,12 @@ a.missing-copayers {
vertical-align: middle; vertical-align: middle;
font-weight: 300; font-weight: 300;
border-bottom: transparent; border-bottom: transparent;
padding: 0;
color: #A5B2BF; color: #A5B2BF;
padding: 1rem 0.7rem;
} }
.sidebar ul.off-canvas-list li a i { .sidebar ul.off-canvas-list li a i {
vertical-align: middle; vertical-align: middle;
}
.sidebar ul.off-canvas-list li a i {
opacity: 0.6; opacity: 0.6;
} }
@ -774,3 +770,9 @@ textarea:focus
-webkit-transform: translate3d(-100%, 0, 0) !important; -webkit-transform: translate3d(-100%, 0, 0) !important;
transform: translate3d(-100%, 0, 0) !important; transform: translate3d(-100%, 0, 0) !important;
} }
/* removes 300ms in IE */
-ms-touch-action: manipulation; /* IE10 /
touch-action: manipulation; /* IE11+ */

View file

@ -95,6 +95,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.isComplete = fc.isComplete(); self.isComplete = fc.isComplete();
self.txps = []; self.txps = [];
self.copayers = []; self.copayers = [];
self.updateColor();
go.walletHome();
storageService.getBackupFlag(self.walletId, function(err, val) { storageService.getBackupFlag(self.walletId, function(err, val) {
self.needsBackup = self.network == 'testnet' ? false : !val; self.needsBackup = self.network == 'testnet' ? false : !val;
@ -103,10 +105,17 @@ angular.module('copayApp.controllers').controller('indexController', function($r
}); });
}; };
self.setTab = function(tab) { self.setTab = function(tab, reset, tries) {
if (self.tab === tab) tries = tries || 0;
if (self.tab === tab && !reset)
return; return;
if (! document.getElementById('menu-' + tab) && ++tries<5) {
return $timeout(function() {
self.setTab(tab,reset);
}, 300);
}
if (!self.tab) if (!self.tab)
self.tab = 'walletHome'; self.tab = 'walletHome';
@ -257,7 +266,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
}; };
self.openWallet = function() { self.openWallet = function() {
var fc = profileService.focusedClient; var fc = profileService.focusedClient;
self.updateColor();
$timeout(function() { $timeout(function() {
$rootScope.$apply(); $rootScope.$apply();
self.setOngoingProcess('openingWallet', true); self.setOngoingProcess('openingWallet', true);
@ -406,8 +414,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r
}); });
if (used) { if (used) {
$log.debug('Address ' + addr + ' was used. Cleaning Cache.') $log.debug('Address ' + addr + ' was used. Cleaning Cache.')
$rootScope.$emit('Local/NeedNewAddress', err);
storageService.clearLastAddress(self.walletId, function(err) { storageService.clearLastAddress(self.walletId, function(err) {
$rootScope.$emit('Local/NeedNewAddress', err);
if (cb) return cb(); if (cb) return cb();
}); });
}; };
@ -553,17 +561,27 @@ angular.module('copayApp.controllers').controller('indexController', function($r
go.walletHome(); go.walletHome();
}); });
self.debouncedUpdate = lodash.throttle(function() {
self.updateAll();
self.updateTxHistory();
}, 4000, {leading: false, trailing: true});
// No need ot listing to Local/Resume since
// reconnection and Local/Online will be triggered
lodash.each(['Local/Online', 'Local/Resume'], function(eventName) { lodash.each(['Local/Online', 'Local/Resume'], function(eventName) {
$rootScope.$on(eventName, function(event) { $rootScope.$on(eventName, function(event) {
$log.debug('### Online event'); $log.debug('### ' + eventName + ' event');
self.isOffline = false; self.debouncedUpdate();
self.updateAll();
self.updateTxHistory();
}); });
}); });
$rootScope.$on('Local/Online', function(event) {
self.isOffline = false;
});
$rootScope.$on('Local/Offline', function(event) { $rootScope.$on('Local/Offline', function(event) {
$log.debug('Offline event'); $log.debug('### Offline event');
self.isOffline = true; self.isOffline = true;
$timeout(function() { $timeout(function() {
$rootScope.$apply(); $rootScope.$apply();
@ -686,8 +704,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.updateTxHistory(); self.updateTxHistory();
}); });
$rootScope.$on('Local/SetTab', function(event, tab) { $rootScope.$on('Local/SetTab', function(event, tab, reset) {
self.setTab(tab); self.setTab(tab, reset);
}); });
$rootScope.$on('Local/NeedsPassword', function(event, isSetup, cb) { $rootScope.$on('Local/NeedsPassword', function(event, isSetup, cb) {

View file

@ -21,8 +21,8 @@ angular.module('copayApp.controllers').controller('sidebarController',
self.switchWallet = function(wid) { self.switchWallet = function(wid) {
self.walletSelection = false; self.walletSelection = false;
profileService.setAndStoreFocus(wid, function() {}); profileService.setAndStoreFocus(wid, function() {
go.walletHome(); });
}; };
self.toggleWalletSelection = function() { self.toggleWalletSelection = function() {

View file

@ -25,33 +25,51 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
this.isMobile = isMobile.any(); this.isMobile = isMobile.any();
var disableScannerListener = $rootScope.$on('dataScanned', function(event, data) { var disableScannerListener = $rootScope.$on('dataScanned', function(event, data) {
$scope.$emit('Local/SetTab', 'send');
self.setForm(data); self.setForm(data);
$rootScope.$emit('Local/SetTab', 'send');
}); });
var disablePaymentUriListener = $rootScope.$on('paymentUri', function(event, uri) { var disablePaymentUriListener = $rootScope.$on('paymentUri', function(event, uri) {
$timeout(function() { $timeout(function() {
$scope.$emit('Local/SetTab', 'send'); $rootScope.$emit('Local/SetTab', 'send');
self.setForm(uri); self.setForm(uri);
}, 100); }, 100);
}); });
var disableAddrListener = $rootScope.$on('Local/NeedNewAddress', function() { var disableAddrListener = $rootScope.$on('Local/NeedNewAddress', function() {
self.getAddress(); self.setNewAddress();
}); });
var disableFocusListener = $rootScope.$on('Local/NewFocusedWallet', function() { var disableFocusListener = $rootScope.$on('Local/NewFocusedWallet', function() {
self.addr = null;
self.resetForm(); self.resetForm();
}); });
var disableOnlineListener = $rootScope.$on('Local/Online', function() {
// This is needed then the apps go to sleep
$timeout(function() {
self.bindTouchDown();
}, 2000);
});
var disableResumeListener = $rootScope.$on('Local/Resume', function() {
// This is needed then the apps go to sleep
$timeout(function() {
self.bindTouchDown();
}, 2000);
});
var disableTabListener = $rootScope.$on('Local/TabChanged', function(e, tab) { var disableTabListener = $rootScope.$on('Local/TabChanged', function(e, tab) {
// This will slow down switch, do not add things here!
switch (tab) { switch (tab) {
case 'receive':
// just to be sure we have an address
self.setAddress();
break;
case 'send': case 'send':
self.resetError(); self.resetError();
self.setInputs();
case 'receive':
self.getAddress();
break;
}; };
}); });
@ -61,6 +79,8 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
disablePaymentUriListener(); disablePaymentUriListener();
disableTabListener(); disableTabListener();
disableFocusListener(); disableFocusListener();
disableResumeListener();
disableOnlineListener();
$rootScope.hideMenuBar = false; $rootScope.hideMenuBar = false;
}); });
@ -267,17 +287,17 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
}); });
modalInstance.result.then(function(txp) { modalInstance.result.then(function(txp) {
$scope.$emit('Local/TxProposalAction');
if (txp) { if (txp) {
self.setOngoingProcess();
txStatus.notify(txp); txStatus.notify(txp);
} }
$scope.$emit('Local/TxProposalAction');
}); });
}; };
// Receive // Receive
this.setNewAddress = function() {
this.newAddress = function() {
var fc = profileService.focusedClient; var fc = profileService.focusedClient;
self.generatingAddress = true; self.generatingAddress = true;
fc.createAddress(function(err, addr) { fc.createAddress(function(err, addr) {
@ -297,16 +317,19 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
}); });
}; };
this.getAddress = function() { this.setAddress = function() {
if (self.addr)
return;
var fc = profileService.focusedClient; var fc = profileService.focusedClient;
$timeout(function() { $timeout(function() {
storageService.getLastAddress(fc.credentials.walletId, function(err, addr) { storageService.getLastAddress(fc.credentials.walletId, function(err, addr) {
if (addr) { if (addr) {
self.addr = addr; self.addr = addr;
$scope.$digest();
} else { } else {
self.newAddress(); self.setNewAddress();
} }
$scope.$digest();
}); });
}); });
}; };
@ -345,10 +368,29 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
this.error = this.success = null; this.error = this.success = null;
}; };
this.bindTouchDown = function(tries) {
var self = this;
tries = tries || 0;
if (tries > 5) return;
var e = document.getElementById('menu-walletHome');
if (!e) return $timeout(function() {
self.bindTouchDown(++tries);
}, 500);
var hideMenuBar = lodash.debounce(function(hide) { // on touchdown elements
$log.debug('Binding touchstart elements...');
['menu-walletHome', 'menu-send', 'menu-receive', 'menu-history'].forEach(function(id) {
var e = document.getElementById(id);
if (e) e.addEventListener('touchstart', function() {
angular.element(e).triggerHandler('click');
});
});
}
this.hideMenuBar = lodash.debounce(function(hide) {
if (hide) { if (hide) {
$rootScope.hideMenuBar = true; $rootScope.hideMenuBar = true;
this.bindTouchDown();
} else { } else {
$rootScope.hideMenuBar = false; $rootScope.hideMenuBar = false;
} }
@ -358,7 +400,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
this.formFocus = function(what) { this.formFocus = function(what) {
if (isCordova && !this.isWindowsPhoneApp) { if (isCordova && !this.isWindowsPhoneApp) {
hideMenuBar(what); this.hideMenuBar(what);
} }
if (!this.isWindowsPhoneApp) return if (!this.isWindowsPhoneApp) return
@ -379,7 +421,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
}, 1); }, 1);
}; };
this.setInputs = function() { this.setSendFormInputs = function() {
var unitToSat = this.unitToSatoshi; var unitToSat = this.unitToSatoshi;
var satToUnit = 1 / unitToSat; var satToUnit = 1 / unitToSat;
/** /**
@ -454,16 +496,17 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
if (isCordova) { if (isCordova) {
if (name) { if (name) {
window.plugins.spinnerDialog.hide();
window.plugins.spinnerDialog.show(null, name + '...', true); window.plugins.spinnerDialog.show(null, name + '...', true);
} else { } else {
window.plugins.spinnerDialog.hide(); window.plugins.spinnerDialog.hide();
} }
} else { } else {
self.onGoingProcess = name;
$timeout(function() { $timeout(function() {
self.onGoingProcess = name;
$rootScope.$apply(); $rootScope.$apply();
}); });
} };
}; };
this.submitForm = function() { this.submitForm = function() {
@ -532,22 +575,21 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
if (signedTx.status == 'accepted') { if (signedTx.status == 'accepted') {
self.setOngoingProcess('Broadcasting transaction'); self.setOngoingProcess('Broadcasting transaction');
fc.broadcastTxProposal(signedTx, function(err, btx) { fc.broadcastTxProposal(signedTx, function(err, btx) {
self.setOngoingProcess();
if (err) { if (err) {
self.setOngoingProcess();
$scope.error = 'Transaction not broadcasted. Please try again.'; $scope.error = 'Transaction not broadcasted. Please try again.';
$scope.$digest(); $scope.$digest();
return; return cb(err);
} }
$scope.$emit('Local/TxProposalAction'); $scope.$emit('Local/TxProposalAction');
txStatus.notify(btx, function() { txStatus.notify(btx, function() {
self.setOngoingProcess();
return cb(); return cb();
}); });
}); });
} else { } else {
self.setOngoingProcess();
$scope.$emit('Local/TxProposalAction'); $scope.$emit('Local/TxProposalAction');
txStatus.notify(signedTx, function() { txStatus.notify(signedTx, function() {
self.setOngoingProcess();
return cb(); return cb();
}); });
} }
@ -790,4 +832,9 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
return actions.hasOwnProperty('create'); return actions.hasOwnProperty('create');
}; };
// Startup events
this.bindTouchDown();
this.setAddress();
this.setSendFormInputs();
}); });

View file

@ -18,6 +18,8 @@ angular.element(document).ready(function() {
}, false); }, false);
document.addEventListener('resume', function() { document.addEventListener('resume', function() {
console.log('[init.js.21] RESUME'); //TODO
if (!window.ignoreMobilePause) { if (!window.ignoreMobilePause) {
window.location = '#/cordova/resume'; window.location = '#/cordova/resume';
} }
@ -31,10 +33,6 @@ angular.element(document).ready(function() {
document.addEventListener('offline', function() { document.addEventListener('offline', function() {
window.location = '#/cordova/offline'; window.location = '#/cordova/offline';
}, false); }, false);
//
// document.addEventListener("online", function() {
// window.location = '#/cordoba/online';
// }, false);
// Back button event // Back button event
document.addEventListener('backbutton', function() { document.addEventListener('backbutton', function() {

View file

@ -443,16 +443,13 @@ angular
url: '/cordova/:status', url: '/cordova/:status',
views: { views: {
'main': { 'main': {
controller: function($scope, $stateParams, go) { controller: function($rootScope, $stateParams, go) {
switch ($stateParams.status) { switch ($stateParams.status) {
case 'resume': case 'resume':
$scope.$emit('Local/Resume'); $rootScope.$emit('Local/Resume');
break; break;
// case 'online':
// // $scope.$emit('Local/Online');
// break;
case 'offline': case 'offline':
$scope.$emit('Local/Offline'); $rootScope.$emit('Local/Offline');
break; break;
}; };
go.walletHome(); go.walletHome();
@ -506,6 +503,7 @@ angular
importLegacy: 12 importLegacy: 12
}; };
$rootScope.$on('$stateChangeSuccess', function() { $rootScope.$on('$stateChangeSuccess', function() {
$rootScope.$emit('Animation/Disable'); $rootScope.$emit('Animation/Disable');
}); });

View file

@ -55,7 +55,7 @@ angular.module('copayApp.services').factory('go', function($window, $rootScope,
root.path('copayers'); root.path('copayers');
} else { } else {
root.path('walletHome', function() { root.path('walletHome', function() {
$rootScope.$emit('Local/SetTab', 'walletHome'); $rootScope.$emit('Local/SetTab', 'walletHome', true);
}); });
} }
}; };