can switch between addresses on address screen

This commit is contained in:
Kadir Sekha 2018-01-11 12:59:26 +09:00
commit 353214f50f
3 changed files with 42 additions and 7 deletions

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('addressesController', function($scope, $log, $stateParams, $state, $timeout, $ionicHistory, $ionicScrollDelegate, popupService, gettextCatalog, ongoingProcess, lodash, profileService, walletService, bwcError, platformInfo, appConfigService, txFormatService, feeService) {
angular.module('copayApp.controllers').controller('addressesController', function($scope, $log, $stateParams, $state, $timeout, $ionicHistory, $ionicScrollDelegate, popupService, gettextCatalog, ongoingProcess, lodash, profileService, walletService, bwcError, platformInfo, appConfigService, txFormatService, feeService, bitcoinCashJsService) {
var UNUSED_ADDRESS_LIMIT = 5;
var BALANCE_ADDRESS_LIMIT = 5;
var withBalance, cachedWallet;
@ -58,6 +58,19 @@ angular.module('copayApp.controllers').controller('addressesController', functio
};
$scope.allAddresses = $scope.noBalance.concat(withBalance);
if ($scope.wallet.coin == 'bch') {
lodash.each($scope.allAddresses, function(a) {
a.translatedAddresses = bitcoinCashJsService.translateAddresses(a.address);
});
var cashaddrDate = new Date(2018, 0, 15);
var currentDate = new Date();
$scope.addressType = {
type: currentDate >= cashaddrDate ? 'cashaddr' : 'legacy'
};
}
cachedWallet = $scope.wallet.id;
$scope.loading = false;
$log.debug('Addresses cached for Wallet:', cachedWallet);

View file

@ -37,6 +37,17 @@
<i class="icon ion-ios-arrow-thin-right"></i>
</div>
<div ng-if="wallet.coin == 'bch'" class="item item-input item-select">
<div class="view-all input-label" translate>
Address type
</div>
<select ng-model="addressType.type">
<option value="cashaddr">Cash Address</option>
<option value="legacy">Legacy</option>
<option value="bitpay">BitPay</option>
</select>
</div>
<div class="item item-divider item-icon-right" ng-click="newAddress()">
<span translate>Unused Addresses</span>
<i class="icon ion-ios-plus-empty"></i>
@ -54,8 +65,8 @@
<p ng-if="showMore"><span translate>The restore process will stop when 20 addresses are generated in a row which contain no funds. To safely generate more addresses, make a payment to one of the unused addresses which has already been generated.</span>&nbsp;<a ng-click="readMore()" translate>Read less</a></p>
</div>
<div class="item" ng-repeat="u in latestUnused track by $index" copy-to-clipboard="u.address">
{{u.address}}
<div class="item" ng-repeat="u in latestUnused track by $index" copy-to-clipboard="wallet.coin == 'bch' ? u.translatedAddresses[addressType.type] : u.address">
{{wallet.coin == 'bch' ? u.translatedAddresses[addressType.type] : u.address}}
<div class="addr-path">
{{u.path}} {{u.createdOn * 1000 | amDateFormat:'MMMM Do YYYY, hh:mm a'}}
</div>
@ -67,8 +78,8 @@
Addresses With Balance
</div>
<div class="item" ng-repeat="w in latestWithBalance track by $index" copy-to-clipboard="w.address">
{{w.address}}
<div class="item" ng-repeat="w in latestWithBalance track by $index" copy-to-clipboard="wallet.coin == 'bch' ? w.translatedAddresses[addressType.type] : w.address">
{{wallet.coin == 'bch' ? w.translatedAddresses[addressType.type] : w.address}}
<div class="addr-balance">{{w.balanceStr}}</div>
</div>
</div>

View file

@ -9,6 +9,17 @@
<div class="addr-list list">
<div class="item item-divider"></div>
<div ng-if="wallet.coin == 'bch'" class="item item-input item-select">
<div class="view-all input-label" translate>
Address type
</div>
<select ng-model="addressType.type">
<option value="cashaddr">Cash Address</option>
<option value="legacy">Legacy</option>
<option value="bitpay">BitPay</option>
</select>
</div>
<div ng-if="loading" class="updating">
<ion-spinner class="spinner-dark recent" icon="crescent"></ion-spinner>
<span translate>Loading addresses...</span>
@ -22,8 +33,8 @@
<div class="item item-divider"></div>
</div>
<div class="item" ng-repeat="a in allAddresses track by $index" copy-to-clipboard="a.address">
{{a.address}}
<div class="item" ng-repeat="a in allAddresses track by $index" copy-to-clipboard="wallet.coin == 'bch' ? a.translatedAddresses[addressType.type] : a.address">
{{wallet.coin == 'bch' ? a.translatedAddresses[addressType.type] : a.address}}
<div class="addr-path" ng-if="!a.balanceStr">
{{a.path}} {{a.createdOn * 1000 | amDateFormat:'MMMM Do YYYY, hh:mm a'}}
</div>