New functionality and features were added to list in version 4.84.0 of the JourneyApps Runtime. Please refer to the latest docs here.
Version compatibility
list was introduced in version 4.29.0 of the JourneyApps Container.
This component should be used whenever you have a list of items that need to be used to navigate the user to another page, whether it’s a menu on the main view, a list of employees that need to get inspected and managed, or a list of messages or notifications that need to be viewed or read. Since it’s so customizable, you can adapt this component to look suitable for whatever you need to use it for.
A list-item can be defined as either static (for basic usage) or dynamically (will repeat itself for each item in a query). A simple static list will be defined as:
Doing so allows for the creation of complex menu-like structures that contain the flow of navigation.
list-item syntax
list-item tags can be represented as either shorthand (perfect for quick and common use cases) or longhand (for more complicated use cases). In shorthand mode, you can simply add attributes such as content="test" on a list-item while in longhand mode you can nest a <content>test</content> tag inside the list-item.
<!-- The presence of `query` makes the list dynamic --><!-- The presence of `bind` makes the list selectable --><list-itemquery="my_query"bind="my_var"> <header>Header</header><!-- or --> <header>{formatString}</header> <content>Content</content><!-- or --> <content>{formatString}</content> <footer>Content</footer><!-- or --> <footer>{formatString} </footer> <asseticon="my-icon-name" /><!-- or --> <assetsrc="{formatString}" /><!-- or --> <assetsrc="{dbObject.photo}" /> <!-- Supported from v4.31 of the JourneyApps Container --> <accentcolor="positive"label="Label" /><!-- or --> <accentcolor="$:getColor()"label="{formatString}" /><!-- or --> <accentcolor="{formatString}"label="Label" /><!-- The presence of `action` makes the list clickable --><!-- In dynamic list, you can pass the selected item via $selection --> <actionicon="my-icon-name"on-press="clickedFunction" /><!-- or --> <actionicon="my-icon-name"on-press="$:clickedFunction()" /><!-- or --> <actionicon="my-icon-name"on-press="doSomething($selection)" /> <pillslist="$:getList()"><!-- or --> <pillcolor="positive"label="Label"show-if="$:condition()"hide-if="$:condition()"/> <pillcolor="$:getColor()"label="{formatString}"show-if="$:condition()"hide-if="$:condition()"/> <pillcolor="{formatString}"label="{formatString}"/> </pills></list-item>
Lists support the <action> tag, making it clickable.
In dynamic lists, the current item is passed through to the `on-click` as `$selection`, e.g. `on-click="doSomething($selection)"`
The <action> tag has the following configuration:
pills
<pills> appear next to the header of an item. They can be used to convey status-like information about the item in a dynamic and colorful way. Pills can either be declared in the view XML (Static pills) or in the view JS (Dynamic pills)
Tip: Use a list instead of a menu with a lot of button elements inside of it. list is a lot more compact and more familiar to the user than a long list of buttons.
Without using short-hand syntax, declaring the above menu looks like this:
<list> <list-item> <header> Home </header> <asseticon="ion-home" /> <actionicon="ion-chevron-right"on-press="$:goToHome()" /> </list-item> <list-item> <header> Back </header> <asseticon="ion-home" /> <actionicon="ion-ios-arrow-back"on-press="$:goBack()" /> </list-item></list>
Dynamic lists
<list> <list-itemquery="my_query"> <header> {name} </header> <content> Click here for more info on {name} </content> <accentcolor="{color}" /> <actionicon="ion-chevron-right"on-press="$:show($selection)" /> </list-item></list>
Static & Dynamic lists
<list> <list-item> <header> New User </header> <content> Click here to create a new user </content> <accentcolor="positive" /> <actionicon="ion-chevron-right"on-press="createNewUser" /> </list-item> <list-itemquery="my_users"> <header> {name} </header> <content> Click here for more info on {name} </content> <accentcolor="info" /> <actionicon="ion-more"on-press="show($selection)" /> </list-item></list>
label: Format String (optional)
color: String (optional)
Valid values for color:
- Any of your app's named colors (primary, secondary, positive, negative, etc)
- A hex value, e.g. #FFF
- A view variable my_var
- A function resolving to any of the above values, e.g. $:getMyColor()
Defaults to: info
<accent label="{formatString}color="string" />
No
action
See below
Yes
(on-press and on-press-icon)
pills
See below
No
on-press
required
The JavaScript/TypeScript function call to be performed when the user clicks on the list item.
icon
optional
The icon to display on the right-hand side. Valid options include any Ionicon. Defaults to no icon.
validate
optional
Whether to run field validation before calling the associated on-press (see above). Can be either true, false, or the result of a function, e.g. ($:shouldBeValidated()).
label
Required
The text to display in the pill. Can be a format string.
color
Optional
The color of the pill.
Valid values for color:
Any of your app's named colors (primary, secondary, positive, negative, etc)
A hex value, e.g. #FFF
A view variable my_var
A function resolving to any of the above values, e.g. $:getMyColor()
Defaults to: primary
show-if
Optional
If the pill should display or not. Valid values include true, false or the result of a function, e.g. $:shouldShowPill()
Defaults to: true