Global UIKit 主题令牌(ChatUITheme)
Global UIKit 主题令牌:ChatUITheme 属于 Theme(样式令牌)。本页的 props / events / behaviors 来自 sdk-imkit.json → globalUIKit,声明与示例来自 bindings.ios.uikit,不手写漂移。
契约属性(props)
| 属性 | 类型 | 可选 | 说明 |
|---|---|---|---|
palette | {background,surface,textPrimary,textSecondary,brand,danger} | 否 | 颜色令牌(背景 / 卡片 / 主次文本 / 品牌色 / 危险色) |
typography | {body,caption,title} | 否 | 字体令牌(正文 / 辅助 / 标题),支持 Dynamic Type |
layout | {bubbleRadius,avatarSize,spacing} | 否 | 布局令牌(气泡圆角 / 头像尺寸 / 间距) |
事件(events)
该组件不声明事件:它是数据 / 渲染模型,由 ViewModel 与视图驱动。
行为(behaviors)
- 浅色/深色两套预设
- 动态字体(Dynamic Type)
- 宿主可整体覆盖或按组件覆盖
- 运行中切换主题即时生效
公开符号与声明
| 语言 | 声明 |
|---|---|
| Swift | IMPChatUITheme(palette: IMPChatPalette, typography: IMPChatTypography, layout: IMPChatLayout) / .light / .dark |
| Objective-C | + (instancetype)globalLight; + (instancetype)globalDark; - (instancetype)initWithPalette:(IMPOSGlobalChatPalette *)palette typography:(IMPOSGlobalChatTypography *)typography layout:(IMPOSGlobalChatLayout *)layout; |
使用示例(Swift / Objective-C)
// 主题令牌:浅色 / 深色预设,可按令牌覆盖
var theme = IMPChatUITheme.light
theme.palette.brand = "#4F46E5"
print(theme.palette.background)// 主题:类方法预设或自定义令牌
IMPOSGlobalChatUITheme *theme = [IMPOSGlobalChatUITheme globalLight];
self.theme.palette.brand = [UIColor systemIndigoColor];示例口径
示例由绑定签名与契约类型生成:构造函数参数、协议方法、属性名均来自契约;实际业务中把示例变量替换为宿主实例即可。
在架构中的位置
| 项 | 值 |
|---|---|
| 层 | Theme(样式令牌) |
| 依赖 | GlobalUIKit -> IMKit -> IMLib(公开接口) |
| 相关组件 | ChatListViewController、ChatViewController |
错误处理
ViewModel 层通过事件上报错误(如 error(err));错误码与处理建议见 Global IM UIKit 错误处理、状态码(运行时 43 条)与 状态码全量对照(440 条)。