一个基于Swift构建聊天应用的轻量级框架:Chatto
jopen
9年前
Chatto是一个Swift轻量级框架用于构建聊天应用。它被设计为可扩展和高性能。与Chatto一起的还有ChattoAdditions一个 companion 框架,它包括了消息气泡,和一个可扩展的输入组件。
特性
- 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
如何使用
- Subclass ChatViewController
- OverridecreateChatInputView()to useChattoAdditions.ChatInputBaror provide your own component
- Provide a data source with your messages
- 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 }