Open full view…

Save Dark Mode State

Thu, 10 Aug 2017 19:28:11 GMT

I am working on implementing a switch that allows the user to chose a Dark Mode or a Light Mode. I was wondering how I can make this persist across all launches in the easiest way possible. I am extremely low level when it comes to this but can generally get a feel for things decently fast. Any and all suggestions are of great help. Thanks in advance!

Sat, 12 Aug 2017 19:19:03 GMT

You can achieve this with css and or jquery/javascript whichever client-side language your using. Use jquery toggleClass or addClass/removeClass to dynamically change the theme since they are classes. The persistence can easily be achieved using localStorage built in to F7. Make sure the theme switcher that you are creating is on a standard form and add the class required to ensure all controls on the form are saved to local storage. The class looks like this: class="store-data" - add it to the forms opening tag. Now the 'state' of the switch will be saved automatically and can be retrieved during app load its a key=value pair and you can save any form control which has a 'name' attribute defined. Try it and see ...