Merge pull request #4339 from JDonadio/bug/select-color

Fix color selection - IOs
This commit is contained in:
Gustavo Maximiliano Cortez 2016-06-10 10:16:47 -03:00 committed by GitHub
commit ec33c32733
2 changed files with 39 additions and 52 deletions

View File

@ -1,18 +1,11 @@
<div <div class="topbar-container" ng-include="'views/includes/topbar.html'"
class="topbar-container"
ng-include="'views/includes/topbar.html'"
ng-init="titleSection='Color'; goBackToState = 'preferences'"> ng-init="titleSection='Color'; goBackToState = 'preferences'">
</div> </div>
<div class="content preferences" ng-controller="preferencesColorController">
<div class="content preferences" ng-controller="preferencesColorController as p">
<h4></h4> <h4></h4>
<ul class="no-bullet m0">
<li ng-repeat="c in p.colorOpts" ng-click="p.save(c)"> <ion-radio class="size-12" ng-repeat="c in colorList" ng-value="c" ng-model="currentColor" ng-click="save(c)">
<span ng-style="{'color': c}">&block;</span> <span ng-style="{'color': c}">&block;</span>
<i class="fi-check size-16 right" ng-show="p.color == c"></i> </ion-radio>
</li>
</ul>
</div> </div>
<div class="extra-margin-bottom"></div>

View File

@ -1,9 +1,8 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('preferencesColorController', angular.module('copayApp.controllers').controller('preferencesColorController', function($scope, $log, configService, profileService, go) {
function($scope, $timeout, $log, configService, profileService, go) {
var config = configService.getSync(); $scope.colorList = [
this.colorOpts = [
'#DD4B39', '#DD4B39',
'#F38F12', '#F38F12',
'#FAA77F', '#FAA77F',
@ -22,26 +21,21 @@ angular.module('copayApp.controllers').controller('preferencesColorController',
var fc = profileService.focusedClient; var fc = profileService.focusedClient;
var walletId = fc.credentials.walletId; var walletId = fc.credentials.walletId;
var config = configService.getSync(); var config = configService.getSync();
config.colorFor = config.colorFor || {}; config.colorFor = config.colorFor || {};
this.color = config.colorFor[walletId] || '#4A90E2';
this.save = function(color) { $scope.currentColor = config.colorFor[walletId] || '#4A90E2';
var self = this;
$scope.save = function(color) {
var opts = { var opts = {
colorFor: {} colorFor: {}
}; };
opts.colorFor[walletId] = color; opts.colorFor[walletId] = color;
configService.set(opts, function(err) { configService.set(opts, function(err) {
if (err) $log.warn(err);
go.preferences(); go.preferences();
if (err) $log.warn(err);
$scope.$emit('Local/ColorUpdated'); $scope.$emit('Local/ColorUpdated');
$timeout(function() {
$scope.$apply();
}, 100);
}); });
}; };
}); });