Revert "use ios and android keyboard for entering amount"
This reverts commit a399023e00.
This commit is contained in:
parent
a399023e00
commit
2fb7a08be4
2 changed files with 68 additions and 85 deletions
|
|
@ -18,11 +18,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
|
||||
var fixedUnit;
|
||||
|
||||
$scope.amountModel = { amount: 0 };
|
||||
|
||||
$scope.isChromeApp = platformInfo.isChromeApp;
|
||||
$scope.isAndroid = platformInfo.isAndroid;
|
||||
$scope.isIos = platformInfo.isIOS;
|
||||
|
||||
$scope.$on('$ionicView.leave', function() {
|
||||
angular.element($window).off('keydown');
|
||||
|
|
@ -34,6 +30,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
$scope.minShapeshiftAmount = parseFloat(data.stateParams.minShapeshiftAmount);
|
||||
$scope.maxShapeshiftAmount = parseFloat(data.stateParams.maxShapeshiftAmount);
|
||||
$scope.shapeshiftOrderId = data.stateParams.shapeshiftOrderId;
|
||||
//console.log($scope.shapeshiftOrderId);
|
||||
}
|
||||
|
||||
var config = configService.getSync().wallet.settings;
|
||||
|
|
@ -139,28 +136,25 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
var reNr = /^[1234567890\.]$/;
|
||||
var reOp = /^[\*\+\-\/]$/;
|
||||
|
||||
if (!$scope.isAndroid && !$scope.isIos) {
|
||||
var disableKeys = angular.element($window).on('keydown', function(e) {
|
||||
if (!e.key) return;
|
||||
if (e.which === 8) { // you can add others here inside brackets.
|
||||
e.preventDefault();
|
||||
$scope.removeDigit();
|
||||
}
|
||||
var disableKeys = angular.element($window).on('keydown', function(e) {
|
||||
if (!e.key) return;
|
||||
if (e.which === 8) { // you can add others here inside brackets.
|
||||
e.preventDefault();
|
||||
$scope.removeDigit();
|
||||
}
|
||||
|
||||
if (e.key.match(reNr)) {
|
||||
$scope.pushDigit(e.key);
|
||||
} else if (e.key.match(reOp)) {
|
||||
$scope.pushOperator(e.key);
|
||||
} else if (e.keyCode === 86) {
|
||||
if (e.ctrlKey || e.metaKey) processClipboard();
|
||||
} else if (e.keyCode === 13) $scope.finish();
|
||||
if (e.key.match(reNr)) {
|
||||
$scope.pushDigit(e.key);
|
||||
} else if (e.key.match(reOp)) {
|
||||
$scope.pushOperator(e.key);
|
||||
} else if (e.keyCode === 86) {
|
||||
if (e.ctrlKey || e.metaKey) processClipboard();
|
||||
} else if (e.keyCode === 13) $scope.finish();
|
||||
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
$scope.specificAmount = $scope.specificAlternativeAmount = '';
|
||||
$scope.isCordova = platformInfo.isCordova;
|
||||
unitToSatoshi = config.unitToSatoshi;
|
||||
|
|
@ -172,10 +166,10 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
|
||||
// in SAT ALWAYS
|
||||
if ($stateParams.toAmount) {
|
||||
$scope.amountModel.amount = (($stateParams.toAmount) * satToUnit).toFixed(unitDecimals);
|
||||
$scope.amount = (($stateParams.toAmount) * satToUnit).toFixed(unitDecimals);
|
||||
}
|
||||
|
||||
$scope.processAmount();
|
||||
processAmount();
|
||||
|
||||
$timeout(function() {
|
||||
$ionicScrollDelegate.resize();
|
||||
|
|
@ -196,8 +190,8 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
}
|
||||
|
||||
function paste(value) {
|
||||
$scope.amountModel.amount = value;
|
||||
$scope.processAmount();
|
||||
$scope.amount = value;
|
||||
processAmount();
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
|
|
@ -221,8 +215,8 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
|
||||
|
||||
$scope.toggleAlternative = function() {
|
||||
if ($scope.amountModel.amount && isExpression($scope.amountModel.amount)) {
|
||||
var amount = evaluate(format($scope.amountModel.amount));
|
||||
if ($scope.amount && isExpression($scope.amount)) {
|
||||
var amount = evaluate(format($scope.amount));
|
||||
$scope.globalResult = '= ' + processResult(amount);
|
||||
}
|
||||
};
|
||||
|
|
@ -231,7 +225,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
$scope.unit = availableUnits[unitIndex].shortName;
|
||||
$scope.alternativeUnit = availableUnits[altUnitIndex].shortName;
|
||||
|
||||
$scope.processAmount();
|
||||
processAmount();
|
||||
$log.debug('Update unit coin @amount unit:' + $scope.unit + " alternativeUnit:" + $scope.alternativeUnit);
|
||||
};
|
||||
|
||||
|
|
@ -273,23 +267,23 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
};
|
||||
|
||||
function checkFontSize() {
|
||||
if ($scope.amountModel.amount && $scope.amountModel.amount.length >= SMALL_FONT_SIZE_LIMIT) $scope.smallFont = true;
|
||||
if ($scope.amount && $scope.amount.length >= SMALL_FONT_SIZE_LIMIT) $scope.smallFont = true;
|
||||
else $scope.smallFont = false;
|
||||
};
|
||||
|
||||
$scope.pushDigit = function(digit) {
|
||||
if ($scope.amountModel.amount && $scope.amountModel.amount.length >= LENGTH_EXPRESSION_LIMIT) return;
|
||||
if (!$scope.isAndroid && !$scope.isIos && $scope.amountModel.amount.indexOf('.') > -1 && digit == '.') return;
|
||||
if (availableUnits[unitIndex].isFiat && $scope.amountModel.amount.indexOf('.') > -1 && $scope.amountModel.amount[$scope.amountModel.amount.indexOf('.') + 2]) return;
|
||||
if ($scope.amount && $scope.amount.length >= LENGTH_EXPRESSION_LIMIT) return;
|
||||
if ($scope.amount.indexOf('.') > -1 && digit == '.') return;
|
||||
if (availableUnits[unitIndex].isFiat && $scope.amount.indexOf('.') > -1 && $scope.amount[$scope.amount.indexOf('.') + 2]) return;
|
||||
|
||||
$scope.amountModel.amount = ($scope.amountModel.amount + digit).replace('..', '.');
|
||||
$scope.amount = ($scope.amount + digit).replace('..', '.');
|
||||
checkFontSize();
|
||||
$scope.processAmount();
|
||||
processAmount();
|
||||
};
|
||||
|
||||
$scope.pushOperator = function(operator) {
|
||||
if (!$scope.amountModel.amount || $scope.amountModel.amount.length == 0) return;
|
||||
$scope.amountModel.amount = _pushOperator($scope.amountModel.amount);
|
||||
if (!$scope.amount || $scope.amount.length == 0) return;
|
||||
$scope.amount = _pushOperator($scope.amount);
|
||||
|
||||
function _pushOperator(val) {
|
||||
if (!isOperator(lodash.last(val))) {
|
||||
|
|
@ -311,26 +305,26 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
};
|
||||
|
||||
$scope.removeDigit = function() {
|
||||
$scope.amountModel.amount = ($scope.amountModel.amount).toString().slice(0, -1);
|
||||
$scope.processAmount();
|
||||
$scope.amount = ($scope.amount).toString().slice(0, -1);
|
||||
processAmount();
|
||||
checkFontSize();
|
||||
};
|
||||
|
||||
$scope.resetAmount = function() {
|
||||
$scope.amountModel.amount = $scope.alternativeAmount = $scope.globalResult = '';
|
||||
$scope.amount = $scope.alternativeAmount = $scope.globalResult = '';
|
||||
$scope.allowSend = false;
|
||||
checkFontSize();
|
||||
};
|
||||
|
||||
$scope.processAmount = function() {
|
||||
var formatedValue = format($scope.amountModel.amount);
|
||||
function processAmount() {
|
||||
var formatedValue = format($scope.amount);
|
||||
var result = evaluate(formatedValue);
|
||||
$scope.allowSend = lodash.isNumber(result) && +result > 0
|
||||
&& (!$scope.shapeshiftOrderId
|
||||
|| (result >= $scope.minShapeshiftAmount && result <= $scope.maxShapeshiftAmount));
|
||||
|
||||
if (lodash.isNumber(result)) {
|
||||
$scope.globalResult = isExpression($scope.amountModel.amount) ? '= ' + processResult(result) : '';
|
||||
$scope.globalResult = isExpression($scope.amount) ? '= ' + processResult(result) : '';
|
||||
|
||||
if (availableUnits[unitIndex].isFiat) {
|
||||
|
||||
|
|
@ -390,7 +384,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
$scope.finish = function() {
|
||||
|
||||
var unit = availableUnits[unitIndex];
|
||||
var _amount = evaluate(format($scope.amountModel.amount));
|
||||
var _amount = evaluate(format($scope.amount));
|
||||
var coin = unit.id;
|
||||
if (unit.isFiat) {
|
||||
coin = availableUnits[altUnitIndex].id;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue