From a7b2dc24af568758358c6f6d1f1019bdd506de35 Mon Sep 17 00:00:00 2001 From: Javier Date: Fri, 25 Nov 2016 15:12:55 -0300 Subject: [PATCH] replace selector for menu popover --- src/js/controllers/amount.js | 26 ++++++++++++++++---- src/js/directives/sendMaxSelector.js | 26 -------------------- src/sass/views/includes/sendMaxSelector.scss | 21 ---------------- www/views/amount.html | 7 +----- www/views/includes/sendMaxSelector.html | 12 --------- 5 files changed, 22 insertions(+), 70 deletions(-) delete mode 100644 src/js/directives/sendMaxSelector.js delete mode 100644 src/sass/views/includes/sendMaxSelector.scss delete mode 100644 www/views/includes/sendMaxSelector.html diff --git a/src/js/controllers/amount.js b/src/js/controllers/amount.js index 47faec030..f4f8d9d72 100644 --- a/src/js/controllers/amount.js +++ b/src/js/controllers/amount.js @@ -1,12 +1,13 @@ 'use strict'; -angular.module('copayApp.controllers').controller('amountController', function($scope, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService, ongoingProcess, bitpayCardService, popupService, bwcError, payproService, profileService, bitcore, amazonService) { +angular.module('copayApp.controllers').controller('amountController', function($scope, $filter, $timeout, $ionicScrollDelegate, $ionicHistory, $ionicPopover, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService, ongoingProcess, bitpayCardService, popupService, bwcError, payproService, profileService, bitcore, amazonService) { var unitToSatoshi; var satToUnit; var unitDecimals; var satToBtc; var SMALL_FONT_SIZE_LIMIT = 10; var LENGTH_EXPRESSION_LIMIT = 19; + var MENU_ITEM_HEIGHT = 55; $scope.$on('$ionicView.leave', function() { angular.element($window).off('keydown'); @@ -14,6 +15,7 @@ angular.module('copayApp.controllers').controller('amountController', function($ $scope.$on("$ionicView.beforeEnter", function(event, data) { $scope.isGiftCard = data.stateParams.isGiftCard; + $scope.showMenu = $ionicHistory.backView().stateName == 'tabs.send'; $scope.isWallet = data.stateParams.isWallet; $scope.cardId = data.stateParams.cardId; $scope.toAddress = data.stateParams.toAddress; @@ -73,14 +75,28 @@ angular.module('copayApp.controllers').controller('amountController', function($ $timeout(function() { $ionicScrollDelegate.resize(); - }); + }, 10); }); - $scope.showSendMaxSelector = function() { - $scope.sendMax = true; + $scope.showSendMaxMenu = function($event) { + var sendMaxObj = { + text: gettextCatalog.getString('Send max amount'), + action: setSendMax, + }; + + $scope.items = [sendMaxObj]; + $scope.height = $scope.items.length * MENU_ITEM_HEIGHT; + + $ionicPopover.fromTemplateUrl('views/includes/menu-popover.html', { + scope: $scope + }).then(function(popover) { + $scope.menu = popover; + $scope.menu.show($event); + }); }; - $scope.setSendMax = function() { + function setSendMax() { + $scope.menu.hide(); $state.transitionTo('tabs.send.confirm', { isWallet: $scope.isWallet, toAmount: null, diff --git a/src/js/directives/sendMaxSelector.js b/src/js/directives/sendMaxSelector.js deleted file mode 100644 index 8cb7f397d..000000000 --- a/src/js/directives/sendMaxSelector.js +++ /dev/null @@ -1,26 +0,0 @@ -'use strict'; - -angular.module('copayApp.directives') - .directive('sendMaxSelector', function($timeout) { - return { - restrict: 'E', - templateUrl: 'views/includes/sendMaxSelector.html', - transclude: true, - scope: { - show: '=sendMaxSelectorShow', - wallet: '=sendMaxSelectorWallet', - onSelect: '=sendMaxSelectorOnSelect' - }, - link: function(scope, element, attrs) { - scope.hide = function() { - scope.show = false; - }; - scope.setSendMax = function() { - $timeout(function() { - scope.hide(); - }, 100); - scope.onSelect(); - }; - } - }; - }); diff --git a/src/sass/views/includes/sendMaxSelector.scss b/src/sass/views/includes/sendMaxSelector.scss deleted file mode 100644 index 6463fdb93..000000000 --- a/src/sass/views/includes/sendMaxSelector.scss +++ /dev/null @@ -1,21 +0,0 @@ -send-max-selector { - - .bp-action-sheet__sheet { - padding-left: 2rem; - padding-right: .75rem; - } - - .max-selector { - a.item { - border: none; - padding-top: 20px; - padding-bottom: 20px; - span { - &.item-note { - color: #3A3A3A; - font-family: "Roboto-Light"; - } - } - } - } -} diff --git a/www/views/amount.html b/www/views/amount.html index 24df99096..cfdfb9373 100644 --- a/www/views/amount.html +++ b/www/views/amount.html @@ -6,7 +6,7 @@ - @@ -98,9 +98,4 @@ - - diff --git a/www/views/includes/sendMaxSelector.html b/www/views/includes/sendMaxSelector.html deleted file mode 100644 index 29241b5b1..000000000 --- a/www/views/includes/sendMaxSelector.html +++ /dev/null @@ -1,12 +0,0 @@ - -
Shortcuts
- - - Send max amount - {{wallet.status.availableBalanceStr}} - - -
- Cancel -
-