Arun Joseph
01/24/2022, 7:39 PMif (enabled) {
Icon(
painter = painterResource(id = iconId),
contentDescription = null,
modifier = Modifier.size(32.dp),
tint = iconColor
)
} else {
Icon(
painter = painterResource(id = iconId),
contentDescription = null,
modifier = Modifier.size(32.dp),
)
}
I am trying something along these lines
Icon(
painter = painterResource(id = iconId),
contentDescription = null,
modifier = Modifier.size(32.dp),
tint = if (enabled) iconColor else ...
)
mkrussel
01/24/2022, 7:44 PMIcon
for tint for the else part.
LocalContentColor.current.copy(alpha = LocalContentAlpha.current)
Arun Joseph
01/24/2022, 7:46 PMif (enabled) myvalue else [default value whatever it is]
Arun Joseph
01/24/2022, 8:26 PMJan Bína
01/24/2022, 8:34 PMBut my code has to change if that default value changes in future.That doesn't make much sense. Changing the default value would be breaking change so I wouldn't expect that happening. And if it will change, having it overriden is actually better for you, because your ui stays the same which is probably intended... Anyway, if you really want it that way, your best option now is to create your own Icon composable with nullable tintColor which will call the default Icon with or without tintColor...
Arun Joseph
01/24/2022, 8:40 PMThat doesn't make much sense. Changing the default value would be breaking change so I wouldn't expect that happening. And if it will change, having it overriden is actually better for you, because your ui stays the same which is probably intended...This is a good point. Probably i was more thinking why to find the default color from library and put it in my code.
Arun Joseph
01/24/2022, 8:43 PMelse Color.Unspecified,
but that looks like taking a different path than
LocalContentColor.current.copy(alpha = LocalContentAlpha.current)