diff --git a/src/js/controllers/pincode.js b/src/js/controllers/pincode.js index dca8f08f4..448ed58fa 100644 --- a/src/js/controllers/pincode.js +++ b/src/js/controllers/pincode.js @@ -1,6 +1,7 @@ 'use strict'; -angular.module('copayApp.controllers').controller('pincodeController', function($timeout, $scope, $log, $window) { +angular.module('copayApp.controllers').controller('pincodeController', function($timeout, $scope, $log, $window, configService) { + $scope.pincode = ''; angular.element($window).on('keydown', function(e) { if (e.which === 8) { // you can add others here inside brackets. @@ -11,34 +12,39 @@ angular.module('copayApp.controllers').controller('pincodeController', function( if (e.key && e.key.match(/^[0-9]$/)) $scope.add(e.key); else if (e.key && e.key == 'Enter') - console.log('DONE'); - }); - - $scope.$on('$ionicView.beforeEnter', function(event, data) { - $scope.passcode = ""; + checkPasscode(); }); $scope.add = function(value) { - if (isComplete()) $log.debug("The four digit code was entered"); + if (isComplete()) checkPasscode(); else updatePassCode(value); }; $scope.delete = function() { - if ($scope.passcode.length > 0) { - $scope.passcode = $scope.passcode.substring(0, $scope.passcode.length - 1); + if ($scope.pincode.length > 0) { + $scope.pincode = $scope.pincode.substring(0, $scope.pincode.length - 1); updatePassCode(); } }; function isComplete() { - if ($scope.passcode.length < 4) return false; + if ($scope.pincode.length < 4) return false; else return true; }; function updatePassCode(value) { - if (value) $scope.passcode = $scope.passcode + value; + if (value) $scope.pincode = $scope.pincode + value; $timeout(function() { + checkPasscode(); $scope.$apply(); }); }; + + function checkPasscode() { + configService.whenAvailable(function(config) { + var value = '1234'; + if (value != $scope.pincode) return; + console.log('MATCH'); + }); + }; }); diff --git a/src/js/controllers/tab-home.js b/src/js/controllers/tab-home.js index 7a3fd83f8..8abcb08d2 100644 --- a/src/js/controllers/tab-home.js +++ b/src/js/controllers/tab-home.js @@ -15,6 +15,17 @@ angular.module('copayApp.controllers').controller('tabHomeController', $scope.isNW = platformInfo.isNW; $scope.showRateCard = {}; + function openPincodeModal() { + $ionicModal.fromTemplateUrl('views/modals/pincode.html', { + scope: $scope, + backdropClickToClose: false, + hardwareBackButtonClose: false + }).then(function(modal) { + $scope.pincodeModal = modal; + $scope.pincodeModal.show(); + }); + }; + openPincodeModal(); $scope.$on("$ionicView.afterEnter", function() { startupService.ready(); }); diff --git a/src/js/routes.js b/src/js/routes.js index b02f18937..4fc657bd4 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -672,22 +672,6 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr } }) - /* - * - * Pin Code - * - */ - - .state('tabs.home.pincode', { - url: '/pincode', - views: { - 'tab-home@tabs': { - templateUrl: 'views/pincode.html', - controller: 'pincodeController' - } - } - }) - /* * * Paper Wallet diff --git a/src/js/services/configService.js b/src/js/services/configService.js index 747554ca1..1a16992fb 100644 --- a/src/js/services/configService.js +++ b/src/js/services/configService.js @@ -53,6 +53,10 @@ angular.module('copayApp.services').factory('configService', function(storageSer } }, + pincode: { + value: null, + }, + // External services recentTransactions: { enabled: true, diff --git a/src/sass/views/pincode.scss b/src/sass/views/pincode.scss index 64a4b8584..97413fc47 100644 --- a/src/sass/views/pincode.scss +++ b/src/sass/views/pincode.scss @@ -1,38 +1,36 @@ -.button-stretch { +#pin-code { + background-color: #C3C3C3; + + .button-stretch { + width: 100%; + } + .col-offset-15 { + margin-left: 15%; + } + @mixin centerer { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + } + .content { + position: absolute; width: 100%; -} - -.col-offset-15 { - margin-left: 15%; -} - -@mixin centerer { - position: absolute; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); -} - -.content { - position: relative; - width: 100%; - height: 100%; -} - -.block-code { - @include centerer; - top: 20% !important; - width: 50%; - - > .row > .col { - border-bottom: 1px solid #3E3E3E; - padding: 5px; - margin: 10px; - height: 35px; + height: 100%; + .block-code { + @include centerer; + top: 20% !important; + width: 50%; + > .row > .col { + border-bottom: 1px solid #3E3E3E; + padding: 5px; + margin: 10px; + height: 35px; + } + } + .block-buttons { + @include centerer; + padding: 20px; + } } } - -.block-buttons { - @include centerer; - padding: 20px; -} diff --git a/www/views/pincode.html b/www/views/modals/pincode.html similarity index 88% rename from www/views/pincode.html rename to www/views/modals/pincode.html index 7bbf96677..aeee3a3dc 100644 --- a/www/views/pincode.html +++ b/www/views/modals/pincode.html @@ -1,18 +1,18 @@ - +
- {{passcode.substring(0, 1)}} + {{pincode.substring(0, 1)}}
- {{passcode.substring(1, 2)}} + {{pincode.substring(1, 2)}}
- {{passcode.substring(2, 3)}} + {{pincode.substring(2, 3)}}
- {{passcode.substring(3, 4)}} + {{pincode.substring(3, 4)}}
@@ -63,7 +63,4 @@
- -
+ diff --git a/www/views/tab-home.html b/www/views/tab-home.html index 6f0d57ece..6d2ec9247 100644 --- a/www/views/tab-home.html +++ b/www/views/tab-home.html @@ -66,7 +66,7 @@
Wallets - +