{"id":19313649,"url":"https://github.com/geektree0101/gtchatkit","last_synced_at":"2025-04-22T16:31:18.482Z","repository":{"id":56912402,"uuid":"123530405","full_name":"GeekTree0101/GTChatKit","owner":"GeekTree0101","description":"iOS ChatKit built on Texture(AsyncDisplayKit) and written in Swift","archived":false,"fork":false,"pushed_at":"2018-12-17T21:35:14.000Z","size":4225,"stargazers_count":20,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T15:47:16.350Z","etag":null,"topics":["asyncdisplaykit","chat","ios","swift","texture"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GeekTree0101.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-02T04:31:25.000Z","updated_at":"2023-02-07T08:47:52.000Z","dependencies_parsed_at":"2022-08-20T20:50:35.042Z","dependency_job_id":null,"html_url":"https://github.com/GeekTree0101/GTChatKit","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeekTree0101%2FGTChatKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeekTree0101%2FGTChatKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeekTree0101%2FGTChatKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeekTree0101%2FGTChatKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GeekTree0101","download_url":"https://codeload.github.com/GeekTree0101/GTChatKit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250277122,"owners_count":21403985,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asyncdisplaykit","chat","ios","swift","texture"],"created_at":"2024-11-10T00:40:35.006Z","updated_at":"2025-04-22T16:31:17.952Z","avatar_url":"https://github.com/GeekTree0101.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GTChatKit: iOS ChatKit built on Texture\n\n[![Travis CI](https://travis-ci.org/GeekTree0101/GTChatKit.svg?branch=master)](https://travis-ci.org/GeekTree0101/GTChatKit)\n[![Version](https://img.shields.io/cocoapods/v/GTChatKit.svg?style=flat)](http://cocoapods.org/pods/GTChatKit)\n[![License](https://img.shields.io/cocoapods/l/GTChatKit.svg?style=flat)](http://cocoapods.org/pods/GTChatKit)\n[![Platform](https://img.shields.io/cocoapods/p/GTChatKit.svg?style=flat)](http://cocoapods.org/pods/GTChatKit)\n\nGTChatKit is build on Texture for easy building iOS Message Application. \nAlso it support Bi-directional Paging CollectionView\n\nWhy? Texture\nTexture is an iOS framework built on top of UIKit that keeps even the most complex user interfaces smooth and responsive. more information [Here](http://texturegroup.org/)\n\n### Pagination Example\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003eAppending\u003c/td\u003e\n    \u003ctd align=\"center\"\u003ePrepending\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003cth rowspan=\"9\"\u003e\u003cimg src=\"https://github.com/GeekTree0101/GTChatKit/blob/master/resource/append.gif\"\u003e\u003c/th\u003e\n    \u003cth rowspan=\"9\"\u003e\u003cimg src=\"https://github.com/GeekTree0101/GTChatKit/blob/master/resource/prepend.gif\"\u003e\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n\u003c/table\u003e\n\n### Message Input Box Example\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003eInActive\u003c/td\u003e\n    \u003ctd align=\"center\"\u003eActive\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003cth rowspan=\"9\"\u003e\u003cimg src=\"https://github.com/GeekTree0101/GTChatKit/blob/master/resource/messageBoxInActive.png\"\u003e\u003c/th\u003e\n    \u003cth rowspan=\"9\"\u003e\u003cimg src=\"https://github.com/GeekTree0101/GTChatKit/blob/master/resource/messageBoxActive.png\"\u003e\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n\u003c/table\u003e\n\n## Usage\n[example source](https://github.com/GeekTree0101/GTChatKit/tree/master/Example)\n\n### 1. Create GTChatNodeController subclass\n\n``` swift\nclass ChatNodeController: GTChatNodeController { ... }\n```\n\u003e and you can create subclass instance \n``` swift\nlet viewController = ChatNodeController()\n```\n\u003e if you want custom collection flow layout follow it\n``` swift\nlet customFlowLayout = YOURCUSTOMCollectionFlowLayout()\nlet viewController = GTChatNodeController(layout: customFlowLayout)\n```\n\n\u003e you can access chatNode and node(backgroundNode)\n``` swift\nclass ChatNodeController: GTChatNodeController {\n\n    ...\n\n    func foo() {\n\n        let collectionView = self.chatNode // chatNode is equal to UICollectionView\n        let backgroundView = self.node // self.node is equal to backgroundView(UIView)\n    }\n\n}\n```\n\n### 2. GTChatNodeDelegate implementation\n```swift\nextension ChatNodeController: GTChatNodeDelegate {\n    func shouldAppendBatchFetch(for chatNode: ASCollectionNode) -\u003e Bool {\n        // Should Append Batch Fetch\n        return true\n    }\n    \n    func shouldPrependBatchFetch(for chatNode: ASCollectionNode) -\u003e Bool {\n        // Should Prepend Batch Fetch\n        return true\n    }\n\n    func chatNode(_ chatNode: ASCollectionNode, willBeginAppendBatchFetchWith context: ASBatchContext) {\n        // Network Call Handling\n        // If Network Call Completed then context should be completed\n        // required example\n        // eg) self.completeBatchFetching(true, endDirection: .none)\n    }\n\n    func chatNode(_ chatNode: ASCollectionNode, willBeginPrependBatchFetchWith context: ASBatchContext) {\n        ...\n    }\n}\n```\n\n### 3. completeBatchFetching\n\n``` swift\n    func completeBatchFetching(_ complated: Bool, endDirection: BatchFetchDirection) { ... }\n\n    endDirection: automatically block append or prepend batch fetching\n    self.completeBatchFetching(true, endDirection: .append) -\u003e no more append doesn't work\n    self.completeBatchFetching(true, endDirection: .prepend) -\u003e no more prepend doesn't work\n```\n\n### 4. pagingStatus property\n\nyou can see 4 steps paging status\n1. initial\n2. appending\n3. prepending\n4. some\n\n(2), (3) is Loading status\n(4: some) is means networking is finished and got new items\nyou do not need to be aware of (1: initial status) existence\n\n### 5. If you need attach message input node then override layoutSpecThatFits method on subclass\n\n\u003e Also, when keyboard is activated, you can get keyboard height from keyboardVisibleHeight property\n``` swift\n    override func layoutSpecThatFits(_ constrainedSize: ASSizeRange, chatNode: ASCollectionNode) -\u003e ASLayoutSpec {\n        let messageInsets: UIEdgeInsets = .init(top: .infinity,\n                                                left: 0.0,\n                                                bottom: self.keyboardVisibleHeight,\n                                                right: 0.0)\n\n        let messageLayout = ASInsetLayoutSpec(insets: messageInsets,\n                                              child: self.messageNode)\n\n        // overlay message input box onto chatNode\n        let messageOverlayedLayout = ASOverlayLayoutSpec(child: chatNode,\n                                                         overlay: messageLayout)\n\n        return ASInsetLayoutSpec(insets: .zero, child: messageOverlayedLayout)\n    }\n```\n\n### 6. overriding setupChatRangeTuningParameters method\n\u003e If you deal with the tuning parameters for range type on your scrolling node \n\u003e More Information [Here](http://texturegroup.org/docs/intelligent-preloading.html)\n\n``` swift\n    // default\n    open func setupChatRangeTuningParameters() {\n        self.chatNode.setTuningParameters(ASRangeTuningParameters(leadingBufferScreenfuls: 1.5,\n                                                              trailingBufferScreenfuls: 1.5),\n                                      for: .full,\n                                      rangeType: .display)\n        self.chatNode.setTuningParameters(ASRangeTuningParameters(leadingBufferScreenfuls: 2,\n                                                              trailingBufferScreenfuls: 2),\n                                      for: .full,\n                                      rangeType: .preload)\n    }\n```\n\n### 7. GTChatKit System Message Input Box\n\n``` swift\n        let node = GTChatMessageBoxNode()\n\n        // Create ChatMessageButtonNode\n        let cameraButton = GTChatMessageButtonNode()\n            .setButtonSize(.init(width: 24.0, height: 24.0))\n            .setButtonImage(#imageLiteral(resourceName: \"photo\"), color: .white, for: .normal)\n            .setButtonImage(#imageLiteral(resourceName: \"photo\"), color: UIColor.white.withAlphaComponent(0.5), for: .disabled)\n        \n        let sendButton = GTChatMessageButtonNode()\n            .setButtonSize(.init(width: 24.0, height: 24.0))\n            .setButtonImage(#imageLiteral(resourceName: \"send\"), color: .white, for: .normal)\n            .setButtonImage(#imageLiteral(resourceName: \"send\"), color: UIColor.white.withAlphaComponent(0.5), for: .disabled)\n        \n        node.messageNode.setMessageContainerInsets(UIEdgeInsetsMake(5.0, 10.0, 5.0, 10.0))\n        \n        // apply Message Box Attributes\n        node.setLeftButtons([cameraButton], spacing: 10.0) // attach left button items\n            .setRightButtons([sendButton], spacing: 10.0) // attach right button items\n            .setMessageBoxHeight(50.0, maxiumNumberOfLine: 6, isRounded: true) // set message input box size\n```\n\n## Requirements\n- Xcode \u003c~ 9.0\n- iOS \u003c~ 9.x\n- Swift \u003c~ 3.x, 4.0\n\n## Installation\n\nGTChatKit is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod 'GTChatKit'\n```\n\n## Author\n\nGeektree0101, h2s1880@gmail.com\n\n## License\n\nGTChatKit is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeektree0101%2Fgtchatkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeektree0101%2Fgtchatkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeektree0101%2Fgtchatkit/lists"}