Are there any plans to make something similar to X...
# compose
s
Are there any plans to make something similar to XML's
@tools:sample
with tools-provided sample data that are only available in
@Preview
Composables and that aren't shipped to the actual builds? 😍 I'd especially like this with regards to image resources. Strings I can hard code in my previews. 🙂
l
i’m not sure what we’ll end up with, but we have thrown around a few ideas similar to this but haven’t gotten around to it yet
z
Seems like you can access resources from
@Preview
functions, so someone could build a small library with some fake data like this that would be easy to plug in.
s
Yeah, wouldn't expect this to be top priority, was primarily wondering if it was on the roadmap. 🙂
The problem with putting it in a library or something similar to that, is that it would likely also get shipped with your app (or, at least be available outside of the tooling), which is not ideal.
t
In theory you do not need this feature because you could just provide fake data inside of the @Preview method which could call you view Composable functions with dummy data.
s
Indeed, but how would you go about providing fake vectors or images, for instance?
Without bundling them in your app's bundled resources.
t
I think this is a problem of kotlin/java. Currently i only know one way to exclude ressources from release builds and that is defining them only in the debug build folder or in a flavor. So than you need to seperate your resources into classes which are only defined in the debug build. Not really nice. But as long as we do not have #include syntax or similar from C / Swift it is the only way i think.
s
That works. But I'm thinking since the preview functionality is included with the tooling, then it kinda makes sense to have the preview sample data be available in the same set. As mentioned above, they have thought a little about it, and there's definitely no rush. simple smile