From 13cc57a509c0f35c62d72a8ca5df33e713eff50a Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Dominguez Date: Tue, 8 May 2018 00:06:59 +0900 Subject: [PATCH 1/8] test --- www/views/amount.html | 1 - 1 file changed, 1 deletion(-) diff --git a/www/views/amount.html b/www/views/amount.html index 5058f7221..75eddab3b 100644 --- a/www/views/amount.html +++ b/www/views/amount.html @@ -6,7 +6,6 @@ -
Recipient
From f4c0cc2bad202b62582b85768e04469904b09654 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Dominguez Date: Tue, 8 May 2018 00:28:44 +0900 Subject: [PATCH 2/8] Migration to virtual keyboard --- src/js/controllers/amount.js | 12 +- src/sass/views/amount.scss | 260 +++++++++++++++++++++++++++++------ www/css/main.css | 176 +++++++++++++++++++----- www/views/amount.html | 209 +++++++++++----------------- 4 files changed, 449 insertions(+), 208 deletions(-) diff --git a/src/js/controllers/amount.js b/src/js/controllers/amount.js index fd268671f..e3b29a12d 100644 --- a/src/js/controllers/amount.js +++ b/src/js/controllers/amount.js @@ -39,6 +39,10 @@ angular.module('copayApp.controllers').controller('amountController', function($ if (data.stateParams.noPrefix) { $scope.showWarningMessage = data.stateParams.noPrefix != 0; + if ($scope.showWarningMessage) { + var message = 'Address doesn\'t contain currency information, please make sure you are sending the correct currency.'; + popupService.showAlert('', message, function() {}, 'Ok'); + } } var config = configService.getSync().wallet.settings; @@ -245,6 +249,7 @@ angular.module('copayApp.controllers').controller('amountController', function($ }; $scope.changeUnit = function() { + $scope.amountModel.amount = '0'; if ($scope.alternativeAmount == 0) { $scope.alternativeAmount = null; @@ -293,9 +298,12 @@ angular.module('copayApp.controllers').controller('amountController', function($ $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 (($scope.amountModel.amount.indexOf('.') > -1 || $scope.amountModel.amount == '') && digit == '.') return; + if ($scope.amountModel.amount == '0' && digit == '0') return; if (availableUnits[unitIndex].isFiat && $scope.amountModel.amount.indexOf('.') > -1 && $scope.amountModel.amount[$scope.amountModel.amount.indexOf('.') + 2]) return; - + + if ($scope.amountModel.amount == '0' && digit != '.') { $scope.amountModel.amount = ''} + $scope.amountModel.amount = ($scope.amountModel.amount + digit).replace('..', '.'); checkFontSize(); $scope.processAmount(); diff --git a/src/sass/views/amount.scss b/src/sass/views/amount.scss index cd77cb501..08892c88d 100644 --- a/src/sass/views/amount.scss +++ b/src/sass/views/amount.scss @@ -233,58 +233,238 @@ } } } - .keypad { - text-align: center; - font-size: 24px; - font-weight: lighter; - position: absolute; - bottom: 0; - width: 100%; - color: $v-mid-gray; - .row { - padding: 0 !important; - margin: 0 !important; - } + .scroll-content { + display: flex; + flex-direction: column; - .col { - line-height: 45px; - } + .send-amount { + flex: 1 1 auto; + display: flex; + flex-direction: column; + justify-content: center; - .operator { - background-color: $v-subtle-gray; - font-weight: normal; - cursor: pointer; + .send-amount-tool { + flex: 0 1 auto; - &:active { - background-color: $v-light-gray; + .send-amount-tool-input { + text-align: center; + position: relative; + padding: 10px 30px; + + .primary-amount { + input, .unit, .primary-amount-display { + font-size: 1.8em; + + @media (min-width: 375px) { + font-size: 2.1em; + } + + @media (min-width: 414px) { + font-size: 2.4em; + } + } + + &.long { + input, .unit, .primary-amount-display { + font-size: 1.6em; + + @media (min-width: 375px) { + font-size: 1.8em; + } + + @media (min-width: 414px) { + font-size: 2em; + } + } + } + + &.very-long { + input, .unit, .primary-amount-display { + font-size: 0.9em; + + @media (min-width: 375px) { + font-size: 1.3em; + } + + @media (min-width: 414px) { + font-size: 1.4em; + } + } + } + + + input { + border:0; + padding:0; + white-space:normal; + background:none; + line-height:1; + box-sizing:content-box; + display: inline-block; + vertical-align: middle; + margin: 0; + height: 1em; + margin-right: 5px; + font-family: 'ProximaNova'; + + @media (min-width: 375px) { + } + + @media (min-width: 414px) { + } + } + + .unit, + .primary-amount-display { + display: inline-block; + vertical-align: middle; + line-height: 1em; + } + + .unit { + font-weight: bold; + } + + .primary-amount-display { + margin-right: 5px; + word-break: break-all; + } + } + + .switch-currencies { + position: absolute; + right: 0; + top: 50%; + transform: translate(0, -50%); + padding: 5px; + + img { + width: 18px; + } + } + } + + .send-amount-actions { + margin-top: 15px; + display: flex; + align-items: center; + justify-content: center; + + .button { + flex: 1 1 auto; + line-height: 1.2em; + + + .button { + margin-left: 10px; + } + + span { + display: flex; + align-items: center; + justify-content: center; + } + } + } } } - .operator-send { - font-weight: bolder; - color: #fff; - background-color: $positive; - font-size: 36px; - cursor: pointer; - - &:active { - background-color: #eaeaea; + .button { + &.no-margin { + margin: 0; } } - .digit{ - cursor: pointer; - border-top: 1px solid $v-subtle-gray; - border-left: 1px solid $v-subtle-gray; - &:active { - background-color: $v-subtle-gray; - } + .notification-warning { + display: block; + padding: .75rem 1.25rem; + color: #856404; + background-color: #fff3cd; + border: 1px solid #ffeeba; + line-height: 1.4em; + margin-bottom: 20px; } - @media(max-height: 480px) { - font-size: 12px; + .keypad-container { + position: relative; + //flex: 0 1 196px; + @media (min-height: 667px) { + //flex: 0 1 224px; + } + + .keypad { + text-align: center; + font-size: 18px; + font-weight: lighter; + position: absolute; + bottom: 0; + width: 100%; + color: $v-mid-gray; + + @media (min-height: 667px) { + font-size: 24px; + } + + .row { + padding: 0 !important; + margin: 0 !important; + } + + .col { + line-height: 38px; + + @media (min-height: 667px) { + line-height: 45px; + } + } + + .row { + &:last-child { + .col { + padding-bottom: 10px; + } + } + } + + .operator { + background-color: $v-subtle-gray; + font-weight: normal; + cursor: pointer; + + &:active { + background-color: $v-light-gray; + } + } + + .operator-send { + font-weight: bolder; + color: #fff; + background-color: $positive; + font-size: 36px; + cursor: pointer; + + &:active { + background-color: #eaeaea; + } + } + + .digit{ + cursor: pointer; + border-top: 1px solid $v-subtle-gray; + border-left: 1px solid $v-subtle-gray; + transition: all 0.1s ease; + + &:active { + background-color: $v-subtle-gray; + } + } + + @media(max-height: 480px) { + font-size: 12px; + + } + } } } -} +} \ No newline at end of file diff --git a/www/css/main.css b/www/css/main.css index 1cc07e123..9a78aed23 100644 --- a/www/css/main.css +++ b/www/css/main.css @@ -10425,42 +10425,146 @@ textarea.d-block { margin-top: 0; font-size: 16px; } } -#view-amount .keypad { - text-align: center; - font-size: 24px; - font-weight: lighter; - position: absolute; - bottom: 0; - width: 100%; - color: #667; } - #view-amount .keypad .row { - padding: 0 !important; - margin: 0 !important; } - #view-amount .keypad .col { - line-height: 45px; } - #view-amount .keypad .operator { - background-color: #f2f2f2; - font-weight: normal; - cursor: pointer; } - #view-amount .keypad .operator:active { - background-color: #9b9bab; } - #view-amount .keypad .operator-send { - font-weight: bolder; - color: #fff; - background-color: #494949; - font-size: 36px; - cursor: pointer; } - #view-amount .keypad .operator-send:active { - background-color: #eaeaea; } - #view-amount .keypad .digit { - cursor: pointer; - border-top: 1px solid #f2f2f2; - border-left: 1px solid #f2f2f2; } - #view-amount .keypad .digit:active { - background-color: #f2f2f2; } - @media (max-height: 480px) { - #view-amount .keypad { - font-size: 12px; } } +#view-amount .scroll-content { + display: flex; + flex-direction: column; } + #view-amount .scroll-content .send-amount { + flex: 1 1 auto; + display: flex; + flex-direction: column; + justify-content: center; } + #view-amount .scroll-content .send-amount .send-amount-tool { + flex: 0 1 auto; } + #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input { + text-align: center; + position: relative; + padding: 10px 30px; } + #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount input, #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount .unit, #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount .primary-amount-display { + font-size: 1.8em; } + @media (min-width: 375px) { + #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount input, #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount .unit, #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount .primary-amount-display { + font-size: 2.1em; } } + @media (min-width: 414px) { + #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount input, #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount .unit, #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount .primary-amount-display { + font-size: 2.4em; } } + #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount.long input, #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount.long .unit, #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount.long .primary-amount-display { + font-size: 1.6em; } + @media (min-width: 375px) { + #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount.long input, #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount.long .unit, #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount.long .primary-amount-display { + font-size: 1.8em; } } + @media (min-width: 414px) { + #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount.long input, #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount.long .unit, #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount.long .primary-amount-display { + font-size: 2em; } } + #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount.very-long input, #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount.very-long .unit, #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount.very-long .primary-amount-display { + font-size: 0.9em; } + @media (min-width: 375px) { + #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount.very-long input, #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount.very-long .unit, #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount.very-long .primary-amount-display { + font-size: 1.3em; } } + @media (min-width: 414px) { + #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount.very-long input, #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount.very-long .unit, #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount.very-long .primary-amount-display { + font-size: 1.4em; } } + #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount input { + border: 0; + padding: 0; + white-space: normal; + background: none; + line-height: 1; + box-sizing: content-box; + display: inline-block; + vertical-align: middle; + margin: 0; + height: 1em; + margin-right: 5px; + font-family: 'ProximaNova'; } + #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount .unit, + #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount .primary-amount-display { + display: inline-block; + vertical-align: middle; + line-height: 1em; } + #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount .unit { + font-weight: bold; } + #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount .primary-amount-display { + margin-right: 5px; + word-break: break-all; } + #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .switch-currencies { + position: absolute; + right: 0; + top: 50%; + transform: translate(0, -50%); + padding: 5px; } + #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .switch-currencies img { + width: 18px; } + #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-actions { + margin-top: 15px; + display: flex; + align-items: center; + justify-content: center; } + #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-actions .button { + flex: 1 1 auto; + line-height: 1.2em; } + #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-actions .button + .button { + margin-left: 10px; } + #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-actions .button span { + display: flex; + align-items: center; + justify-content: center; } + #view-amount .scroll-content .button.no-margin { + margin: 0; } + #view-amount .scroll-content .notification-warning { + display: block; + padding: .75rem 1.25rem; + color: #856404; + background-color: #fff3cd; + border: 1px solid #ffeeba; + line-height: 1.4em; + margin-bottom: 20px; } + #view-amount .scroll-content .keypad-container { + position: relative; } + #view-amount .scroll-content .keypad-container .keypad { + text-align: center; + font-size: 18px; + font-weight: lighter; + position: absolute; + bottom: 0; + width: 100%; + color: #667; } + @media (min-height: 667px) { + #view-amount .scroll-content .keypad-container .keypad { + font-size: 24px; } } + #view-amount .scroll-content .keypad-container .keypad .row { + padding: 0 !important; + margin: 0 !important; } + #view-amount .scroll-content .keypad-container .keypad .col { + line-height: 38px; } + @media (min-height: 667px) { + #view-amount .scroll-content .keypad-container .keypad .col { + line-height: 45px; } } + #view-amount .scroll-content .keypad-container .keypad .row:last-child .col { + padding-bottom: 10px; } + #view-amount .scroll-content .keypad-container .keypad .operator { + background-color: #f2f2f2; + font-weight: normal; + cursor: pointer; } + #view-amount .scroll-content .keypad-container .keypad .operator:active { + background-color: #9b9bab; } + #view-amount .scroll-content .keypad-container .keypad .operator-send { + font-weight: bolder; + color: #fff; + background-color: #494949; + font-size: 36px; + cursor: pointer; } + #view-amount .scroll-content .keypad-container .keypad .operator-send:active { + background-color: #eaeaea; } + #view-amount .scroll-content .keypad-container .keypad .digit { + cursor: pointer; + border-top: 1px solid #f2f2f2; + border-left: 1px solid #f2f2f2; + transition: all 0.1s ease; } + #view-amount .scroll-content .keypad-container .keypad .digit:active { + background-color: #f2f2f2; } + @media (max-height: 480px) { + #view-amount .scroll-content .keypad-container .keypad { + font-size: 12px; } } #view-confirm { background-color: #ffffff; } diff --git a/www/views/amount.html b/www/views/amount.html index 75eddab3b..13a795b0d 100644 --- a/www/views/amount.html +++ b/www/views/amount.html @@ -1,136 +1,85 @@ - - - {{'Enter amount' | translate}} - - - - -
-
Recipient
- -
- - - - - - - - - - - - - - - {{toName || displayAddress || toAddress}} -
-
- -
- Note: Address doesn't contain currency information, please make sure you are sending the correct currency. -
-
- Amount + + + {{'Enter amount' | translate}} + + + + + +
+ +
+
+ Minimum amount: {{minShapeshiftAmount}}
+ Maximum amount: {{maxShapeshiftAmount}}
+
+
+
+
+ {{ amountModel.amount || 0 }}{{unit}} +
+ {{globalResult}} {{unit}} +
+ {{alternativeAmount || '0.00'}} {{alternativeUnit}} +
+
+
+
+ + +
+
-
- Minimum amount: {{minShapeshiftAmount}}
- Maximum amount: {{maxShapeshiftAmount}}
-
-
-
- {{amountModel.amount || "0.00" }} - {{unit}} -
-
-
{{globalResult}} {{unit}}
-
<> {{alternativeAmount || '0.00'}} {{alternativeUnit}}
-
-
- - + +
+
+ +
+
7
+
8
+
9
+
+ +
+
4
+
5
+
6
+
+ +
+
1
+
2
+
3
+
+ +
+
.
+
0
+
+
-
- -
- Note: Address doesn't contain currency information, please make sure you are sending the correct currency.

- Amount
-
- Minimum amount: {{minShapeshiftAmount}}
- Maximum amount: {{maxShapeshiftAmount}}
-
-
- - - {{unit}} - - {{globalResult}} {{unit}} - <> {{alternativeAmount || '0.00'}} {{alternativeUnit}} -
-
- - -
-
- -
- -
- -
-
-
-
- -
-
- -
-
7
-
8
-
9
-
÷
-
- -
-
4
-
5
-
6
-
×
-
- -
-
1
-
2
-
3
-
+
-
- -
-
.
-
0
-
-
-
-
- - - + + \ No newline at end of file From 2f73ffd61c84c79e3e47670c085eb84b2f3de891 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Dominguez Date: Tue, 8 May 2018 11:39:32 +0900 Subject: [PATCH 3/8] Migrate keyboard from Sam and some fixes --- app-template/package-template.json | 3 ++- src/js/controllers/amount.js | 2 ++ src/js/controllers/tab-send.js | 12 +++++++++++- www/img/icon-convert.svg | 15 +++++++++++++++ www/views/amount.html | 2 +- www/views/tab-send.html | 6 ++++-- 6 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 www/img/icon-convert.svg diff --git a/app-template/package-template.json b/app-template/package-template.json index 3c92fdbbd..955e33e7e 100644 --- a/app-template/package-template.json +++ b/app-template/package-template.json @@ -60,6 +60,7 @@ "bower": "^1.7.9", "cordova-custom-config": "^3.0.5", "cordova-plugin-qrscanner": "^2.5.0", + "cordova-plugin-vibration": "^3.0.1", "coveralls": "^2.11.9", "express": "^4.11.2", "fs": "0.0.2", @@ -126,4 +127,4 @@ "pre-commit": "^1.1.3" }, "pre-commit": "unstage-package" -} +} \ No newline at end of file diff --git a/src/js/controllers/amount.js b/src/js/controllers/amount.js index e3b29a12d..5b67912c6 100644 --- a/src/js/controllers/amount.js +++ b/src/js/controllers/amount.js @@ -307,6 +307,7 @@ angular.module('copayApp.controllers').controller('amountController', function($ $scope.amountModel.amount = ($scope.amountModel.amount + digit).replace('..', '.'); checkFontSize(); $scope.processAmount(); + navigator.vibrate(50); }; $scope.pushOperator = function(operator) { @@ -342,6 +343,7 @@ angular.module('copayApp.controllers').controller('amountController', function($ $scope.amountModel.amount = $scope.alternativeAmount = $scope.globalResult = ''; $scope.allowSend = false; checkFontSize(); + navigator.vibrate(50); }; $scope.processAmount = function() { diff --git a/src/js/controllers/tab-send.js b/src/js/controllers/tab-send.js index bfda5cfc4..377cb9a49 100644 --- a/src/js/controllers/tab-send.js +++ b/src/js/controllers/tab-send.js @@ -6,7 +6,9 @@ angular.module('copayApp.controllers').controller('tabSendController', function( var CONTACTS_SHOW_LIMIT; var currentContactsPage; $scope.isChromeApp = platformInfo.isChromeApp; - + $scope.sectionDisplay = { + transferToWallet: false + }; var hasWallets = function() { $scope.wallets = profileService.getWallets({ @@ -247,4 +249,12 @@ angular.module('copayApp.controllers').controller('tabSendController', function( updateList(); }); }); + + $scope.toggle = function(section) { + $scope.sectionDisplay[section] = !$scope.sectionDisplay[section]; + $timeout(function() { + $ionicScrollDelegate.resize(); + $scope.$apply(); + }, 10); + }; }); diff --git a/www/img/icon-convert.svg b/www/img/icon-convert.svg new file mode 100644 index 000000000..6890197c1 --- /dev/null +++ b/www/img/icon-convert.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/www/views/amount.html b/www/views/amount.html index 13a795b0d..994c112cf 100644 --- a/www/views/amount.html +++ b/www/views/amount.html @@ -33,7 +33,7 @@ Send max amount -
-
+
Transfer to Wallet + +
-
+
Date: Tue, 8 May 2018 16:17:19 +0900 Subject: [PATCH 4/8] Improvement/Fix - Virtual keyboard --- src/js/controllers/amount.js | 122 ++++++++++++++++++++++- src/js/controllers/modals/altCurrency.js | 119 ++++++++++++++++++++++ www/views/amount.html | 12 +-- www/views/modals/altCurrency.html | 34 +++++++ 4 files changed, 280 insertions(+), 7 deletions(-) create mode 100644 src/js/controllers/modals/altCurrency.js create mode 100644 www/views/modals/altCurrency.html diff --git a/src/js/controllers/amount.js b/src/js/controllers/amount.js index 5b67912c6..128badeae 100644 --- a/src/js/controllers/amount.js +++ b/src/js/controllers/amount.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('amountController', function($scope, $filter, $timeout, $ionicScrollDelegate, $ionicHistory, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService, ongoingProcess, popupService, bwcError, payproService, profileService, bitcore, amazonService, nodeWebkitService) { +angular.module('copayApp.controllers').controller('amountController', function($scope, $filter, $timeout, $ionicModal, $ionicScrollDelegate, $ionicHistory, storageService, walletService, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService, ongoingProcess, popupService, bwcError, payproService, profileService, bitcore, amazonService, nodeWebkitService) { var _id; var unitToSatoshi; @@ -30,6 +30,8 @@ angular.module('copayApp.controllers').controller('amountController', function($ $scope.$on("$ionicView.beforeEnter", function(event, data) { + initCurrencies(); + if (data.stateParams.shapeshiftOrderId && data.stateParams.shapeshiftOrderId.length > 0) { $scope.minShapeshiftAmount = parseFloat(data.stateParams.minShapeshiftAmount); $scope.maxShapeshiftAmount = parseFloat(data.stateParams.maxShapeshiftAmount); @@ -345,6 +347,20 @@ angular.module('copayApp.controllers').controller('amountController', function($ checkFontSize(); navigator.vibrate(50); }; + + + $scope.openPopup = function() { + $ionicModal.fromTemplateUrl('views/modals/altCurrency.html', { + scope: $scope + }).then(function(modal) { + $scope.altCurrencyModal = modal; + $scope.altCurrencyModal.show(); + }); + }; + + $scope.close = function() { + $scope.altCurrencyModal.hide(); + }; $scope.processAmount = function() { var formatedValue = format($scope.amountModel.amount); @@ -496,4 +512,108 @@ angular.module('copayApp.controllers').controller('amountController', function($ } }; + + + // Currency + + var next = 10; + var completeAlternativeList = []; + + var popularCurrencyList = [ + {isoCode: 'USD', order: 0}, + {isoCode: 'EUR', order: 1}, + {isoCode: 'JPY', order: 2}, + {isoCode: 'GBP', order: 3}, + {isoCode: 'AUD', order: 4}, + {isoCode: 'CAD', order: 5}, + {isoCode: 'CHF', order: 6}, + {isoCode: 'CNY', order: 7}, + {isoCode: 'KRW', order: 8}, + {isoCode: 'HKD', order: 9}, + ] + + function initCurrencies() { + var unusedCurrencyList = [{ + isoCode: 'LTL' + }, { + isoCode: 'BTC' + }, { + isoCode: 'BCC' + }, { + isoCode: 'BCH_BTC' + }, { + isoCode: 'BCH' + }]; + rateService.whenAvailable(function() { + + $scope.listComplete = false; + + var idx = lodash.indexBy(unusedCurrencyList, 'isoCode'); + var idx2 = lodash.indexBy($scope.lastUsedAltCurrencyList, 'isoCode'); + var idx3 = lodash.indexBy(popularCurrencyList, 'isoCode'); + var alternatives = rateService.listAlternatives(true); + + lodash.each(alternatives, function(c) { + if (idx3[c.isoCode]) { + idx3[c.isoCode].name = c.name; + } + if (!idx[c.isoCode] && !idx2[c.isoCode] && !idx3[c.isoCode]) { + completeAlternativeList.push(c); + } + }); + + $scope.altCurrencyList = completeAlternativeList.slice(0, 10); + $scope.lastUsedPopularList = lodash.unique(lodash.union($scope.lastUsedAltCurrencyList, popularCurrencyList), 'isoCode'); + + $timeout(function() { + $scope.$apply(); + }); + }); + } + + $scope.loadMore = function() { + $timeout(function() { + $scope.altCurrencyList = completeAlternativeList.slice(0, next); + next += 10; + $scope.listComplete = $scope.altCurrencyList.length >= completeAlternativeList.length; + $scope.$broadcast('scroll.infiniteScrollComplete'); + }, 100); + }; + + $scope.findCurrency = function(search) { + if (!search) init(); + $scope.altCurrencyList = lodash.filter(completeAlternativeList, function(item) { + var val = item.name + var val2 = item.isoCode; + return lodash.includes(val.toLowerCase(), search.toLowerCase()) || lodash.includes(val2.toLowerCase(), search.toLowerCase()); + }); + $timeout(function() { + $scope.$apply(); + }); + }; + + $scope.save = function(newAltCurrency) { + var opts = { + wallet: { + settings: { + alternativeName: newAltCurrency.name, + alternativeIsoCode: newAltCurrency.isoCode, + } + } + }; + + configService.set(opts, function(err) { + if (err) $log.warn(err); + walletService.updateRemotePreferences(profileService.getWallets()); + var altUnitIndex = lodash.findIndex(availableUnits, { + isFiat: true + }); + availableUnits[altUnitIndex].id = newAltCurrency.isoCode; + availableUnits[altUnitIndex].name = newAltCurrency.isoCode; + availableUnits[altUnitIndex].shortName = newAltCurrency.isoCode; + fiatCode = newAltCurrency.isoCode; + updateUnitUI(); + $scope.close(); + }); + }; }); diff --git a/src/js/controllers/modals/altCurrency.js b/src/js/controllers/modals/altCurrency.js new file mode 100644 index 000000000..1629b35e9 --- /dev/null +++ b/src/js/controllers/modals/altCurrency.js @@ -0,0 +1,119 @@ +'use strict'; + +angular.module('copayApp.controllers').controller('altCurrencyController', + function($scope, $log, $timeout, $ionicHistory, $ionicModal, configService, rateService, lodash, profileService, walletService, storageService, $ionicNavBarDelegate) { + + $scope.close = function () { + $ionicModal.close(); + }; + + var next = 10; + var completeAlternativeList = []; + + var popularCurrencyList = [ + {isoCode: 'USD', order: 0}, + {isoCode: 'EUR', order: 1}, + {isoCode: 'JPY', order: 2}, + {isoCode: 'GBP', order: 3}, + {isoCode: 'AUD', order: 4}, + {isoCode: 'CAD', order: 5}, + {isoCode: 'CHF', order: 6}, + {isoCode: 'CNY', order: 7}, + {isoCode: 'KRW', order: 8}, + {isoCode: 'HKD', order: 9}, + ] + + function initCurrencies() { + var unusedCurrencyList = [{ + isoCode: 'LTL' + }, { + isoCode: 'BTC' + }, { + isoCode: 'BCC' + }, { + isoCode: 'BCH_BTC' + }, { + isoCode: 'BCH' + }]; + rateService.whenAvailable(function() { + + $scope.listComplete = false; + + var idx = lodash.indexBy(unusedCurrencyList, 'isoCode'); + var idx2 = lodash.indexBy($scope.lastUsedAltCurrencyList, 'isoCode'); + var idx3 = lodash.indexBy(popularCurrencyList, 'isoCode'); + var alternatives = rateService.listAlternatives(true); + + lodash.each(alternatives, function(c) { + if (idx3[c.isoCode]) { + idx3[c.isoCode].name = c.name; + } + if (!idx[c.isoCode] && !idx2[c.isoCode] && !idx3[c.isoCode]) { + completeAlternativeList.push(c); + } + }); + + $scope.altCurrencyList = completeAlternativeList.slice(0, 10); + $scope.lastUsedPopularList = lodash.unique(lodash.union($scope.lastUsedAltCurrencyList, popularCurrencyList), 'isoCode'); + + $timeout(function() { + $scope.$apply(); + }); + }); + } + + $scope.loadMore = function() { + $timeout(function() { + $scope.altCurrencyList = completeAlternativeList.slice(0, next); + next += 10; + $scope.listComplete = $scope.altCurrencyList.length >= completeAlternativeList.length; + $scope.$broadcast('scroll.infiniteScrollComplete'); + }, 100); + }; + + $scope.findCurrency = function(search) { + if (!search) initCurrencies(); + $scope.altCurrencyList = lodash.filter(completeAlternativeList, function(item) { + var val = item.name + var val2 = item.isoCode; + return lodash.includes(val.toLowerCase(), search.toLowerCase()) || lodash.includes(val2.toLowerCase(), search.toLowerCase()); + }); + $timeout(function() { + $scope.$apply(); + }); + }; + + $scope.save = function(newAltCurrency) { + var opts = { + wallet: { + settings: { + alternativeName: newAltCurrency.name, + alternativeIsoCode: newAltCurrency.isoCode, + } + } + }; + + configService.set(opts, function(err) { + if (err) $log.warn(err); + saveLastUsed(newAltCurrency); + walletService.updateRemotePreferences(profileService.getWallets()); + }); + }; + + function saveLastUsed(newAltCurrency) { + $scope.lastUsedAltCurrencyList.unshift(newAltCurrency); + $scope.lastUsedAltCurrencyList = lodash.uniq($scope.lastUsedAltCurrencyList, 'isoCode'); + $scope.lastUsedAltCurrencyList = $scope.lastUsedAltCurrencyList.slice(0, 3); + storageService.setLastCurrencyUsed(JSON.stringify($scope.lastUsedAltCurrencyList), function() {}); + }; + + $scope.$on("$ionicView.beforeEnter", function(event, data) { + var config = configService.getSync(); + $scope.currentCurrency = config.wallet.settings.alternativeIsoCode; + + storageService.getLastCurrencyUsed(function(err, lastUsedAltCurrency) { + $scope.lastUsedAltCurrencyList = lastUsedAltCurrency ? JSON.parse(lastUsedAltCurrency) : []; + initCurrencies(); + }); + }); + }); diff --git a/www/views/amount.html b/www/views/amount.html index 994c112cf..f704d6a1c 100644 --- a/www/views/amount.html +++ b/www/views/amount.html @@ -5,9 +5,9 @@ - + -
+
@@ -33,7 +33,7 @@ Send max amount -
-
-
+
+
7
@@ -77,7 +77,7 @@ class="button button-full button-primary no-margin" ng-disabled="!allowSend" ng-click="finish()" - style="order: 2" + style="position: absolute; bottom: 0;" translate> Next diff --git a/www/views/modals/altCurrency.html b/www/views/modals/altCurrency.html new file mode 100644 index 000000000..39010d0c4 --- /dev/null +++ b/www/views/modals/altCurrency.html @@ -0,0 +1,34 @@ + + +
+ {{'Alternative Currency'|translate}} +
+ +
+ +
+ +
+
+ {{lastUsedAltCurrency.name}} {{lastUsedAltCurrency.isoCode}} + +
+
+
{{altCurrency.name}} {{altCurrency.isoCode}} +
+
+ + +
+
From a19ae00b072495c0a444e3e5aab32a520078cbe5 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Dominguez Date: Tue, 8 May 2018 16:23:46 +0900 Subject: [PATCH 5/8] Fix - Search in the modal --- www/views/modals/altCurrency.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/views/modals/altCurrency.html b/www/views/modals/altCurrency.html index 39010d0c4..609543a80 100644 --- a/www/views/modals/altCurrency.html +++ b/www/views/modals/altCurrency.html @@ -11,7 +11,7 @@
From fa291c757d919f97f4ee6513c103f8a5952fdc87 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Dominguez Date: Tue, 8 May 2018 16:26:50 +0900 Subject: [PATCH 6/8] Fix - init is not defined --- src/js/controllers/amount.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/controllers/amount.js b/src/js/controllers/amount.js index 128badeae..f4fb9c6f8 100644 --- a/src/js/controllers/amount.js +++ b/src/js/controllers/amount.js @@ -581,7 +581,7 @@ angular.module('copayApp.controllers').controller('amountController', function($ }; $scope.findCurrency = function(search) { - if (!search) init(); + if (!search) initCurrencies(); $scope.altCurrencyList = lodash.filter(completeAlternativeList, function(item) { var val = item.name var val2 = item.isoCode; From 1ec2bf7ba09264cae9cd41b231cae78d07e397a0 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Dominguez Date: Tue, 8 May 2018 16:44:55 +0900 Subject: [PATCH 7/8] Fix - Search with popularCurrencyList as well --- src/js/controllers/amount.js | 171 ++++++++++++----------- src/js/controllers/modals/altCurrency.js | 119 ---------------- www/views/modals/altCurrency.html | 2 +- 3 files changed, 87 insertions(+), 205 deletions(-) delete mode 100644 src/js/controllers/modals/altCurrency.js diff --git a/src/js/controllers/amount.js b/src/js/controllers/amount.js index f4fb9c6f8..9e74e9fdc 100644 --- a/src/js/controllers/amount.js +++ b/src/js/controllers/amount.js @@ -517,103 +517,104 @@ angular.module('copayApp.controllers').controller('amountController', function($ // Currency var next = 10; - var completeAlternativeList = []; + var completeAlternativeList = []; - var popularCurrencyList = [ - {isoCode: 'USD', order: 0}, - {isoCode: 'EUR', order: 1}, - {isoCode: 'JPY', order: 2}, - {isoCode: 'GBP', order: 3}, - {isoCode: 'AUD', order: 4}, - {isoCode: 'CAD', order: 5}, - {isoCode: 'CHF', order: 6}, - {isoCode: 'CNY', order: 7}, - {isoCode: 'KRW', order: 8}, - {isoCode: 'HKD', order: 9}, - ] + var popularCurrencyList = [ + {isoCode: 'USD', order: 0}, + {isoCode: 'EUR', order: 1}, + {isoCode: 'JPY', order: 2}, + {isoCode: 'GBP', order: 3}, + {isoCode: 'AUD', order: 4}, + {isoCode: 'CAD', order: 5}, + {isoCode: 'CHF', order: 6}, + {isoCode: 'CNY', order: 7}, + {isoCode: 'KRW', order: 8}, + {isoCode: 'HKD', order: 9}, + ] - function initCurrencies() { - var unusedCurrencyList = [{ - isoCode: 'LTL' - }, { - isoCode: 'BTC' - }, { - isoCode: 'BCC' - }, { - isoCode: 'BCH_BTC' - }, { - isoCode: 'BCH' - }]; - rateService.whenAvailable(function() { + function initCurrencies() { + var unusedCurrencyList = [{ + isoCode: 'LTL' + }, { + isoCode: 'BTC' + }, { + isoCode: 'BCC' + }, { + isoCode: 'BCH_BTC' + }, { + isoCode: 'BCH' + }]; + rateService.whenAvailable(function() { - $scope.listComplete = false; + $scope.listComplete = false; - var idx = lodash.indexBy(unusedCurrencyList, 'isoCode'); - var idx2 = lodash.indexBy($scope.lastUsedAltCurrencyList, 'isoCode'); - var idx3 = lodash.indexBy(popularCurrencyList, 'isoCode'); - var alternatives = rateService.listAlternatives(true); + var idx = lodash.indexBy(unusedCurrencyList, 'isoCode'); + var idx2 = lodash.indexBy($scope.lastUsedAltCurrencyList, 'isoCode'); + var idx3 = lodash.indexBy(popularCurrencyList, 'isoCode'); + var alternatives = rateService.listAlternatives(true); - lodash.each(alternatives, function(c) { - if (idx3[c.isoCode]) { - idx3[c.isoCode].name = c.name; - } - if (!idx[c.isoCode] && !idx2[c.isoCode] && !idx3[c.isoCode]) { - completeAlternativeList.push(c); - } - }); - - $scope.altCurrencyList = completeAlternativeList.slice(0, 10); - $scope.lastUsedPopularList = lodash.unique(lodash.union($scope.lastUsedAltCurrencyList, popularCurrencyList), 'isoCode'); - - $timeout(function() { - $scope.$apply(); - }); + lodash.each(alternatives, function(c) { + if (idx3[c.isoCode]) { + idx3[c.isoCode].name = c.name; + } + if (!idx[c.isoCode] && !idx2[c.isoCode] && !idx3[c.isoCode]) { + completeAlternativeList.push(c); + } }); - } - $scope.loadMore = function() { - $timeout(function() { - $scope.altCurrencyList = completeAlternativeList.slice(0, next); - next += 10; - $scope.listComplete = $scope.altCurrencyList.length >= completeAlternativeList.length; - $scope.$broadcast('scroll.infiniteScrollComplete'); - }, 100); - }; + $scope.altCurrencyList = completeAlternativeList.slice(0, 10); + $scope.lastUsedPopularList = lodash.unique(lodash.union($scope.lastUsedAltCurrencyList, popularCurrencyList), 'isoCode'); - $scope.findCurrency = function(search) { - if (!search) initCurrencies(); - $scope.altCurrencyList = lodash.filter(completeAlternativeList, function(item) { - var val = item.name - var val2 = item.isoCode; - return lodash.includes(val.toLowerCase(), search.toLowerCase()) || lodash.includes(val2.toLowerCase(), search.toLowerCase()); - }); $timeout(function() { $scope.$apply(); }); - }; + }); + } - $scope.save = function(newAltCurrency) { - var opts = { - wallet: { - settings: { - alternativeName: newAltCurrency.name, - alternativeIsoCode: newAltCurrency.isoCode, - } + $scope.loadMore = function() { + $timeout(function() { + $scope.altCurrencyList = completeAlternativeList.slice(0, next); + next += 10; + $scope.listComplete = $scope.altCurrencyList.length >= completeAlternativeList.length; + $scope.$broadcast('scroll.infiniteScrollComplete'); + }, 100); + }; + + $scope.findCurrency = function(search) { + if (!search) initCurrencies(); + var list = lodash.unique(lodash.union(completeAlternativeList, lodash.union($scope.lastUsedAltCurrencyList, popularCurrencyList)), 'isoCode'); + $scope.altCurrencyList = lodash.filter(list, function(item) { + var val = item.name + var val2 = item.isoCode; + return lodash.includes(val.toLowerCase(), search.toLowerCase()) || lodash.includes(val2.toLowerCase(), search.toLowerCase()); + }); + $timeout(function() { + $scope.$apply(); + }); + }; + + $scope.save = function(newAltCurrency) { + var opts = { + wallet: { + settings: { + alternativeName: newAltCurrency.name, + alternativeIsoCode: newAltCurrency.isoCode, } - }; - - configService.set(opts, function(err) { - if (err) $log.warn(err); - walletService.updateRemotePreferences(profileService.getWallets()); - var altUnitIndex = lodash.findIndex(availableUnits, { - isFiat: true - }); - availableUnits[altUnitIndex].id = newAltCurrency.isoCode; - availableUnits[altUnitIndex].name = newAltCurrency.isoCode; - availableUnits[altUnitIndex].shortName = newAltCurrency.isoCode; - fiatCode = newAltCurrency.isoCode; - updateUnitUI(); - $scope.close(); - }); + } }; + + configService.set(opts, function(err) { + if (err) $log.warn(err); + walletService.updateRemotePreferences(profileService.getWallets()); + var altUnitIndex = lodash.findIndex(availableUnits, { + isFiat: true + }); + availableUnits[altUnitIndex].id = newAltCurrency.isoCode; + availableUnits[altUnitIndex].name = newAltCurrency.isoCode; + availableUnits[altUnitIndex].shortName = newAltCurrency.isoCode; + fiatCode = newAltCurrency.isoCode; + updateUnitUI(); + $scope.close(); + }); + }; }); diff --git a/src/js/controllers/modals/altCurrency.js b/src/js/controllers/modals/altCurrency.js deleted file mode 100644 index 1629b35e9..000000000 --- a/src/js/controllers/modals/altCurrency.js +++ /dev/null @@ -1,119 +0,0 @@ -'use strict'; - -angular.module('copayApp.controllers').controller('altCurrencyController', - function($scope, $log, $timeout, $ionicHistory, $ionicModal, configService, rateService, lodash, profileService, walletService, storageService, $ionicNavBarDelegate) { - - $scope.close = function () { - $ionicModal.close(); - }; - - var next = 10; - var completeAlternativeList = []; - - var popularCurrencyList = [ - {isoCode: 'USD', order: 0}, - {isoCode: 'EUR', order: 1}, - {isoCode: 'JPY', order: 2}, - {isoCode: 'GBP', order: 3}, - {isoCode: 'AUD', order: 4}, - {isoCode: 'CAD', order: 5}, - {isoCode: 'CHF', order: 6}, - {isoCode: 'CNY', order: 7}, - {isoCode: 'KRW', order: 8}, - {isoCode: 'HKD', order: 9}, - ] - - function initCurrencies() { - var unusedCurrencyList = [{ - isoCode: 'LTL' - }, { - isoCode: 'BTC' - }, { - isoCode: 'BCC' - }, { - isoCode: 'BCH_BTC' - }, { - isoCode: 'BCH' - }]; - rateService.whenAvailable(function() { - - $scope.listComplete = false; - - var idx = lodash.indexBy(unusedCurrencyList, 'isoCode'); - var idx2 = lodash.indexBy($scope.lastUsedAltCurrencyList, 'isoCode'); - var idx3 = lodash.indexBy(popularCurrencyList, 'isoCode'); - var alternatives = rateService.listAlternatives(true); - - lodash.each(alternatives, function(c) { - if (idx3[c.isoCode]) { - idx3[c.isoCode].name = c.name; - } - if (!idx[c.isoCode] && !idx2[c.isoCode] && !idx3[c.isoCode]) { - completeAlternativeList.push(c); - } - }); - - $scope.altCurrencyList = completeAlternativeList.slice(0, 10); - $scope.lastUsedPopularList = lodash.unique(lodash.union($scope.lastUsedAltCurrencyList, popularCurrencyList), 'isoCode'); - - $timeout(function() { - $scope.$apply(); - }); - }); - } - - $scope.loadMore = function() { - $timeout(function() { - $scope.altCurrencyList = completeAlternativeList.slice(0, next); - next += 10; - $scope.listComplete = $scope.altCurrencyList.length >= completeAlternativeList.length; - $scope.$broadcast('scroll.infiniteScrollComplete'); - }, 100); - }; - - $scope.findCurrency = function(search) { - if (!search) initCurrencies(); - $scope.altCurrencyList = lodash.filter(completeAlternativeList, function(item) { - var val = item.name - var val2 = item.isoCode; - return lodash.includes(val.toLowerCase(), search.toLowerCase()) || lodash.includes(val2.toLowerCase(), search.toLowerCase()); - }); - $timeout(function() { - $scope.$apply(); - }); - }; - - $scope.save = function(newAltCurrency) { - var opts = { - wallet: { - settings: { - alternativeName: newAltCurrency.name, - alternativeIsoCode: newAltCurrency.isoCode, - } - } - }; - - configService.set(opts, function(err) { - if (err) $log.warn(err); - saveLastUsed(newAltCurrency); - walletService.updateRemotePreferences(profileService.getWallets()); - }); - }; - - function saveLastUsed(newAltCurrency) { - $scope.lastUsedAltCurrencyList.unshift(newAltCurrency); - $scope.lastUsedAltCurrencyList = lodash.uniq($scope.lastUsedAltCurrencyList, 'isoCode'); - $scope.lastUsedAltCurrencyList = $scope.lastUsedAltCurrencyList.slice(0, 3); - storageService.setLastCurrencyUsed(JSON.stringify($scope.lastUsedAltCurrencyList), function() {}); - }; - - $scope.$on("$ionicView.beforeEnter", function(event, data) { - var config = configService.getSync(); - $scope.currentCurrency = config.wallet.settings.alternativeIsoCode; - - storageService.getLastCurrencyUsed(function(err, lastUsedAltCurrency) { - $scope.lastUsedAltCurrencyList = lastUsedAltCurrency ? JSON.parse(lastUsedAltCurrency) : []; - initCurrencies(); - }); - }); - }); diff --git a/www/views/modals/altCurrency.html b/www/views/modals/altCurrency.html index 609543a80..af8ecb083 100644 --- a/www/views/modals/altCurrency.html +++ b/www/views/modals/altCurrency.html @@ -15,7 +15,7 @@ placeholder="{{'Search your currency' | translate}}">
-
+
{{lastUsedAltCurrency.name}} {{lastUsedAltCurrency.isoCode}} From 350f10370907f2537b4bcf8522f5131154de0eb9 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Dominguez Date: Tue, 8 May 2018 17:43:24 +0900 Subject: [PATCH 8/8] Fix - Keyboard on desktop (delete) --- src/js/controllers/amount.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/js/controllers/amount.js b/src/js/controllers/amount.js index 9e74e9fdc..7807ac06d 100644 --- a/src/js/controllers/amount.js +++ b/src/js/controllers/amount.js @@ -164,8 +164,10 @@ angular.module('copayApp.controllers').controller('amountController', function($ 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 (!$scope.altCurrencyModal) { + e.preventDefault(); + $scope.removeDigit(); + } } if (e.key.match(reNr)) { @@ -359,7 +361,8 @@ angular.module('copayApp.controllers').controller('amountController', function($ }; $scope.close = function() { - $scope.altCurrencyModal.hide(); + $scope.altCurrencyModal.remove(); + $scope.altCurrencyModal = false; }; $scope.processAmount = function() {