Is there a way to simulate Multiple Context receiv...
# compose
d
Is there a way to simulate Multiple Context receivers without this feature enabled? 🙂 I want to write a modifier working with align from ColumnScope...
Copy code
internal fun Modifier.bottomOverlayPadding(): Modifier {
  return Modifier
    .align(Alignment.End) // can't use, need ColumnScope
}
o
I would simply pass a
scope
as first param to your custom modifier and then use
with
in modifier body:
Copy code
fun Modifier.bottomOverlayPadding(scope: ColumnScope) = with(scope) {
    align(Alignment.End)
}
… or if you prefer some “hacky” way you may return a lambda with your needed
scope
:
Copy code
fun Modifier.bottomOverlayPadding(): ColumnScope.() -> Modifier = { align(Alignment.End) }
But usage will be a “little” strange with double parentheses 😅
Copy code
.bottomOverlayPadding()()
d
nice hacks! 😁 The first one I thought of, the second one is "nice" too)) thanks, will consider if I want to go either route...
👍 1