onboarding

This commit is contained in:
Gabriel Bazán 2016-08-25 16:31:47 -03:00
commit aacfe0a326
47 changed files with 699 additions and 332 deletions

View file

@ -0,0 +1,21 @@
'use strict';
angular.module('copayApp.controllers').controller('backupRequestController', function($rootScope, $scope, $state, $ionicPopup, $stateParams, profileService, walletService) {
$scope.openPopup = function() {
var backupLaterPopup = $ionicPopup.show({
templateUrl: "views/includes/backupLaterPopup.html",
scope: $scope,
});
$scope.goBack = function() {
backupLaterPopup.close();
};
$scope.continue = function() {
backupLaterPopup.close();
$state.go('onboarding.disclaimer');
};
}
});

View file

@ -0,0 +1,21 @@
'use strict';
angular.module('copayApp.controllers').controller('backupWarningController', function($rootScope, $scope, $state, $ionicPopup, $stateParams, profileService, walletService) {
$scope.openPopup = function() {
var backupWarningPopup = $ionicPopup.show({
templateUrl: "views/includes/backupWarningPopup.html",
scope: $scope,
});
$scope.close = function() {
backupWarningPopup.close();
var wallet = profileService.getWallets()[0];
$state.go('wallet.backup', {
walletId: wallet.credentials.walletId,
fromOnboarding: true
})
};
}
});

View file

@ -0,0 +1,17 @@
'use strict';
angular.module('copayApp.controllers').controller('collectEmailController', function($rootScope, $scope, $state, $stateParams, $timeout, $ionicModal, profileService, walletService) {
$scope.save = function(form) {
var wallet = profileService.getWallet($stateParams.walletId);
var email = $scope.email || '';
walletService.updateRemotePreferences(wallet, {
email: email,
}, function(err) {
if (err) $log.warn(err);
$state.go('onboarding.notifications');
});
};
});

View file

@ -0,0 +1,24 @@
'use strict';
angular.module('copayApp.controllers').controller('disclaimerController', function($scope, $state, $log, $ionicModal, profileService) {
$scope.confirm = function() {
profileService.setDisclaimerAccepted(function(err) {
if (err) $log.error(err);
else {
$state.go('tabs.home');
}
});
};
this.openModal = function() {
$ionicModal.fromTemplateUrl('views/modals/addressbook.html', {
scope: $scope
}).then(function(modal) {
$scope.addressbookModal = modal;
$scope.addressbookModal.show();
});
};
});

View file

@ -0,0 +1,12 @@
'use strict';
angular.module('copayApp.controllers').controller('notificationsController', function($scope, $state, platformInfo) {
if (!platformInfo.isCordova) $state.go('onboarding.backupRequest');
$scope.allowNotif = function() {
// T O D O
$state.go('onboarding.backupRequest');
}
});

View file

@ -0,0 +1,15 @@
'use strict';
angular.module('copayApp.controllers').controller('termsController', function($scope, $log, $state, uxLanguage, profileService) {
$scope.lang = uxLanguage.currentLanguage;
$scope.confirm = function() {
profileService.setDisclaimerAccepted(function(err) {
if (err) $log.error(err);
else {
$state.go('tabs.home');
}
});
};
});

View file

@ -0,0 +1,71 @@
'use strict';
angular.module('copayApp.controllers').controller('tourController',
function($scope, $stateParams, $state, $log, $timeout, ongoingProcess, storageService, profileService) {
$scope.init = function() {
$scope.data = {
index: 0
};
$scope.options = {
loop: false,
effect: 'flip',
speed: 500,
spaceBetween: 100
}
};
$scope.createProfile = function(opts) {
var tries = 0;
opts = opts || {};
$log.debug('Creating profile');
ongoingProcess.set('creatingWallet', true);
profileService.create(opts, function(err) {
if (err) {
$log.warn(err);
$scope.error = err;
$scope.$apply();
return $timeout(function() {
$log.warn('Retrying to create profile......');
if (tries == 3) {
tries == 0;
return $scope.createProfile({
noWallet: true
});
} else {
tries += 1;
return $scope.createProfile();
}
}, 3000);
};
$scope.error = "";
ongoingProcess.set('creatingWallet', false);
var wallet = profileService.getWallets()[0];
$state.go('onboarding.collectEmail', {
walletId: wallet.credentials.walletId
});
});
};
$scope.goBack = function() {
if ($scope.data.index != 0) $scope.slider.slidePrev();
else $state.go('onboarding.welcome');
}
$scope.slideNext = function() {
if ($scope.data.index != 2) $scope.slider.slideNext();
else $state.go('onboarding.welcome');
}
$scope.$on("$ionicSlides.sliderInitialized", function(event, data) {
$scope.slider = data.slider;
});
$scope.$on("$ionicSlides.slideChangeStart", function(event, data) {
$scope.data.index = data.slider.activeIndex;
});
$scope.$on("$ionicSlides.slideChangeEnd", function(event, data) {});
});