unoplatform / uno

Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
https://platform.uno
Apache License 2.0
8.9k stars 720 forks source link

Element-level Theme #3302

Open MartinZikmund opened 4 years ago

MartinZikmund commented 4 years ago

What would you like to be added:

Support for:

In case of WASM, we should ideally also apply color-scheme based on the actual theme of each element

Also see the comments below for further requirements!

Why is this needed:

For full theming fidelity.

For which Platform:

Anything else we need to know?

MartinZikmund commented 3 years ago

When this is implemented, the related Uno-specific TODO in BackdropMaterial.cs needs to be removed (and replaced with the original WinUI implementation)

MartinZikmund commented 3 years ago

While initial support for ActualTheme and ActualThemeChanged is added in #6655, it will need further improvements when this is implemented. Specifically consider the following scenario:

  1. OS theme is set to light and App does not explicitly set RequestedTheme
  2. On MainPage.Loaded a Border is created. Its ActualTheme should match application theme
  3. We store the border instance in a field like _border, but do not add it to the visual tree.
  4. We set root element's RequestedTheme to Dark
  5. Now the _border should still have ActualTheme of Light!
  6. Only when the _border is added to the visual tree, its ActualTheme will switch to Dark and ActualThemeChanged is triggered.

However - the following scenario should work as well:

  1. OS theme is set to light and App does not explicitly set RequestedTheme
  2. On MainPage.Loaded a Border is created. Its ActualTheme should match application theme
  3. We store the border instance in a field like _border, but do not add it to the visual tree.
  4. We switch the OS theme to Dark
  5. No ActualThemeChanged event is triggered automatically.
  6. When ActualTheme is queried, ActualThemeChanged is triggered, and the new theme is Dark

ActualThemeChanged event is triggered on theme change automatically only for elements which are part of the visual tree, others trigger it only when explicitly queried.

MartinZikmund commented 1 year ago

The changes in https://github.com/unoplatform/uno/pull/11983 have introduced DefaultTextForegroundThemeBrush support, which also needs to adhere to the element-level theme!

MartinZikmund commented 9 months ago

When supported, native date and time pickers should follow the picker's actual theme instead of the application one See PRs for

mcNets commented 3 months ago

@MartinZikmund you should consider Desktop apps too, it isn't in the platforms list.