Hello, as an Android and JavaFX Developer, who’s used to developer user interfaces in XML, coding business apps on Corona can be a hard task. Especially to layout your components (e.g.: to make all align center and vertical).
I have developed a library called View, which tries to solve this issue by letting you code your user interface through XML. Let me show how it works:
-- in your main.lua local viewLoader = require("view") local view = viewLoader:setView("layout.xml") -- create all corona components declared in layout.xml and draw on screen
– Create a file with .xml extension in your project’s folder, example layout.xml:
\<LinearLayout id="layoutLinear" x="10" orientation="vertical" align="center" paddingX="10"\> \<Text id="txtUsername" x="10" y="10" text="Username" /\> \<TextField /\> \<Text id="txtPassword" x="10" y="50" text="Password" /\> \<TextField /\> \<Button label="Login" /\> \</LinearLayout\>
The result is shown on image attached to this post:
At the moment of this post, It’s not fully functional, but works with texts, buttons, textfields, textbox and spinner. You can align elements on left or center and also use vertical or horizontal orientation.
Code can be found at my Github: https://github.com/lsoaresesilva/corona_view
Hope, you enjoy!
PS1: Need to do unit test, but it driving me crazy, as Corona does dot offer support for mocks and such;
PS2: I would appreciate any help to improve the Library
PS3: I’m improving docs and github help, be pattient, please!