It's an oldie but a goody, and I know there are lots of solutions to the mobile slide out menu, but I have my reasons for this simple approach.
- PCF custom component - requires pro code (security checks), and enablement by admins
- Standard custom component - The scoping of the component and passing of variables makes this solution painful for most.
There is one negative, you have to copy paste this to screens, but its simple enough and as long as you don't have loads of screens (and you really shouldn't), its not an issue.
The menu has 2 key components, a timer and container. The timer runs constantly (auto start, reset, repeat all set to true), and it does a validation check each cycle.
The onTimerEnd() code is:
which checks to see if it is set to open or close, and if it is in the correct state. if it is not it decrease a variable used for the menu width.
The container is our menu, and it contains a gallery for all of our screens. The screens need to be stored in a collection created on the app onStart() (the only bit of configuration you need to do).
Just ensure that the screen is the screen object, not text.
We then add a standard labels in the gallery that use the collections item name and onSelect() it navigates to the collection item screen.
The final touches are the label underline uses below expression to show which screen you are on:
And we have a hamburger icon to open/close the menu with below onSelect():
I also used a change so that the menu still shows so we set color() to:
On each screen set onHidden() to:
Then its a simple case of copying and pasting the container and the menu on to each page.