Hi all,
First of all, I want to say that any suggestion to improve the code will be highly appreciated, since I am kind of new (1-2 months) with Corona and lua.
I am trying to implement an accordion-widget. For those who are not familiar with the nomenclature, it is something like the following:
https://jqueryui.com/accordion/
Small background:
In order to implement the accordion, I created a label (a rectangle background with text) that expands a TableView for each section (jquery example nomenclature) that I want to show on the screen. All the sections are wrapped inside a ScrollView widget.
So far, I had the following issues:
- The TableView rows are mispositioned <- my main issue ;
- The TableView would not show up when I clicked on a label;
- I cannot access to the children of a ScrollView
1.
This issue occurs when I add rows to the TableViews while they are hidden (tableview.height = 0). Then, when I expand the tableview after clicking on the label, instead of showing the rows at the top of the tableview, it shows the first row at the bottom and I can only see the other rows after scrolling the tableview. This is bad because I need to insert the rows after getting the information asynchronously from a server. I would like to avoid the solution of creating a “splash screen” while the information is not yet inserted on the tableview, since everything works fine if the information is inserted on the tableviews while they are not hidden.
The source code is attached with comments on the functions and variables so you can have a better idea of what I have and so you can make suggestions to improve it. After all, I think that this is the first “public” implementation of the accordion to corona.
2.
I figured out that the first issue occured because I had intialized the TableView height to 0. When I would try to transition its height to 96 (just a random constant), it would not do a thing. So, as a workaround, I initialized the TableView to that specific value and then after I set it to 0. This sounds me silly, so if you have any suggestion, please go ahead.
3.
At some point I would like to access the sections by getting the scrollview children, but I cannot get that information. I tried scrollview[child_index], but it seems that that does not work.
Thanks in advance for all the suggestions,
Rodrigo