diff --git a/src/js/controllers/advancedSettings.js b/src/js/controllers/advancedSettings.js index c5cd65103..826ae3c81 100644 --- a/src/js/controllers/advancedSettings.js +++ b/src/js/controllers/advancedSettings.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('advancedSettingsController', function($scope, $rootScope, $log, $window, lodash, configService, uxLanguage, platformInfo, profileService, feeService, storageService, $ionicHistory, $timeout, $ionicScrollDelegate) { +angular.module('copayApp.controllers').controller('advancedSettingsController', function($scope, $rootScope, $log, $window, $ionicModal, lodash, configService, uxLanguage, platformInfo, pushNotificationsService, profileService, feeService, storageService, $ionicHistory, $timeout, $ionicScrollDelegate) { var updateConfig = function() { var config = configService.getSync(); @@ -11,10 +11,12 @@ angular.module('copayApp.controllers').controller('advancedSettingsController', $scope.recentTransactionsEnabled = { value: config.recentTransactions.enabled }; - $scope.hideNextSteps = { value: config.hideNextSteps.enabled }; + $scope.usePincode = { + value: config.pincode ? config.pincode.enabled : false + }; }; $scope.spendUnconfirmedChange = function() { @@ -31,7 +33,24 @@ angular.module('copayApp.controllers').controller('advancedSettingsController', $scope.nextStepsChange = function() { var opts = { hideNextSteps: { - enabled: $scope.hideNextSteps.value + enabled: $scope.hideNextSteps.value + }, + }; + configService.set(opts, function(err) { + if (err) $log.debug(err); + }); + }; + + $scope.savePincodeChanges = function(val) { + if (!val || val.length < 4) { + $scope.usePincode = { + value: false + } + return; + } + var opts = { + usePincode: { + enabled: $scope.usePincode.enabled }, }; configService.set(opts, function(err) { @@ -50,6 +69,18 @@ angular.module('copayApp.controllers').controller('advancedSettingsController', }); }; + $scope.showPincodeModal = function() { + $scope.fromSettings = true; + $ionicModal.fromTemplateUrl('views/modals/pincode.html', { + scope: $scope, + backdropClickToClose: false, + hardwareBackButtonClose: false + }).then(function(modal) { + $scope.pincodeModal = modal; + $scope.pincodeModal.show(); + }); + }; + $scope.$on("$ionicView.beforeEnter", function(event, data) { updateConfig(); }); diff --git a/src/js/controllers/pincode.js b/src/js/controllers/pincode.js index 448ed58fa..53c3da987 100644 --- a/src/js/controllers/pincode.js +++ b/src/js/controllers/pincode.js @@ -41,10 +41,16 @@ angular.module('copayApp.controllers').controller('pincodeController', function( }; function checkPasscode() { + console.log('Checking'); configService.whenAvailable(function(config) { var value = '1234'; if (value != $scope.pincode) return; console.log('MATCH'); }); }; + + $scope.cancel = function() { + $scope.savePincodeChanges(false); + $scope.pincodeModal.hide(); + }; }); diff --git a/src/js/controllers/tab-home.js b/src/js/controllers/tab-home.js index 8abcb08d2..00566a01f 100644 --- a/src/js/controllers/tab-home.js +++ b/src/js/controllers/tab-home.js @@ -25,7 +25,7 @@ angular.module('copayApp.controllers').controller('tabHomeController', $scope.pincodeModal.show(); }); }; - openPincodeModal(); + // openPincodeModal(); $scope.$on("$ionicView.afterEnter", function() { startupService.ready(); }); diff --git a/src/js/services/configService.js b/src/js/services/configService.js index 1a16992fb..9e1a54319 100644 --- a/src/js/services/configService.js +++ b/src/js/services/configService.js @@ -54,6 +54,7 @@ angular.module('copayApp.services').factory('configService', function(storageSer }, pincode: { + enabled: false, value: null, }, diff --git a/src/sass/views/pincode.scss b/src/sass/views/pincode.scss index 97413fc47..040d0113a 100644 --- a/src/sass/views/pincode.scss +++ b/src/sass/views/pincode.scss @@ -1,6 +1,9 @@ #pin-code { background-color: #C3C3C3; - + .close { + cursor: pointer; + padding: .5rem; + } .button-stretch { width: 100%; } @@ -15,6 +18,7 @@ } .content { position: absolute; + text-align: center; width: 100%; height: 100%; .block-code { diff --git a/www/views/advancedSettings.html b/www/views/advancedSettings.html index 9905fdec2..26566061b 100644 --- a/www/views/advancedSettings.html +++ b/www/views/advancedSettings.html @@ -13,7 +13,7 @@
If enabled, wallets will also try to spend unconfirmed funds. This option may cause transaction delays.
- +
@@ -28,6 +28,12 @@ Hide Next Steps Card + +
+ + + Use pin to lock/unlock the app + diff --git a/www/views/modals/pincode.html b/www/views/modals/pincode.html index aeee3a3dc..ab75264e7 100644 --- a/www/views/modals/pincode.html +++ b/www/views/modals/pincode.html @@ -1,4 +1,5 @@ +
Close
@@ -52,13 +53,13 @@
- +
- +