commit
c12e47e9c1
13 changed files with 183 additions and 16 deletions
42
src/js/controllers/preferencesPriceDisplay.js
Normal file
42
src/js/controllers/preferencesPriceDisplay.js
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('preferencesPriceDisplayController', function($scope, $q, $timeout, configService, $ionicNavBarDelegate) {
|
||||
|
||||
$scope.save = function(priceDisplay) {
|
||||
|
||||
if ($scope.noSave) return;
|
||||
|
||||
var opts = {
|
||||
wallet: {
|
||||
settings: {
|
||||
priceDisplay: priceDisplay
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
configService.set(opts, function(err) {
|
||||
if (err) $log.debug(err);
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.$on("$ionicView.enter", function(event, data) {
|
||||
$ionicNavBarDelegate.showBar(true);
|
||||
});
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
$scope.init();
|
||||
});
|
||||
|
||||
$scope.init = function () {
|
||||
configService.whenAvailable(function(config) {
|
||||
$scope.selectedPriceDisplay = config.wallet.settings.priceDisplay;
|
||||
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
@ -116,6 +116,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
});
|
||||
|
||||
configService.whenAvailable(function(config) {
|
||||
$scope.selectedPriceDisplay = config.wallet.settings.priceDisplay;
|
||||
$scope.recentTransactionsEnabled = config.recentTransactions.enabled;
|
||||
if ($scope.recentTransactionsEnabled) getNotifications();
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ angular.module('copayApp.controllers').controller('tabSettingsController', funct
|
|||
isoCode: config.wallet.settings.alternativeIsoCode
|
||||
};
|
||||
|
||||
$scope.selectedPriceDisplay = config.wallet.settings.priceDisplay;
|
||||
|
||||
// TODO move this to a generic service
|
||||
bitpayAccountService.getAccounts(function(err, data) {
|
||||
if (err) $log.error(err);
|
||||
|
|
|
|||
|
|
@ -367,6 +367,15 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
});
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
|
||||
configService.whenAvailable(function (config) {
|
||||
$scope.selectedPriceDisplay = config.wallet.settings.priceDisplay;
|
||||
|
||||
$timeout(function () {
|
||||
$scope.apply();
|
||||
});
|
||||
});
|
||||
|
||||
$scope.walletId = data.stateParams.walletId;
|
||||
$scope.wallet = profileService.getWallet($scope.walletId);
|
||||
if (!$scope.wallet) return;
|
||||
|
|
|
|||
|
|
@ -413,6 +413,15 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
}
|
||||
}
|
||||
})
|
||||
.state('tabs.priceDisplay', {
|
||||
url: '/priceDisplay',
|
||||
views: {
|
||||
'tab-settings@tabs': {
|
||||
controller: 'preferencesPriceDisplayController',
|
||||
templateUrl: 'views/preferencesPriceDisplay.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('tabs.about', {
|
||||
url: '/about',
|
||||
views: {
|
||||
|
|
@ -1199,11 +1208,46 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
}
|
||||
});
|
||||
})
|
||||
.run(function($rootScope, $state, $location, $log, $timeout, startupService, ionicToast, fingerprintService, $ionicHistory, $ionicPlatform, $window, appConfigService, lodash, platformInfo, profileService, uxLanguage, gettextCatalog, openURLService, storageService, scannerService, configService, emailService, /* plugins START HERE => */ buydotbitcoindotcomService, glideraService, amazonService, bitpayCardService, applicationService, mercadoLibreService) {
|
||||
.run(function($rootScope, $state, $location, $log, $timeout, startupService, ionicToast, fingerprintService, $ionicHistory, $ionicPlatform, $window, appConfigService, lodash, platformInfo, profileService, uxLanguage, gettextCatalog, openURLService, storageService, scannerService, configService, emailService, /* plugins START HERE => */ buydotbitcoindotcomService, glideraService, amazonService, bitpayCardService, applicationService, mercadoLibreService, rateService) {
|
||||
|
||||
$ionicPlatform.ready(function() {
|
||||
|
||||
// Init language
|
||||
uxLanguage.init(function (lang) {
|
||||
|
||||
uxLanguage.init();
|
||||
// Try to load the profile
|
||||
profileService.loadAndBindProfile(function(err) {
|
||||
|
||||
// If err, first time so I define the currency rate by language
|
||||
if (err) {
|
||||
var rateCode = uxLanguage.getRateCode(lang);
|
||||
|
||||
$ionicPlatform.ready(function() {
|
||||
rateService.whenAvailable(function() {
|
||||
var alternatives = rateService.listAlternatives(true);
|
||||
|
||||
var newAltCurrency = lodash.find(alternatives, {
|
||||
'isoCode': rateCode
|
||||
});
|
||||
|
||||
configService.whenAvailable(function(config) {
|
||||
var opts = {
|
||||
wallet: {
|
||||
settings: {
|
||||
alternativeName: newAltCurrency.name,
|
||||
alternativeIsoCode: newAltCurrency.isoCode,
|
||||
}
|
||||
}
|
||||
};
|
||||
configService.set(opts, function(err) {
|
||||
if (err) $log.warn(err);
|
||||
});
|
||||
});
|
||||
$log.debug('Setting default currency : ' + newAltCurrency);
|
||||
});
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
if (screen.width < 768 && platformInfo.isCordova)
|
||||
screen.lockOrientation('portrait');
|
||||
|
||||
|
|
@ -1278,6 +1322,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
$log.debug('No profile... redirecting');
|
||||
$state.go('onboarding.tour');
|
||||
} else if (err.message && err.message.match('NONAGREEDDISCLAIMER')) {
|
||||
$scope.setRateByLanguage();
|
||||
if (lodash.isEmpty(profileService.getWallets())) {
|
||||
$log.debug('No wallets and no disclaimer... redirecting');
|
||||
$state.go('onboarding.tour');
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ angular.module('copayApp.services').factory('configService', function(storageSer
|
|||
unitCode: 'btc',
|
||||
alternativeName: 'US Dollar',
|
||||
alternativeIsoCode: 'USD',
|
||||
priceDisplay: 'fiat', // 'fiat' || 'crypto'
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -181,6 +182,11 @@ angular.module('copayApp.services').factory('configService', function(storageSer
|
|||
configCache.wallet.settings.unitCode = defaultConfig.wallet.settings.unitCode;
|
||||
}
|
||||
|
||||
// If display is not configure, take the default value
|
||||
if (!configCache.wallet.settings.priceDisplay) {
|
||||
configCache.wallet.settings.display = defaultConfig.wallet.settings.priceDisplay;
|
||||
}
|
||||
|
||||
// Convert tarascash wallet to new style cash wallet
|
||||
if (configCache.bwsbcc && configCache.bwsbcc.url && configCache.bwsbcc.url.indexOf('bwsbcc') >= 0) {
|
||||
configCache.bwsbcc = defaultConfig.bwscash.url;
|
||||
|
|
|
|||
|
|
@ -6,12 +6,6 @@ angular.module('copayApp.services').factory('openURLService', function($rootScop
|
|||
var handleOpenURL = function(args) {
|
||||
|
||||
$log.info('Handling Open URL: ' + JSON.stringify(args));
|
||||
// Stop it from caching the first view as one to return when the app opens
|
||||
$ionicHistory.nextViewOptions({
|
||||
historyRoot: true,
|
||||
disableBack: false,
|
||||
disableAnimation: true
|
||||
});
|
||||
|
||||
var url = args.url;
|
||||
if (!url) {
|
||||
|
|
|
|||
|
|
@ -8,41 +8,53 @@ angular.module('copayApp.services')
|
|||
root.availableLanguages = [{
|
||||
name: 'English',
|
||||
isoCode: 'en',
|
||||
rateCode: 'USD'
|
||||
}, {
|
||||
name: 'Español',
|
||||
isoCode: 'es',
|
||||
rateCode: 'EUR'
|
||||
}, {
|
||||
name: 'Français',
|
||||
isoCode: 'fr',
|
||||
rateCode: 'EUR'
|
||||
}, {
|
||||
name: 'Italiano',
|
||||
isoCode: 'it',
|
||||
rateCode: 'EUR'
|
||||
}, {
|
||||
name: 'Nederlands',
|
||||
isoCode: 'nl',
|
||||
rateCode: 'EUR'
|
||||
}, {
|
||||
name: 'Polski',
|
||||
isoCode: 'pl',
|
||||
rateCode: 'EUR'
|
||||
}, {
|
||||
name: 'Deutsch',
|
||||
isoCode: 'de',
|
||||
rateCode: 'EUR'
|
||||
}, {
|
||||
name: '日本語',
|
||||
isoCode: 'ja',
|
||||
useIdeograms: true,
|
||||
rateCode: 'JPY'
|
||||
}, {
|
||||
name: '中文(简体)',
|
||||
isoCode: 'zh',
|
||||
useIdeograms: true,
|
||||
rateCode: 'CNY'
|
||||
}, {
|
||||
name: 'Pусский',
|
||||
isoCode: 'ru',
|
||||
rateCode: 'RUB'
|
||||
}, {
|
||||
name: 'Português',
|
||||
isoCode: 'pt',
|
||||
rateCode: 'EUR'
|
||||
}, {
|
||||
name: '한국어',
|
||||
isoCode: 'ko'
|
||||
isoCode: 'ko',
|
||||
rateCode: 'KRW'
|
||||
}];
|
||||
|
||||
// }, {
|
||||
|
|
@ -105,18 +117,19 @@ angular.module('copayApp.services')
|
|||
return root.availableLanguages;
|
||||
};
|
||||
|
||||
root.init = function(cb) {
|
||||
root.init = function(cb, cbSuccess) {
|
||||
configService.whenAvailable(function(config) {
|
||||
var userLang = config.wallet.settings.defaultLanguage;
|
||||
|
||||
if (userLang && userLang != root.currentLanguage) {
|
||||
root._set(userLang);
|
||||
if (cb) return cb(userLang);
|
||||
} else {
|
||||
root._detect(function(lang) {
|
||||
root._set(lang);
|
||||
if (cb) return cb(lang);
|
||||
});
|
||||
}
|
||||
if (cb) return cb();
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -126,5 +139,11 @@ angular.module('copayApp.services')
|
|||
}), 'name');
|
||||
};
|
||||
|
||||
root.getRateCode = function(lang) {
|
||||
return lodash.result(lodash.find(root.availableLanguages, {
|
||||
'isoCode': lang
|
||||
}), 'rateCode');
|
||||
};
|
||||
|
||||
return root;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -28,6 +28,10 @@ body {
|
|||
font-family:'ProximaNova' !important;
|
||||
}
|
||||
|
||||
.capitalize {
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
.textlogo {
|
||||
color: #FFF;
|
||||
font-size: 20px;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@
|
|||
Incomplete
|
||||
</span>
|
||||
<span ng-if="wallet.isComplete()">
|
||||
<span ng-if="!wallet.balanceHidden && !wallet.scanning"> {{wallet.status.totalBalanceStr ? wallet.status.totalBalanceStr : ( wallet.cachedBalance ? wallet.cachedBalance + (wallet.cachedBalanceUpdatedOn ? ' · ' + ( wallet.cachedBalanceUpdatedOn * 1000 | amTimeAgo) : '') : '' ) }} </span>
|
||||
<span ng-if="selectedPriceDisplay == 'crypto' && !wallet.balanceHidden && !wallet.scanning"> {{wallet.status.totalBalanceStr ? wallet.status.totalBalanceStr : ( wallet.cachedBalance ? wallet.cachedBalance + (wallet.cachedBalanceUpdatedOn ? ' · ' + ( wallet.cachedBalanceUpdatedOn * 1000 | amTimeAgo) : '') : '' ) }} </span>
|
||||
<span ng-if="selectedPriceDisplay == 'fiat' && !wallet.balanceHidden && !wallet.scanning"> {{wallet.status.totalBalanceAlternative ? wallet.status.totalBalanceAlternative : ( wallet.cachedBalance ? wallet.cachedBalance + (wallet.cachedBalanceUpdatedOn ? ' · ' + ( wallet.cachedBalanceUpdatedOn * 1000 | amTimeAgo) : '') : '' ) }} {{wallet.status.alternativeIsoCode}}</span>
|
||||
<span ng-if="wallet.scanning" translate> Scanning funds... </span>
|
||||
|
||||
<span ng-if="wallet.balanceHidden && !wallet.scanning" translate>[Balance Hidden]</span>
|
||||
|
|
|
|||
19
www/views/preferencesPriceDisplay.html
Normal file
19
www/views/preferencesPriceDisplay.html
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<ion-view id="settings-pricedisplay" class="settings" show-tabs>
|
||||
<ion-nav-bar class="bar-royal">
|
||||
<ion-nav-title>
|
||||
{{'Price display'|translate}}
|
||||
</ion-nav-title>
|
||||
<ion-nav-back-button>
|
||||
</ion-nav-back-button>
|
||||
</ion-nav-bar>
|
||||
<ion-content>
|
||||
<div class="price-display">
|
||||
<ion-radio class="capitalize" ng-value="'fiat'" ng-model="selectedPriceDisplay" ng-click="save(selectedPriceDisplay)">
|
||||
fiat
|
||||
</ion-radio>
|
||||
<ion-radio class="capitalize" ng-value="'crypto'" ng-model="selectedPriceDisplay" ng-click="save(selectedPriceDisplay)">
|
||||
cryptocurrency
|
||||
</ion-radio>
|
||||
</div>
|
||||
</ion-content>
|
||||
</ion-view>
|
||||
|
|
@ -55,7 +55,7 @@
|
|||
{{currentLanguageName|translate}}
|
||||
</span>
|
||||
<i class="icon bp-arrow-right"></i>
|
||||
</a>
|
||||
</a>
|
||||
|
||||
<a class="item has-setting-value item-icon-left item-icon-right" ui-sref="tabs.altCurrency">
|
||||
<i class="icon big-icon-svg">
|
||||
|
|
@ -67,6 +67,17 @@
|
|||
</span>
|
||||
<i class="icon bp-arrow-right"></i>
|
||||
</a>
|
||||
|
||||
<a class="item has-setting-value item-icon-left item-icon-right" ui-sref="tabs.priceDisplay">
|
||||
<i class="icon big-icon-svg">
|
||||
<img src="img/icon-alternative-currency.svg" class="bg"/>
|
||||
</i>
|
||||
<span class="setting-title">{{'Price Display' | translate}}</span>
|
||||
<span class="setting-value capitalize">
|
||||
{{selectedPriceDisplay}}
|
||||
</span>
|
||||
<i class="icon bp-arrow-right"></i>
|
||||
</a>
|
||||
|
||||
<a class="item has-setting-value item-icon-left item-icon-right" ui-sref="tabs.fee">
|
||||
<i class="icon big-icon-svg">
|
||||
|
|
|
|||
|
|
@ -30,7 +30,21 @@
|
|||
</div>
|
||||
|
||||
<div
|
||||
ng-show="!updateStatusError && !wallet.balanceHidden && !wallet.scanning"
|
||||
ng-show="selectedPriceDisplay=='fiat' && !updateStatusError && !wallet.balanceHidden && !wallet.scanning"
|
||||
on-hold="hideToggle()"
|
||||
ng-style="{'transform': amountScale}"
|
||||
ng-class="{amount__balance: amountIsCollapsible}">
|
||||
<strong class="size-36">{{status.totalBalanceAlternative}} {{status.alternativeIsoCode}}</strong>
|
||||
<div
|
||||
class="size-14 amount-alternative"
|
||||
ng-if="status.totalBalanceAlternative && wallet.network == 'livenet'"
|
||||
ng-style="{opacity: altAmountOpacity}">
|
||||
{{status.totalBalanceStr}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
ng-show="selectedPriceDisplay=='crypto' && !updateStatusError && !wallet.balanceHidden && !wallet.scanning"
|
||||
on-hold="hideToggle()"
|
||||
ng-style="{'transform': amountScale}"
|
||||
ng-class="{amount__balance: amountIsCollapsible}">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue