diff --git a/src/js/controllers/amount.js b/src/js/controllers/amount.js index 5eee4d003..73c53515d 100644 --- a/src/js/controllers/amount.js +++ b/src/js/controllers/amount.js @@ -24,7 +24,9 @@ angular.module('copayApp.controllers').controller('amountController', function($ $scope.showAlternativeAmount = !!$scope.cardId; $scope.toColor = data.stateParams.toColor; - if (!$scope.cardId && !$stateParams.toAddress) { + $scope.customAmount = data.stateParams.customAmount; + + if (!$scope.cardId && !data.stateParams.toAddress) { $log.error('Bad params at amount') throw ('bad params'); } @@ -240,13 +242,20 @@ angular.module('copayApp.controllers').controller('amountController', function($ } else { var amount = $scope.showAlternativeAmount ? fromFiat(_amount) : _amount; - $state.transitionTo('tabs.send.confirm', { - isWallet: $scope.isWallet, - toAmount: (amount * unitToSatoshi).toFixed(0), - toAddress: $scope.toAddress, - toName: $scope.toName, - toEmail: $scope.toEmail - }); + if ($scope.customAmount) { + $state.transitionTo('tabs.receive.customAmount', { + toAmount: (amount * unitToSatoshi).toFixed(0), + toAddress: $scope.toAddress + }); + } else { + $state.transitionTo('tabs.send.confirm', { + isWallet: $scope.isWallet, + toAmount: (amount * unitToSatoshi).toFixed(0), + toAddress: $scope.toAddress, + toName: $scope.toName, + toEmail: $scope.toEmail + }); + } } }; }); diff --git a/src/js/controllers/customAmount.js b/src/js/controllers/customAmount.js new file mode 100644 index 000000000..ea3e56ceb --- /dev/null +++ b/src/js/controllers/customAmount.js @@ -0,0 +1,27 @@ +'use strict'; + +angular.module('copayApp.controllers').controller('customAmountController', function($rootScope, $scope, $stateParams, $ionicHistory, txFormatService, platformInfo) { + + $scope.$on("$ionicView.beforeEnter", function(event, data) { + var satToBtc = 1 / 100000000; + $scope.isCordova = platformInfo.isCordova; + $scope.address = data.stateParams.toAddress; + $scope.amount = parseInt(data.stateParams.toAmount); + $scope.amountBtc = ($scope.amount * satToBtc).toFixed(8); + $scope.amountStr = txFormatService.formatAmountStr($scope.amount); + $scope.altAmountStr = txFormatService.formatAlternativeStr($scope.amount); + }); + + $scope.shareAddress = function(uri) { + window.plugins.socialsharing.share(uri, null, null, null); + }; + + $scope.finish = function() { + $ionicHistory.nextViewOptions({ + disableAnimate: false, + historyRoot: true + }); + $ionicHistory.goBack(-2); + }; + +}); diff --git a/src/js/controllers/modals/customAmount.js b/src/js/controllers/modals/customAmount.js deleted file mode 100644 index 386ed1073..000000000 --- a/src/js/controllers/modals/customAmount.js +++ /dev/null @@ -1,79 +0,0 @@ -'use strict'; - -angular.module('copayApp.controllers').controller('customAmountController', function($scope, $timeout, $filter, platformInfo, rateService) { - var self = $scope.self; - - $scope.unitName = self.unitName; - $scope.alternativeAmount = self.alternativeAmount; - $scope.alternativeName = self.alternativeName; - $scope.alternativeIsoCode = self.alternativeIsoCode; - $scope.isRateAvailable = self.isRateAvailable; - $scope.unitToSatoshi = self.unitToSatoshi; - $scope.unitDecimals = self.unitDecimals; - var satToUnit = 1 / self.unitToSatoshi; - $scope.showAlternative = false; - $scope.isCordova = platformInfo.isCordova; - - Object.defineProperty($scope, - "_customAlternative", { - get: function() { - return $scope.customAlternative; - }, - set: function(newValue) { - $scope.customAlternative = newValue; - if (typeof(newValue) === 'number' && $scope.isRateAvailable) { - $scope.customAmount = parseFloat((rateService.fromFiat(newValue, $scope.alternativeIsoCode) * satToUnit).toFixed($scope.unitDecimals), 10); - } else { - $scope.customAmount = null; - } - }, - enumerable: true, - configurable: true - }); - - Object.defineProperty($scope, - "_customAmount", { - get: function() { - return $scope.customAmount; - }, - set: function(newValue) { - $scope.customAmount = newValue; - if (typeof(newValue) === 'number' && $scope.isRateAvailable) { - $scope.customAlternative = parseFloat((rateService.toFiat(newValue * $scope.unitToSatoshi, $scope.alternativeIsoCode)).toFixed(2), 10); - } else { - $scope.customAlternative = null; - } - $scope.alternativeAmount = $scope.customAlternative; - }, - enumerable: true, - configurable: true - }); - - $scope.submitForm = function(form) { - var satToBtc = 1 / 100000000; - var amount = form.amount.$modelValue; - var amountSat = parseInt((amount * $scope.unitToSatoshi).toFixed(0)); - $timeout(function() { - $scope.customizedAmountUnit = amount + ' ' + $scope.unitName; - $scope.customizedAlternativeUnit = $filter('formatFiatAmount')(form.alternative.$modelValue) + ' ' + $scope.alternativeIsoCode; - if ($scope.unitName == 'bits') { - amount = (amountSat * satToBtc).toFixed(8); - } - $scope.customizedAmountBtc = amount; - }, 1); - }; - - $scope.toggleAlternative = function() { - $scope.showAlternative = !$scope.showAlternative; - }; - - $scope.shareAddress = function(uri) { - if (platformInfo.isCordova) { - window.plugins.socialsharing.share(uri, null, null, null); - } - }; - - $scope.cancel = function() { - $scope.customAmountModal.hide(); - }; -}); diff --git a/src/js/controllers/tab-receive.js b/src/js/controllers/tab-receive.js index cae89c917..14a61732a 100644 --- a/src/js/controllers/tab-receive.js +++ b/src/js/controllers/tab-receive.js @@ -1,8 +1,9 @@ 'use strict'; -angular.module('copayApp.controllers').controller('tabReceiveController', function($rootScope, $scope, $timeout, $log, $ionicModal, $state, $ionicHistory, storageService, platformInfo, walletService, profileService, configService, lodash, gettextCatalog, popupService, bwcError) { +angular.module('copayApp.controllers').controller('tabReceiveController', function($rootScope, $scope, $timeout, $log, $ionicModal, $state, $ionicHistory, $ionicPopover, storageService, platformInfo, walletService, profileService, configService, lodash, gettextCatalog, popupService, bwcError) { var listeners = []; + var MENU_ITEM_HEIGHT = 55; $scope.isCordova = platformInfo.isCordova; $scope.isNW = platformInfo.isNW; $scope.walletAddrs = {}; @@ -139,6 +140,31 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi }); }; + var goRequestAmount = function() { + $scope.menu.hide(); + $state.go('tabs.receive.amount', { + customAmount: true, + toAddress: $scope.addr + }); + } + + $scope.showMenu = function(allAddresses, $event) { + var requestAmountObj = { + text: gettextCatalog.getString('Request Specific amount'), + action: goRequestAmount, + }; + + $scope.items = [requestAmountObj]; + $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.$on("$ionicView.beforeEnter", function(event, data) { $scope.wallets = profileService.getWallets(); diff --git a/src/js/routes.js b/src/js/routes.js index 1141c5a33..6aa16fa48 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -632,6 +632,31 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr } }) + /* + * + * Request Specific amount + * + */ + + .state('tabs.receive.amount', { + url: '/amount/:customAmount/:toAddress', + views: { + 'tab-receive@tabs': { + controller: 'amountController', + templateUrl: 'views/amount.html' + } + } + }) + .state('tabs.receive.customAmount', { + url: '/customAmount/:toAmount/:toAddress', + views: { + 'tab-receive@tabs': { + controller: 'customAmountController', + templateUrl: 'views/customAmount.html' + } + } + }) + /* * * Init backup flow diff --git a/src/sass/views/amount.scss b/src/sass/views/amount.scss index 47df0f90f..0933f08ad 100644 --- a/src/sass/views/amount.scss +++ b/src/sass/views/amount.scss @@ -34,7 +34,7 @@ position: absolute; top: 10px; } - .amount-pane { + .amount-pane-send { position: absolute; top: 95px; bottom: 0; @@ -65,6 +65,37 @@ } } } + .amount-pane-receive { + position: absolute; + top: 0; + bottom: 0; + width: 100%; + background-color: #fff; + padding: 0 16px; + + .amount-bar { + padding: 24px 0; + font-size: 18px; + .title { + float: left; + padding-top: 10px; + color: $dark-gray; + font-weight: bold; + } + } + .amount { + display: flex; + flex-direction: column; + justify-content: center; + flex-grow: 1; + position: absolute; + bottom: 254px; + top: 66px; + .light { + color: $light-gray; + } + } + } .amount { &__editable { margin-bottom: 1rem; diff --git a/src/sass/views/custom-amount.scss b/src/sass/views/custom-amount.scss new file mode 100644 index 000000000..11d529355 --- /dev/null +++ b/src/sass/views/custom-amount.scss @@ -0,0 +1,16 @@ +#custom-amount { + .share { + justify-content: center; + } + .info { + .single-line { + display: flex; + align-items: center; + padding-top: 17px; + padding-bottom: 17px; + .item-note { + margin-left: 10px; + } + } + } +} diff --git a/src/sass/views/tab-receive.scss b/src/sass/views/tab-receive.scss index 4d36162a4..084baed3b 100644 --- a/src/sass/views/tab-receive.scss +++ b/src/sass/views/tab-receive.scss @@ -200,7 +200,7 @@ } } #bit-address { - position: realtive; + position: relative; } } } diff --git a/src/sass/views/views.scss b/src/sass/views/views.scss index 08bcddf5e..1e88f8af0 100644 --- a/src/sass/views/views.scss +++ b/src/sass/views/views.scss @@ -41,3 +41,4 @@ @import "includes/walletSelector"; @import "integrations/coinbase"; @import "integrations/glidera"; +@import "custom-amount"; diff --git a/www/views/amount.html b/www/views/amount.html index bafed47af..3dd481bb1 100644 --- a/www/views/amount.html +++ b/www/views/amount.html @@ -1,7 +1,7 @@ - {{'Enter Amount'|translate}} + {{'Enter Amount' | translate}} @@ -9,7 +9,7 @@ -
+
Recipient
@@ -26,7 +26,7 @@
-
+
Amount
diff --git a/www/views/customAmount.html b/www/views/customAmount.html new file mode 100644 index 000000000..0e250ad47 --- /dev/null +++ b/www/views/customAmount.html @@ -0,0 +1,39 @@ + + + + {{'Custom Amount' | translate}} + + + + + + + + +
+ + +
+
+
+ Address + + {{address}} + +
+
+ Amount + + {{amountStr}} - {{altAmountStr}} + +
+
+
+
diff --git a/www/views/modals/customAmount.html b/www/views/modals/customAmount.html deleted file mode 100644 index 2f33a3158..000000000 --- a/www/views/modals/customAmount.html +++ /dev/null @@ -1,88 +0,0 @@ - - - -

Request a specific amount

-
- - -
-
-

QR Code

-
    -
  • - -
    - - - Share address - -
    -
  • -
- -

Details

-
    -
  • - Address: - - {{addr}} - -
  • -
  • - Amount: - - {{customizedAmountUnit}} - {{customizedAlternativeUnit}} - -
  • -
-
- -
-
-
-
- - - Not valid - - - - -
-
- -
- - - {{unitName}} -
-
-
- - -
- - -
-
-
-
-
- diff --git a/www/views/tab-receive.html b/www/views/tab-receive.html index d07713685..fed491ad4 100644 --- a/www/views/tab-receive.html +++ b/www/views/tab-receive.html @@ -1,6 +1,11 @@ {{'Receive' | translate}} + + +