Skip to main content
Version: 4.60

gallery

Creates a gallery layer. Gallerys can retrieve children dynamically from a Database table or be configured statically using galleryItems.

note

Actions are explicitly forbidden on the gallery layer. Use the galleries children to execute actions.

Field Configurations

KeyTypeDescriptionDefault Value
"galleryItems"ArrayThe gallery items can either be defined by a JSON string literal or an array of objects.null
"galleryPageOffset"UnitSizeOffset of the elements.0
"galleryPageWidth"UnitSizeWidth of each gallery item."100%"
"insets"ObjectUse the provided values to space the gallery content.null
"layout"StringThe layout to be applied.null
"layoutField"StringQuery result field to use as layout.null
"path"StringSpecific path of gallery items.null
"query"StringQuery in the related DB table.null
"queryParams"ArrayThe params to append to the query.null
"scrollCircular"BooleanDetermines, if the gallery can scroll infinite.true
"scrollEvent"StringEvent fired when switching items (trackingKey is the tracking key of the elements or the index, if not available).null
"table"StringName of the DB-Table.null
"template"StringThe client template to be applied.null
"templateField"StringQuery result field to use as template.null
"timerInterval"NumberAutomatically scrolls gallery. Disable automatic scrolling by omitting this value.0

Inherited

From Base Layer

Base Layer

Field Configurations

KeyTypeDescriptionDefault Value
"_value"Value[PREVIEW] Dynamic value of the layer.null
"accessibilityAppendState"StringDefines this layer appends its state to the accessibility text.null
"accessibilityText"StringText for accessibility navigation. Can be translated.null
"actions"ActionListList of actions, which will be executed when the layer is tapped.null
"borderColor"ColorThe color of the border in hex color value.null
"borderRadius"UnitSizeThe radius applies to all corners; with a borderWidth of 0 the border is not drawn and radius is set anyway.0
"borderWidth"UnitSizeThe width of the border.0
"bottomLeftRadius"UnitSizeRadius for the bottom left corner.0
"bottomRightRadius"UnitSizeRadius for the bottom right corner.0
"classes"ArrayList of classes for layer styles.null
"conditions"ConditionsList of conditions to alter the layer state.null
"constraints"ConstraintsA list of constraints defining the position of the layer in a layout.null
"consumesKeyboard"BooleanThis layer will be used to shrink, if a keyboard is shown.null
"dataKey"StringName for assigning data to this layer.null
"focusColor"ColorThe highlight color of this layer when it is focused. Mainly used on TV. If no color is provided, the pressedColor will be used.null
"hidden"BooleanIndicates whether the layer is hidden. Default: false.false
"isAccessibilityElement"StringDefines if this layer is important for accessibility navigation. The default depends on the layer type.null
"layerRotation"NumberThe layer is rotated by the specified degree.0
"name"StringUnique name in the layout. Used for alignment or actions.null
"opacity"NumberThe opacity of the layer.1
"overInsetBottom"BooleanDetermines if this layer ignores the save space at the bottom of the device.false
"overInsetTop"BooleanDetermines if this layer ignores the save space at the top of the device.false
"pressedColor"ColorThe highlight color of this layer when it is pressed. Mainly used on TV. If no color is provided, the focusColor will be used.null
"safeArea"SafeAreaTypeObjectDetermines the safe area behaviour.null
"shadowElevation"NumberThe elevation of this layer for casting shadows.0
"state"StringThe state the layer will use as default."default"
"states"LayerStatesA list of named states that affect the appearance of the layer.null
"topLeftRadius"UnitSizeRadius for the top left corner.0
"topRightRadius"UnitSizeRadius for the top right corner.0
"touchFeedback"TouchFeedbackDetermines if the layer should show a touch feedback if touched."visible"
"trackingKey"StringDefines a key for a scroll event.null
"type"LayerTypeThe type of the layernull
"value"Value(Initial) value of the layer.null

Examples

Goal: Create a full-width gallery with a height of 450 pt that automatically rotates between three images every 10 seconds.

  1. Add a gallery layer to the layout:
{
"name": "gallery",
"type": "gallery",
"dataKey": "myGallery",
"timerInterval": "10",
"constraints": [
{
"type": "pos",
"x": "0",
"y": "0"
},
{
"type": "pos",
"x": "0",
"anchor": "e",
"relativeAnchor": "e"
},
{
"type": "size",
"height": "450pt"
}
]
}

