uno icon indicating copy to clipboard operation
uno copied to clipboard

Support system accent color retrieval with UIColorType.Accent

Open MartinZikmund opened this issue 4 years ago β€’ 6 comments

What would you like to be added:

UISettings class allows retrieval of UIColorType.Accent and its darker and lighter versions. This can be supported on Android where system accent color can be set.

Why is this needed:

UWP parity.

Resources

  • https://xamlbrewer.wordpress.com/2017/02/22/using-a-dynamic-system-accent-color-in-uwp/

For which Platform:

  • [ ] iOS
  • [x] Android
  • [ ] WebAssembly
  • [ ] WebAssembly renderers for Xamarin.Forms
  • [ ] macOS
  • [ ] Skia
    • [ ] WPF
    • [ ] GTK (Linux)
    • [ ] Tizen
  • [ ] Windows
  • [ ] Build tasks
  • [ ] Solution Templates

MartinZikmund avatar Nov 02 '20 17:11 MartinZikmund

Gotchas:

  • The accent color can potentially be anything (its "rules" are not clearly defined). We need to ensure that we don't use it as the "default accent" color, in case it would break accessibility (or adjust it by shifting the color to a safe range)
  • It will require adding some color helpers for RGB -> HSL conversion, so the color brightness can be changed properly to scale to darker/lighter

MartinZikmund avatar Nov 02 '20 17:11 MartinZikmund

Note that (according to UWP docs at least, I haven't tested) the base accent color can also be overridden by app code:

<Application.Resources>
    <ResourceDictionary>
        <Color x:Key="SystemAccentColor">#107C10</Color>
    </ResourceDictionary>
</Application.Resources>

davidjohnoliver avatar Nov 02 '20 17:11 davidjohnoliver

@davidjohnoliver we have that tracked in #3555 , that would be even more useful to support πŸ‘ (I think most apps override accent color anyway). However, even if overwritten in resources, UISettings should still return the "system" color.

MartinZikmund avatar Nov 02 '20 17:11 MartinZikmund

Browsers also support this feature now: https://github.com/w3c/csswg-drafts/issues/5187#issuecomment-800651916

jeromelaban avatar Oct 21 '21 13:10 jeromelaban

Now supported in major browsers: https://twitter.com/una/status/1506383666548822020

Twitter
β€œ`accent-color` is now supported in all modern browsers πŸŽ‰πŸŽ¨

One line of code enables you to style previously-hard-to-access form controls like checkboxes and radio buttons

body { accent-color: hotpink; }

Works really nicely with the color-scheme property too! https://t.co/YRFQYyKQ2G”

jeromelaban avatar Apr 09 '22 13:04 jeromelaban

@MartinZikmund: Uno currently only uses the default "windows" blue, and is ignoring the windows "accent-color", see #16608 Can this be fixed?

kucint avatar May 13 '24 06:05 kucint