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
class="bottom-bar row collapse">
<div class="bottom-bar row collapse">
<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>
<div class="size-10 tu">
{{item.title|translate}}
@ -11,5 +10,5 @@
</div>
</a>
</div>
</div>

View file

@ -10,7 +10,7 @@
</section>
<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>
<a ng-show="closeToHome" class="p10 ng-animate-disabled"
ng-click="topbar.goHome(); closeToHome = null">

View file

@ -224,7 +224,7 @@
</div>
<div class="row m20t">
<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>
Generate new address
</button>

View file

@ -275,7 +275,6 @@ a.missing-copayers {
.sidebar li {
overflow: hidden;
padding: 1rem 0.7rem;
border-bottom: 1px solid #f1f3f5;
}
@ -327,15 +326,12 @@ a.missing-copayers {
vertical-align: middle;
font-weight: 300;
border-bottom: transparent;
padding: 0;
color: #A5B2BF;
padding: 1rem 0.7rem;
}
.sidebar ul.off-canvas-list li a i {
vertical-align: middle;
}
.sidebar ul.off-canvas-list li a i {
opacity: 0.6;
}
@ -774,3 +770,9 @@ textarea:focus
-webkit-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.txps = [];
self.copayers = [];
self.updateColor();
go.walletHome();
storageService.getBackupFlag(self.walletId, function(err, val) {
self.needsBackup = self.network == 'testnet' ? false : !val;
@ -103,10 +105,17 @@ angular.module('copayApp.controllers').controller('indexController', function($r
});
};
self.setTab = function(tab) {
if (self.tab === tab)
self.setTab = function(tab, reset, tries) {
tries = tries || 0;
if (self.tab === tab && !reset)
return;
if (! document.getElementById('menu-' + tab) && ++tries<5) {
return $timeout(function() {
self.setTab(tab,reset);
}, 300);
}
if (!self.tab)
self.tab = 'walletHome';
@ -257,7 +266,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
};
self.openWallet = function() {
var fc = profileService.focusedClient;
self.updateColor();
$timeout(function() {
$rootScope.$apply();
self.setOngoingProcess('openingWallet', true);
@ -406,8 +414,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r
});
if (used) {
$log.debug('Address ' + addr + ' was used. Cleaning Cache.')
$rootScope.$emit('Local/NeedNewAddress', err);
storageService.clearLastAddress(self.walletId, function(err) {
$rootScope.$emit('Local/NeedNewAddress', err);
if (cb) return cb();
});
};
@ -553,17 +561,27 @@ angular.module('copayApp.controllers').controller('indexController', function($r
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) {
$rootScope.$on(eventName, function(event) {
$log.debug('### Online event');
self.isOffline = false;
self.updateAll();
self.updateTxHistory();
$log.debug('### ' + eventName + ' event');
self.debouncedUpdate();
});
});
$rootScope.$on('Local/Online', function(event) {
self.isOffline = false;
});
$rootScope.$on('Local/Offline', function(event) {
$log.debug('Offline event');
$log.debug('### Offline event');
self.isOffline = true;
$timeout(function() {
$rootScope.$apply();
@ -686,8 +704,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.updateTxHistory();
});
$rootScope.$on('Local/SetTab', function(event, tab) {
self.setTab(tab);
$rootScope.$on('Local/SetTab', function(event, tab, reset) {
self.setTab(tab, reset);
});
$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.walletSelection = false;
profileService.setAndStoreFocus(wid, function() {});
go.walletHome();
profileService.setAndStoreFocus(wid, function() {
});
};
self.toggleWalletSelection = function() {

View file

@ -25,33 +25,51 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
this.isMobile = isMobile.any();
var disableScannerListener = $rootScope.$on('dataScanned', function(event, data) {
$scope.$emit('Local/SetTab', 'send');
self.setForm(data);
$rootScope.$emit('Local/SetTab', 'send');
});
var disablePaymentUriListener = $rootScope.$on('paymentUri', function(event, uri) {
$timeout(function() {
$scope.$emit('Local/SetTab', 'send');
$rootScope.$emit('Local/SetTab', 'send');
self.setForm(uri);
}, 100);
});
var disableAddrListener = $rootScope.$on('Local/NeedNewAddress', function() {
self.getAddress();
self.setNewAddress();
});
var disableFocusListener = $rootScope.$on('Local/NewFocusedWallet', function() {
self.addr = null;
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) {
// This will slow down switch, do not add things here!
switch (tab) {
case 'receive':
// just to be sure we have an address
self.setAddress();
break;
case 'send':
self.resetError();
self.setInputs();
case 'receive':
self.getAddress();
break;
};
});
@ -61,6 +79,8 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
disablePaymentUriListener();
disableTabListener();
disableFocusListener();
disableResumeListener();
disableOnlineListener();
$rootScope.hideMenuBar = false;
});
@ -267,17 +287,17 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
});
modalInstance.result.then(function(txp) {
$scope.$emit('Local/TxProposalAction');
if (txp) {
self.setOngoingProcess();
txStatus.notify(txp);
}
$scope.$emit('Local/TxProposalAction');
});
};
// Receive
this.newAddress = function() {
this.setNewAddress = function() {
var fc = profileService.focusedClient;
self.generatingAddress = true;
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;
$timeout(function() {
storageService.getLastAddress(fc.credentials.walletId, function(err, addr) {
if (addr) {
self.addr = addr;
$scope.$digest();
} else {
self.newAddress();
self.setNewAddress();
}
$scope.$digest();
});
});
};
@ -345,10 +368,29 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
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) {
$rootScope.hideMenuBar = true;
this.bindTouchDown();
} else {
$rootScope.hideMenuBar = false;
}
@ -358,7 +400,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
this.formFocus = function(what) {
if (isCordova && !this.isWindowsPhoneApp) {
hideMenuBar(what);
this.hideMenuBar(what);
}
if (!this.isWindowsPhoneApp) return
@ -379,7 +421,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
}, 1);
};
this.setInputs = function() {
this.setSendFormInputs = function() {
var unitToSat = this.unitToSatoshi;
var satToUnit = 1 / unitToSat;
/**
@ -454,16 +496,17 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
if (isCordova) {
if (name) {
window.plugins.spinnerDialog.hide();
window.plugins.spinnerDialog.show(null, name + '...', true);
} else {
window.plugins.spinnerDialog.hide();
}
} else {
self.onGoingProcess = name;
$timeout(function() {
self.onGoingProcess = name;
$rootScope.$apply();
});
}
};
};
this.submitForm = function() {
@ -532,22 +575,21 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
if (signedTx.status == 'accepted') {
self.setOngoingProcess('Broadcasting transaction');
fc.broadcastTxProposal(signedTx, function(err, btx) {
self.setOngoingProcess();
if (err) {
self.setOngoingProcess();
$scope.error = 'Transaction not broadcasted. Please try again.';
$scope.$digest();
return;
return cb(err);
}
$scope.$emit('Local/TxProposalAction');
txStatus.notify(btx, function() {
self.setOngoingProcess();
return cb();
});
});
} else {
self.setOngoingProcess();
$scope.$emit('Local/TxProposalAction');
txStatus.notify(signedTx, function() {
self.setOngoingProcess();
return cb();
});
}
@ -790,4 +832,9 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
return actions.hasOwnProperty('create');
};
// Startup events
this.bindTouchDown();
this.setAddress();
this.setSendFormInputs();
});

View file

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

View file

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

View file

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