maui icon indicating copy to clipboard operation
maui copied to clipboard

ImageButton does not render Image source for Current Theme Colors

Open pierre01 opened this issue 2 years ago • 4 comments

Description

ImageButtons always render the image with the default color (Black by default) Regardless of the Theme, but Tabs and Flyout header icons are adapting to the theme

Expected behavior: The .SVG image to .Png adapter should create icons of colors adapted to the current theme like tab and flyout header buttons image

Steps to Reproduce

Create a new maui application Add some image buttons Switch between themes Dark/Light the Image does not adapt to the theme

Version with bug

6.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android, Windows

Affected platform versions

Android 11 API 30 - Windows 11 Pro 22000.348

Did you find any workaround?

Create separate images for Dark and Light Themes

Relevant log output

No response

pierre01 avatar May 25 '22 20:05 pierre01

repro with vs main build(32525.350.main)

VincentBu avatar May 26 '22 06:05 VincentBu

I believe your solution should be the only way (Create separate images for Dark and Light Theme). We can only determine the image source of the ImageButton, the image is created at the building time and convert .svg to .png. You must create separate image sources to distinguish. Just my guess. But if anybody can provide the way to generate different color .png from the same .svg source will help. For now, I have to rename the same .svg into different names, like wine_light, wine_dark, which is not so good.

Kumima avatar May 27 '22 03:05 Kumima

@Kumima I understand, but since they do the job for other .svg images automatically, like the Tab icons.

Rendered automatically in Light Theme: image

and Dark Theme: image

They should be able to do it for the button icons too... or at least have a way to not duplicate the full image and just change the fill property.

pierre01 avatar May 27 '22 03:05 pierre01

I wonder if the OS does special things for tabs, and not for buttons - so we just get lucky with those.

mattleibow avatar Nov 10 '22 20:11 mattleibow

The image resizing system <MauiImage> does not generated themed images. The magic just happens to work on some controls on some platforms.

For true colors, new images will have to be generated. You can also use the TintColor attribute on <MauiImage> to do this as well:

<MauiImage Include="black_image.svg" TintColor="Red" />

This will generate the PNG, but with red in the places that are not transparent.

mattleibow avatar May 12 '23 15:05 mattleibow

The Tint Works Great with the MauiToolkit Thank you!!

pierre01 avatar May 14 '23 11:05 pierre01