refactor - only mobile
This commit is contained in:
parent
93168cdae6
commit
e89847af55
5 changed files with 58 additions and 72 deletions
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
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) {
|
||||
angular.module('copayApp.controllers').controller('advancedSettingsController', function($scope, $timeout, $state, $log, $window, $ionicModal, lodash, configService, uxLanguage, platformInfo, pushNotificationsService, profileService, feeService, storageService, $ionicHistory, $ionicScrollDelegate, pincodeService) {
|
||||
|
||||
var updateConfig = function() {
|
||||
var config = configService.getSync();
|
||||
|
|
@ -53,27 +53,22 @@ angular.module('copayApp.controllers').controller('advancedSettingsController',
|
|||
};
|
||||
|
||||
$scope.usePincodeChange = function() {
|
||||
// pincodeService.lockChange({
|
||||
// fromSettings: true,
|
||||
// locking: $scope.usePincode.enabled
|
||||
// });
|
||||
$state.go('tabs.pincode', {
|
||||
fromSettings: true,
|
||||
locking: $scope.usePincode.enabled
|
||||
});
|
||||
};
|
||||
|
||||
$rootScope.$on('updatePincodeOption', function(event) {
|
||||
$timeout(function() {
|
||||
var config = configService.getSync();
|
||||
$scope.usePincode = {
|
||||
enabled: config.pincode ? config.pincode.enabled : false
|
||||
};
|
||||
$scope.$apply();
|
||||
});
|
||||
$scope.$on('updatePincodeOption', function(event) {
|
||||
var config = configService.getSync();
|
||||
$scope.usePincode = {
|
||||
enabled: config.pincode ? config.pincode.enabled : false
|
||||
};
|
||||
$scope.$apply();
|
||||
});
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
$scope.isCordova = platformInfo.isCordova;
|
||||
updateConfig();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,36 +1,17 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('pincodeController', function($rootScope, $state, $timeout, $scope, $log, $window, configService) {
|
||||
angular.module('copayApp.controllers').controller('pincodeController', function($state, $stateParams, $timeout, $scope, $log, $window, configService) {
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
$scope.$on("$ionicView.beforeEnter", function(event) {
|
||||
$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);
|
||||
$scope.fromSettings = $stateParams.fromSettings == 'true' ? true : false;
|
||||
$scope.locking = $stateParams.locking == 'true' ? true : false;
|
||||
});
|
||||
|
||||
angular.element($window).on('keydown', function(e) {
|
||||
if (e.which === 8) {
|
||||
e.preventDefault();
|
||||
$scope.delete();
|
||||
}
|
||||
|
||||
if (e && e.key.match(/^[0-9]$/))
|
||||
$scope.add(e.key);
|
||||
else if (e && e.keyCode == 27)
|
||||
$scope.close();
|
||||
else if (e && e.keyCode == 13)
|
||||
$scope.save();
|
||||
});
|
||||
|
||||
$scope.add = function(value) {
|
||||
updatePassCode(value);
|
||||
};
|
||||
|
||||
$scope.delete = function() {
|
||||
if ($scope.currentPincode.length > 0) {
|
||||
$scope.currentPincode = $scope.currentPincode.substring(0, $scope.currentPincode.length - 1);
|
||||
updatePassCode();
|
||||
$scope.updatePinCode();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -39,12 +20,18 @@ angular.module('copayApp.controllers').controller('pincodeController', function(
|
|||
else return true;
|
||||
};
|
||||
|
||||
function updatePassCode(value) {
|
||||
if (value && $scope.currentPincode.length < 4)
|
||||
$scope.updatePinCode = function(value) {
|
||||
if (value && !isComplete()) {
|
||||
$scope.currentPincode = $scope.currentPincode + value;
|
||||
}
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
if (!$scope.locking && isComplete()) {
|
||||
$timeout(function() {
|
||||
$scope.save();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$scope.save = function() {
|
||||
|
|
@ -52,29 +39,27 @@ angular.module('copayApp.controllers').controller('pincodeController', function(
|
|||
var config = configService.getSync();
|
||||
var match = config.pincode.value == $scope.currentPincode ? true : false;
|
||||
|
||||
if (!$scope.fromSettings && match) {
|
||||
$scope.currentPincode = '';
|
||||
$scope.close();
|
||||
return;
|
||||
}
|
||||
if (!$scope.locking) {
|
||||
if (!match) return;
|
||||
saveSettings($scope.locking, '');
|
||||
if (match) {
|
||||
$scope.fromSettings ? saveSettings($scope.locking, '') : $scope.close();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
checkCodes();
|
||||
}
|
||||
checkCodes();
|
||||
};
|
||||
|
||||
function checkCodes() {
|
||||
if (!$scope.newPincode) {
|
||||
$scope.newPincode = $scope.currentPincode;
|
||||
$scope.currentPincode = '';
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
} else {
|
||||
if ($scope.newPincode == $scope.currentPincode)
|
||||
saveSettings($scope.locking, $scope.newPincode);
|
||||
}
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
};
|
||||
|
||||
function saveSettings(enabled, value) {
|
||||
|
|
@ -92,7 +77,7 @@ angular.module('copayApp.controllers').controller('pincodeController', function(
|
|||
};
|
||||
|
||||
$scope.close = function() {
|
||||
$rootScope.$emit('updatePincodeOption');
|
||||
$scope.$emit('updatePincodeOption');
|
||||
if ($scope.fromSettings) $state.go('tabs.advanced');
|
||||
else $state.go('tabs.home');
|
||||
};
|
||||
|
|
|
|||
|
|
@ -126,9 +126,9 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
*/
|
||||
|
||||
.state('pincode', {
|
||||
url: '/pincode/:fromSettings/:locking',
|
||||
url: '/pincode/',
|
||||
controller: 'pincodeController',
|
||||
templateUrl: 'views/pincode.html'
|
||||
templateUrl: 'views/pincode.html',
|
||||
})
|
||||
|
||||
/*
|
||||
|
|
@ -457,6 +457,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
'tab-settings@tabs': {
|
||||
controller: 'pincodeController',
|
||||
templateUrl: 'views/pincode.html',
|
||||
cache: false
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
@ -1112,7 +1113,7 @@ 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, /* plugins START HERE => */ coinbaseService, glideraService, amazonService, bitpayCardService) {
|
||||
.run(function($rootScope, $state, $location, $log, $timeout, startupService, $ionicHistory, $ionicPlatform, $window, appConfigService, lodash, platformInfo, profileService, uxLanguage, gettextCatalog, openURLService, storageService, scannerService, configService, /* plugins START HERE => */ coinbaseService, glideraService, amazonService, bitpayCardService) {
|
||||
|
||||
uxLanguage.init();
|
||||
|
||||
|
|
@ -1218,11 +1219,11 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
historyRoot: true
|
||||
});
|
||||
configService.whenAvailable(function(config) {
|
||||
console.log('### CONFIG', config.pincode);
|
||||
if (config.pincode && config.pincode.enabled) {
|
||||
$state.go('pincode', {
|
||||
fromSettings: false,
|
||||
locking: false
|
||||
startupService.ready();
|
||||
if (platformInfo.isCordova && config.pincode && config.pincode.enabled) {
|
||||
$state.transitionTo('pincode').then(function() {
|
||||
// Clear history
|
||||
$ionicHistory.clearHistory();
|
||||
});
|
||||
} else {
|
||||
$state.transitionTo('tabs.home').then(function() {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
<div class="item item-divider"></div>
|
||||
|
||||
<ion-toggle ng-model="usePincode.enabled" toggle-class="toggle-balanced" ng-change="usePincodeChange()">
|
||||
<ion-toggle ng-if="isCordova" ng-model="usePincode.enabled" toggle-class="toggle-balanced" ng-change="usePincodeChange()">
|
||||
<span class="toggle-label" translate>Use pin to lock/unlock the app</span>
|
||||
</ion-toggle>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,9 @@
|
|||
<ion-modal-view id="pin-code" ng-controller="pincodeController" hide-tabs>
|
||||
<ion-view id="pin-code" ng-controller="pincodeController" hide-tabs hide-back-button="!fromSettings">
|
||||
<ion-nav-bar class="bar-royal">
|
||||
<ion-nav-title>{{'Pin Code' | translate}}</ion-nav-title>
|
||||
<ion-nav-back-button>
|
||||
</ion-nav-back-button>
|
||||
</ion-nav-bar>
|
||||
<div ng-if="fromSettings" ng-click="close()" class="close" translate>Close</div>
|
||||
<div class="content">
|
||||
<div class="block-code">
|
||||
|
|
@ -20,35 +25,35 @@
|
|||
<div class="block-buttons">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<button class="button button-light button-stretch" ng-click="add('1')">1</button>
|
||||
<button class="button button-light button-stretch" ng-click="updatePinCode('1')">1</button>
|
||||
</div>
|
||||
<div class="col">
|
||||
<button class="button button-light button-stretch" ng-click="add('2')">2</button>
|
||||
<button class="button button-light button-stretch" ng-click="updatePinCode('2')">2</button>
|
||||
</div>
|
||||
<div class="col">
|
||||
<button class="button button-light button-stretch" ng-click="add('3')">3</button>
|
||||
<button class="button button-light button-stretch" ng-click="updatePinCode('3')">3</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<button class="button button-light button-stretch" ng-click="add('4')">4</button>
|
||||
<button class="button button-light button-stretch" ng-click="updatePinCode('4')">4</button>
|
||||
</div>
|
||||
<div class="col">
|
||||
<button class="button button-light button-stretch" ng-click="add('5')">5</button>
|
||||
<button class="button button-light button-stretch" ng-click="updatePinCode('5')">5</button>
|
||||
</div>
|
||||
<div class="col">
|
||||
<button class="button button-light button-stretch" ng-click="add('6')">6</button>
|
||||
<button class="button button-light button-stretch" ng-click="updatePinCode('6')">6</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<button class="button button-light button-stretch" ng-click="add('7')">7</button>
|
||||
<button class="button button-light button-stretch" ng-click="updatePinCode('7')">7</button>
|
||||
</div>
|
||||
<div class="col">
|
||||
<button class="button button-light button-stretch" ng-click="add('8')">8</button>
|
||||
<button class="button button-light button-stretch" ng-click="updatePinCode('8')">8</button>
|
||||
</div>
|
||||
<div class="col">
|
||||
<button class="button button-light button-stretch" ng-click="add('9')">9</button>
|
||||
<button class="button button-light button-stretch" ng-click="updatePinCode('9')">9</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
|
@ -56,7 +61,7 @@
|
|||
<button class="button button-light button-stretch icon ion-checkmark" ng-click="save()" ng-disabled=""></button>
|
||||
</div>
|
||||
<div class="col">
|
||||
<button class="button button-light button-stretch" ng-click="add('0')">0</button>
|
||||
<button class="button button-light button-stretch" ng-click="updatePinCode('0')">0</button>
|
||||
</div>
|
||||
<div class="col">
|
||||
<button class="button button-light button-stretch icon ion-arrow-left-a" ng-click="delete()"></button>
|
||||
|
|
@ -64,4 +69,4 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ion-modal-view>
|
||||
</ion-view>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue