diff --git a/public/views/modals/customized-amount.html b/public/views/modals/customized-amount.html deleted file mode 100644 index 755b38b1f..000000000 --- a/public/views/modals/customized-amount.html +++ /dev/null @@ -1,88 +0,0 @@ - - - -

Request a specific amount

-
- - - - - diff --git a/public/views/modals/inputAmount.html b/public/views/modals/inputAmount.html index a4e2a6948..28e360fda 100644 --- a/public/views/modals/inputAmount.html +++ b/public/views/modals/inputAmount.html @@ -1,4 +1,4 @@ - + -
-
-
{{amount}}
-
{{amountResult}} {{alternativeIsoCode}}
-
${{alternativeAmount}}
-
{{alternativeResult}} {{unitName}}
+ +
+
+
{{amount}}
+
{{amountResult}} {{alternativeIsoCode}}
+
${{alternativeAmount}}
+
{{alternativeResult}} {{unitName}}
+
+ +
+ + + + +
+ +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
-
- - - - -
+ -
- \ No newline at end of file + + diff --git a/public/views/walletHome.html b/public/views/walletHome.html index 41ea72713..7c8bc9f1b 100644 --- a/public/views/walletHome.html +++ b/public/views/walletHome.html @@ -303,9 +303,9 @@
-
@@ -407,11 +407,11 @@
- + Not valid - +
diff --git a/src/css/ionic-migration.css b/src/css/ionic-migration.css index 01a6623d7..4b666e7a8 100644 --- a/src/css/ionic-migration.css +++ b/src/css/ionic-migration.css @@ -107,17 +107,7 @@ border: 1px solid #E9E9EC; } -.button.button-balanced:hover { - background-color: #b2b2b2; - border: 1px solid #E9E9EC; -} - -.button.button-balanced:active { - background-color: #ababab; - border: 1px solid #E9E9EC; -} - -.button { +.button-amount { text-transform: none; } 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/modals/inputAmount.js b/src/js/controllers/modals/inputAmount.js index 94e43520d..0b3b60e69 100644 --- a/src/js/controllers/modals/inputAmount.js +++ b/src/js/controllers/modals/inputAmount.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('inputAmountController', function($scope, lodash, configService, go, rateService) { +angular.module('copayApp.controllers').controller('inputAmountController', function($rootScope, $scope, lodash, configService, go, rateService) { var unitToSatoshi; var satToUnit; var unitDecimals; @@ -10,10 +10,10 @@ angular.module('copayApp.controllers').controller('inputAmountController', funct var config = configService.getSync().wallet.settings; $scope.unitName = config.unitName; $scope.alternativeIsoCode = config.alternativeIsoCode; + $scope.specificAmount = $scope.specificAlternativeAmount = null; unitToSatoshi = config.unitToSatoshi; satToUnit = 1 / unitToSatoshi; unitDecimals = config.unitDecimals; - console.log($scope.showAlternativeAmount); resetAmount(); }; @@ -23,11 +23,11 @@ angular.module('copayApp.controllers').controller('inputAmountController', funct if ($scope.showAlternativeAmount) { $scope.alternativeAmount = $scope.amountResult; - amount = processFormat($scope.amount); + amount = format($scope.amount); $scope.alternativeResult = isOperator(lodash.last(amount)) ? evaluate(amount.slice(0, -1)) : evaluate(amount); } else { $scope.amount = $scope.alternativeResult; - amount = processFormat($scope.alternativeAmount); + amount = format($scope.alternativeAmount); $scope.amountResult = isOperator(lodash.last(amount)) ? evaluate(amount.slice(0, -1)) : evaluate(amount); } }; @@ -105,16 +105,24 @@ angular.module('copayApp.controllers').controller('inputAmountController', funct } } - var formatedValue = processFormat(val); + var formatedValue = format(val); var result = evaluate(formatedValue); if (lodash.isNumber(result)) { $scope.amount = $scope.alternativeAmount = val; - $scope.alternativeResult = parseFloat((rateService.fromFiat(result, $scope.alternativeIsoCode) * satToUnit).toFixed(unitDecimals), 10); - $scope.amountResult = parseFloat((rateService.toFiat(result * unitToSatoshi, $scope.alternativeIsoCode)).toFixed(2), 10); + $scope.alternativeResult = fromFiat(result); + $scope.amountResult = toFiat(result); } }; + function fromFiat(val) { + return parseFloat((rateService.fromFiat(val, $scope.alternativeIsoCode) * satToUnit).toFixed(unitDecimals), 10); + }; + + function toFiat(val) { + return parseFloat((rateService.toFiat(val * unitToSatoshi, $scope.alternativeIsoCode)).toFixed(2), 10); + }; + function evaluate(val) { var result; try { @@ -125,23 +133,27 @@ angular.module('copayApp.controllers').controller('inputAmountController', funct return result; }; - function processFormat(val) { + function format(val) { return val.toString().replace('x', '*'); }; - $scope.save = function() { - if ($scope.showAlternativeAmount) { - if ($scope.alternativeResult == 0) return; + $scope.finish = function() { + var amount = toFiat($scope.alternativeResult); + var alternativeAmount = $scope.showAlternative ? fromFiat(amount) : toFiat(amount); - self.showAlternativeAmount = true; - self.setForm(null, $scope.alternativeResult, null); + if ($scope.address) { + $scope.specificAmount = amount; + $scope.specificAlternativeAmount = alternativeAmount; } else { - if ($scope.amountResult == 0) return; - - self.showAlternativeAmount = false; - self.setForm(null, $scope.amountResult, null); + if ($scope.showAlternativeAmount) { + self.showAlternative = true; + self.setForm(null, alternativeAmount, null); + } else { + self.showAlternative = false; + self.setForm(null, amount, null); + } + $scope.cancel(); } - $scope.cancel(); }; $scope.cancel = function() { diff --git a/src/js/controllers/walletHome.js b/src/js/controllers/walletHome.js index 59cbab500..980c509f6 100644 --- a/src/js/controllers/walletHome.js +++ b/src/js/controllers/walletHome.js @@ -216,21 +216,6 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi } }; - this.openCustomizedAmountModal = function(addr) { - var fc = profileService.focusedClient; - - $scope.color = fc.backgroundColor; - $scope.self = self; - $scope.addr = addr; - - $ionicModal.fromTemplateUrl('views/modals/customized-amount.html', { - scope: $scope - }).then(function(modal) { - $scope.customAmountModal = modal; - $scope.customAmountModal.show(); - }); - }; - // Send this.resetError = function() { @@ -544,10 +529,11 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi }); }; - $scope.openInputAmountModal = function() { + $scope.openInputAmountModal = function(addr) { var fc = profileService.focusedClient; $scope.color = fc.backgroundColor; $scope.showAlternativeAmount = $scope.showAlternative || null; + $scope.address = addr || null; $scope.self = self; $ionicModal.fromTemplateUrl('views/modals/inputAmount.html', {