Global IM UIKit
Global IM UIKit 是 iOS 的新一代 MVVM UI 体系(对标融云 Global IM UIKit):ViewController 负责视图与生命周期,ViewModel 持有状态与业务编排,DataSource / Delegate 负责数据与交互回调,CellModel 描述渲染,Theme 统一令牌。共 12 个组件,全部由契约 sdk-imkit.json → globalUIKit 生成。
平台与状态
包名:ImpIaaSIMUIKit;绑定状态:ga;入口:IMPChatListViewController / IMPChatViewController。
仅 iOS 交付(与融云一致);Swift 12 个公开符号、Objective-C 12 个声明。
依赖方向:GlobalUIKit -> IMKit -> IMLib(公开接口)。
架构分层
| 层 | 职责 | 组件 |
|---|---|---|
| ViewController(视图/生命周期) | 渲染视图、处理生命周期与用户输入,不持有业务状态 | ChatListViewController、ChatViewController、ChatInputController |
| ViewModel(状态与业务编排) | 状态机:加载、增量合并、发送/已读/撤回等编排,向视图暴露状态 | ChatListViewModel、ChatViewModel |
| DataSource(列表数据) | 向列表提供数据(会话 / 消息),支持测试注入 | ChatListDataSource、ChatDataSource |
| Delegate(交互回调) | 把用户交互回调给宿主(导航、详情、重发由宿主实现) | ChatListDelegate、ChatDelegate |
| CellModel(渲染模型) | 把消息转换为可渲染模型(时间、状态、已读、撤回) | ChatCellModel |
| Theme(样式令牌) | 统一颜色 / 字体 / 布局令牌,支持浅色、深色与 Dynamic Type | ChatUITheme |
路由层(宿主可替换):ChatRouter。
完整分层与数据流见 架构分层。
组件总览
| 组件 | 职责 | 层 | Props | Events | 文档 |
|---|---|---|---|---|---|
ChatListViewController | 会话列表页(列表/搜索/连接态/空态/骨架) | ViewController | 4 | 4 | 会话列表页(列表/搜索/连接态/空态/骨架) |
ChatViewController | 聊天页(消息流/输入/历史/已读/撤回) | ViewController | 4 | 5 | 聊天页(消息流/输入/历史/已读/撤回) |
ChatListViewModel | 会话列表状态机 | ViewModel | 3 | 2 | 会话列表状态机 |
ChatViewModel | 聊天页状态机 | ViewModel | 4 | 3 | 聊天页状态机 |
ChatListDataSource | 会话列表数据源协议 | DataSource | 1 | 1 | 会话列表数据源协议 |
ChatListDelegate | 会话列表交互回调协议 | Delegate | 0 | 3 | 会话列表交互回调协议 |
ChatDataSource | 消息列表数据源协议 | DataSource | 1 | 1 | 消息列表数据源协议 |
ChatDelegate | 聊天页交互回调协议 | Delegate | 0 | 4 | 聊天页交互回调协议 |
ChatCellModel | 消息渲染模型 | CellModel | 5 | 0 | 消息渲染模型 |
ChatInputController | 输入区控制器 | ViewController | 2 | 3 | 输入区控制器 |
ChatRouter | 统一路由(宿主可替换) | Router | 1 | 2 | 统一路由(宿主可替换) |
ChatUITheme | Global UIKit 主题令牌 | Theme | 3 | 0 | Global UIKit 主题令牌 |
快速链接
- 快速开始:Swift + Objective-C 双语言,5 步接入
- 架构分层:VC / VM / DataSource / Delegate / CellModel / Theme / Router
- 与 IMKit 的关系与迁移:10 个 IMKit 组件 ↔ 12 个 Global UIKit 组件的映射
- 主题定制 · Dynamic Type · 自定义 Cell · 路由
- 性能与最佳实践 · 错误处理 · 更新日志 · Release Notes
验收口径
- Global UIKit 仅 iOS 交付(与融云一致),但 ViewModel/CellModel 语义必须可由 IMKit 组件语义复现
- GlobalUIKit 只能 import IMLib/IMKit 公开接口,禁止直连网络/存储
- 必须提供可运行 Demo(会话列表→聊天→发送→已读→主题切换)与截图/录屏