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
Enum that defines the available editions for Nativeblocks. The NativeblocksEdition can either be a cloud configuration or a community-based frame configuration.
public enum NativeblocksEdition
cloud
Cloud-based configuration with an endpoint, API key, and development mode option.
case cloud(endpoint: String, apiKey: String, developmentMode: Bool)
community
Community-based configuration using local frame data. The frame data is a dictionary where each key is a route and each value is the corresponding frame URL.
case community(frameData: [String: String])
getInstance()
Gets the shared instance of the NativeblocksManager.
public static func getInstance() -> NativeblocksManager
Returns
The shared NativeblocksManager instance.
initialize(edition:)
Initializes the NativeblocksManager with the specified edition.
public static func initialize(edition: NativeblocksEdition)
Parameters
- edition: The NativeblocksEdition that determines the configuration type, such as cloud or community.
provideAction(actionKeyType:action:_:)
Provides an action for the specified action key type.
public func provideAction(actionKeyType: String, action: any INativeAction)
Parameters
- actionKeyType: The key type associated with the action.
- action: The action instance implementing the INativeAction protocol.
provideBlock(blockKeyType:block:_:)
Provides a block for the specified block key type.
public func provideBlock(blockKeyType: String, block: any INativeBlock)
Parameters
- blockKeyType: The key type associated with the block.
- block: The block instance implementing the INativeBlock protocol.
provideEventLogger(loggerType:logger:_:)
Provides an event logger for the specified logger type.
public func provideEventLogger(loggerType: String, logger: any INativeLogger)
Parameters
- loggerType: The key type associated with the logger.
- logger: The logger instance implementing the INativeLogger protocol.
wandKit(_:)
Configures the WandKit components for the Nativeblocks manager.
public func wandKit(_ wandKit: WandKit...) -> NativeblocksManager
Parameters
- wandKit: A variadic parameter for passing one or more WandKit instances.
Returns
The current instance of NativeblocksManager.
syncFrame(frameRoute:)
Synchronizes the frame for the specified route asynchronously.
public func syncFrame(frameRoute: String)
Parameters
- frameRoute: The route of the frame to synchronize.
getScaffold(onSuccess:onFailure:)
Retrieves the scaffold for the frames asynchronously.
public func getScaffold(
onSuccess: @escaping (NativeScaffoldModel) -> Void,
onFailure: @escaping (String) -> Void
)
Parameters
- onSuccess: A closure called when the scaffold retrieval is successful, providing a NativeScaffoldModel.
- onFailure: A closure called when the retrieval fails, providing an error message.
destroy()
Destroys the NativeblocksManager and releases all associated resources.
public func destroy()
NativeblocksFrame
Represents a view that manages and displays a Nativeblocks frame. The NativeblocksFrame is used to display a portion of the UI as defined by a specific route and its arguments.
public struct NativeblocksFrame: View
Inheritance
View
Initializers
init(route:routeArguments:loading:error:)
Initializes a new NativeblocksFrame with the specified parameters.
public init(route: String, routeArguments: [String: String], loading: @escaping () -> AnyView, error: @escaping (String) -> AnyView)
Parameters
- route: The route to be loaded.
- routeArguments: A dictionary of arguments to pass to the route.
- loading: A closure that returns a view to be shown while the content is loading.
- error: A closure that takes a message string and returns a view to be shown when an error occurs.
Properties
body
public var body: some View
NativeblocksLoading
Represents a view displayed during the loading state of a NativeblocksFrame.
public struct NativeblocksLoading: View
Inheritance
View
Initializers
init()
public init()
Properties
body
public var body: some View
NativeblocksError
Represents a view displayed when an error occurs while loading a NativeblocksFrame.
public struct NativeblocksError: View
Inheritance
View
Initializers
init(message:)
Initializes a new NativeblocksError view with the specified message.
public init(message: String)
Parameters
- message: The error message to display.
Properties
body
public var body: some View
NativeScaffoldModel
Represents the scaffold model for Nativeblocks, containing metadata about frames and their routes.
public struct NativeScaffoldModel
Properties
frames
A collection of frame routes defined within the scaffold.
public let frames: [NativeFrameRouteModel]
NativeFrameRouteModel
Represents a frame route model, which defines a specific UI element and its associated metadata.
public struct NativeFrameRouteModel
Properties
id
The unique identifier for the frame route.
public let id: String?
name
The name of the frame route, used for display or identification.
public let name: String?
type
The type of the frame, such as a standard frame, bottom sheet, or dialog.
public let type: FrameTypeModel?
route
The route path for this frame, used for navigation.
public let route: String?
isStarter
Indicates whether this frame is the starting frame in the application.
public let isStarter: Bool?
routeArguments
A collection of arguments that can be passed to this route.
public let routeArguments: [NativeRouteArgumentsModel]?
NativeRouteArgumentsModel
Represents an argument for a specific route, defined by its name.
public struct NativeRouteArgumentsModel
Properties
name
The name of the argument.
public let name: String?
FrameTypeModel
Defines the types of frames available in Nativeblocks.
public enum FrameTypeModel: String
Inheritance
String
Enumeration Cases
frame
A standard frame type, typically a full-screen or main view.
case frame = "FRAME"
bottomSheet
A bottom sheet type, often used for partial overlays on the screen.
case bottomSheet = "BOTTOM_SHEET"
dialog
A dialog type, used for modal interactions.
case dialog = "DIALOG"