use accept slider directive
This commit is contained in:
parent
32c30e7041
commit
473feddfc8
7 changed files with 118 additions and 108 deletions
|
|
@ -1,11 +1,11 @@
|
|||
<ion-view id="view-confirm">
|
||||
<ion-view id="view-confirm" ng-controller="confirmController" ng-init="init()">
|
||||
<ion-nav-bar class="bar-royal">
|
||||
<ion-nav-back-button>
|
||||
<i class="icon ion-ios-arrow-thin-left"></i>
|
||||
</ion-nav-back-button>
|
||||
</ion-nav-bar>
|
||||
|
||||
<ion-content scroll="false" ng-controller="confirmController" ng-init="init()">
|
||||
<ion-content>
|
||||
|
||||
<div class="list card">
|
||||
<div class="item item-text-wrap">
|
||||
|
|
@ -49,9 +49,7 @@
|
|||
<i ng-show="!description" class="icon ion-ios-plus-empty size-21"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button class="item button button-block button-positive" ng-click="approve()">
|
||||
<span translate>Send</span>
|
||||
</button>
|
||||
</ion-content>
|
||||
<accept class="accept-slide"></accept>
|
||||
</div>
|
||||
</ion-view>
|
||||
|
|
|
|||
7
public/views/includes/acceptSlide.html
Normal file
7
public/views/includes/acceptSlide.html
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<ion-slides options="{loop: false, effect: 'flip', speed: 500, pagination: false, initialSlide: 1}" slider="data.slider">
|
||||
<ion-slide-page>
|
||||
</ion-slide-page>
|
||||
<ion-slide-page>
|
||||
<div><h1>Slide to accept</h1><i class="icon-arrow-right3 size-24 right"></i></div>
|
||||
</ion-slide-page>
|
||||
</ion-slides>
|
||||
|
|
@ -161,13 +161,5 @@
|
|||
</button>
|
||||
</div>
|
||||
</ion-content>
|
||||
<div class="accept-slide" ng-disabled="loading || paymentExpired" ng-if="tx.pendingForUs && canSign && !hideSlider">
|
||||
<ion-slides options="options" slider="data.slider">
|
||||
<ion-slide-page>
|
||||
</ion-slide-page>
|
||||
<ion-slide-page>
|
||||
<div><h1>Slide to accept</h1><i class="icon-arrow-right3 size-24 right"></i></div>
|
||||
</ion-slide-page>
|
||||
</ion-slides>
|
||||
</div>
|
||||
<accept class="accept-slide" ng-disabled="loading || paymentExpired" ng-if="tx.pendingForUs && canSign && !hideSlider"></accept>
|
||||
</ion-modal-view>
|
||||
|
|
|
|||
|
|
@ -1,10 +1,86 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, $ionicNavBarDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, $ionicPopup, gettext, txFormatService, ongoingProcess, $ionicModal, $ionicHistory, popupService) {
|
||||
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $ionicSlideBoxDelegate, $filter, $timeout, $ionicScrollDelegate, $ionicNavBarDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, $ionicPopup, gettext, txFormatService, ongoingProcess, $ionicModal, $ionicHistory, popupService) {
|
||||
$ionicNavBarDelegate.title(gettextCatalog.getString('Confirm'));
|
||||
var cachedTxp = {};
|
||||
var isChromeApp = platformInfo.isChromeApp;
|
||||
|
||||
$scope.init = function() {
|
||||
if ($stateParams.paypro) {
|
||||
return setFromPayPro($stateParams.paypro, function(err) {
|
||||
if (err && !isChromeApp) {
|
||||
showAlert(gettext('Could not fetch payment'));
|
||||
}
|
||||
});
|
||||
}
|
||||
// TODO (URL , etc)
|
||||
if (!$stateParams.toAddress || !$stateParams.toAmount) {
|
||||
$log.error('Bad params at amount')
|
||||
throw ('bad params');
|
||||
}
|
||||
$scope.isCordova = platformInfo.isCordova;
|
||||
$scope.hideSlider = false;
|
||||
$scope.data = {};
|
||||
|
||||
var config = configService.getSync().wallet;
|
||||
$scope.feeLevel = config.settings ? config.settings.feeLevel : '';
|
||||
|
||||
var amount = $scope.toAmount = parseInt($stateParams.toAmount);
|
||||
$scope.amountStr = txFormatService.formatAmountStr($scope.toAmount);
|
||||
|
||||
$scope.toAddress = $stateParams.toAddress;
|
||||
$scope.toName = $stateParams.toName;
|
||||
$scope.toEmail = $stateParams.toEmail;
|
||||
$scope.description = $stateParams.description;
|
||||
$scope.paypro = $stateParams.paypro;
|
||||
|
||||
var networkName = (new bitcore.Address($scope.toAddress)).network.name;
|
||||
$scope.network = networkName;
|
||||
|
||||
$scope.notAvailable = false;
|
||||
var wallets = profileService.getWallets({
|
||||
onlyComplete: true,
|
||||
network: networkName,
|
||||
});
|
||||
|
||||
var filteredWallets = [];
|
||||
var index = 0;
|
||||
|
||||
lodash.each(wallets, function(w) {
|
||||
walletService.getStatus(w, {}, function(err, status) {
|
||||
if (err || !status) {
|
||||
$log.error(err);
|
||||
} else {
|
||||
if (!status.availableBalanceSat) $log.debug('No balance available in: ' + w.name);
|
||||
if (status.availableBalanceSat > amount) filteredWallets.push(w);
|
||||
}
|
||||
|
||||
if (++index == wallets.length) {
|
||||
if (!lodash.isEmpty(filteredWallets)) {
|
||||
$scope.wallets = lodash.clone(filteredWallets);
|
||||
$scope.notAvailable = false;
|
||||
} else {
|
||||
$scope.notAvailable = true;
|
||||
$log.warn('No wallet available to make the payment');
|
||||
}
|
||||
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
return;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
txFormatService.formatAlternativeStr(amount, function(v) {
|
||||
$scope.alternativeAmountStr = v;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.$on('accepted', function(event) {
|
||||
$scope.hideSlider = true;
|
||||
$scope.approve();
|
||||
});
|
||||
|
||||
$scope.$on('Wallet/Changed', function(event, wallet) {
|
||||
if (lodash.isEmpty(wallet)) {
|
||||
|
|
@ -76,76 +152,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
});
|
||||
};
|
||||
|
||||
$scope.init = function() {
|
||||
if ($stateParams.paypro) {
|
||||
return setFromPayPro($stateParams.paypro, function(err) {
|
||||
if (err && !isChromeApp) {
|
||||
showAlert(gettext('Could not fetch payment'));
|
||||
}
|
||||
});
|
||||
}
|
||||
// TODO (URL , etc)
|
||||
if (!$stateParams.toAddress || !$stateParams.toAmount) {
|
||||
$log.error('Bad params at amount')
|
||||
throw ('bad params');
|
||||
}
|
||||
$scope.isCordova = platformInfo.isCordova;
|
||||
|
||||
var config = configService.getSync().wallet;
|
||||
$scope.feeLevel = config.settings ? config.settings.feeLevel : '';
|
||||
|
||||
var amount = $scope.toAmount = parseInt($stateParams.toAmount);
|
||||
$scope.amountStr = txFormatService.formatAmountStr($scope.toAmount);
|
||||
|
||||
$scope.toAddress = $stateParams.toAddress;
|
||||
$scope.toName = $stateParams.toName;
|
||||
$scope.toEmail = $stateParams.toEmail;
|
||||
$scope.description = $stateParams.description;
|
||||
$scope.paypro = $stateParams.paypro;
|
||||
|
||||
var networkName = (new bitcore.Address($scope.toAddress)).network.name;
|
||||
$scope.network = networkName;
|
||||
|
||||
$scope.notAvailable = false;
|
||||
var wallets = profileService.getWallets({
|
||||
onlyComplete: true,
|
||||
network: networkName,
|
||||
});
|
||||
|
||||
var filteredWallets = [];
|
||||
var index = 0;
|
||||
|
||||
lodash.each(wallets, function(w) {
|
||||
walletService.getStatus(w, {}, function(err, status) {
|
||||
if (err || !status) {
|
||||
$log.error(err);
|
||||
} else {
|
||||
if (!status.availableBalanceSat) $log.debug('No balance available in: ' + w.name);
|
||||
if (status.availableBalanceSat > amount) filteredWallets.push(w);
|
||||
}
|
||||
|
||||
if (++index == wallets.length) {
|
||||
if (!lodash.isEmpty(filteredWallets)) {
|
||||
$scope.wallets = lodash.clone(filteredWallets);
|
||||
$scope.notAvailable = false;
|
||||
} else {
|
||||
$scope.notAvailable = true;
|
||||
$log.warn('No wallet available to make the payment');
|
||||
}
|
||||
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
return;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
txFormatService.formatAlternativeStr(amount, function(v) {
|
||||
$scope.alternativeAmountStr = v;
|
||||
});
|
||||
};
|
||||
|
||||
function setWallet(wallet, delayed) {
|
||||
var stop;
|
||||
$scope.wallet = wallet;
|
||||
|
|
@ -258,7 +264,8 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
|
||||
return walletService.onlyPublish(wallet, txp, function(err, txp) {
|
||||
if (err) return setSendError(err);
|
||||
$state.transitionTo('tabs.home');
|
||||
$ionicHistory.clearHistory();
|
||||
$state.go('tabs.home');
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -275,6 +282,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
};
|
||||
|
||||
$scope.cancel = function() {
|
||||
$state.transitionTo('tabs.send');
|
||||
$state.go('tabs.send');
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -49,28 +49,11 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
|
|||
});
|
||||
};
|
||||
|
||||
$scope.options = {
|
||||
loop: false,
|
||||
effect: 'flip',
|
||||
speed: 500,
|
||||
pagination: false,
|
||||
initialSlide: 1
|
||||
}
|
||||
|
||||
$scope.$on("$ionicSlides.sliderInitialized", function(event, data) {
|
||||
$scope.slider = data.slider;
|
||||
$scope.$on('accepted', function(event) {
|
||||
$scope.hideSlider = true;
|
||||
$scope.sign();
|
||||
});
|
||||
|
||||
$scope.$on("$ionicSlides.slideChangeStart", function(event, data) {
|
||||
$scope.data.index = data.slider.activeIndex;
|
||||
if ($scope.data.index == 0) {
|
||||
$scope.hideSlider = true;
|
||||
$scope.sign();
|
||||
}
|
||||
});
|
||||
|
||||
$scope.$on("$ionicSlides.slideChangeEnd", function(event, data) {});
|
||||
|
||||
checkPaypro();
|
||||
|
||||
// ToDo: use tx.customData instead of tx.message
|
||||
|
|
|
|||
|
|
@ -162,4 +162,20 @@ angular.module('copayApp.directives')
|
|||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
.directive('accept', function($log, profileService, walletService, lodash) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
templateUrl: 'views/includes/acceptSlide.html',
|
||||
scope: {},
|
||||
link: function(scope, element, attrs) {
|
||||
scope.$on("$ionicSlides.sliderInitialized", function(event, data) {
|
||||
scope.slider = data.slider;
|
||||
});
|
||||
|
||||
scope.$on("$ionicSlides.slideChangeEnd", function(event, data) {
|
||||
if (data.slider.activeIndex == 0) scope.$emit('accepted');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,4 +4,11 @@
|
|||
position: absolute;
|
||||
top: 10px;
|
||||
}
|
||||
.accept-slide {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue