Tyrrrz / LightBulb

Reduces eye strain by adjusting gamma based on the current time
MIT License
2.22k stars 140 forks source link

Launching LightBulb for the first time in dark mode causes brief light mode flash #300

Closed LilithSilver closed 2 weeks ago

LilithSilver commented 3 months ago

Version

v2.5

Platform

Windows 10

Steps to reproduce

  1. Set system theme to Dark
  2. Open LightBulb
  3. Note that the light mode briefly flashes on, before transitioning quickly back to dark mode.

Details

A fairly minor cosmetic issue, but I believe it was introduced in 03218e810537043a70328cac3a924199d29f2037. The reason is that MaterialTheme is not meant to be overridden from code with the CurrentTheme property -- MaterialThemeBase is for that purpose.

Using the following in App.axaml fixes the issue for me:

...
<Style>
    <Style.Resources>
        <ResourceDictionary>
            <!-- Fix bug with initialization of MaterialPaperBrush using MaterialThemeBase -->
            <SolidColorBrush x:Key="MaterialPaperBrush" Color="#FF0000"></SolidColorBrush>
        </ResourceDictionary>
    </Style.Resources>
</Style>
<materialStyles:MaterialThemeBase />
...

I assume it was changed to avoid the awkward bug fix, which is a bug with Avalonia.DialogHost (pretty sure). We could always tackle the bug on their end?

Checklist

Tyrrrz commented 3 months ago

A fairly minor cosmetic issue, but I believe it was introduced in 03218e8. The reason is that MaterialTheme is not meant to be overridden from code with the CurrentTheme property -- MaterialThemeBase is for that purpose.

I understand that, but I found that MaterialThemeBase works extremely poorly and there were too many issues I've experienced in the projects where I tried to use it. In general, the Material tooling seems to be very buggy when it comes to Avalonia.

After some consideration, I decided that using MaterialTheme was the least of all available evils.

The flash still seems to happen even when using MaterialThemeBase, it just goes from black (colors unset) to dark instead of light to dark. It's more noticeable if your configured theme is set to light instead of dark, in that case.

LilithSilver commented 3 months ago

The flash still seems to happen even when using MaterialThemeBase, it just goes from black (colors unset) to dark instead of light to dark. It's more noticeable if your configured theme is set to light instead of dark, in that case.

Interesting, I see that now -- This happens with my proposed fix, but not in my original PR code. Not sure where the bug is, then.

Tyrrrz commented 2 weeks ago

Going to close this as "won't fix" as this is pretty insignificant in the grand scheme of things, and I want to avoid dealing with the intricacies of Material.Avalonia as much as possible 😅