add wallet widget in confirm (send) view

This commit is contained in:
Javier 2016-08-23 16:15:10 -03:00
parent 4231dcadc7
commit 3bc3552129
3 changed files with 57 additions and 74 deletions

View File

@ -2,11 +2,9 @@
<ion-nav-bar class="bar-stable">
<ion-nav-title>Enter Amount</ion-nav-title>
<ion-nav-buttons side="primary">
<button class="button" href ui-sref="tabs.send">
<i class="ion-arrow-left-c"></i> Back
<button class="button no-border" ui-sref="tabs.send">
<i class="icon ion-chevron-left"></i> Back
</button>
</ion-nav-buttons>
</ion-nav-bar>
@ -17,7 +15,7 @@
<div class="list card">
<div class="item item-divider">
Recipient
Recipient
</div>
<div class="item item-text-wrap item-icon-left">

View File

@ -3,15 +3,13 @@
<ion-pane>
<ion-nav-bar class="bar-stable">
<ion-nav-title>Confirm</ion-nav-title>
<ion-nav-buttons side="primary">
<button class="button" href ui-sref="tabs.send">
<i class="ion-arrow-left-c"></i> Back
<button class="button no-border" ui-sref="tabs.send">
<i class="icon ion-chevron-left"></i> Back
</button>
</ion-nav-buttons>
</ion-nav-bar>
<ion-content scroll="false" ng-controller="confirmController" ng-init="init()">
<div class="card">
@ -24,9 +22,15 @@
<div class="list card">
<div class="item">Fee: {{feeLevel}}
<<<<<<< eb8c739515d024200f5ea2bad72fffb21437375b
<span class="item-note">
{{fee || '...'}}
</span>
=======
<span class="item-note">
{{fee || '...'}}
</span>
>>>>>>> add wallet widget in confirm (send) view
</div>
<div class="item item-icon-left">
@ -42,11 +46,10 @@
</div>
<div class="item item-icon-left">
<i class="icon icon-wallet size-21" ng-style="{'color':recipientColor}"></i>
<i class="icon ion-briefcase size-21"></i>
<label translate>From</label>
<p ng-show="network=='testnet'">[Only showing testnet wallets]</p>
<p ng-show="someFiltered">[Filtering wallets with no enought balance]</p>
</div>
<<<<<<< eb8c739515d024200f5ea2bad72fffb21437375b
<div class="item item-text-wrap" ng-style="{'height' : '200px'}">
<ion-slides class="slides" options="options" slider="data.slider">
@ -66,6 +69,9 @@
</ion-slides>
</div>
=======
<wallets only-complete="true" network="{{network}}"></wallets>
>>>>>>> add wallet widget in confirm (send) view
<div class="item item-icon-left item-icon-right" ng-click="showDescriptionPopup()">
<span ng-show="!description">Add Description</span>
@ -75,11 +81,11 @@
</div>
</div>
<div class="card">
<button class="item button button-full button-balanced" ng-click="approve()" ng-disabled="!txp" ng-show="wallet.canSign()"> Approve </button>
<button class="item button button-full button-balanced" ng-click="approve()" ng-disabled="!txp" ng-show="!wallet.canSign()"> Send </button>
</div>
<div class="button-block">
<button class="item button button-full button-balanced" ng-click="approve()" ng-disabled="!txp">
<span ng-show="wallet.canSign()" translate>Approve</span>
<span ng-show="!wallet.canSign()" translate>Send</span>
</button>
</div>
</ion-content>
</ion-view>

View File

@ -42,7 +42,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
};
};
var setFromPayPro = function(uri, cb) {
if (!cb) cb = function() {};
@ -92,9 +91,8 @@ angular.module('copayApp.controllers').controller('confirmController', function(
});
};
$scope.init = function() {
$scope.wallet = profileService.getWallets()[0];
if ($stateParams.paypro) {
return setFromPayPro($stateParams.paypro, function(err) {
@ -125,61 +123,48 @@ angular.module('copayApp.controllers').controller('confirmController', function(
var network = (new bitcore.Address($scope.toAddress)).network.name;
$scope.network = network;
function setWallets() {
var w = profileService.getWallets({
onlyComplete: true,
network: network,
});
$scope.wallets = lodash.filter(w, function(x) {
if (!x.availableBalanceSat) return true;
return x.availableBalanceSat > amount;
});
$scope.someFiltered = $scope.wallets.length != w.length;
};
var stop;
function setWallet(wallet, delayed) {
$scope.wallet = wallet;
$scope.fee = $scope.txp = null;
$timeout(function() {
$scope.$apply();
}, 10);
if (stop) {
$timeout.cancel(stop);
stop = null;
}
if (cachedTxp[wallet.id]) {
apply(cachedTxp[wallet.id]);
} else {
stop = $timeout(function() {
createTx(wallet, function(err, txp) {
if (err) return;
cachedTxp[wallet.id] = txp;
apply(txp);
});
}, delayed ? 2000 : 1);
}
};
txFormatService.formatAlternativeStr(amount, function(v) {
$scope.alternativeAmountStr = v;
});
};
$scope.$on("$ionicSlides.slideChangeEnd", function(event, data) {
setWallet($scope.wallets[data.slider.activeIndex], true);
});
$scope.$on('Wallet/Changed', function(event, wallet) {
$log.debug('Wallet changed: ' + wallet.name);
setWallet(wallet, true);
$scope.$apply();
});
setWallets();
setWallet($scope.wallets[0]);
function setWallet(wallet, delayed) {
var stop;
$scope.wallet = wallet;
$scope.fee = $scope.txp = null;
$timeout(function() {
$ionicScrollDelegate.resize();
}, 100);
$scope.$apply();
}, 10);
if (stop) {
$timeout.cancel(stop);
stop = null;
}
function apply(txp) {
$scope.fee = txFormatService.formatAmountStr(txp.fee);
$scope.txp = txp;
$scope.$apply();
};
if (cachedTxp[wallet.id]) {
apply(cachedTxp[wallet.id]);
} else {
stop = $timeout(function() {
createTx(wallet, $scope.toAddress, $scope.toAmount, $scope.comment || null, function(err, txp) {
if (err) return;
cachedTxp[wallet.id] = txp;
apply(txp);
});
}, delayed ? 2000 : 1);
}
};
var setSendError = function(msg) {
@ -244,7 +229,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
});
};
$scope.openPPModal = function() {
$ionicModal.fromTemplateUrl('views/modals/paypro.html', {
scope: $scope
@ -254,8 +238,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
});
};
$scope.approve = function() {
var wallet = $scope.wallet;
var txp = $scope.txp;
@ -287,7 +269,4 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$scope.cancel = function() {
$state.transitionTo('tabs.send');
};
});