From 6aae2eb1dfa6cb838b08ae765002151d2bd24ff0 Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Sun, 4 Oct 2020 12:07:10 +1100 Subject: [PATCH] Support setting app state at startup --- v2/internal/ffenestri/ffenestri_darwin.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/v2/internal/ffenestri/ffenestri_darwin.c b/v2/internal/ffenestri/ffenestri_darwin.c index 5f260145d..95c24d21e 100644 --- a/v2/internal/ffenestri/ffenestri_darwin.c +++ b/v2/internal/ffenestri/ffenestri_darwin.c @@ -838,6 +838,14 @@ void createMainWindow(struct Application *app) { app->mainWindow = mainWindow; } +const char* getInitialState(struct Application *app) { + if( isDarkMode(app) ) { + return "window.wails.System.IsDarkMode.set(true);"; + } else { + return "window.wails.System.IsDarkMode.set(false);"; + } +} + void Run(struct Application *app, int argc, char **argv) { processDecorations(app); @@ -944,6 +952,11 @@ void Run(struct Application *app, int argc, char **argv) { const char *internalCode = concat(temp, (const char*)&runtime); free((void*)temp); + // Add code that sets up the initial state, EG: State Stores. + temp = concat(internalCode, getInitialState(app)); + free((void*)internalCode); + internalCode = temp; + // Loop over assets and build up one giant Mother Of All Evals int index = 1; while(1) {