Skip to content

feat(splash): match the WASM loader's theme-aware colors and logo - #1667

Draft
MartinZikmund wants to merge 2 commits into
mainfrom
dev/mazi/ess-theme-aware-wasm
Draft

MartinZikmund wants to merge 2 commits into
mainfrom
dev/mazi/ess-theme-aware-wasm

Conversation

@MartinZikmund

Copy link
Copy Markdown
Member

What changed

  • ExtendedSplashScreen on WebAssembly now picks the splash background and logo from appmanifest.js with the same rules as the Uno.Wasm.Bootstrap HTML loader:
    • Background: if lightThemeBackgroundColor or darkThemeBackgroundColor is present, splashScreenColor is ignored. Light uses lightThemeBackgroundColor (default #F3F3F3), dark uses darkThemeBackgroundColor (default #202020). With neither key, splashScreenColor applies to both themes; missing or transparent falls back to the per-theme defaults.
    • Logo: splashScreenImageDark in dark theme when present, otherwise splashScreenImage. Absolute http(s) image URLs are used as is, as the bootstrapper does.
  • The naive manifest parsing (split on , and :) is replaced by a small dependency-free parser (WasmAppManifest.Parse) for the flat var UnoAppManifest = { ... } shape: single or double quotes, optional quoted keys, escapes, comments, trailing commas; non-string values are ignored, and malformed input yields whatever was read before the problem (no exception).
  • The pure logic (Parse, SelectSplash) lives in WasmAppManifest, free of UI types, so it can be tested without a browser.
  • Docs updated in doc/controls/ExtendedSplashScreen.md.

Behavior change worth knowing: a manifest without splashScreenColor used to give a white splash; it now gives the loader's per-theme default, which is what the HTML loader draws.

Why

Uno.Wasm.Bootstrap#1097 makes the HTML loader theme-aware. The toolkit draws a XAML copy of it so the hand-off is seamless, so it has to apply the same rules or the splash flips colour/logo in dark mode. unoplatform/uno.resizetizer#157 will generate these manifest keys.

How the browser theme is detected, and why

The theme must be the browser's prefers-color-scheme, not the app's RequestedTheme: the HTML loader runs before the app starts and can only see the browser preference, so following RequestedTheme would flip the hand-off whenever an app forces a theme.

I used the existing SystemThemeHelper.GetCurrentOsTheme() (reads UISettings Background). In Uno's SystemThemeHelper (Uno.WinRT), the browser implementation calls window.matchMedia("(prefers-color-scheme: dark)"), and UISettings.GetColorValue is derived from it, independent of the app's RequestedTheme or any root element theme. So no new JS interop is needed. Rejected alternatives: Application.RequestedTheme (reflects app overrides), [JSImport] of matchMedia (works, but duplicates what Uno already does and adds interop to the library).

Caveat: Uno.Helpers.Theming.SystemThemeHelper itself is internal to Uno, which is why the toolkit's own helper is used. This was verified by reading the Uno sources, not by running a WASM app.

Validation

  • Wrote the tests first (WasmAppManifestTests, 29 cases: per-theme keys win, only one per-theme key, only splashScreenColor, transparent/missing/empty, dark image fallback, quoting, escapes, commas and braces inside values, comments, trailing commas, non-string values, duplicates, truncated and garbage input); they failed to compile before the implementation existed.
  • Ran them in a scratch MSTest project that compiles WasmAppManifest.cs and the test file directly: 29 passed, 0 failed.
  • dotnet build src/Uno.Toolkit.UI/Uno.Toolkit.WinUI.csproj -f net10.0: succeeded, 0 warnings, 0 errors. dotnet format whitespace left no changes.
  • Not run: the full runtime test suite and a real WASM head in light and dark mode. The tests are in Uno.Toolkit.RuntimeTests, so CI will run them.

🤖 Generated with Claude Code

https://claude.ai/code/session_013terw2KRvw8e64cogQymUL

MartinZikmund and others added 2 commits October 8, 2026 10:38
ExtendedSplashScreen now applies the Uno.Wasm.Bootstrap loader rules when it
rebuilds the splash from appmanifest.js: lightThemeBackgroundColor and
darkThemeBackgroundColor (with #F3F3F3/#202020 defaults, ignoring
splashScreenColor when either is set) and splashScreenImageDark. The theme is
the browser's color scheme, read through UISettings, not the app's theme.

The manifest is now read by a small tolerant parser instead of splitting the
text on commas and colons.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013terw2KRvw8e64cogQymUL
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants