remove slider directive and replace sliders in paperwallet view

This commit is contained in:
Gabriel Bazán 2017-05-04 12:13:55 -03:00
parent e76924cb74
commit dbc49e9ce0
5 changed files with 37 additions and 54 deletions

View File

@ -101,21 +101,15 @@ angular.module('copayApp.controllers').controller('paperWalletController',
$state.go('tabs.home');
};
$scope.$on('Wallet/Changed', function(event, wallet) {
if (!wallet) {
$log.debug('No wallet provided');
return;
}
if (wallet == $scope.wallet) {
$log.debug('No change in wallet');
return;
}
$scope.onWalletSelect = function(wallet) {
$scope.wallet = wallet;
$log.debug('Wallet changed: ' + wallet.name);
$timeout(function() {
$scope.$apply();
});
});
};
$scope.showWalletSelector = function() {
if ($scope.singleWallet) return;
$scope.walletSelectorTitle = gettextCatalog.getString('Transfer to');
$scope.showWallets = true;
};
$scope.$on("$ionicView.beforeEnter", function(event, data) {
$scope.scannedKey = (data.stateParams && data.stateParams.privateKey) ? data.stateParams.privateKey : null;
@ -127,6 +121,7 @@ angular.module('copayApp.controllers').controller('paperWalletController',
onlyComplete: true,
network: 'livenet',
});
$scope.singleWallet = $scope.wallets.length == 1;
if (!$scope.wallets || !$scope.wallets.length) {
$scope.noMatchingWallet = true;

View File

@ -127,7 +127,6 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
$scope.init = function() {
$scope.wallet = $scope.wallets[0];
$scope.updateCurrentWallet($scope.wallet);
$scope.showWalletSelector();
};
$scope.$on("$ionicView.leave", function(event, data) {

View File

@ -143,23 +143,4 @@ angular.module('copayApp.directives')
});
}
}
})
.directive('wallets', function($log, profileService, walletService, lodash) {
return {
restrict: 'E',
templateUrl: 'views/includes/wallets.html',
scope: {
wallets: '=wallets'
},
link: function(scope, element, attrs) {
scope.$on("$ionicSlides.sliderInitialized", function(event, data) {
scope.slider = data.slider;
scope.$emit('Wallet/Changed', scope.wallets ? scope.wallets[0] : null);
});
scope.$on("$ionicSlides.slideChangeStart", function(event, data) {
scope.$emit('Wallet/Changed', scope.wallets ? scope.wallets[data.slider.activeIndex] : null);
});
}
}
});

View File

@ -1,18 +0,0 @@
<div class="wallets" ng-show="wallets[0]">
<ion-slides class="slides" slider="data.slider" options="sliderOptions">
<ion-slide-page ng-repeat="wallet in wallets track by $index">
<div class="card" ng-click="slider.slideTo($index)">
<div class="item item-icon-left text-right" ng-class="{'noBalance': !wallet.status.availableBalanceStr}">
<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"/>
</i>
<span class="wallet-name">{{wallet.name || wallet.id}}</span>
<span class="item-note m10l" ng-if="!wallet.balanceHidden">
{{wallet.status.availableBalanceStr}}
</span>
<span class="item-note m10l" ng-if="wallet.balanceHidden" translate>[Balance Hidden]</span>
</div>
</div>
</ion-slide-page>
</ion-slides>
</div>

View File

@ -18,10 +18,29 @@
<div ng-show="!balance" class="size-24 ng-hide">...</div>
</div>
</div>
<wallets id="wallet-slider" wallets="wallets" options="sliderOptions"></wallets>
<div class="text-center size-12 text-gray">
<span translate>Funds will be transferred to</span>:
<b>{{wallet.walletAlias || wallet.name}}</b>
</div>
<div class="list card" ng-click="showWalletSelector()" ng-if="wallets[0]">
<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"/>
</i>
<span>
{{wallet.name || wallet.id}}
</span>
<p>
<span ng-if="!wallet.balanceHidden"> {{wallet.status.totalBalanceStr}} </span>
<span ng-if="wallet.balanceHidden" translate>[Balance Hidden]</span>
<span class="tab-home__wallet__multisig-number" ng-if="wallet.n > 1">
{{wallet.m}}-of-{{wallet.n}}
</span>
<span class="assertive" ng-if="wallet.error">{{wallet.error}}</span>
&nbsp;
</p>
<i ng-if="!singleWallet" class="icon bp-arrow-right"></i>
</a>
</div>
</div>
<div class="text-center padding ng-hide" ng-show="noMatchingWallet">
@ -34,4 +53,11 @@
<span translate>Funds transferred</span>
</slide-to-accept-success>
</ion-content>
<wallet-selector
wallet-selector-title="walletSelectorTitle"
wallet-selector-wallets="wallets"
wallet-selector-selected-wallet="wallet"
wallet-selector-show="showWallets"
wallet-selector-on-select="onWalletSelect">
</wallet-selector>
</ion-view>