一個基于Swift構建聊天應用的輕量級框架:Chatto

jopen 9年前發布 | 18K 次閱讀 Chatto Apple Swift開發

Chatto是一個Swift輕量級框架用于構建聊天應用。設計為可擴展高性能。與Chatto一起的還有ChattoAdditions一個 companion 框架,它包括了消息氣泡,和一個可擴展的輸入組件。

一個基于Swift構建聊天應用的輕量級框架:Chatto 一個基于Swift構建聊天應用的輕量級框架:Chatto 一個基于Swift構建聊天應用的輕量級框架:Chatto 一個基于Swift構建聊天應用的輕量級框架:Chatto

特性

  • Calculation of collection view changes and layout in background
  • Supports pagination in both directions and autoloading
  • Message count contention for fast pagination and rotation with thousands of messsages
  • Accessory view revealing by swiping from right
  • Interactive keyboard dismissal
  • Text bubbles
  • Photo bubbles
  • Extensible input bar

如何使用

  1. Subclass ChatViewController
  2. OverridecreateChatInputView()to useChattoAdditions.ChatInputBaror provide your own component
  3. Provide a data source with your messages
  4. OverridecreatePresenterBuilders(). There will be a presenter for each message that will be responsible for the UI of that message.
override func createPresenterBuilders() -> [ChatItemType: [ChatItemPresenterBuilderProtocol]] {
    return [
        TextMessageModel.chatItemType: [
            TextMessagePresenterBuilder(
                viewModelBuilder: TextMessageViewModelDefaultBuilder(),
                interactionHandler: TextMessageHandler(baseHandler: self.baseMessageHandler)
            )
        ]
    ]
}

override func createChatInputView() -> UIView {
    let chatInputView = ChatInputBar.loadNib()
    self.configureChatInputBar(chatInputView)
    self.chatInputPresenter = ChatInputBarPresenter(chatInputView: chatInputView, chatInputItems: self.createChatInputItems())
    return chatInputView
}

override func viewDidLoad() {
    super.viewDidLoad()
    self.chatDataSource = self.myDataSource
}

項目主頁:http://www.baiduhome.net/lib/view/home/1448866193608

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!