views instead modal

This commit is contained in:
JDonadio 2017-03-03 14:18:56 -03:00
commit 93168cdae6
4 changed files with 52 additions and 19 deletions

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('advancedSettingsController', function($scope, $rootScope, $timeout, $log, $window, $ionicModal, lodash, configService, uxLanguage, platformInfo, pushNotificationsService, profileService, feeService, storageService, $ionicHistory, $ionicScrollDelegate, pincodeService) { angular.module('copayApp.controllers').controller('advancedSettingsController', function($scope, $rootScope, $timeout, $state, $log, $window, $ionicModal, lodash, configService, uxLanguage, platformInfo, pushNotificationsService, profileService, feeService, storageService, $ionicHistory, $ionicScrollDelegate, pincodeService) {
var updateConfig = function() { var updateConfig = function() {
var config = configService.getSync(); var config = configService.getSync();
@ -53,7 +53,11 @@ angular.module('copayApp.controllers').controller('advancedSettingsController',
}; };
$scope.usePincodeChange = function() { $scope.usePincodeChange = function() {
pincodeService.lockChange({ // pincodeService.lockChange({
// fromSettings: true,
// locking: $scope.usePincode.enabled
// });
$state.go('tabs.pincode', {
fromSettings: true, fromSettings: true,
locking: $scope.usePincode.enabled locking: $scope.usePincode.enabled
}); });

View file

@ -1,7 +1,13 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('pincodeController', function($rootScope, $timeout, $scope, $log, $window, configService) { angular.module('copayApp.controllers').controller('pincodeController', function($rootScope, $state, $timeout, $scope, $log, $window, configService) {
$scope.currentPincode = $scope.newPincode = '';
$scope.$on("$ionicView.beforeEnter", function(event, data) {
$scope.currentPincode = $scope.newPincode = '';
$scope.fromSettings = data.stateParams.fromSettings == 'true' ? true : false;
$scope.locking = data.stateParams.locking == 'true' ? true : false;
console.log('### From Settings:', $scope.fromSettings, 'Locking:', $scope.locking);
});
angular.element($window).on('keydown', function(e) { angular.element($window).on('keydown', function(e) {
if (e.which === 8) { if (e.which === 8) {
@ -87,6 +93,7 @@ angular.module('copayApp.controllers').controller('pincodeController', function(
$scope.close = function() { $scope.close = function() {
$rootScope.$emit('updatePincodeOption'); $rootScope.$emit('updatePincodeOption');
$scope.pincodeModal.remove(); if ($scope.fromSettings) $state.go('tabs.advanced');
else $state.go('tabs.home');
}; };
}); });

View file

@ -119,6 +119,18 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
} }
}) })
/*
*
* Pin code
*
*/
.state('pincode', {
url: '/pincode/:fromSettings/:locking',
controller: 'pincodeController',
templateUrl: 'views/pincode.html'
})
/* /*
* *
* URI * URI
@ -439,6 +451,15 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
} }
} }
}) })
.state('tabs.pincode', {
url: '/pincode/:fromSettings/:locking',
views: {
'tab-settings@tabs': {
controller: 'pincodeController',
templateUrl: 'views/pincode.html',
}
}
})
/* /*
* *
@ -1091,20 +1112,11 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
} }
}); });
}) })
.run(function($rootScope, $state, $location, $log, $timeout, $ionicHistory, $ionicPlatform, $window, appConfigService, lodash, platformInfo, profileService, uxLanguage, gettextCatalog, openURLService, storageService, scannerService, configService, pincodeService, /* plugins START HERE => */ coinbaseService, glideraService, amazonService, bitpayCardService) { .run(function($rootScope, $state, $location, $log, $timeout, $ionicHistory, $ionicPlatform, $window, appConfigService, lodash, platformInfo, profileService, uxLanguage, gettextCatalog, openURLService, storageService, scannerService, configService, /* plugins START HERE => */ coinbaseService, glideraService, amazonService, bitpayCardService) {
uxLanguage.init(); uxLanguage.init();
$ionicPlatform.ready(function() { $ionicPlatform.ready(function() {
configService.whenAvailable(function(config) {
if (config.pincode && config.pincode.enabled) {
pincodeService.lockChange({
fromSettings: false,
locking: false,
});
}
});
if (screen.width < 768 && platformInfo.isCordova) if (screen.width < 768 && platformInfo.isCordova)
screen.lockOrientation('portrait'); screen.lockOrientation('portrait');
@ -1205,9 +1217,19 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
disableAnimate: true, disableAnimate: true,
historyRoot: true historyRoot: true
}); });
$state.transitionTo('tabs.home').then(function() { configService.whenAvailable(function(config) {
// Clear history console.log('### CONFIG', config.pincode);
$ionicHistory.clearHistory(); if (config.pincode && config.pincode.enabled) {
$state.go('pincode', {
fromSettings: false,
locking: false
});
} else {
$state.transitionTo('tabs.home').then(function() {
// Clear history
$ionicHistory.clearHistory();
});
}
}); });
}); });
} }

View file

@ -1,4 +1,4 @@
<ion-modal-view id="pin-code" ng-controller="pincodeController"> <ion-modal-view id="pin-code" ng-controller="pincodeController" hide-tabs>
<div ng-if="fromSettings" ng-click="close()" class="close" translate>Close</div> <div ng-if="fromSettings" ng-click="close()" class="close" translate>Close</div>
<div class="content"> <div class="content">
<div class="block-code"> <div class="block-code">