Open gskinner opened 3 years ago
For the code injection, it could also be interesting to allow for some kind of child / children injection.
For example something like this could inject the generated output of the whole group:
Container(child: <THIS>, ...)
Whereas, this could inject an array of the children:
Column(children: <CHILDREN>, ...)
It might be worth ensuring we consider some kind of parameter system for adjusting the output. Maybe even leverage JSON so it's easy to parse?
Column(children: <CHILDREN{"layout":"none"}>, ...)
For the custom widget code I am just creating component in Adobe XD and name it for example "MySuperTextField" - and just do not export it. Instead I am creating widget in my project with the same name so it is placed right there.
@JakubNeukirch - ya, that's a smart way to work around it now. I'm hoping to do something a bit more explicit with the proposal above.
A fourth option for adding a builder parameter would also really open up options for externally modifying the behavior of an exported widget:
After an extensive battle with XD UI, I have the initial implementation of these features working locally, and am hoping to commit them after a bit more testing. Unfortunately, it doesn't look like XD UI supports monospaced fonts in textareas.
I just pushed c6b6ba4e1f1612de9deedc31dfe3e334e1e1be79 which is a monster commit that adds this feature and a bunch of additional updates / refactoring that I tackled as part of it. It seems to be quite functional, and people are welcome to test, but there are still some edge cases that need consideration - specifically how to deal with decorators (ex. onTap, blur, etc), and whether there's a reasonable way to check custom code for syntax errors.
Short description: All groups in XD now present an setting to set their export mode to one of four options:
buildMyGroup(context)
. This reduces the depth of nesting, which makes the generated code more readable, and could potentially be overridden in subclasses.I just pushed initial support for tags in custom code to let you inject the target item's exported code <THIS>
or a list of its children <CHILDREN>
. This includes support for enabling group decorators: <THIS{"decorators":true}>
and adjusting layout for children: <CHILDREN{"layout":"none|size"}>
.
This is very much alpha functionality, and is subject to removal or significant change.
This proposal aims to address two specific issues:
To address both these cases, we could add an option for Groups to allow the user to specify alternative ways to generate its code.
build
), and check for duplicates on export. This could also potentially allow for a devs to subclass the widget and override specific build methods.Here's a rough mockup of what this could look like:
While there's an argument for supporting this functionality on other element types (ex. replacing the code for a text field with an input), I think keeping it limited will simplify the UI and implementation, while remaining super easy to work around (ex. simply make the text field a group).
Thoughts/feedback are very welcome.