Demo 3 - Canvas app components
Objective: In this demo, you will show how to create a component in a component library.
Task 3.1 - Create component library
-
In the demo solution, create a new component library.
- Rename Component1 as
MenuComponent
. - Set the component’s Width to 150 and Height to 250.
- In the right-hand pane, select New custom property.
- Set Display Name to Items
- Set Property Name to Items
- Set Description to Items
- Select Input for Property type
- Select Tables for Data type
- Select Create and then in the Items property enter
Table({Item:"Home", Screen: "Screen1"},{Item:"About", Screen: "Screen2"} )
. - Add a blank vertical gallery to the component.
- Rename gallery to
MenuList
- Enter
MenuComponent.Items
for the gallery’s Items property - Select Title for Layout.
- Set TemplateSize to
50
. - Select the MenuComponent, in the right-hand pane, select New custom property.
- Set Display Name to Selected
- Set Property Name to Selected
- Set Description to Selected
- Select Output for Property type
- Select Text for Data type
- Select Create and then in the Selected property enter
MenuList.Selected.Screen
. - Select Save and name the library
Menu Library
.
Task 3.2 - Use component library
-
In the demo solution, edit the Pet Training canvas app.
- Add a blank Screen.
- Rename to
HomeScreen
. - Move the HomeScreen up twice.
- Select the Components tab, select Get more components, and import the MenuComponent.
- Expand Library components and add the MenuComponent to the HomeScreen.
- Rename component to
ScreenMenu
. - In the Items property enter
Table({Item:"Home", Screen: "HomeScreen"},{Item:"Pets", Screen: "MainScreen"}, {Item:"Details", Screen: "DetailScreen"} )
. - Add a button to the HomeScreen.
- Set Text to “Go”
- Set OnSelect to
If(ScreenMenu.Selected = "HomeScreen", Navigate(HomeScreen), If(ScreenMenu.Selected = "MainScreen", Navigate(MainScreen), Navigate(DetailScreen)))