Foundation
This document provides an overview of the Nativeblocks Foundation blocks, actions and utilities. These blocks and actions serve as fundamental components, enabling developers to build dynamic and customizable user interfaces using Jetpack Compose. Additionally, utility functions and extensions enhance development workflows and integrate seamlessly with server-driven UI frameworks.
All the blocks described below are core blocks provided by Nativeblocks Studio, making them readily available for use in projects.
Getting Started
To integrate NativeblocksFoundation into your Android project, follow these steps:
1. Add the Library to Your Project
Include the Nativeblocks Foundation library in your project's build.gradle file:
dependencies {
implementation("io.nativeblocks:nativeblocks-foundation-android:1.2.1")
}
2. Initialize Nativeblocks in Your Application
Import and register the Nativeblocks Foundation blocks in your application class or entry point:
import io.nativeblocks.NativeblocksManager
class MyApp : Application() {
override fun onCreate() {
super.onCreate()
NativeblocksManager.initialize(this)
// Register foundation blocks
FoundationProvider.provide()
}
}
3. Start Using Nativeblocks Foundation Blocks
After registering the foundation blocks, you can use them directly in your Compose-based layouts to create server-driven UIs.
Provided Actions
The following actions are provided in NativeblocksFoundation:
NativeChangeVariable
An native action responsible for changing the variable within the Nativeblocks system.
The NativeChangeVariable class enables the modification of a value dynamically.
It supports variable substitution, conditional evaluation, and arithmetic operations for property values.
Variable Value Supported Formats
- {var:variable-key}: Replaces with the value of the variable.
- {index}: Replaces with the list item index.
- #SCRIPT 2 + 2 #ENDSCRIPT: The string with evaluated JavaScript code replacing the script tags.
NativeChangeBlockProperty
An Action responsible for changing the properties of a block within the Nativeblocks system. This action allows modification of a block's properties across different device types (Mobile, Tablet, and Desktop).
Changes the specified property of a block.
This function updates the mobile, tablet, and desktop values of a block's property. It supports variable substitution and conditional evaluation for the property values.
Property Value Supported Formats
- {var:variable-key}: Replaces with the value of the variable.
- {index}: Replaces with the list item index.
- #SCRIPT 2 + 2 #ENDSCRIPT: The string with evaluated JavaScript code replacing the script tags.
Provided Blocks
The following blocks are provided in NativeblocksFoundation:
NativeBox
NativeColumn
NativeRow
NativeLazyColumn
NativeLazyRow
NativeSpacer
NativeText
NativeTextField
NativeButton
NativeImage
Provided Types
The following types are provided in NativeblocksFoundation: