Launching a Widget on Tab Click
Last updated
Last updated
Discover how to launch a widget when a user clicks a tab in your mobile app.
First, ensure the widget is already created in the system. You can either build a new one or choose an existing one. We'll build a new widget using the (e.g., Search Widget Template). This template lets you configure multiple tabs, each connected to a data source to display specific information. The data source can be a database or a Lucy Action. After selecting a data source, you can even customise the information shown under each tab by mapping UI elements to the selected data source values.
Before following this tutorial, ensure you are familiar with creating folders, databases, and Lucy Actions.
In this example, we will use an existing database as the data source.
To create a widget
On the app homepage, go to the My Work tab.
Search and click the required folder and open it.
Go to the User Interfaces tab.
Click the + button.
Choose the Start from Scratch option.
Pick the desired type of Widget Template, e.g., Search Widget.
Click Edit this Template to open it on the widget designer page.
Give a name for the widget.
Go to the General tab on the right.
In the Name box, type in a suitable name.
Customise the properties of the widget.
Click the header section of the widget. Its properties panel will open.
Pick a background colour for the header section or you can select a background image.
Select a background image.
In the background image field, click the Search icon.
Select a background image from the gallery.
Upload your image button: You can also upload your own image by clicking this button.
The selected background will be applied to the header.
Change the Background Position and the Background Size if necessary.
Add and Configure Tabs in the widget.
Under Search Tabs section, in the Tab 1 box, type a appropriate name for the first tab.
Click the Add Column button to add more tabs.
If you do not wish to add tabs, deselect the Show Tabs option under Display Options.
Bind a data source to each tab to display information:
In the widget, navigate to the required tab and click the Bind a Source button.
Choose either an existing Lucy Action or a database. For example, let's bind a database.
Go to the Databases tab.
Search and select the required database.
Click Select this Source.
Format the data as required, e.g., filtering data
Click Looks Good. Now the selected database will be displayed under Source field and will be linked to the respective tab.
Map the database properties/values to required UI elements.
Add a database value to the Image Field.
In the properties panel, go to Image section and select the Image Type as Image.
In the Image Field, a JSON expression will be displayed. Remove the code and pick the required value from the Available Values pop up window. The Available Values pop up window lists all the values retrieved from the selected database.
The selected value will be applied and displayed in the Image Field.
Add a database value to the Title Field.
In the properties panel, go to the Title section.
In the Title Field, a JSON expression will be displayed. Remove the code and pick the required value from the Available Values pop up window. The Available Values pop up window lists all the values retrieved from the selected database.
The selected value will be applied and displayed in the Title Field.
Add a database value to the Sub Title Field.
In the properties panel, go to the Sub Title section.
In the Sub Title Field, a JSON expression will be displayed. Remove the code and pick the required value from the Available Values pop up window. The Available Values pop up window lists all the values retrieved from the selected database.
The selected value will be applied and displayed in the Sub Title Field.
Configure the top labels and bottom labels if necessary.
In the properties panel, go to the Top Label section.
Click Add New Item.
In the Text field, Remove the 'My label' text.
Select the suitable database value from the Available Values pop up window or you can just enter a label.
Click the Icon field and pick an appropriate icon for the label.
Pick a icon colour.
Select how you want to display the label (Normal or Pill).
Add more labels as necessary.
In the properties panel, go to the Bottom Label section. Repeat steps 4-1 to 4-8 to add bottom labels.
Customise the UI elements as necessary, such as changing the title colour, size, etc.
Click Save Widget to save the changes. Now your widget will be saved under the User Interfaces tab within the folder.
After building our widget, let's link it to a tab in the mobile app.
Click here to learn more about adding and configuring a tab in your mobile app.
Choosing a Page TypeOn the Lucy web app homepage, go to the Mobile App tab. Mobile app designer page displays.
Click the Bottom Tab Bar Navigation to open Properties panel.
Under the Configure Tabs section, locate the tab you want to link the widget.
Select the Type as Widget.
Click the Select a Widget button on the mobile screen.
Pick the required widget from the list (widget names will appear in the list).
Click Save to apply the changes. The selected widget will now display in your mobile app under the required tab.