horologist icon indicating copy to clipboard operation
horologist copied to clipboard

StandardChip placeholder icon color not changing when disabled

Open luizgrp opened this issue 3 years ago • 3 comments

StandardChip placeholder icon should have an alpha applied in order to change the color when on disabled state.

Compare:

Screen Shot 2022-07-11 at 15 17 40

Our implementation relies on Chip from androidx.wear.compose.material which seems to implement this functionality. From the kdoc:

In order to correctly render when the Chip is not enabled the icon must set its alpha value to [LocalContentAlpha].

However, our implementation uses Coil's rememberAsyncImagePainter to display a placeholder, which receives a Painter type as placeholder, and might not work well with that alpha applied in Chip.

Expected outcome from this task

  • PrimaryChip preview for disabled state displays placeholder icon with correct alpha applied
  • SecondaryChip preview for disabled state displays placeholder icon with correct alpha applied
  • Other previews for PrimaryChip and SecondaryChip are not affected
  • PrimaryChip snapshot test for disabled state displays placeholder icon with correct alpha applied
  • SecondaryChip snapshot test for disabled state displays placeholder icon with correct alpha applied
  • Other snapshot tests for PrimaryChip and SecondaryChip are not affected

luizgrp avatar Jul 06 '22 08:07 luizgrp

@yschimke This might already be resolved please confirm I can see icon with correct alpha , please confirm

Screenshot 2022-07-10 at 7 00 30 PM

MohitMandalia avatar Jul 10 '22 13:07 MohitMandalia

@MohitMandalia thanks for checking this, it looks like the issue happens with the placeholder icon. I've updated the issue title and description.

The issue also happens when an image is used instead of icon, which I will raise a separate issue for it:

disabled enabled
Screenshot_20220711_150839 Screenshot_20220711_151339

luizgrp avatar Jul 11 '22 17:07 luizgrp

Okk cool.

MohitMandalia avatar Jul 12 '22 04:07 MohitMandalia

Hey, I was trying to look into this and I was wondering; is there a reason why you can not just apply a LocalContentAlpha.Current to the image if it is disabled? :smile: From the previews it seems correct, but I got thrown off by this

However, our implementation uses Coil's rememberAsyncImagePainter to display a placeholder, 
which receives a Painter type as placeholder, and might not work well with that alpha applied in Chip.

Does that mean that I would need to deprecate and alter the api to not get a painter as a placeholder? and then use something else than rememberAsyncImagePainter?

With the alpha applied to the images, it looks like this for the placeholder disabled preview

Screenshot 2022-08-29 at 16 49 12

oas004 avatar Aug 29 '22 18:08 oas004

@oas004 if you can see it fixed with this, please put up a PR. Thanks!

yschimke avatar Aug 30 '22 07:08 yschimke