request PIN to disable it - add disabled options

This commit is contained in:
JDonadio 2017-04-20 12:59:15 -03:00
parent 01343d120d
commit 328ec337e1
2 changed files with 34 additions and 11 deletions

View File

@ -12,6 +12,7 @@ angular.module('copayApp.controllers').controller('lockSetupController', functio
method: 'pin',
label: gettextCatalog.getString('Lock by PIN'),
needsBackup: null,
disabled: null,
},
];
@ -20,15 +21,11 @@ angular.module('copayApp.controllers').controller('lockSetupController', functio
method: 'fingerprint',
label: gettextCatalog.getString('Lock by Fingerprint'),
needsBackup: null,
disabled: null,
});
}
var config = configService.getSync();
var method = config.lock && config.lock.method;
if (!method) $scope.currentOption = $scope.options[0];
else $scope.currentOption = lodash.find($scope.options, {
'method': method
});
checkAndSelectOption();
processWallets();
};
@ -36,6 +33,26 @@ angular.module('copayApp.controllers').controller('lockSetupController', functio
init();
});
function checkAndSelectOption() {
var config = configService.getSync();
var method = config.lock && config.lock.method;
if (!method) {
$scope.currentOption = $scope.options[0];
$scope.options[1].disabled = false;
$scope.options[2].disabled = false;
} else {
if (method == 'fingerprint') $scope.options[1].disabled = true;
if (method == 'pin') $scope.options[2].disabled = true;
$scope.currentOption = lodash.find($scope.options, {
'method': method
});
}
$timeout(function() {
$scope.$apply();
});
};
function processWallets() {
var wallets = profileService.getWallets();
var singleLivenetWallet = wallets.length == 1 && wallets[0].network == 'livenet' && wallets[0].needsBackup;
@ -73,9 +90,14 @@ angular.module('copayApp.controllers').controller('lockSetupController', functio
var config = configService.getSync();
var savedMethod = config.lock && config.lock.method;
if (!selectedMethod)
saveConfig();
else if (selectedMethod == 'fingerprint') {
if (!selectedMethod) {
if (!savedMethod) return;
if (savedMethod == 'pin') $state.transitionTo('tabs.pin', {
fromSettings: true,
locking: false,
});
else saveConfig();
} else if (selectedMethod == 'fingerprint') {
if (savedMethod == 'pin') {
askForDisablePin(function(disablePin) {
if (disablePin) saveConfig('fingerprint');
@ -116,6 +138,7 @@ angular.module('copayApp.controllers').controller('lockSetupController', functio
configService.set(opts, function(err) {
if (err) $log.debug(err);
checkAndSelectOption();
});
};
});

View File

@ -6,8 +6,8 @@
</ion-nav-bar>
<ion-content>
<ion-radio ng-repeat="opt in options" ng-value="opt" ng-model="currentOption" ng-click="select(opt.method)" ng-disabled="opt.needsBackup">
<span ng-class="{'disabled': opt.needsBackup}">{{opt.label}}</span>
<ion-radio ng-repeat="opt in options" ng-value="opt" ng-model="currentOption" ng-click="select(opt.method)" ng-disabled="opt.needsBackup || opt.disabled">
<span ng-class="{'disabled': opt.needsBackup || opt.disabled}">{{opt.label}}</span>
</ion-radio>
<div class="assertive" style="text-align: center; margin: 4rem" ng-if="errorMsg">