-
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamically setting light/dark themes at runtime #19
Comments
For anyone coming across this in the future, I managed to get most of what I was hoping for by overriding type App () as app =
inherit Application ()
let runner =
App.program
|> XamarinFormsProgram.run app
override this.OnResume () =
runner.Dispatch App.Msg.RefreshTheme |
@gaelian . I'm implementing a similar use case and what I end up doing was to :
|
I'm currently trying to figure out how to get light/dark themes working with my full Elmish style Fabulous app (multi-page, somewhat following the composition model of the FabulousContacts example app). I've managed to get the themes sorted out, mainly by the F#-coded styling approach, plus some native styling that I needed to do in the Android project (via values and values-night, etc). The F# style code is simple, an excerpt example:
These values are used within the various view functions to set colours on elements.
The themes are working, except that I can't apply them at runtime, e.g. if the theme changes automatically due to time of day or if the user manually changes the theme while the app is still running. The theme is only set when the app starts. I was hoping to use the
Application.Current.RequestedThemeChanged
event to dispatch a message (in conjunction with the approach discussed under Triggering Commands from External Events) as I assumed that I would need to somehow trigger an update of the pages in the app for the F#-coded styling approach to work and reapply the different colours to the view elements. But as @TimLariviere mentions here, theApplication.Current.RequestedThemeChanged
event does not seem to fire.If anyone could give any info or examples on how they have managed dynamically applying light/dark themes at runtime for Fabulous, that would be much appreciated.
The text was updated successfully, but these errors were encountered: