Layers
Layers are the basic building blocks of every mos. app. Layers include basic shapes that can be colored (like the color layer), text fields (text layer) and various others like image or video layers.
By combining multiple layers so-called layouts are created which, combined with data (e.g. from templates) make up the individual views of an application.
Layoutsโ
Layouts are saved in the ./layouts
directory of the app and each layout file should be structured as follows:
{
"name": "myLayout",
"layers": [
]
}
name
is the name of this layout (should be identical to the filename)layers
contains a list of layers within this layout.
Exampleโ
Below is the section of a layout file using a single color layer as a background:
{
"name": "myLayout",
"layers": [
{
"type": "color",
"name": "background",
"value": "#FFFFFF",
"constraints": [
{
"type": "pos",
"x": "0",
"y": "0",
"anchor": "nw",
"relativeAnchor": "nw"
},
{
"type": "pos",
"x": "0",
"y": "0",
"anchor": "se",
"relativeAnchor": "se"
}
]
},
...
]
}
This layer is positioned using constraints (see layout).
The position is defined by specifying anchor points relative to a parent layer. If the given layer has no parent it is positioned relative to the whole screen (usually not including the status and navigation/gesture bar).
Having a the layers nw
and se
anchors pinned to the screens nw
and se
anchors, the color-layer acts as a background covering the entire screen.
Since nw
is the default value for anchor
and relativeAnchor
nw
anchor, this constraint can be shortened to:
"constraints": [
{
"type": "pos",
"x": "0",
"y": "0"
},
{
"type": "pos",
"x": "0",
"y": "0",
"anchor": "se",
"relativeAnchor": "se"
}
]
For an in depth documentation of layouting see layout.
Creating a button provides an example of how to use multiple layers to create a button.
Index of all layer typesโ
Below is a complete list of all layers:
๐๏ธ autoPlayGallery
Creates a gallery which can also change images in an given interval
๐๏ธ barcode
Opens the camera to scan a barcode.
๐๏ธ barcodeRenderer
Displays a barcode as an image.
๐๏ธ calendar
Creates a swipeable calendar as a monthly view.
๐๏ธ camera
Shows a live preview of the device's camera.
๐๏ธ chat
The chat layer creates a chat view.
๐๏ธ checkBox
Creates a form check box.
๐๏ธ color
The color layer creates a colored area of the chosen color. It is most commonly used to create a background plane or to visually distinguish different elements from one another. The color layer can be used everywhere you can usually define layers. To use the color layer it is important to set a value in form of a hex color code, i.e. #000000 for black or #ffffff for white, otherwise your color layer will be transparent.
๐๏ธ container
Creates a container in which you can zoom and scroll. Elements such as text, color, etc. in a container are specified as children. With containers you can use the constraints to divide the screen again. You can only use anchors between elements in the same container.
๐๏ธ datePicker
Creates an empty layer. If the user taps it, a date picker is presented.
๐๏ธ gallery
Creates a gallery layer. Gallerys can retrieve children dynamically from a Database table or be configured statically using galleryItems.
๐๏ธ goniometer
The GoniometerLayer displays a Goniometer (Protractor) to measure angles in degrees with.
๐๏ธ gradient
Displays a GradientLayer.
๐๏ธ grid
Arranges content as tiles, arranged from top left to bottom right.
๐๏ธ image
The image type can be used to creat an image layer. The provided value serves as the source of the image.
๐๏ธ insert
An insert layer is used to display dynamic data, i.e. the results of other layers and requires type insert.
๐๏ธ layout
Type layout can be used to create an additional layout layer within the parent layout. If the data in dependent database table change, the layout will be reloaded.
๐๏ธ lottieImage
The lottieImage type can be used to create an animated layer. The provided value serves as the source of the animation.
๐๏ธ map
A map layer is used to create an interactive map that can be used to visualize markers and routes.
๐๏ธ multiLayout
Layers of type multiLayout show an additional layout in their bounds, similar to layered nodes. If the data of dependend tables change, the layout is reloaded.
๐๏ธ pagination
Pagination for the Gallery Layer.
๐๏ธ pdf
The pdf layer displays a PDF file.
๐๏ธ picker
Allows the user to pick one or multiple files from the system storage. These files can be images, videos, files or audio files. Since the picker layer itself has no visible appearance, it is usually placed inside a container layer.
๐๏ธ progressBar
Indicates progress. The progress is displayed linearly from the minimum to the maximum.
๐๏ธ ruler
The RulerLayer displays a ruler in either cm or inch.
๐๏ธ segmented
Displays a segmented button, that can be selected. The selected index is the form layer's value.
๐๏ธ selectBox
A form select box can be created by the type selectBox.
๐๏ธ slider
Layer displaying a slider control.
๐๏ธ speechRecognition
A layer that uses speech recognition on touch.
๐๏ธ spinner
The spinner layer displays a loading spinner. It is often used to indicate to the user that a process is running in the background.
๐๏ธ text
Creates a text layer. The value is the text to be displayed. Alternatively, the text layer can also be used to display FontAwesome icons. To do so, simply set the font to FontAwesome and select a FontAwesome icon as the value.
๐๏ธ textBox
The textBox layer allows user input in text form. It is used when the user is required to enter information such as a username.
๐๏ธ video
Displays a video.
๐๏ธ web
The type web can be used to create a Web Layer. Web layers load a Web view into the display area.
๐๏ธ youTube
This layer uses a native framework to display YouTube videos.