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() {
|
$scope.setAddress = function(newAddr) {
|
||||||
if (!$scope.wallet || $scope.generatingAddress || !$scope.wallet.isComplete()) return;
|
|
||||||
$scope.addr = null;
|
$scope.addr = null;
|
||||||
|
if (!$scope.wallet || $scope.generatingAddress || !$scope.wallet.isComplete()) return;
|
||||||
$scope.generatingAddress = true;
|
$scope.generatingAddress = true;
|
||||||
walletService.getAddress($scope.wallet, false, function(err, addr) {
|
walletService.getAddress($scope.wallet, newAddr, function(err, addr) {
|
||||||
$scope.generatingAddress = false;
|
$scope.generatingAddress = false;
|
||||||
|
|
||||||
if (err) {
|
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() {
|
$scope.shouldShowReceiveAddressFromHardware = function() {
|
||||||
var wallet = $scope.wallet;
|
var wallet = $scope.wallet;
|
||||||
if (wallet.isPrivKeyExternal() && wallet.credentials.hwInfo) {
|
if (wallet.isPrivKeyExternal() && wallet.credentials.hwInfo) {
|
||||||
|
|
@ -108,36 +94,38 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
|
||||||
$scope.wallets = profileService.getWallets();
|
$scope.wallets = profileService.getWallets();
|
||||||
$scope.singleWallet = $scope.wallets.length == 1;
|
$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 = [
|
listeners = [
|
||||||
$rootScope.$on('bwsEvent', function(e, walletId, type, n) {
|
$rootScope.$on('bwsEvent', function(e, walletId, type, n) {
|
||||||
// Update current address
|
// 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) {
|
$scope.$on("$ionicView.leave", function(event, data) {
|
||||||
lodash.each(listeners, function(x) {
|
lodash.each(listeners, function(x) {
|
||||||
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.onWalletSelect = function(wallet) {
|
||||||
$scope.updateCurrentWallet(wallet);
|
$scope.wallet = wallet;
|
||||||
|
$scope.setAddress();
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.showWalletSelector = function() {
|
$scope.showWalletSelector = function() {
|
||||||
|
|
|
||||||
|
|
@ -1,42 +1,33 @@
|
||||||
#tab-receive {
|
#tab-receive {
|
||||||
|
@extend .deflash-blue;
|
||||||
.address {
|
.address {
|
||||||
background: #fff;
|
background: #fff;
|
||||||
height: 65vh;
|
overflow: auto;
|
||||||
@media(max-height: 600px) and (max-width: 320px) {
|
height: 100%;
|
||||||
height: 70vh;
|
|
||||||
.button {
|
|
||||||
min-height: 50px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
&-info {
|
&-info {
|
||||||
height: 100%;
|
padding-top: 22vh;
|
||||||
display: flex;
|
padding-bottom: 17vh;
|
||||||
flex-direction: column;
|
@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 {
|
.address-label {
|
||||||
margin-top: 5%;
|
margin-top: 5%;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
.qr {
|
|
||||||
position: relative;
|
|
||||||
top: 15%;
|
|
||||||
}
|
|
||||||
.backup {
|
|
||||||
background-color: orange;
|
|
||||||
color: #fff;
|
|
||||||
position: absolute;
|
|
||||||
z-index: 2;
|
|
||||||
i {
|
|
||||||
padding: 10px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.request-button {
|
.request-button {
|
||||||
padding-top: 20px;
|
padding-top: 20px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.incomplete {
|
.incomplete {
|
||||||
height: 100%;
|
|
||||||
.title {
|
.title {
|
||||||
margin-top: 10%;
|
padding-top: 10%;
|
||||||
font-size: 25px;
|
font-size: 25px;
|
||||||
color: #444;
|
color: #444;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
@ -44,12 +35,27 @@
|
||||||
.subtitle {
|
.subtitle {
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
color: #444;
|
color: #444;
|
||||||
margin-top: 20%;
|
margin-top: 10%;
|
||||||
text-align: center;
|
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>
|
<button class="button button-standard button-primary" ng-click="goCopayers()" translate>Open wallet</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="address-info" ng-if="wallet && wallet.isComplete()">
|
<div class="address-info" ng-if="wallet && wallet.isComplete()">
|
||||||
<div class="row backup" ng-show="wallet.needsBackup" ng-click="openBackupNeededModal()">
|
<div copy-to-clipboard="copyToClipboard()">
|
||||||
<div class="text-center col center-block">
|
<span ng-show="shouldShowReceiveAddressFromHardware()">
|
||||||
<i class="icon ion-alert"></i><span translate>Wallet not backed up</span><i class="icon ion-ios-arrow-thin-right"></i>
|
<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>
|
</div>
|
||||||
<div class="row qr">
|
<div ng-show="addr" class="request-button">
|
||||||
<div class="text-center col">
|
<button class="button button-standard button-primary button-outline button-small" ng-click="requestSpecificAmount()" translate>Request Specific amount</button>
|
||||||
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</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">
|
<a ng-if="wallet" class="item item-sub item-icon-left item-big-icon-left item-icon-right">
|
||||||
<i class="icon big-icon-svg">
|
<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"/>
|
<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>
|
<i ng-if="!singleWallet" class="icon bp-arrow-right"></i>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</ion-content>
|
</ion-content>
|
||||||
<wallet-selector
|
<wallet-selector
|
||||||
wallet-selector-title="walletSelectorTitle"
|
wallet-selector-title="walletSelectorTitle"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue