Merge pull request #5983 from cmgustavo/bug/receive-tab-02
Bug/receive tab 02
This commit is contained in:
commit
18319b470f
3 changed files with 80 additions and 87 deletions
|
|
@ -14,11 +14,11 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
|
|||
});
|
||||
};
|
||||
|
||||
$scope.setAddress = function() {
|
||||
if (!$scope.wallet || $scope.generatingAddress || !$scope.wallet.isComplete()) return;
|
||||
$scope.setAddress = function(newAddr) {
|
||||
$scope.addr = null;
|
||||
if (!$scope.wallet || $scope.generatingAddress || !$scope.wallet.isComplete()) return;
|
||||
$scope.generatingAddress = true;
|
||||
walletService.getAddress($scope.wallet, false, function(err, addr) {
|
||||
walletService.getAddress($scope.wallet, newAddr, function(err, addr) {
|
||||
$scope.generatingAddress = false;
|
||||
|
||||
if (err) {
|
||||
|
|
@ -74,20 +74,6 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
|
|||
});
|
||||
};
|
||||
|
||||
$scope.updateCurrentWallet = function(wallet) {
|
||||
walletService.getStatus(wallet, {}, function(err, status) {
|
||||
if (err) {
|
||||
return popupService.showAlert(bwcError.msg(err, gettextCatalog.getString('Could not update wallet')));
|
||||
}
|
||||
$timeout(function() {
|
||||
$scope.wallet = profileService.getWallet(wallet.id);
|
||||
$scope.wallet.status = status;
|
||||
$scope.setAddress();
|
||||
$scope.$apply();
|
||||
}, 200);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.shouldShowReceiveAddressFromHardware = function() {
|
||||
var wallet = $scope.wallet;
|
||||
if (wallet.isPrivKeyExternal() && wallet.credentials.hwInfo) {
|
||||
|
|
@ -108,36 +94,38 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
|
|||
$scope.wallets = profileService.getWallets();
|
||||
$scope.singleWallet = $scope.wallets.length == 1;
|
||||
|
||||
if (!$scope.wallets[0]) return;
|
||||
|
||||
// select first wallet if no wallet selected previously
|
||||
var selectedWallet = checkSelectedWallet($scope.wallet, $scope.wallets);
|
||||
$scope.onWalletSelect(selectedWallet);
|
||||
|
||||
listeners = [
|
||||
$rootScope.$on('bwsEvent', function(e, walletId, type, n) {
|
||||
// Update current address
|
||||
if ($scope.wallet && walletId == $scope.wallet.id) $scope.updateCurrentWallet($scope.wallet);
|
||||
if ($scope.wallet && walletId == $scope.wallet.id && type == 'NewIncomingTx') $scope.setAddress(true);
|
||||
})
|
||||
];
|
||||
|
||||
if (!$scope.wallets[0]) return;
|
||||
if (!$scope.wallet) return $scope.init();
|
||||
|
||||
var w = lodash.find($scope.wallets, function(w) {
|
||||
return w.id == $scope.wallet.id;
|
||||
});
|
||||
if (w) $scope.updateCurrentWallet($scope.wallet);
|
||||
else $scope.init();
|
||||
];
|
||||
});
|
||||
|
||||
$scope.init = function() {
|
||||
$scope.wallet = $scope.wallets[0];
|
||||
$scope.updateCurrentWallet($scope.wallet);
|
||||
};
|
||||
|
||||
$scope.$on("$ionicView.leave", function(event, data) {
|
||||
lodash.each(listeners, function(x) {
|
||||
x();
|
||||
});
|
||||
});
|
||||
|
||||
var checkSelectedWallet = function(wallet, wallets) {
|
||||
if (!wallet) return wallets[0];
|
||||
var w = lodash.find(wallets, function(w) {
|
||||
return w.id == wallet.id;
|
||||
});
|
||||
if (!w) return wallets[0];
|
||||
return wallet;
|
||||
}
|
||||
|
||||
$scope.onWalletSelect = function(wallet) {
|
||||
$scope.updateCurrentWallet(wallet);
|
||||
$scope.wallet = wallet;
|
||||
$scope.setAddress();
|
||||
};
|
||||
|
||||
$scope.showWalletSelector = function() {
|
||||
|
|
|
|||
|
|
@ -1,42 +1,33 @@
|
|||
#tab-receive {
|
||||
@extend .deflash-blue;
|
||||
.address {
|
||||
background: #fff;
|
||||
height: 65vh;
|
||||
@media(max-height: 600px) and (max-width: 320px) {
|
||||
height: 70vh;
|
||||
.button {
|
||||
min-height: 50px;
|
||||
}
|
||||
}
|
||||
overflow: auto;
|
||||
height: 100%;
|
||||
&-info {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-top: 22vh;
|
||||
padding-bottom: 17vh;
|
||||
@media(max-height: 800px) {
|
||||
padding-top: 17vh;
|
||||
}
|
||||
@media(max-height: 700px) {
|
||||
padding-top: 14vh;
|
||||
}
|
||||
@media(max-height: 600px) {
|
||||
padding-top: 7vh;
|
||||
}
|
||||
text-align: center;
|
||||
.address-label {
|
||||
margin-top: 5%;
|
||||
font-size: 13px;
|
||||
}
|
||||
.qr {
|
||||
position: relative;
|
||||
top: 15%;
|
||||
}
|
||||
.backup {
|
||||
background-color: orange;
|
||||
color: #fff;
|
||||
position: absolute;
|
||||
z-index: 2;
|
||||
i {
|
||||
padding: 10px;
|
||||
}
|
||||
}
|
||||
.request-button {
|
||||
padding-top: 20px;
|
||||
}
|
||||
}
|
||||
.incomplete {
|
||||
height: 100%;
|
||||
.title {
|
||||
margin-top: 10%;
|
||||
padding-top: 10%;
|
||||
font-size: 25px;
|
||||
color: #444;
|
||||
text-align: center;
|
||||
|
|
@ -44,12 +35,27 @@
|
|||
.subtitle {
|
||||
padding: 20px;
|
||||
color: #444;
|
||||
margin-top: 20%;
|
||||
margin-top: 10%;
|
||||
text-align: center;
|
||||
}
|
||||
.button {
|
||||
margin-top: 20%;
|
||||
}
|
||||
}
|
||||
}
|
||||
.backup {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
cursor: pointer;
|
||||
background-color: orange;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
padding: 5px 0;
|
||||
i {
|
||||
margin: 0 10px;
|
||||
}
|
||||
}
|
||||
.wallet-selector {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,34 +18,32 @@
|
|||
<button class="button button-standard button-primary" ng-click="goCopayers()" translate>Open wallet</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="address-info" ng-if="wallet && wallet.isComplete()">
|
||||
<div class="row backup" ng-show="wallet.needsBackup" ng-click="openBackupNeededModal()">
|
||||
<div class="text-center col center-block">
|
||||
<i class="icon ion-alert"></i><span translate>Wallet not backed up</span><i class="icon ion-ios-arrow-thin-right"></i>
|
||||
<div class="address-info" ng-if="wallet && wallet.isComplete()">
|
||||
<div copy-to-clipboard="copyToClipboard()">
|
||||
<span ng-show="shouldShowReceiveAddressFromHardware()">
|
||||
<button class="button button-standard button-primary" ng-click="showReceiveAddressFromHardware()">
|
||||
<span translate>Show address</span>
|
||||
</button>
|
||||
</span>
|
||||
<qrcode ng-if="addr" size="220" data="bitcoin:{{addr}}" color="#334"></qrcode>
|
||||
<div class="address-label">
|
||||
<span class="ellipsis">{{addr}}</span>
|
||||
<ion-spinner ng-show="!addr" class="spinner-dark" icon="crescent"></ion-spinner>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row qr">
|
||||
<div class="text-center col">
|
||||
<div copy-to-clipboard="copyToClipboard()">
|
||||
<span ng-show="shouldShowReceiveAddressFromHardware()">
|
||||
<button class="button button-standard button-primary" ng-click="showReceiveAddressFromHardware()">
|
||||
<span translate>Show address</span>
|
||||
</button>
|
||||
</span>
|
||||
<qrcode ng-if="addr" size="220" data="bitcoin:{{addr}}" color="#334"></qrcode>
|
||||
<div class="address-label">
|
||||
<span class="ellipsis">{{addr}}</span>
|
||||
<ion-spinner ng-show="!addr" class="spinner-dark" icon="crescent"></ion-spinner>
|
||||
</div>
|
||||
</div>
|
||||
<div ng-show="addr" class="request-button">
|
||||
<button class="button button-standard button-primary button-outline" ng-click="requestSpecificAmount()" translate>Request Specific amount</button>
|
||||
</div>
|
||||
</div>
|
||||
<div ng-show="addr" class="request-button">
|
||||
<button class="button button-standard button-primary button-outline button-small" ng-click="requestSpecificAmount()" translate>Request Specific amount</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
<div ng-click="showWalletSelector()" ng-if="wallets[0]">
|
||||
|
||||
<div class="backup" ng-if="wallets[0] && wallet && wallet.isComplete() && wallet.needsBackup" ng-click="openBackupNeededModal()">
|
||||
<i class="icon ion-alert"></i>
|
||||
<span translate>Wallet not backed up</span>
|
||||
<i class="icon ion-ios-arrow-thin-right"></i>
|
||||
</div>
|
||||
|
||||
<div class="wallet-selector" ng-click="showWalletSelector()" ng-if="wallets[0] && wallet">
|
||||
<a ng-if="wallet" class="item item-sub item-icon-left item-big-icon-left item-icon-right">
|
||||
<i class="icon big-icon-svg">
|
||||
<img src="img/icon-wallet.svg" ng-class="{'wallet-background-color-default': !wallet.color}" ng-style="{'background-color': wallet.color}" class="bg wallet"/>
|
||||
|
|
@ -66,6 +64,7 @@
|
|||
<i ng-if="!singleWallet" class="icon bp-arrow-right"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</ion-content>
|
||||
<wallet-selector
|
||||
wallet-selector-title="walletSelectorTitle"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue