chanjungskim
03/24/2023, 2:25 AMMarcello Galhardo
03/25/2023, 4:57 PMfun Modifier.thenIf(
predicate: Boolean,
block: () -> Modifier,
) = then(if (predicate) block() else this)
And now you can rewrite that code as such:
Modifier
.thenIf(label != null) {
Modifier
.padding(8.dp)
.semantics(mergeDescendants = true) {
// no-op
}
}
.background(colors.backgroundColor(enabled).value, shape)
.defaultMinSize(
minWidth = 120.dp,
minHeight = 24.dp
)
That isn’t much better than the apply
+ if
you did - if you are willing to give more details, maybe we can find an alternative solution.chanjungskim
03/27/2023, 2:14 AMJan
04/12/2023, 9:42 PMchanjungskim
04/13/2023, 5:13 AMJan
04/13/2023, 8:47 AM