Travis Griggs
04/03/2024, 5:52 PMMaterialTheme.typography.bodyMedium.copy(color = (backgroundColor.luminance() > 0.5).opt(Color._TextDark, Color.White))
I'd like to be able to select the .copy(...)
half and "extract method" so I ended up with a new function:
fun TextStyle.coloredFor(backgroundColor:Color) = this.copy(color = (backgroundColor.luminance() > 0.5).opt(Color._TextDark, Color.White))
and the original rewritten as:
MaterialTheme.typography.bodyMedium.coloredFor(backgroundColor)
I have tried selecting different parts and tried different refactoring menu options, but none some to have the ability to infer the receiver as the target of the extracted behavior.bod
04/03/2024, 8:09 PM