add popover menu to share/scan addresses
This commit is contained in:
parent
439300743d
commit
de65f88b9e
10 changed files with 117 additions and 59 deletions
|
|
@ -1,8 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('addressesController', function($scope, $stateParams, $state, $timeout, $ionicScrollDelegate, configService, popupService, gettextCatalog, ongoingProcess, lodash, profileService, walletService) {
|
||||
angular.module('copayApp.controllers').controller('addressesController', function($scope, $stateParams, $state, $timeout, $ionicHistory, $ionicPopover, $ionicScrollDelegate, configService, popupService, gettextCatalog, ongoingProcess, lodash, profileService, walletService, platformInfo) {
|
||||
var UNUSED_ADDRESS_LIMIT = 5;
|
||||
var BALANCE_ADDRESS_LIMIT = 5;
|
||||
var MENU_ITEM_HEIGHT = 55;
|
||||
var config;
|
||||
var unitName;
|
||||
var unitToSatoshi;
|
||||
|
|
@ -11,6 +12,8 @@ angular.module('copayApp.controllers').controller('addressesController', functio
|
|||
var withBalance;
|
||||
$scope.showInfo = false;
|
||||
$scope.showMore = false;
|
||||
$scope.allAddressesView = false;
|
||||
$scope.isCordova = platformInfo.isCordova;
|
||||
$scope.wallet = profileService.getWallet($stateParams.walletId);
|
||||
|
||||
function init() {
|
||||
|
|
@ -111,6 +114,79 @@ angular.module('copayApp.controllers').controller('addressesController', functio
|
|||
});
|
||||
};
|
||||
|
||||
$scope.showMenu = function(allAddresses, $event) {
|
||||
var scanObj = {
|
||||
text: gettextCatalog.getString('Scan addresses for funds'),
|
||||
action: scan,
|
||||
};
|
||||
|
||||
var sendAddressesObj = {
|
||||
text: gettextCatalog.getString('Send addresses by email'),
|
||||
action: sendByEmail,
|
||||
}
|
||||
|
||||
$scope.items = allAddresses ? [sendAddressesObj] : [scanObj];
|
||||
$scope.height = $scope.items.length * MENU_ITEM_HEIGHT;
|
||||
|
||||
$ionicPopover.fromTemplateUrl('views/includes/menu-popover.html', {
|
||||
scope: $scope
|
||||
}).then(function(popover) {
|
||||
$scope.menu = popover;
|
||||
$scope.menu.show($event);
|
||||
});
|
||||
};
|
||||
|
||||
var scan = function() {
|
||||
walletService.startScan($scope.wallet);
|
||||
$scope.menu.hide();
|
||||
$ionicHistory.clearHistory();
|
||||
$state.go('tabs.home');
|
||||
};
|
||||
|
||||
var sendByEmail = function() {
|
||||
function formatDate(ts) {
|
||||
var dateObj = new Date(ts * 1000);
|
||||
if (!dateObj) {
|
||||
$log.debug('Error formating a date');
|
||||
return 'DateError';
|
||||
}
|
||||
if (!dateObj.toJSON()) {
|
||||
return '';
|
||||
}
|
||||
return dateObj.toJSON();
|
||||
};
|
||||
|
||||
ongoingProcess.set('sendingByEmail', true);
|
||||
$timeout(function() {
|
||||
var body = 'Copay Wallet "' + $scope.walletName + '" Addresses\n Only Main Addresses are shown.\n\n';
|
||||
body += "\n";
|
||||
body += $scope.allAddresses.map(function(v) {
|
||||
return ('* ' + v.address + ' ' + 'xpub' + v.path.substring(1) + ' ' + formatDate(v.createdOn));
|
||||
}).join("\n");
|
||||
ongoingProcess.set('sendingByEmail', false);
|
||||
|
||||
window.plugins.socialsharing.shareViaEmail(
|
||||
body,
|
||||
'Copay Addresses',
|
||||
null, // TO: must be null or an array
|
||||
null, // CC: must be null or an array
|
||||
null, // BCC: must be null or an array
|
||||
null, // FILES: can be null, a string, or an array
|
||||
function() {},
|
||||
function() {}
|
||||
);
|
||||
|
||||
$scope.menu.hide();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
$scope.allAddressesView = data.stateName == 'tabs.receive.allAddresses' ? true : false;
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
});
|
||||
|
||||
$scope.$on("$ionicView.afterEnter", function(event, data) {
|
||||
config = configService.getSync().wallet.settings;
|
||||
unitToSatoshi = config.unitToSatoshi;
|
||||
|
|
|
|||
|
|
@ -1,59 +1,15 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('preferencesInformation',
|
||||
function($scope, $log, $timeout, $ionicHistory, platformInfo, lodash, profileService, configService, $stateParams, walletService, $state) {
|
||||
var base = 'xpub';
|
||||
function($scope, $log, $ionicHistory, platformInfo, lodash, profileService, configService, $stateParams, $state) {
|
||||
var wallet = profileService.getWallet($stateParams.walletId);
|
||||
var walletId = wallet.id;
|
||||
var config = configService.getSync();
|
||||
var b = 1;
|
||||
var colorCounter = 1;
|
||||
var BLACK_WALLET_COLOR = '#202020';
|
||||
$scope.isCordova = platformInfo.isCordova;
|
||||
config.colorFor = config.colorFor || {};
|
||||
|
||||
$scope.sendAddrs = function() {
|
||||
function formatDate(ts) {
|
||||
var dateObj = new Date(ts * 1000);
|
||||
if (!dateObj) {
|
||||
$log.debug('Error formating a date');
|
||||
return 'DateError';
|
||||
}
|
||||
if (!dateObj.toJSON()) {
|
||||
return '';
|
||||
}
|
||||
return dateObj.toJSON();
|
||||
};
|
||||
|
||||
$timeout(function() {
|
||||
walletService.getMainAddresses(wallet, {}, function(err, addrs) {
|
||||
if (err) {
|
||||
$log.warn(err);
|
||||
return;
|
||||
};
|
||||
|
||||
var body = 'Copay Wallet "' + $scope.walletName + '" Addresses\n Only Main Addresses are shown.\n\n';
|
||||
body += "\n";
|
||||
body += addrs.map(function(v) {
|
||||
return ('* ' + v.address + ' ' + base + v.path.substring(1) + ' ' + formatDate(v.createdOn));
|
||||
}).join("\n");
|
||||
|
||||
window.plugins.socialsharing.shareViaEmail(
|
||||
body,
|
||||
'Copay Addresses',
|
||||
null, // TO: must be null or an array
|
||||
null, // CC: must be null or an array
|
||||
null, // BCC: must be null or an array
|
||||
null, // FILES: can be null, a string, or an array
|
||||
function() {},
|
||||
function() {}
|
||||
);
|
||||
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.saveBlack = function() {
|
||||
function save(color) {
|
||||
var opts = {
|
||||
|
|
@ -68,14 +24,8 @@ angular.module('copayApp.controllers').controller('preferencesInformation',
|
|||
});
|
||||
};
|
||||
|
||||
if (b != 5) return b++;
|
||||
save('#202020');
|
||||
};
|
||||
|
||||
$scope.scan = function() {
|
||||
walletService.startScan(wallet);
|
||||
$ionicHistory.removeBackView();
|
||||
$state.go('tabs.home');
|
||||
if (colorCounter != 5) return colorCounter++;
|
||||
save(BLACK_WALLET_COLOR);
|
||||
};
|
||||
|
||||
$scope.$on("$ionicView.enter", function(event, data) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue