Using the intro template provided by the Ionic guys, seen here, I have a small app that will go through the tutorial before getting to the main view. But what I’m noticing is that upon launching the app, it’s visible for a moment before transitioning to the main view.
Now this isn’s a crazy issue but what I was wondering if there was a better way to speed up the reading of the local storage.
I came up with one idea where after the angular reads the local storage and changes the view, I hide the splash screen. Fixes the issue, but the splash screen is shown for a longer amount of time.
Any ideas on how I can reduce the splash screen display time without having the intro view visible?
How about using a resolve in your config? The resolve will not allow the state change until you know the status of ‘didTutorial’. So, the intro won’t flash.
@Calendee what I figured would work would be to set a call back in my $scope.startApp(); function, but still not working. I set the auto-hide-splash-screen option to false in the config.xml file so I can control when to show and hide the splash screen through angular.
To my understanding, this should work, but it’s still hiding the splash screen before the transition. I figured this would be the safest bet since I’m not too familiar with ui-router and all of its option.
I added a timeout to each call so that there would be a safe amount of time to allow for the transitions. 750 ms was a good guess (good enough for me at least) but if there is an actual time on how long the transition last, that timeout value can be set to that.
Hey @Calendee sorry to bring up an old post but my client has fallen out with my quick solution. It was more like a band-aid and setting up a resolve seems to be more of a correct way to address the problem. Though I am having some trouble trying to figure out what I have to do.
So I have my intro state like this
//Intro State
.state('intro', {
url: '/',
templateUrl: 'templates/intro.html',
controller: 'IntroCtrl',
resolve: {
app: function ($scope, window, console, navigator) {
if (window.localStorage.didTutorial === 'true') {
$scope.startApp(function () {});
} else {
console.log('Need to do into');
navigator.splashscreen.hide();
}
}
}
})
But the whole app breaks and noting loads. Any ideas?
I THINK the problem is that you are not returning anything with your resolve. Resolves are supposed to … “resolve” to a result. NOTE : You can also just return a value.
I don’t know if you’re allowed to put that other stuff in.
The return value of $resolve is a promise for an object that contains (in this order of precedence)
any locals (if specified)
the resolved return values of all injectables
any values inherited from a parent call to $resolve (if specified)