⌘K

Block

Blocks in Nativeblocks represent modular UI components that can be dynamically rendered based on their configuration and properties. Each block is identified by a unique type and is implemented using the INativeBlock interface.


Example of a Block Workflow

  1. A block is defined with its unique key type and associated properties.
  2. The block is registered in the NativeBlockProvider.
  3. During runtime, the block is retrieved and rendered using the blockView(blockProps:) method.

NativeBlockProvider

A singleton class responsible for managing and providing blocks within the Nativeblocks SDK. The NativeBlockProvider class maintains a registry of blocks that can be dynamically provided based on the block type.

class NativeBlockProvider

INativeBlock

Defines the contract for native blocks in the framework.

interface INativeBlock

BlockView

Composable function representing the UI of a block.

@Composable
fun BlockView(blockProps: BlockProps)

Parameters

  • blockProps: Properties to customize the behavior and content of the block.

BlockProps

Represents the properties required for rendering and handling a native block.

data class BlockProps

Properties

  • listItemIndex: Index of the list item associated with the block (optional).
  • variables: Map of variables used within the block, identified by their keys (optional).
  • onVariableChange: Callback invoked when a variable changes (optional).
  • actions: Map of actions associated with the block, grouped by their identifiers (optional).
  • onHandleAction: Callback invoked to handle an action with the given index, action model, and type (optional).
  • block: The model representing the block to be rendered (optional).
  • onSubBlock: Composable callback to render sub-blocks within the specified slot and index (optional).

NativeBlockModel

Represents a block within a native UI framework, including its properties, data, visibility, position, and hierarchical structure.

data class NativeBlockModel

Properties

  • id: Unique identifier of the block.
  • parentId: Identifier of the parent block to establish hierarchy.
  • slot: Slot name where the block resides.
  • keyType: Type of the key used to identify the block.
  • key: Key associated with the block.
  • visibility: Visibility state of the block (e.g., visible, hidden).
  • position: Position of the block in its container.
  • data: Data associated with the block, mapped by keys to their values and types.
  • properties: Properties associated with the block, including values for different device types.
  • slots: Slots within the block for additional content or nested structures.
  • subBlocks: Sub-blocks nested within this block, mapped by their identifiers.

NativeBlockPropertyModel

Represents a property of a native block, including device-specific values and its type.

data class NativeBlockPropertyModel

Properties

  • key: Key identifying the property.
  • valueMobile: Value of the property for mobile devices.
  • valueTablet: Value of the property for tablets.
  • valueDesktop: Value of the property for desktop devices.
  • type: Type of the property (e.g., string, boolean).

NativeBlockDataModel

Represents a piece of data associated with a native block, including its key, value, and type.

data class NativeBlockDataModel

Properties

  • key: Key identifying the data entry.
  • value: Value of the data entry.
  • type: Type of the data entry (e.g., string, integer).

NativeBlockSlotModel

Represents a slot within a native block for holding additional content.

data class NativeBlockSlotModel

Properties

  • slot: Name of the slot.