Foundation
This document provides an overview of the Nativeblocks Foundation blocks, actions and utilities. These blocks and actions are fundamental components that allow developers to build rich and customizable user interfaces in SwiftUI. Additionally, utility functions and extensions are provided to enhance development workflows.
All the blocks and actions described below are basics provided in Nativeblocks Studio, making them readily available for use in projects.
Getting Started
To integrate NativeblocksFoundation into your project, add it via Swift Package Manager (SPM):
- Add the library to your Package.swift file:
dependencies: [
.package(
url: "https://github.com/nativeblocks/nativeblocks-foundation-ios.git",
.upToNextMajor(from: "1.2.2")
),
],
- Import the library in your Swift file:
import NativeblocksFoundation
- Provide nativeblocks foundation blocks :
NativeblocksFoundationProvider.provide()
- Start using the blocks provided by NativeblocksFoundation to create dynamic, server-driven UIs.
Sample App Example
Here is an example of a basic app using NativeblocksFoundation:
import Nativeblocks
import NativeblocksFoundation
NativeblocksManager.initialize()
// ADD This line of codes
NativeblocksFoundationProvider.provide()
Provided Actions
The following actions are provided in NativeblocksFoundation:
NativeChangeVariable
An 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
NativeZStack
NativeHStack
NativeVStack
NativeLazyHStack
NativeLazyVStack
NativeSpacer
NativeText
NativeTextField
NativeButton
NativeImage
NativeScrollView
Provided Types
The following types are provided in NativeblocksFoundation: