item

Overview

An item in the general-section is similar to that in a section. These provide users a way to perform an action or navigate to a view. See more information here.

In addition to customizable items, the general-section contains a number of non-customizable items, namely links to the "Messages", "Set Language" and "About" screens.

Basic Example

Standard Attributes

label

See section > item > label

on-press

pageon-press

validate

Optional

Type: boolean

Default: false

Validation will check all required fields on the view and confirm that they contain values before performing the on-press action.

main.view.xml
<item label="User details" on-press="$:userDetails()" validate="true" />

Advanced Attributes

from-js

See section > item > from-js

id

See section > item > id

icon

See section > item > icon

indicator

See navigation > indicator

items

See section > item > items

show-if and hide-if

pageshow-ifpagehide-if

type

Optional

Type: messages

Default: The default messages page will be setup and included in the general-section.

Overrides the default Messages item in the general-section. It is important to also specify an indicator for this item.

main.view.xml
<general-section>
    <item type="messages"
          label="Custom Messages"
          on-press="$:navigate.link('custom_messages')"
          indicator="$:messageIndicator()" icon="far fa-envelope"  />
</general-section>
main.js
function messageIndicator() {
    var messages = DB.push_notification.where(
        "user = ? and status = ?",
        user,
        null
    );
    var count = messages.count();
    return count == 0 ? null : { value: count, color: "negative" };
}

Last updated