How to Persist Last Visited Page and Theme (Dark/Light) in Crank Software GUI After Restart
Hi everyone,
I’m currently working on a GUI project in Crank Software and I’ve run into a couple of challenges I’d really appreciate some guidance on:
1. Restoring the Last Visited Page
In my application, I typically work with 5–6 pages. I’d like to implement a feature where the last visited page is remembered even after the app is closed and reopened — essentially, when the app restarts, it should land on the page the user last viewed.
- Is there a recommended approach in Crank to store and retrieve the last visited page?
- Should I use persistent storage to track the page ID?
- Are there any built-in mechanisms within Storyboard that support this pattern?
2. Saving and Restoring the Selected Theme (Dark/Light)
I’ve implemented both Dark and Light themes in the application. However, on restart, it always defaults to the Light theme. I’d like the app to restore the last selected theme on reboot.
- What’s the best way to store the user’s theme preference?
- Can I use persistent variables or a simple settings file for this.
0
Comments
Hi Sahil,
1 - Last Visited Page:
You can use the gre function gre.env to get the `active_screen`. This paired with either a gre.exit event (called when the app shuts down) will allow you to store the current screen in some config file. When the app initializes you can read this config entry and navigate to the associated screen.
Note; if your app gets shut down using a power button the gre.exit may not be called, in this case you probably want to tie it to a screenshow event.
2 - Selected Theme:
This can be done in a similar way to the last screen, whenever the theme gets changed you should update some config file which is then read and applied on app init.
Thanks,
Jake
Please sign in to leave a comment.