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';
|
'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 UNUSED_ADDRESS_LIMIT = 5;
|
||||||
var BALANCE_ADDRESS_LIMIT = 5;
|
var BALANCE_ADDRESS_LIMIT = 5;
|
||||||
|
var MENU_ITEM_HEIGHT = 55;
|
||||||
var config;
|
var config;
|
||||||
var unitName;
|
var unitName;
|
||||||
var unitToSatoshi;
|
var unitToSatoshi;
|
||||||
|
|
@ -11,6 +12,8 @@ angular.module('copayApp.controllers').controller('addressesController', functio
|
||||||
var withBalance;
|
var withBalance;
|
||||||
$scope.showInfo = false;
|
$scope.showInfo = false;
|
||||||
$scope.showMore = false;
|
$scope.showMore = false;
|
||||||
|
$scope.allAddressesView = false;
|
||||||
|
$scope.isCordova = platformInfo.isCordova;
|
||||||
$scope.wallet = profileService.getWallet($stateParams.walletId);
|
$scope.wallet = profileService.getWallet($stateParams.walletId);
|
||||||
|
|
||||||
function init() {
|
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) {
|
$scope.$on("$ionicView.afterEnter", function(event, data) {
|
||||||
config = configService.getSync().wallet.settings;
|
config = configService.getSync().wallet.settings;
|
||||||
unitToSatoshi = config.unitToSatoshi;
|
unitToSatoshi = config.unitToSatoshi;
|
||||||
|
|
|
||||||
|
|
@ -1,59 +1,15 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('preferencesInformation',
|
angular.module('copayApp.controllers').controller('preferencesInformation',
|
||||||
function($scope, $log, $timeout, $ionicHistory, platformInfo, lodash, profileService, configService, $stateParams, walletService, $state) {
|
function($scope, $log, $ionicHistory, platformInfo, lodash, profileService, configService, $stateParams, $state) {
|
||||||
var base = 'xpub';
|
|
||||||
var wallet = profileService.getWallet($stateParams.walletId);
|
var wallet = profileService.getWallet($stateParams.walletId);
|
||||||
var walletId = wallet.id;
|
var walletId = wallet.id;
|
||||||
var config = configService.getSync();
|
var config = configService.getSync();
|
||||||
var b = 1;
|
var colorCounter = 1;
|
||||||
|
var BLACK_WALLET_COLOR = '#202020';
|
||||||
$scope.isCordova = platformInfo.isCordova;
|
$scope.isCordova = platformInfo.isCordova;
|
||||||
config.colorFor = config.colorFor || {};
|
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() {
|
$scope.saveBlack = function() {
|
||||||
function save(color) {
|
function save(color) {
|
||||||
var opts = {
|
var opts = {
|
||||||
|
|
@ -68,14 +24,8 @@ angular.module('copayApp.controllers').controller('preferencesInformation',
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (b != 5) return b++;
|
if (colorCounter != 5) return colorCounter++;
|
||||||
save('#202020');
|
save(BLACK_WALLET_COLOR);
|
||||||
};
|
|
||||||
|
|
||||||
$scope.scan = function() {
|
|
||||||
walletService.startScan(wallet);
|
|
||||||
$ionicHistory.removeBackView();
|
|
||||||
$state.go('tabs.home');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.$on("$ionicView.enter", function(event, data) {
|
$scope.$on("$ionicView.enter", function(event, data) {
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ angular.module('copayApp.services').factory('ongoingProcess', function($log, $ti
|
||||||
'sendingFeedback': gettext('Sending feedback...'),
|
'sendingFeedback': gettext('Sending feedback...'),
|
||||||
'generatingNewAddress': gettext('Generating new address...'),
|
'generatingNewAddress': gettext('Generating new address...'),
|
||||||
'gettingAddresses': gettext('Getting addresses...'),
|
'gettingAddresses': gettext('Getting addresses...'),
|
||||||
|
'sendingByEmail': gettext('Preparing addresses...'),
|
||||||
};
|
};
|
||||||
|
|
||||||
root.clear = function() {
|
root.clear = function() {
|
||||||
|
|
|
||||||
12
src/sass/views/includes/menu-popover.scss
Normal file
12
src/sass/views/includes/menu-popover.scss
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#menu-popover {
|
||||||
|
border-radius: 5px;
|
||||||
|
.list {
|
||||||
|
.item {
|
||||||
|
cursor: pointer;
|
||||||
|
cursor: hand;
|
||||||
|
&:hover {
|
||||||
|
background-color: #E4E2E2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -115,7 +115,6 @@
|
||||||
.item {
|
.item {
|
||||||
padding-top: 5px;
|
padding-top: 5px;
|
||||||
padding-bottom: 5px;
|
padding-bottom: 5px;
|
||||||
display: inline-block;
|
|
||||||
font-size: .7rem;
|
font-size: .7rem;
|
||||||
@media(min-width:350px){
|
@media(min-width:350px){
|
||||||
font-size:.9rem;
|
font-size:.9rem;
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
@import "export";
|
@import "export";
|
||||||
@import "import";
|
@import "import";
|
||||||
@import "join";
|
@import "join";
|
||||||
|
@import "includes/menu-popover";
|
||||||
@import "includes/walletActivity";
|
@import "includes/walletActivity";
|
||||||
@import "includes/wallets";
|
@import "includes/wallets";
|
||||||
@import "includes/modals/modals";
|
@import "includes/modals/modals";
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,15 @@
|
||||||
<ion-nav-title>{{'Wallet Addresses' | translate}}</ion-nav-title>
|
<ion-nav-title>{{'Wallet Addresses' | translate}}</ion-nav-title>
|
||||||
<ion-nav-back-button>
|
<ion-nav-back-button>
|
||||||
</ion-nav-back-button>
|
</ion-nav-back-button>
|
||||||
|
<ion-nav-buttons side="secondary">
|
||||||
|
<button class="button back-button" ng-click="showMenu(false, $event)">
|
||||||
|
<i class="icon ion-ios-more"></i>
|
||||||
|
</button>
|
||||||
|
</ion-nav-buttons>
|
||||||
</ion-nav-bar>
|
</ion-nav-bar>
|
||||||
|
|
||||||
<ion-content>
|
<ion-content>
|
||||||
<div class="zero-state banner-icon">
|
<div class="text-center banner-icon">
|
||||||
<i class="icon zero-state-icon">
|
<i class="icon zero-state-icon">
|
||||||
<img src="img/tab-icons/ico-receive-selected.svg"/>
|
<img src="img/tab-icons/ico-receive-selected.svg"/>
|
||||||
</i>
|
</i>
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,11 @@
|
||||||
<ion-nav-title>{{'All Addresses' | translate}}</ion-nav-title>
|
<ion-nav-title>{{'All Addresses' | translate}}</ion-nav-title>
|
||||||
<ion-nav-back-button>
|
<ion-nav-back-button>
|
||||||
</ion-nav-back-button>
|
</ion-nav-back-button>
|
||||||
|
<ion-nav-buttons side="secondary">
|
||||||
|
<button class="button back-button" ng-click="showMenu(true, $event)" ng-hide="!isCordova && allAddressesView">
|
||||||
|
<i class="icon ion-ios-more"></i>
|
||||||
|
</button>
|
||||||
|
</ion-nav-buttons>
|
||||||
</ion-nav-bar>
|
</ion-nav-bar>
|
||||||
|
|
||||||
<ion-content>
|
<ion-content>
|
||||||
|
|
|
||||||
9
www/views/includes/menu-popover.html
Normal file
9
www/views/includes/menu-popover.html
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
<ion-popover-view ng-style="{'height': height + 'px'}" id="menu-popover">
|
||||||
|
<ion-content>
|
||||||
|
<div class="list">
|
||||||
|
<div class="item" ng-repeat="i in items track by $index" ng-click="i.action()">
|
||||||
|
{{i.text}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ion-content>
|
||||||
|
</ion-popover-view>
|
||||||
|
|
@ -70,7 +70,7 @@
|
||||||
<div class="item item-icon-left item-icon-right">
|
<div class="item item-icon-left item-icon-right">
|
||||||
<i class="icon icon-svg receive-tab-bitcoin-icon"><img src="img/icon-bitcoin-symbol.svg"></i>
|
<i class="icon icon-svg receive-tab-bitcoin-icon"><img src="img/icon-bitcoin-symbol.svg"></i>
|
||||||
<span class="bit-address-gen-address" ng-if="generatingAddress">...</span>
|
<span class="bit-address-gen-address" ng-if="generatingAddress">...</span>
|
||||||
<span class="bit-address-gen-address" ng-if="!generatingAddress">{{walletAddrs[wallet.id]}}</span>
|
<span class="bit-address-gen-address" ng-if="!generatingAddress" class="ellipsis">{{walletAddrs[wallet.id]}}</span>
|
||||||
<i class="icon ion-ios-arrow-right"></i>
|
<i class="icon ion-ios-arrow-right"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue