会话列表页(列表/搜索/连接态/空态/骨架)(ChatListViewController)

会话列表页(列表/搜索/连接态/空态/骨架):ChatListViewController 属于 ViewController(视图 / 生命周期 / 输入)。本页的 props / events / behaviors 来自 sdk-imkit.json → globalUIKit,声明与示例来自 bindings.ios.uikit,不手写漂移。

契约属性(props)​

属性类型可选说明
viewModelChatListViewModel否页面状态机(ChatListViewModel / ChatViewModel)
themeChatUITheme否主题令牌(ChatUITheme),浅色 / 深色预设或自定义
delegateChatListDelegate?是交互回调协议实现;只回调,不做导航
options{showSearch:bool,showNetworkBanner:bool,showEmptyState:bool}是页面选项(由契约声明的可选字段,例如搜索栏 / 网络横幅 / 历史 / 已读 / typing)

事件(events)​

事件参数说明
selectconversation点击会话(宿主负责路由)
longpressconversation长按会话(宿主展示菜单)
refresh—下拉刷新 / 重试
tapSearch—点击搜索入口

行为(behaviors)​

  • 绑定 ViewModel 状态:loading/empty/error/loaded
  • 未读角标与 @ 角标
  • 连接状态横幅(连接中/断开/重连)
  • 下拉刷新
  • 点击会话回调宿主路由(不自行 push)
  • deinit 取消订阅

公开符号与声明​

语言声明
SwiftIMPChatListViewController(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 条)。

相关文档​