Improvement/Fix - Virtual keyboard
This commit is contained in:
parent
2f73ffd61c
commit
35bf2da0f5
4 changed files with 280 additions and 7 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'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 _id;
|
||||||
var unitToSatoshi;
|
var unitToSatoshi;
|
||||||
|
|
@ -30,6 +30,8 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
||||||
|
|
||||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||||
|
|
||||||
|
initCurrencies();
|
||||||
|
|
||||||
if (data.stateParams.shapeshiftOrderId && data.stateParams.shapeshiftOrderId.length > 0) {
|
if (data.stateParams.shapeshiftOrderId && data.stateParams.shapeshiftOrderId.length > 0) {
|
||||||
$scope.minShapeshiftAmount = parseFloat(data.stateParams.minShapeshiftAmount);
|
$scope.minShapeshiftAmount = parseFloat(data.stateParams.minShapeshiftAmount);
|
||||||
$scope.maxShapeshiftAmount = parseFloat(data.stateParams.maxShapeshiftAmount);
|
$scope.maxShapeshiftAmount = parseFloat(data.stateParams.maxShapeshiftAmount);
|
||||||
|
|
@ -346,6 +348,20 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
||||||
navigator.vibrate(50);
|
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() {
|
$scope.processAmount = function() {
|
||||||
var formatedValue = format($scope.amountModel.amount);
|
var formatedValue = format($scope.amountModel.amount);
|
||||||
var result = evaluate(formatedValue);
|
var result = evaluate(formatedValue);
|
||||||
|
|
@ -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();
|
||||||
|
});
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
119
src/js/controllers/modals/altCurrency.js
Normal file
119
src/js/controllers/modals/altCurrency.js
Normal file
|
|
@ -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();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
</ion-nav-title>
|
</ion-nav-title>
|
||||||
<ion-nav-back-button ng-click="goBack()"></ion-nav-back-button>
|
<ion-nav-back-button ng-click="goBack()"></ion-nav-back-button>
|
||||||
</ion-nav-bar>
|
</ion-nav-bar>
|
||||||
<ion-content scroll="false">
|
<ion-content scroll="false" style="background: #fff;">
|
||||||
|
|
||||||
<div ng-if="!customAmount && !nextStep" style="order: 0; position: relative; height: 100%; background: #fff;">
|
<div ng-if="!customAmount && !nextStep" style="order: 0; position: relative;">
|
||||||
|
|
||||||
<div class="item send-amount">
|
<div class="item send-amount">
|
||||||
<div ng-if="shapeshiftOrderId">
|
<div ng-if="shapeshiftOrderId">
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
<span translate>Send max amount</span>
|
<span translate>Send max amount</span>
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
<button class="button button-sendmax" ng-click="changeUnit()" modal-select ng-model="someModel" options="selectables" modal-title="Select a number">
|
<button class="button button-sendmax" ng-click="openPopup()">
|
||||||
<span>
|
<span>
|
||||||
<i class="icon ion-social-usd"></i> 
|
<i class="icon ion-social-usd"></i> 
|
||||||
<span translate>Change currency</span>
|
<span translate>Change currency</span>
|
||||||
|
|
@ -44,8 +44,8 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="keypad-container" style="order: 1">
|
<div class="keypad-container" style="background: #fff; position: absolute; bottom: 0; margin-bottom: 57px; width: 100%;">
|
||||||
<div class="keypad" style="background: #f2f2f2">
|
<div class="keypad" style="background: #f2f2f2; position: relative;">
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col digit" ng-click="pushDigit('7')">7</div>
|
<div class="col digit" ng-click="pushDigit('7')">7</div>
|
||||||
|
|
@ -77,7 +77,7 @@
|
||||||
class="button button-full button-primary no-margin"
|
class="button button-full button-primary no-margin"
|
||||||
ng-disabled="!allowSend"
|
ng-disabled="!allowSend"
|
||||||
ng-click="finish()"
|
ng-click="finish()"
|
||||||
style="order: 2"
|
style="position: absolute; bottom: 0;"
|
||||||
translate>
|
translate>
|
||||||
Next
|
Next
|
||||||
</button>
|
</button>
|
||||||
|
|
|
||||||
34
www/views/modals/altCurrency.html
Normal file
34
www/views/modals/altCurrency.html
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
<ion-modal-view id="alt-currency">
|
||||||
|
<ion-header-bar class="bar-royal">
|
||||||
|
<div class="title">
|
||||||
|
{{'Alternative Currency'|translate}}
|
||||||
|
</div>
|
||||||
|
<button class="button button-clear" ng-click="close()" translate>
|
||||||
|
{{'Close'|translate}}
|
||||||
|
</button>
|
||||||
|
</ion-header-bar>
|
||||||
|
<ion-content>
|
||||||
|
<div class="bar bar-header item-input-inset m20b">
|
||||||
|
<label class="item-input-wrapper">
|
||||||
|
<i class="icon ion-ios-search placeholder-icon"></i>
|
||||||
|
<input type="search" ng-init="searchedAltCurrency = ''" ng-model="searchedAltCurrency" ng-change=""
|
||||||
|
placeholder="{{'Search your currency' | translate}}">
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="list" ng-if="lastUsedPopularList[0]">
|
||||||
|
<ion-radio class="alt-currency-radio" ng-repeat="lastUsedAltCurrency in lastUsedPopularList" ng-value="lastUsedAltCurrency.isoCode" ng-model="currentCurrency"
|
||||||
|
ng-click="save(lastUsedAltCurrency)">{{lastUsedAltCurrency.name}} <span class="item-note">{{lastUsedAltCurrency.isoCode}}</span>
|
||||||
|
</ion-radio>
|
||||||
|
</div>
|
||||||
|
<div class="list">
|
||||||
|
<div class="item" ng-repeat="altCurrency in altCurrencyList" ng-value="altCurrency.isoCode" ng-model="currentCurrency"
|
||||||
|
ng-click="save(altCurrency)">{{altCurrency.name}} <span class="item-note">{{altCurrency.isoCode}}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<ion-infinite-scroll
|
||||||
|
ng-if="!listComplete"
|
||||||
|
on-infinite="loadMore()"
|
||||||
|
distance="50%">
|
||||||
|
</ion-infinite-scroll>
|
||||||
|
</ion-content>
|
||||||
|
</ion-modal-view>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue