ios - 如何使用 SwiftUI 从 noChannelsView 启动并立即打开您的第一个 channel ?

标签 ios getstream-io getstream-chat

我使用 getStream ChatChannelListView 来呈现所有 channel 。但是,当没有聊天时,我会使用具有启动聊天按钮的自定义 noChannelsView 覆盖 ViewFactory makeNoChannelsView

由于我的 noChannelsView 嵌入在 NavigationView 中,所以它的目的地是 ChatChannel,但是一旦我尝试获取 OneChannel 并打开它,noChatsView 就会开始转换到 ChatChannel,并且在转换的中间,整个 noChannelsView 会被 ChatChannelListView 替换,然后我需要手动进入我选择的 channel 。

最佳答案

对于这样的用例,您可以使用 ChatChannelListView,除了您的自定义 ViewFactory 之外,还可以为其提供一个 selectedChannelId 形式:一个字符串

代码如下所示:

var body: some View {
    ChatChannelListView(
        viewFactory: MyViewFactory(),
        selectedChannelId: "channel-id"
    )
}

为了使其动态化,您可以对 selectedChannelId 使用 @Binding ,并在创建 channel 后更新它,以便直接显示 channel UI。

如果您仍有疑问,请告诉我,我们还推荐这种深度链接技术,如您所见 in our documentation .

最好, 斯特凡

关于ios - 如何使用 SwiftUI 从 noChannelsView 启动并立即打开您的第一个 channel ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73622310/

相关文章:

ios - 分块解析 XML 文件,无需等待 Swift 中的完整下载

View 中的 IOS Swift 3 UILabels 无法正确渲染

getstream-io - 事件的 "Target"和 "To"字段有什么区别?

getstream-io - getstream-io api for swift 中的重复注释

firebase - 'streamChatState!= null' : You must have a StreamChat widget at the top of your widget tree

ios - 在iOS中使用背景图片时,需要删除UITableView中单元格之间的边框

getstream-io - 汇总提要,删除 getstream 中的重复项

flutter - 为什么无法在 flutter 中使用流聊天 api 创建用户?

objective-c - 将焦点放在输入字段时停止自动调整 uiwebview web 内容的大小