How to use `@Preview` when i need context object?
# compose
p
How to use
@Preview
when i need context object?
l
Do you mean you accept
context
as a parameter in your function?
p
@Preview
doesn't accept parameters, so it must be used with default values; i need context object to load resources as default values
To;Dr; you can create a wrapper function which provides everything to your '@composable' function and annotate that function with '@preview'
p
I already do it, but
@Preview
works only outside Activity (or Fragment) , and outside Activity i haven't context object
l
Wrong, you have access to context inside
@Composable
functions
Just retrieve it
val context = +ambient(ContextAmbient)
👍 1
p
that's what i missed. Thank you
l
👍🏼