NativeblocksManager
A singleton class responsible for managing the Nativeblocks instance and its various components. The NativeblocksManager is used to initialize, provide blocks, actions, and loggers, and manage the lifecycle of Nativeblocks.
NativeblocksEdition
Represents the different editions of the Nativeblocks framework.
sealed interface NativeblocksEdition
Cloud
Cloud-based configuration for the Nativeblocks framework.
data class Cloud(
val endpoint: String,
val apiKey: String,
val developmentMode: Boolean
) : NativeblocksEdition
- endpoint: The API endpoint for fetching frame definitions and other resources.
- apiKey: The API key for authenticating requests to the server.
- developmentMode: Indicates if development mode is enabled for testing and debugging.
Community
Community-based configuration for the Nativeblocks framework.
class Community(
val framesData: Map<String, String>,
) : NativeblocksEdition
- framesData: A map where each key represents a route, and each value is the URL or path to the corresponding frame data.
initialize
Initializes the Nativeblocks framework.
fun initialize(applicationContext: Context, edition: NativeblocksEdition)
Parameters
- applicationContext: The application context.
- edition: The edition of Nativeblocks to initialize.
getInstance
Retrieves the singleton instance of the NativeblocksManager.
fun getInstance(): NativeblocksManager
Returns
The NativeblocksManager instance.
wandKit
Configures and sets up the WandKit.
fun wandKit(vararg wandKit: WandKit): NativeblocksManager
Parameters
- wandKit: Vararg of WandKit implementations to set up.
Returns
The NativeblocksManager instance for chaining.
provideBlock
Registers a block implementation.
fun provideBlock(blockType: String, block: INativeBlock): NativeblocksManager
Parameters
- blockType: The type of the block.
- block: The block implementation to register.
Returns
The NativeblocksManager instance for chaining.
provideAction
Registers an action implementation.
fun provideAction(actionType: String, action: INativeAction): NativeblocksManager
Parameters
- actionType: The type of the action.
- action: The action implementation to register.
Returns
The NativeblocksManager instance for chaining.
provideActionContractor
Registers an action contractor.
fun provideActionContractor(actionContractor: INativeActionContractor): NativeblocksManager
Parameters
- actionContractor: The action contractor to register.
Returns
The NativeblocksManager instance for chaining.
provideEventLogger
Registers an event logger.
fun provideEventLogger(loggerType: String, logger: INativeLogger): NativeblocksManager
Parameters
- loggerType: The type of the logger.
- logger: The logger implementation to register.
Returns
The NativeblocksManager instance for chaining.
destroy
Cleans up resources and destroys the NativeblocksManager instance.
fun destroy()
syncFrame
Synchronizes the specified frame with the server.
suspend fun syncFrame(frameRoute: String): NativeblocksManager
Parameters
- frameRoute: The route of the frame to synchronize.
Returns
The NativeblocksManager instance for chaining.
getScaffold
Retrieves the scaffold model for the current configuration.
suspend fun getScaffold(
onSuccess: (value: NativeScaffoldModel) -> Unit,
onFailure: (message: String) -> Unit
)
Parameters
- onSuccess: Callback invoked with the scaffold model upon success.
- onFailure: Callback invoked with an error message upon failure.
NativeblocksFrame
Composable function for rendering a Nativeblocks frame. Sets up the frame with the provided route and arguments, and handles loading and error states.
@Composable
fun NativeblocksFrame(
frameRoute: String,
routeArguments: HashMap<String, String>,
loading: @Composable () -> Unit,
error: @Composable (String) -> Unit
)
Parameters
- frameRoute: The route of the frame to display.
- routeArguments: A map of arguments to pass to the frame route.
- loading: A composable to display during the loading state.
- error: A composable to display in case of an error, accepting an error message.
NativeblocksLoading
Composable function for displaying a loading indicator in Nativeblocks.
@Composable
fun NativeblocksLoading()
NativeblocksError
Composable function for displaying an error message in Nativeblocks.
@Composable
fun NativeblocksError(message: String)
Parameters
- message: The error message to display.
NativeblocksResourceManager
Manages resources such as font families within the Nativeblocks framework.
Methods
provideFontFamily
Registers a font family with a specified name.
fun provideFontFamily(fontName: String, fontFamily: FontFamily): NativeblocksResourceManager
NativeScaffoldModel
Represents the scaffold structure in the native UI framework, consisting of a list of frame routes.
data class NativeScaffoldModel
Properties
- frames: List of frame routes included in the scaffold.
NativeFrameRouteModel
Represents a single frame route, including its metadata and route-specific details.
data class NativeFrameRouteModel
Properties
- id: Unique identifier of the frame route.
- name: Name of the frame route.
- type: Type of the frame (e.g., FRAME, BOTTOM_SHEET, DIALOG).
- route: Route path associated with the frame.
- isStarter: Indicates if this is the starter frame.
- routeArguments: List of arguments for the route.
NativeRouteArgumentsModel
Represents an argument for a route in the native UI framework.
data class NativeRouteArgumentsModel
Properties
- name: Name of the route argument.
FrameTypeModel
Enum representing the types of frames supported in the native UI framework.
enum class FrameTypeModel(val type: String)
Values
- FRAME: Standard frame type.
- BOTTOM_SHEET: Bottom sheet frame type.
- DIALOG: Dialog frame type.