instantiator / flipper-zero-tutorial-app

Code supporting a tutorial series on developing apps for the Flipper Zero
MIT License
38 stars 7 forks source link

TestAppScene and TestAppView should have the same length #2

Open MrModd opened 11 months ago

MrModd commented 11 months ago

Hello, I think that the view dispatcher uses the index passed to view_dispatcher_add_view() to know which module to use for that view. When you do scene_manager_next_scene() I believe the view dispatcher loads the module that was passed in ..._add_view().

You can see this because if you change the order of one of the two enums the application won't show anything. What's happening is that the ..._on_enter() function is building the elements in a module that the view dispatcher didn't load.

I think that in your case it's working just because it happens that the third value of the TestAppScene enum has the same module of the last value of TestAppView enum.

TL;DR I think that the enum TestAppView is not needed and you should use values from TestAppScene in view_dispatcher_add_view(). Moreover you should do an ..._add_view() for each element of TestAppScene.

instantiator commented 11 months ago

HI - thank you so much for raising this. I'll take a look and update if needs be.