https://kotlinlang.org logo
#compose
Title
# compose
s

Se7eN

09/17/2020, 11:58 AM
Is there a way to specify multiple Provide composables to save indentation? Something like:
Copy code
Provide(textStyle = TextSyle(...), emphasis = EmphasisAmbient.current.medium) {
    ...
}
y

Yann Badoual

09/17/2020, 12:09 PM
Provides
takes a vararg, so you could do it, but some "helper provide" functions like
ProvidesEmphasis
are doing additional stuff. So you would need to copy/paste some code, which might be changed in a future release
s

Se7eN

09/17/2020, 12:19 PM
Alright
`Providers`* , right?
y

Yann Badoual

09/17/2020, 12:21 PM
Yes sorry
But I do agree that having to nest 2 block very often for textStyle and emphasis is cumbersome. Easily fixed with an extension for textStyle+emphasis though
s

Se7eN

09/17/2020, 12:47 PM
Yeah it's a good thing to add to the library
l

Louis Pullen-Freilich [G]

09/17/2020, 12:49 PM
In the future these custom
Provide
functions will hopefully go away and you can just use
Providers
like you would for any other Ambient - but currently we need the
Provide
functions as they do more than just setting a value.
s

Se7eN

09/17/2020, 12:55 PM
That would be great
1