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

Luca Nicoletti

10/26/2019, 11:46 AM
Would it be possible to have
@Preview
working on functions with parameters all with default values? That would be great
Will do! Thanks
at
visitPreviewAnnotatedFunction
:
if (function.valueParameters.isNotEmpty()) {
line 101
some components could depend on ambients provided by the top level compoments, for example theming; so we need to wrap our component into MaterialTheme
l

Luca Nicoletti

10/26/2019, 12:37 PM
Yeah my idea was more having it working on something like this:
If I understood correctly, @romainguy was saying: just wrap the function with parameter in another one without parameter which provides dummy data to your parameterised one and annotate the parameter-less one with
@Preview
a

Andrey Kulikov

10/26/2019, 12:41 PM
yeah, this sounds reasonable. my idea was that there would be a lot of ui components which requires some additional configuration and probably it worth writing a separate preview fun for them where you provide everything needed, instead of trying to add @preview to your component directly
l

Luca Nicoletti

10/26/2019, 12:41 PM
That would also work with
default
values as you could just go with
@Preview @Composable noParams() { params() }
And that would work
Sure, that makes a lot of sense
But as you’re doing on param-less function, you can get default value for those things
and accept default params from function with them
a

Andrey Kulikov

10/26/2019, 12:42 PM
agree
l

Luca Nicoletti

10/26/2019, 12:42 PM
I’ll give a try on this task 😛
Will update the thread
7 Views