replace all toggle buttons
This commit is contained in:
parent
501489cb66
commit
a54df263e2
7 changed files with 76 additions and 98 deletions
|
|
@ -16,6 +16,16 @@
|
|||
display: inherit;
|
||||
}
|
||||
|
||||
.item-toggle .toggle {
|
||||
right: 28px;
|
||||
}
|
||||
|
||||
.toggle-label {
|
||||
color: rgb(41, 55, 68);
|
||||
font-size: 14px;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
button, .button {
|
||||
min-width: inherit;
|
||||
min-height: inherit;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ var modules = [
|
|||
'gettext',
|
||||
'ionic',
|
||||
'ngLodash',
|
||||
'uiSwitch',
|
||||
'ngSanitize',
|
||||
'ngCsv',
|
||||
'bwcModule',
|
||||
|
|
|
|||
|
|
@ -6,20 +6,21 @@ angular.module('copayApp.controllers').controller('preferencesController',
|
|||
var fc = profileService.focusedClient;
|
||||
var config = configService.getSync();
|
||||
$scope.deleted = false;
|
||||
|
||||
if (fc.credentials && !fc.credentials.mnemonicEncrypted && !fc.credentials.mnemonic) {
|
||||
$scope.deleted = true;
|
||||
}
|
||||
|
||||
this.init = function() {
|
||||
if (fc) {
|
||||
$scope.encrypt = walletService.isEncrypted(fc);
|
||||
$scope.encryptEnabled = walletService.isEncrypted(fc);
|
||||
this.externalSource = fc.getPrivKeyExternalSourceName() == 'ledger' ? "Ledger" : null;
|
||||
// TODO externalAccount
|
||||
//this.externalIndex = fc.getExternalIndex();
|
||||
}
|
||||
|
||||
this.touchidAvailable = fingerprintService.isAvailable();
|
||||
$scope.touchid = config.touchIdFor ? config.touchIdFor[fc.credentials.walletId] : null;
|
||||
$scope.touchidEnabled = config.touchIdFor ? config.touchIdFor[fc.credentials.walletId] : null;
|
||||
};
|
||||
|
||||
var handleEncryptedWallet = function(client, cb) {
|
||||
|
|
@ -29,60 +30,56 @@ angular.module('copayApp.controllers').controller('preferencesController',
|
|||
});
|
||||
};
|
||||
|
||||
var unwatchEncrypt = $scope.$watch('encrypt', function(val) {
|
||||
var fc = profileService.focusedClient;
|
||||
$scope.encryptChange = function() {
|
||||
if (!fc) return;
|
||||
var val = $scope.encryptEnabled;
|
||||
|
||||
if (val && !walletService.isEncrypted(fc)) {
|
||||
$rootScope.$emit('Local/NeedsPassword', true, function(err, password) {
|
||||
if (err || !password) {
|
||||
$scope.encrypt = false;
|
||||
$scope.encryptEnabled = false;
|
||||
return;
|
||||
}
|
||||
profileService.setPrivateKeyEncryptionFC(password, function() {
|
||||
$rootScope.$emit('Local/NewEncryptionSetting');
|
||||
$scope.encrypt = true;
|
||||
$scope.encryptEnabled = true;
|
||||
});
|
||||
});
|
||||
} else {
|
||||
if (!val && walletService.isEncrypted(fc)) {
|
||||
handleEncryptedWallet(fc, function(err) {
|
||||
if (err) {
|
||||
$scope.encrypt = true;
|
||||
$scope.encryptEnabled = true;
|
||||
return;
|
||||
}
|
||||
profileService.disablePrivateKeyEncryptionFC(function(err) {
|
||||
$rootScope.$emit('Local/NewEncryptionSetting');
|
||||
if (err) {
|
||||
$scope.encrypt = true;
|
||||
$scope.encryptEnabled = true;
|
||||
$log.error(err);
|
||||
return;
|
||||
}
|
||||
$scope.encrypt = false;
|
||||
$scope.encryptEnabled = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var unwatchRequestTouchid = $scope.$watch('touchid', function(newVal, oldVal) {
|
||||
if (newVal == oldVal || $scope.touchidError) {
|
||||
$scope.touchidError = false;
|
||||
return;
|
||||
}
|
||||
$scope.touchidChange = function() {
|
||||
var walletId = fc.credentials.walletId;
|
||||
|
||||
var opts = {
|
||||
touchIdFor: {}
|
||||
};
|
||||
opts.touchIdFor[walletId] = newVal;
|
||||
opts.touchIdFor[walletId] = $scope.touchidEnabled;
|
||||
|
||||
fingerprintService.check(fc, function(err) {
|
||||
if (err) {
|
||||
$log.debug(err);
|
||||
$timeout(function() {
|
||||
$scope.touchidError = true;
|
||||
$scope.touchid = oldVal;
|
||||
$scope.touchidEnabled = false;
|
||||
}, 100);
|
||||
return;
|
||||
}
|
||||
|
|
@ -90,14 +87,9 @@ angular.module('copayApp.controllers').controller('preferencesController',
|
|||
if (err) {
|
||||
$log.debug(err);
|
||||
$scope.touchidError = true;
|
||||
$scope.touchid = oldVal;
|
||||
$scope.touchidEnabled = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$scope.$on('$destroy', function() {
|
||||
unwatchEncrypt();
|
||||
unwatchRequestTouchid();
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -36,24 +36,22 @@ angular.module('copayApp.controllers').controller('preferencesGlobalController',
|
|||
});
|
||||
}
|
||||
|
||||
var unwatchSpendUnconfirmed = $scope.$watch('spendUnconfirmed', function(newVal, oldVal) {
|
||||
if (newVal == oldVal) return;
|
||||
$scope.spendUnconfirmedChange = function() {
|
||||
var opts = {
|
||||
wallet: {
|
||||
spendUnconfirmed: newVal
|
||||
spendUnconfirmed: $scope.spendUnconfirmed
|
||||
}
|
||||
};
|
||||
configService.set(opts, function(err) {
|
||||
$rootScope.$emit('Local/SpendUnconfirmedUpdated', newVal);
|
||||
$rootScope.$emit('Local/SpendUnconfirmedUpdated', $scope.spendUnconfirmed);
|
||||
if (err) $log.debug(err);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
var unwatchPushNotifications = $scope.$watch('pushNotifications', function(newVal, oldVal) {
|
||||
if (newVal == oldVal) return;
|
||||
$scope.pushNotificationsChange = function() {
|
||||
var opts = {
|
||||
pushNotifications: {
|
||||
enabled: newVal
|
||||
enabled: $scope.pushNotifications
|
||||
}
|
||||
};
|
||||
configService.set(opts, function(err) {
|
||||
|
|
@ -63,38 +61,29 @@ angular.module('copayApp.controllers').controller('preferencesGlobalController',
|
|||
pushNotificationsService.disableNotifications(profileService.walletClients);
|
||||
if (err) $log.debug(err);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
var unwatchGlideraEnabled = $scope.$watch('glideraEnabled', function(newVal, oldVal) {
|
||||
if (newVal == oldVal) return;
|
||||
$scope.glideraChange = function() {
|
||||
var opts = {
|
||||
glidera: {
|
||||
enabled: newVal
|
||||
enabled: $scope.glideraEnabled
|
||||
}
|
||||
};
|
||||
configService.set(opts, function(err) {
|
||||
$rootScope.$emit('Local/GlideraUpdated');
|
||||
if (err) $log.debug(err);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
var unwatchCoinbaseEnabled = $scope.$watch('coinbaseEnabled', function(newVal, oldVal) {
|
||||
if (newVal == oldVal) return;
|
||||
$scope.coinbaseChange = function() {
|
||||
var opts = {
|
||||
coinbase: {
|
||||
enabled: newVal
|
||||
enabled: $scope.coinbaseEnabled
|
||||
}
|
||||
};
|
||||
configService.set(opts, function(err) {
|
||||
$rootScope.$emit('Local/CoinbaseUpdated');
|
||||
if (err) $log.debug(err);
|
||||
});
|
||||
});
|
||||
|
||||
$scope.$on('$destroy', function() {
|
||||
unwatchSpendUnconfirmed();
|
||||
unwatchGlideraEnabled();
|
||||
unwatchCoinbaseEnabled();
|
||||
unwatchPushNotifications();
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue