Packages
mob
0.5.0
0.7.20
0.7.19
0.7.18
0.7.17
0.7.16
0.7.15
0.7.14
0.7.13
0.7.12
0.7.11
0.7.10
0.7.9
0.7.8
0.7.7
0.7.6
0.7.5
0.7.4
0.7.3
0.7.2
0.7.1
0.7.0
0.6.26
0.6.25
0.6.24
0.6.23
0.6.22
0.6.21
0.6.20
0.6.19
0.6.18
0.6.17
0.6.16
0.6.15
0.6.14
0.6.13
0.6.12
0.6.11
0.6.10
0.6.9
0.6.8
0.6.7
0.6.6
0.6.5
0.6.2
0.6.1
0.6.0
0.5.18
0.5.17
0.5.16
0.5.15
0.5.14
0.5.11
0.5.10
0.5.7
0.5.6
0.5.5
0.5.4
0.5.3
0.5.2
0.5.1
0.5.0
0.4.0
0.3.10
0.3.9
0.3.8
0.3.7
0.3.6
0.3.5
0.3.4
0.3.3
0.3.2
0.3.1
0.3.0
0.2.0
0.1.0
BEAM-on-device mobile framework for Elixir
Current section
Files
Jump to
Current section
Files
ios/MobNode.h
// MobNode.h — Data model node for the Mob UI tree (iOS SwiftUI layer).
// Created and mutated by mob_nif.m NIFs; read by MobRootView.swift for rendering.
// No BEAM headers here — kept clean for Swift import via bridging header.
#pragma once
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
#import <WebKit/WebKit.h>
// Shared camera preview session — set by nif_camera_start/stop_preview, read by MobRootView.
extern AVCaptureSession* _Nullable g_preview_session;
// Shared WebView — set by MobWebView when created, read by webview NIFs.
extern WKWebView* _Nullable g_webview;
typedef NS_ENUM(NSInteger, MobNodeType) {
MobNodeTypeColumn,
MobNodeTypeRow,
MobNodeTypeLabel,
MobNodeTypeButton,
MobNodeTypeScroll,
MobNodeTypeBox,
MobNodeTypeDivider,
MobNodeTypeSpacer,
MobNodeTypeProgress,
MobNodeTypeTextField,
MobNodeTypeToggle,
MobNodeTypeSlider,
MobNodeTypeImage,
MobNodeTypeLazyList,
MobNodeTypeTabBar,
MobNodeTypeVideo,
MobNodeTypeCameraPreview,
MobNodeTypeWebView,
MobNodeTypeNativeView,
};
NS_ASSUME_NONNULL_BEGIN
@interface MobNode : NSObject
// Layout
@property (nonatomic) MobNodeType nodeType;
@property (nonatomic, strong, nullable) UIColor* backgroundColor;
@property (nonatomic) CGFloat padding; // uniform; -1 if unset
@property (nonatomic) CGFloat paddingTop; // -1 = use uniform padding
@property (nonatomic) CGFloat paddingRight; // -1 = use uniform padding
@property (nonatomic) CGFloat paddingBottom; // -1 = use uniform padding
@property (nonatomic) CGFloat paddingLeft; // -1 = use uniform padding
// Text / Button
@property (nonatomic, copy, nullable) NSString* text;
@property (nonatomic) CGFloat textSize;
@property (nonatomic, strong, nullable) UIColor* textColor;
// Tap
@property (nonatomic, copy, nullable) void (^onTap)(void);
// Value-bearing change callbacks (set by mob_nif.m; called by SwiftUI)
@property (nonatomic, copy, nullable) void (^onChangeStr)(NSString*);
@property (nonatomic, copy, nullable) void (^onChangeBool)(BOOL);
@property (nonatomic, copy, nullable) void (^onChangeFloat)(double);
// text_field
@property (nonatomic, copy, nullable) NSString* placeholder;
@property (nonatomic, copy, nonnull) NSString* keyboardTypeStr; // "default","number","decimal","email","phone","url"
@property (nonatomic, copy, nonnull) NSString* returnKeyStr; // "done","next","go","search","send"
@property (nonatomic, copy, nullable) void (^onFocus)(void);
@property (nonatomic, copy, nullable) void (^onBlur)(void);
@property (nonatomic, copy, nullable) void (^onSubmit)(void);
// toggle
@property (nonatomic) BOOL checked;
// slider
@property (nonatomic) CGFloat minValue; // default 0.0
@property (nonatomic) CGFloat maxValue; // default 1.0
// Divider
@property (nonatomic) CGFloat thickness; // default 1.0
// Scroll
@property (nonatomic, copy, nonnull) NSString* axis; // "vertical" | "horizontal"
@property (nonatomic) BOOL showIndicator; // default YES
// Spacer — fixedSize == 0 means fill available space
@property (nonatomic) CGFloat fixedSize;
// Progress — NaN means indeterminate
@property (nonatomic) CGFloat value;
@property (nonatomic, strong, nullable) UIColor* color; // track / indicator color
// Layout behaviour
@property (nonatomic) BOOL fillWidth; // fill parent width (default NO; button default YES)
@property (nonatomic) CGFloat cornerRadius; // rounded corners in pt (default 0)
// image
@property (nonatomic, copy, nullable) NSString* src;
@property (nonatomic, copy, nonnull) NSString* contentModeStr; // "fit" | "fill" | "stretch"
@property (nonatomic) CGFloat fixedWidth; // 0 = fill available
@property (nonatomic) CGFloat fixedHeight; // 0 = auto
@property (nonatomic, strong, nullable) UIColor* placeholderColor;
// Typography
@property (nonatomic, copy, nullable) NSString* fontFamily; // nil = system font
@property (nonatomic, copy, nonnull) NSString* fontWeight; // "regular","medium","semibold","bold","light","thin"
@property (nonatomic, copy, nonnull) NSString* textAlign; // "left","center","right"
@property (nonatomic) BOOL italic;
@property (nonatomic) CGFloat lineHeight; // multiplier; 0 = default
@property (nonatomic) CGFloat letterSpacing;
// Tab bar
@property (nonatomic, strong, nullable) NSArray* tabDefs; // array of NSDictionary, each with id/label/icon
@property (nonatomic, copy, nullable) NSString* activeTab; // selected tab id
@property (nonatomic, copy, nullable) void (^onTabSelect)(NSString*); // sends selected tab id as string
// Video player
@property (nonatomic) BOOL videoAutoplay;
@property (nonatomic) BOOL videoLoop;
@property (nonatomic) BOOL videoControls;
// Camera preview
@property (nonatomic, copy, nonnull) NSString* cameraFacing; // "back" | "front"
// WebView
@property (nonatomic, copy, nullable) NSString* webViewUrl; // URL to load
@property (nonatomic, copy, nullable) NSString* webViewAllow; // comma-separated allowed URL prefixes
@property (nonatomic) BOOL webViewShowUrl;
@property (nonatomic, copy, nullable) NSString* webViewTitle; // static title label; overrides show_url
// NativeView — rendered by MobNativeViewRegistry
@property (nonatomic, copy, nullable) NSString* nativeViewModule; // registry key (e.g. "MyApp_ChartComponent")
@property (nonatomic, copy, nullable) NSString* nativeViewId; // user-assigned id
@property (nonatomic) int nativeViewHandle; // NIF component handle for event callbacks
@property (nonatomic, strong, nullable) NSDictionary* nativeViewProps; // full props dict forwarded to the factory
// Accessibility — set from the tap tag atom name; read by XCTest / ui_describe_all
@property (nonatomic, copy, nullable) NSString* accessibilityId;
// Children
@property (nonatomic, strong, nonnull) NSMutableArray<MobNode*>* children;
@end
NS_ASSUME_NONNULL_END