Notice that the dataKey is used to match it with name in the client_template.
Additionally, the timerInterval is set to 10 seconds for smooth image rotation, and there are constraints in place, ensuring a gallery height of 450pt.

  1. Create a gallery item layout:
{
"name": "p_image",
"layers": [
{
"name": "image",
"dataKey": "myImage",
"type": "image",
"scaleType": "scaleAspectFill",
"constraints": [
{
"type": "pos",
"x": "0",
"y": "0"
},
{
"type": "pos",
"x": "0",
"y": "0",
"anchor": "se",
"relativeAnchor": "se"
}
]
}
]
}

In the following line, the scaleAspectFill is set to scaleType to ensure that the image completely fills the gallery according to the defined constraints.
These constraints are designed to make the image occupy the entire gallery.

  1. Add a data block to the client_template with values for the gallery.
    Make sure the items in the data block match the dataKey of the image in p_image:
{
"content": {
"data": [
{
"myImage": {
"value": "http://res.appframework.de/media/demo/image1.png"
}
},
{
"myImage": {
"value": "http://res.appframework.de/media/demo/image2.jpg"
}
},
{
"myImage": {
"value": "http://res.appframework.de/media/demo/image3.jpg"
}
}
],
"myGallery": {
"galleryItems": [
{
"layoutName": "p_image",
"dataSourceType": "data",
"dataSource": "data.0"
},
{
"layoutName": "p_image",
"dataSourceType": "data",
"dataSource": "data.1"
},
{
"layoutName": "p_image",
"dataSourceType": "data",
"dataSource": "data.2"
}
]
}
}
}

To configure the gallery, simply assign:
1. galleryItems to myGallery;
2. p_image to layoutName and set the name of data block to dataSourceType, with the desired data block index set to dataSource.

Result:

Screencapture of the app showing the results of the sample code from Example 1.
A static gallery layer using galleryItems has been created.

Goal: Create the same gallery as in Example 1 using a database table.

  1. Create a database table:
{
"table": {
"name": "galleryData",
"fields": [
{
"name": "ID",
"type": "TEXT"
},
{
"name": "title",
"type": "TEXT"
},
{
"name": "image_url",
"type": "TEXT"
}
],
"primaryKey": [
"ID"
],
"queries": {
"all": {
"custom": "SELECT * FROM galleryData"
},
"byId": {
"custom": "SELECT * FROM galleryData WHERE galleryData.ID = ?"
}
}
},
"data": [
{
"ID": 1,
"title": "image 1",
"image_url": "http://res.appframework.de/media/demo/image1.png"
},
{
"ID": 2,
"title": "image 2",
"image_url": "http://res.appframework.de/media/demo/image2.jpg"
},
{
"ID": 3,
"title": "image 3",
"image_url": "http://res.appframework.de/media/demo/image3.jpg"
}
]
}

The table galleryData which containts 3 fields, 2 queries and also 3 items has been created.
These items will be used in the gallery.

  1. Design the layout to work with the database table.
{
"name": "gallery",
"type": "gallery",
"dataKey": "myGallery",
"table": "galleryData",
"query": "all",
"layout": "p_image",
"template": "imageGallery",
"timerInterval": "10",
"constraints": [
{
"type": "pos",
"x": "0",
"y": "0"
},
{
"type": "pos",
"x": "0",
"anchor": "e",
"relativeAnchor": "e"
},
{
"type": "size",
"height": "450pt"
}
]
}

Some necessary fields that allow the gallery to work with database table have been added.
1. table with value galleryData, which already exists.
2. query with value all, which was defined in section above.
3. layout with value p_image, which already exists.
4. template with value imageGallery, which is to be created in the next step.

  1. Create a client_template for the p_image layout to get values from the database table and display them in the layout.
{
"name": "imageGallery",
"content": {
"myImage": {
"value": "{{image_url}}"
}
}
}

The imageGallery client_template, which will dynamically get value of image_url from query and set to myImage, which p_image will use for displaying the image has been created

Result:

Screencapture of the app showing the results of the sample code from Example 2.
A dynamic gallery layer using a database table has been created.