diff --git a/public/views/modals/amountInput.html b/public/views/modals/inputAmount.html similarity index 58% rename from public/views/modals/amountInput.html rename to public/views/modals/inputAmount.html index 61a7b56e4..a4e2a6948 100644 --- a/public/views/modals/amountInput.html +++ b/public/views/modals/inputAmount.html @@ -1,26 +1,23 @@ - - - -
- Close -
-

Enter amount

- -
- -
-
{{amount}}
-
{{amountResult}} {{alternativeIsoCode}}
-
${{alternativeAmount}}
-
{{alternativeResult}} {{unitName}}
+ + + +

Enter amount

+ +
-
- - +
+
+
{{amount}}
+
{{amountResult}} {{alternativeIsoCode}}
+
${{alternativeAmount}}
+
{{alternativeResult}} {{unitName}}
@@ -52,5 +49,15 @@
- + +
+
+ +
+
+
\ No newline at end of file diff --git a/public/views/walletHome.html b/public/views/walletHome.html index 1342d5cd9..41ea72713 100644 --- a/public/views/walletHome.html +++ b/public/views/walletHome.html @@ -420,8 +420,8 @@ Amount [{{home.alternativeIsoCode}}] diff --git a/src/js/controllers/modals/amountInput.js b/src/js/controllers/modals/inputAmount.js similarity index 75% rename from src/js/controllers/modals/amountInput.js rename to src/js/controllers/modals/inputAmount.js index 5ae1552ba..94e43520d 100644 --- a/src/js/controllers/modals/amountInput.js +++ b/src/js/controllers/modals/inputAmount.js @@ -1,9 +1,10 @@ 'use strict'; -angular.module('copayApp.controllers').controller('amountInputController', function($scope, lodash, configService, go, rateService) { +angular.module('copayApp.controllers').controller('inputAmountController', function($scope, lodash, configService, go, rateService) { var unitToSatoshi; var satToUnit; var unitDecimals; + var self = $scope.self; $scope.init = function() { var config = configService.getSync().wallet.settings; @@ -12,15 +13,15 @@ angular.module('copayApp.controllers').controller('amountInputController', funct unitToSatoshi = config.unitToSatoshi; satToUnit = 1 / unitToSatoshi; unitDecimals = config.unitDecimals; - $scope.showAlternative = false; + console.log($scope.showAlternativeAmount); resetAmount(); }; $scope.toggleAlternative = function() { - $scope.showAlternative = !$scope.showAlternative; + $scope.showAlternativeAmount = !$scope.showAlternativeAmount; var amount; - if ($scope.showAlternative) { + if ($scope.showAlternativeAmount) { $scope.alternativeAmount = $scope.amountResult; amount = processFormat($scope.amount); $scope.alternativeResult = isOperator(lodash.last(amount)) ? evaluate(amount.slice(0, -1)) : evaluate(amount); @@ -32,7 +33,7 @@ angular.module('copayApp.controllers').controller('amountInputController', funct }; $scope.pushDigit = function(digit) { - var amount = $scope.showAlternative ? $scope.alternativeAmount : $scope.amount; + var amount = $scope.showAlternativeAmount ? $scope.alternativeAmount : $scope.amount; if (amount.toString().length >= 10) return; if (amount == 0 && digit == 0) return; @@ -42,7 +43,7 @@ angular.module('copayApp.controllers').controller('amountInputController', funct }; $scope.pushOperator = function(operator) { - if ($scope.showAlternative) { + if ($scope.showAlternativeAmount) { if (!$scope.alternativeAmount || $scope.alternativeAmount.length == 0) return; $scope.alternativeAmount = _pushOperator($scope.alternativeAmount); } else { @@ -67,16 +68,16 @@ angular.module('copayApp.controllers').controller('amountInputController', funct }; $scope.removeDigit = function() { - var amount = $scope.showAlternative ? $scope.alternativeAmount : $scope.amount; + var amount = $scope.showAlternativeAmount ? $scope.alternativeAmount : $scope.amount; if (amount && amount.toString().length == 0) { resetAmount(); return; } - amount = amount.slice(0, -1); + amount = amount.toString().slice(0, -1); - if ($scope.showAlternative) + if ($scope.showAlternativeAmount) $scope.alternativeAmount = amount; else $scope.amount = amount; @@ -94,7 +95,7 @@ angular.module('copayApp.controllers').controller('amountInputController', funct return; } - if ($scope.showAlternative) { + if ($scope.showAlternativeAmount) { if ($scope.alternativeAmount == 0 && val == '.') { $scope.alternativeAmount += val; } @@ -128,7 +129,22 @@ angular.module('copayApp.controllers').controller('amountInputController', funct return val.toString().replace('x', '*'); }; - $scope.close = function() { - go.walletHome(); + $scope.save = function() { + if ($scope.showAlternativeAmount) { + if ($scope.alternativeResult == 0) return; + + self.showAlternativeAmount = true; + self.setForm(null, $scope.alternativeResult, null); + } else { + if ($scope.amountResult == 0) return; + + self.showAlternativeAmount = false; + self.setForm(null, $scope.amountResult, null); + } + $scope.cancel(); + }; + + $scope.cancel = function() { + $scope.inputAmountModal.hide(); }; }); diff --git a/src/js/controllers/walletHome.js b/src/js/controllers/walletHome.js index 52c0f03c9..59cbab500 100644 --- a/src/js/controllers/walletHome.js +++ b/src/js/controllers/walletHome.js @@ -544,6 +544,20 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi }); }; + $scope.openInputAmountModal = function() { + var fc = profileService.focusedClient; + $scope.color = fc.backgroundColor; + $scope.showAlternativeAmount = $scope.showAlternative || null; + $scope.self = self; + + $ionicModal.fromTemplateUrl('views/modals/inputAmount.html', { + scope: $scope + }).then(function(modal) { + $scope.inputAmountModal = modal; + $scope.inputAmountModal.show(); + }); + }; + this.setForm = function(to, amount, comment) { var form = $scope.sendForm; if (to) {