2022-04-26 01:47 AM
Hi again,
I'm currently working on a TouchGFX project that requires me to have some one-time setup with some screens that are only shown to the user if the device is not yet set up, Let's call the first of these screens "WelcomeScreen" as opposed to the "MainScreen" for the sake of brevity.
So, if the device is set up, I want to show the MainScreen to the user, and if the setup procedure is not yet done, I want to show the WelcomeScreen to the user.
What I have tried now is
FrontendApplication& Model::application()
{
return *static_cast<FrontendApplication*>(touchgfx::Application::getInstance());
}
and then add the following lines to the Model's c'tor:
if(setupIsComplete())
{
application().gotoMainScreenNoTransition();
}
else
{
application().gotoWelcomeScreenNoTransition();
}
While testing for different return values of `isSetupComplete` I observed that it doesn't matter what it returned as the calls to gotoXXXScreenNoTransition() have no effect in the Model's c'tor.
Since I thought maybe Model construction occurs too early and the touchgfx::Application is not yet fully initialized at that point, I moved the "switching logic" into the WelcomeScreen's Presenter's `activate` method, which now looks like this:
void WelcomeScreenPresenter::activate()
{
if(model->isSetupComplete())
{
model->goToMainScreen();
}
}
Again, no matter what `isSetupComplete` returns, the screen change does not occur. After the initial troubles, I can change screens programmatically with the method described above without any issues.
Am I missing something here? Is there a better way to change screens according to variables at runtime?
Best Regards,
Michael
Solved! Go to Solution.
2022-04-26 05:41 AM
Hello Michael,
What I would do is kind of a "splash screen" that you can configure the behavior, like if isSetupComplete returns true, then change screen to Mainscreen, else change to WelcomeScreen.
There's already a post on the forum explaining how to make it, I invite you to have a look at .
Also, I attached a simple project that does it, you can use it for reference.
Let me know if you succeed on what you want to do, and if you need further help :)
/Osman
2022-04-26 05:41 AM
Hello Michael,
What I would do is kind of a "splash screen" that you can configure the behavior, like if isSetupComplete returns true, then change screen to Mainscreen, else change to WelcomeScreen.
There's already a post on the forum explaining how to make it, I invite you to have a look at .
Also, I attached a simple project that does it, you can use it for reference.
Let me know if you succeed on what you want to do, and if you need further help :)
/Osman
2022-04-27 03:07 AM
Thanks for your response. I looked at the code and figured that the procedure is something like.
This results in the splash screen being rendered a split-second before another screen is being shown.
What I am still curious about is, why is it possible to switch the screen at that point in time but neither in the Model's C'tor nor in the initial screen's presenter's activate?
If this not at all possible, I'll have to check back with our customer to see if they are fine with a splash screen being shown.
2022-04-28 02:15 AM
I have now used something very close to what @Osman SOYKURT suggests with the splash screen being empty (except for the background color), having two actions as described and doing the following: