会话列表页(列表/搜索/连接态/空态/骨架)(ChatListViewController)
会话列表页(列表/搜索/连接态/空态/骨架):ChatListViewController 属于 ViewController(视图 / 生命周期 / 输入)。本页的 props / events / behaviors 来自 sdk-imkit.json → globalUIKit,声明与示例来自 bindings.ios.uikit,不手写漂移。
契约属性(props)
| 属性 | 类型 | 可选 | 说明 |
|---|---|---|---|
viewModel | ChatListViewModel | 否 | 页面状态机(ChatListViewModel / ChatViewModel) |
theme | ChatUITheme | 否 | 主题令牌(ChatUITheme),浅色 / 深色预设或自定义 |
delegate | ChatListDelegate? | 是 | 交互回调协议实现;只回调,不做导航 |
options | {showSearch:bool,showNetworkBanner:bool,showEmptyState:bool} | 是 | 页面选项(由契约声明的可选字段,例如搜索栏 / 网络横幅 / 历史 / 已读 / typing) |
事件(events)
| 事件 | 参数 | 说明 |
|---|---|---|
select | conversation | 点击会话(宿主负责路由) |
longpress | conversation | 长按会话(宿主展示菜单) |
refresh | — | 下拉刷新 / 重试 |
tapSearch | — | 点击搜索入口 |
行为(behaviors)
- 绑定 ViewModel 状态:loading/empty/error/loaded
- 未读角标与 @ 角标
- 连接状态横幅(连接中/断开/重连)
- 下拉刷新
- 点击会话回调宿主路由(不自行 push)
- deinit 取消订阅
公开符号与声明
| 语言 | 声明 |
|---|---|
| Swift | IMPChatListViewController(viewModel: IMPChatListViewModel, theme: IMPChatUITheme, delegate: IMPChatListDelegate?, options: IMPChatListOptions?) |
| Objective-C | - (instancetype)initWithViewModel:(IMPOSGlobalChatListViewModel *)viewModel theme:(IMPOSGlobalChatUITheme *)theme delegate:(id<IMPOSGlobalChatListDelegate>)delegate options:(IMPOSGlobalChatListOptions *)options; |
使用示例(Swift / Objective-C)
IMPChatListViewController(viewModel: chatListViewModel, theme: .light, delegate: nil, options: nil)IMPOSGlobalChatListViewController *chatListViewController =
[[IMPOSGlobalChatListViewController alloc] initWithViewModel:self.viewModel theme:[IMPOSGlobalChatUITheme globalLight] delegate:nil options:nil];示例口径
示例由绑定签名与契约类型生成:构造函数参数、协议方法、属性名均来自契约;实际业务中把示例变量替换为宿主实例即可。
在架构中的位置
| 项 | 值 |
|---|---|
| 层 | ViewController(视图 / 生命周期 / 输入) |
| 依赖 | GlobalUIKit -> IMKit -> IMLib(公开接口) |
| 相关组件 | ChatListViewModel、ChatListDelegate、ChatUITheme、ChatRouter |
错误处理
ViewModel 层通过事件上报错误(如 error(err));错误码与处理建议见 Global IM UIKit 错误处理、状态码(运行时 43 条)与 状态码全量对照(440 条)。