🧱 Dynamic Components Extensionthat supports every component in your AI2 distribution, instead of having pre-defined components.
I thought about making a full method to create all dynamic components without creating different blocks for every component because it would be useless. So I was trying to find a proper solution for a long time. And here it is!
The minimum required API version for this extension is 1 .
It basically uses Java’s Reflection feature, so this allows you to create ANY component you want dynamically which added to your AI2 distribution. Not only a
Button, but you can also even create a
DatePicker dynamically. Just type the component’s name which you want to create, that’s it!
What is the reflection and how does it work?
Reflection (in programming) allows you to modify the program during runtime, for example, you can create a new Class, Method, etc. and search them by its names!
Basically, it appends
componentName parameter to the
com.google.appinventor.components.runtime. text and creates an instance of it. When you type “Button”, it searches for Button class and creates an instance of it.
So with this method, it is now a fully implemented dynamic component extension.
I must say Java is a powerful language
How can I set the properties for the blocks?
You have two options and both does the same job:
How can I delete all components?
Use a for-each loop for that.
How can I make my own Schema template?
Thanks for being interested in making a JSON template for the extension. You can go to the Wiki section of Dynamic Component’s repository to learn how to create yours.
Creating Templates - DynamicComponents-AI2 Wiki
Is extension works asynchronously, or synchronously?
It works synchronously. I explained why it works synchronously in this post.
Now you can toggle between asynchronously or synchronously with the
App takes a lot of time to create components that uses Image components, how can I fix it?
Replace your existing set Image.Picture components with the Image Utilities component.
If you don’t use Kodular, you can use an extension to load images asynchronously.
How much time it takes to create components?
I created more than 10 000 components and calculated how many seconds will it take to finish creating. Here are the benchmark results.
What projects made with this extension in the community? Here is a list below. Just mention me, PM me, or link this topic in your topic to get your project showed listed here!
Here is the list of projects that use the Dynamic Components extension. Ordered chronologically.
Note that these projects belong to their original posters, I’m not affiliated with these projects in any way.
com.yusufcihan.DynamicComponents.aix (29.3 KB) (v2.1.0)
Looking for old releases and changelog? Check it from here.
You can report bugs, download old releases, contribute the code, and do more from the repository! The code is licensed with MIT license, as said in README.md and LICENSE files.
Donate on Patreon
Creating a donation page didn’t and won’t prevent me from making free and open source stuff, never. I will continue what I do as always, with donations or without them. However, if you like my content, you can support me on Patreon and access some benefits as the exchange of your donation. Thanks for being interested
You can post in topic for help, a question about this extension or PM me anything about you want to talk!
- Yusuf Cihan