Merge branch 'ref/design' of github.com:matiu/copay into ref/design
This commit is contained in:
commit
3bac497049
6 changed files with 186 additions and 174 deletions
|
|
@ -1,72 +1,88 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('searchController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $ionicNavBarDelegate, $state, $stateParams, $ionicScrollDelegate, bwcError, profileService, lodash, configService, gettext, gettextCatalog, platformInfo, walletService) {
|
||||
|
||||
//
|
||||
// self.startSearch = function() {
|
||||
// self.isSearching = true;
|
||||
// self.txHistorySearchResults = [];
|
||||
// self.result = [];
|
||||
// self.historyShowMore = false;
|
||||
// self.nextTxHistory = self.historyShowMoreLimit;
|
||||
// }
|
||||
//
|
||||
// self.cancelSearch = function() {
|
||||
// self.isSearching = false;
|
||||
// self.result = [];
|
||||
// self.setCompactTxHistory();
|
||||
// }
|
||||
//
|
||||
// self.updateSearchInput = function(search) {
|
||||
// self.search = search;
|
||||
// if (isCordova)
|
||||
// window.plugins.toast.hide();
|
||||
// self.throttleSearch();
|
||||
// $ionicScrollDelegate.resize();
|
||||
// }
|
||||
//
|
||||
// self.throttleSearch = lodash.throttle(function() {
|
||||
//
|
||||
// function filter(search) {
|
||||
// self.result = [];
|
||||
//
|
||||
// function computeSearchableString(tx) {
|
||||
// var addrbook = '';
|
||||
// if (tx.addressTo && self.addressbook && self.addressbook[tx.addressTo]) addrbook = self.addressbook[tx.addressTo] || '';
|
||||
// var searchableDate = computeSearchableDate(new Date(tx.time * 1000));
|
||||
// var message = tx.message ? tx.message : '';
|
||||
// var comment = tx.note ? tx.note.body : '';
|
||||
// var addressTo = tx.addressTo ? tx.addressTo : '';
|
||||
// return ((tx.amountStr + message + addressTo + addrbook + searchableDate + comment).toString()).toLowerCase();
|
||||
// }
|
||||
//
|
||||
// function computeSearchableDate(date) {
|
||||
// var day = ('0' + date.getDate()).slice(-2).toString();
|
||||
// var month = ('0' + (date.getMonth() + 1)).slice(-2).toString();
|
||||
// var year = date.getFullYear();
|
||||
// return [month, day, year].join('/');
|
||||
// };
|
||||
//
|
||||
// if (lodash.isEmpty(search)) {
|
||||
// self.historyShowMore = false;
|
||||
// return [];
|
||||
// }
|
||||
// self.result = lodash.filter(self.completeHistory, function(tx) {
|
||||
// if (!tx.searcheableString) tx.searcheableString = computeSearchableString(tx);
|
||||
// return lodash.includes(tx.searcheableString, search.toLowerCase());
|
||||
// });
|
||||
//
|
||||
// if (self.result.length > self.historyShowLimit) self.historyShowMore = true;
|
||||
// else self.historyShowMore = false;
|
||||
//
|
||||
// return self.result;
|
||||
// };
|
||||
//
|
||||
// self.txHistorySearchResults = filter(self.search).slice(0, self.historyShowLimit);
|
||||
// if (isCordova)
|
||||
// window.plugins.toast.showShortBottom(gettextCatalog.getString('Matches: ' + self.result.length));
|
||||
//
|
||||
// $timeout(function() {
|
||||
// $rootScope.$apply();
|
||||
// });
|
||||
//
|
||||
// }, 1000);
|
||||
//
|
||||
var HISTORY_SHOW_LIMIT = 10;
|
||||
var currentTxHistoryPage = 0;
|
||||
var wallet;
|
||||
var isCordova = platformInfo.isCordova;
|
||||
$scope.txHistorySearchResults = [];
|
||||
$scope.filteredTxHistory = [];
|
||||
|
||||
$scope.cancel = function() {
|
||||
$scope.searchModal.hide();
|
||||
};
|
||||
|
||||
$scope.cancelSearch = function() {
|
||||
$scope.txHistorySearchResults = [];
|
||||
$scope.filteredTxHistory = [];
|
||||
$scope.search = '';
|
||||
$scope.currentTxHistoryPage = 0;
|
||||
$ionicScrollDelegate.resize();
|
||||
}
|
||||
|
||||
$scope.updateSearchInput = function(search) {
|
||||
if (isCordova)
|
||||
window.plugins.toast.hide();
|
||||
throttleSearch(search);
|
||||
$ionicScrollDelegate.resize();
|
||||
}
|
||||
|
||||
var throttleSearch = lodash.throttle(function(search) {
|
||||
|
||||
function filter(search) {
|
||||
$scope.filteredTxHistory = [];
|
||||
|
||||
function computeSearchableString(tx) {
|
||||
var addrbook = '';
|
||||
if (tx.addressTo && self.addressbook && self.addressbook[tx.addressTo]) addrbook = self.addressbook[tx.addressTo] || '';
|
||||
var searchableDate = computeSearchableDate(new Date(tx.time * 1000));
|
||||
var message = tx.message ? tx.message : '';
|
||||
var comment = tx.note ? tx.note.body : '';
|
||||
var addressTo = tx.addressTo ? tx.addressTo : '';
|
||||
return ((tx.amountStr + message + addressTo + addrbook + searchableDate + comment).toString()).toLowerCase();
|
||||
}
|
||||
|
||||
function computeSearchableDate(date) {
|
||||
var day = ('0' + date.getDate()).slice(-2).toString();
|
||||
var month = ('0' + (date.getMonth() + 1)).slice(-2).toString();
|
||||
var year = date.getFullYear();
|
||||
return [month, day, year].join('/');
|
||||
};
|
||||
|
||||
if (lodash.isEmpty(search)) {
|
||||
$scope.txHistoryShowMore = false;
|
||||
return [];
|
||||
}
|
||||
|
||||
$scope.filteredTxHistory = lodash.filter($scope.completeTxHistory, function(tx) {
|
||||
if (!tx.searcheableString) tx.searcheableString = computeSearchableString(tx);
|
||||
return lodash.includes(tx.searcheableString, search.toLowerCase());
|
||||
});
|
||||
|
||||
if ($scope.filteredTxHistory.length > HISTORY_SHOW_LIMIT) $scope.txHistoryShowMore = true;
|
||||
else $scope.txHistoryShowMore = false;
|
||||
|
||||
return $scope.filteredTxHistory;
|
||||
};
|
||||
$scope.txHistorySearchResults = filter(search).slice(0, HISTORY_SHOW_LIMIT);
|
||||
if (isCordova)
|
||||
window.plugins.toast.showShortBottom(gettextCatalog.getString('Matches: ' + $scope.filteredTxHistory.length));
|
||||
$timeout(function() {
|
||||
$rootScope.$apply();
|
||||
});
|
||||
|
||||
}, 1000);
|
||||
|
||||
$scope.moreSearchResults = function() {
|
||||
currentTxHistoryPage++;
|
||||
$scope.showHistory();
|
||||
$scope.$broadcast('scroll.infiniteScrollComplete');
|
||||
};
|
||||
|
||||
$scope.showHistory = function() {
|
||||
$scope.txHistorySearchResults = $scope.filteredTxHistory ? $scope.filteredTxHistory.slice(0, (currentTxHistoryPage + 1) * HISTORY_SHOW_LIMIT) : [];
|
||||
$scope.txHistoryShowMore = $scope.filteredTxHistory.length > $scope.txHistorySearchResults.length;
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
$scope.openSearchModal = function() {
|
||||
var wallet = profileService.getWallet($stateParams.walletId);
|
||||
$scope.color = wallet.color;
|
||||
$scope.self = self;
|
||||
|
||||
$ionicModal.fromTemplateUrl('views/modals/search.html', {
|
||||
scope: $scope,
|
||||
|
|
@ -73,7 +72,7 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
|
||||
var progressFn = function(txs) {
|
||||
$scope.updatingTxHistoryProgress = txs ? txs.length : 0;
|
||||
completeTxHistory = txs;
|
||||
$scope.completeTxHistory = txs;
|
||||
$scope.showHistory();
|
||||
$scope.$digest();
|
||||
};
|
||||
|
|
@ -88,7 +87,7 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
$scope.updateTxHistoryError = true;
|
||||
return;
|
||||
}
|
||||
completeTxHistory = txHistory;
|
||||
$scope.completeTxHistory = txHistory;
|
||||
|
||||
$scope.showHistory();
|
||||
$scope.$apply();
|
||||
|
|
@ -97,12 +96,9 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
};
|
||||
|
||||
$scope.showHistory = function() {
|
||||
if ($scope.isSearching) {
|
||||
$scope.txHistorySearchResults = filteredTxHistory ? filteredTxHistory.slice(0, (currentTxHistoryPage + 1) * HISTORY_SHOW_LIMIT) : [];
|
||||
$scope.txHistoryShowMore = filteredTxHistory.length > $scope.txHistorySearchResults.length;
|
||||
} else if (completeTxHistory) {
|
||||
$scope.txHistory = completeTxHistory.slice(0, (currentTxHistoryPage + 1) * HISTORY_SHOW_LIMIT);
|
||||
$scope.txHistoryShowMore = completeTxHistory.length > $scope.txHistory.length;
|
||||
if ($scope.completeTxHistory) {
|
||||
$scope.txHistory = $scope.completeTxHistory.slice(0, (currentTxHistoryPage + 1) * HISTORY_SHOW_LIMIT);
|
||||
$scope.txHistoryShowMore = $scope.completeTxHistory.length > $scope.txHistory.length;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -122,12 +118,11 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
};
|
||||
|
||||
var currentTxHistoryPage;
|
||||
var completeTxHistory;
|
||||
var wallet;
|
||||
|
||||
$scope.init = function() {
|
||||
currentTxHistoryPage = 0;
|
||||
completeTxHistory = [];
|
||||
$scope.completeTxHistory = [];
|
||||
|
||||
wallet = profileService.getWallet($stateParams.walletId);
|
||||
$scope.wallet = wallet;
|
||||
|
|
|
|||
|
|
@ -608,7 +608,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
*
|
||||
*/
|
||||
|
||||
.state('amazon', {
|
||||
.state('amazon', {
|
||||
url: '/amazon',
|
||||
abstract: true,
|
||||
template: '<ion-nav-view name="amazon"></ion-nav-view>'
|
||||
|
|
@ -630,7 +630,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
}
|
||||
});
|
||||
})
|
||||
.run(function($rootScope, $state, $location, $log, $timeout, $ionicPlatform, lodash, platformInfo, profileService, uxLanguage, gettextCatalog) {
|
||||
.run(function($rootScope, $state, $location, $log, $timeout, $ionicHistory, $ionicPlatform, lodash, platformInfo, profileService, uxLanguage, gettextCatalog) {
|
||||
|
||||
if (platformInfo.isCordova) {
|
||||
if (screen.width < 768) {
|
||||
|
|
@ -678,14 +678,28 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
StatusBar.styleLightContent();
|
||||
}
|
||||
|
||||
$ionicPlatform.registerBackButtonAction(function(event) {
|
||||
event.preventDefault();
|
||||
}, 100);
|
||||
$ionicPlatform.registerBackButtonAction(function(e) {
|
||||
|
||||
var secondBackButtonPress = false;
|
||||
var intval = setInterval(function() {
|
||||
secondBackButtonPress = false;
|
||||
}, 5000);
|
||||
var fromDisclaimer = $ionicHistory.currentStateName().match(/disclaimer/) ? 'true' : '';
|
||||
var fromTabs = $ionicHistory.currentStateName().match(/tabs/) ? 'true' : '';
|
||||
|
||||
if ($rootScope.backButtonPressedOnceToExit || fromDisclaimer) {
|
||||
ionic.Platform.exitApp();
|
||||
}
|
||||
|
||||
else if ($ionicHistory.backView() && !fromTabs) {
|
||||
$ionicHistory.goBack();
|
||||
}
|
||||
else {
|
||||
$rootScope.backButtonPressedOnceToExit = true;
|
||||
window.plugins.toast.showShortBottom(gettextCatalog.getString('Press again to exit'));
|
||||
setInterval(function() {
|
||||
$rootScope.backButtonPressedOnceToExit = false;
|
||||
}, 5000);
|
||||
}
|
||||
e.preventDefault();
|
||||
},
|
||||
101);
|
||||
|
||||
$ionicPlatform.on('pause', function() {
|
||||
// Nothing to do
|
||||
|
|
@ -695,30 +709,6 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
$rootScope.$emit('Local/Resume');
|
||||
});
|
||||
|
||||
$ionicPlatform.on('backbutton', function(event) {
|
||||
|
||||
var loc = window.location;
|
||||
var fromDisclaimer = loc.toString().match(/disclaimer/) ? 'true' : '';
|
||||
var fromHome = loc.toString().match(/index\.html#\/$/) ? 'true' : '';
|
||||
|
||||
if (fromDisclaimer == 'true')
|
||||
navigator.app.exitApp();
|
||||
|
||||
if (platformInfo.isMobile && fromHome == 'true') {
|
||||
if (secondBackButtonPress)
|
||||
navigator.app.exitApp();
|
||||
else
|
||||
window.plugins.toast.showShortBottom(gettextCatalog.getString('Press again to exit'));
|
||||
}
|
||||
|
||||
if (secondBackButtonPress)
|
||||
clearInterval(intval);
|
||||
else
|
||||
secondBackButtonPress = true;
|
||||
|
||||
$state.go('tabs.home');
|
||||
});
|
||||
|
||||
$ionicPlatform.on('menubutton', function() {
|
||||
window.location = '#/preferences';
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue