├── .gitignore ├── .swiftlint.yml ├── .travis.yml ├── Brewfile ├── Example ├── .gitignore ├── GTChatKit.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── GTChatKit-Example.xcscheme ├── GTChatKit.xcworkspace │ └── contents.xcworkspacedata ├── GTChatKit │ ├── AppDelegate.swift │ ├── Base.lproj │ │ └── LaunchScreen.xib │ ├── ChatCellNode.swift │ ├── ChatLoadingIndicatorNode.swift │ ├── ChatNodeController.swift │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Contents.json │ │ ├── photo.imageset │ │ │ ├── Contents.json │ │ │ └── photo.png │ │ ├── photo.png │ │ ├── resources │ │ │ ├── Contents.json │ │ │ ├── eumji.imageset │ │ │ │ ├── Contents.json │ │ │ │ └── eumji.jpg │ │ │ ├── eunha.imageset │ │ │ │ ├── Contents.json │ │ │ │ └── eunha.jpg │ │ │ ├── sinbi.imageset │ │ │ │ ├── Contents.json │ │ │ │ └── sinbi.jpg │ │ │ ├── sowon.imageset │ │ │ │ ├── Contents.json │ │ │ │ └── sowon.jpg │ │ │ ├── yelin.imageset │ │ │ │ ├── Contents.json │ │ │ │ └── yelin.jpg │ │ │ └── yuju.imageset │ │ │ │ ├── Contents.json │ │ │ │ └── yuju.jpg │ │ ├── send.imageset │ │ │ ├── Contents.json │ │ │ └── send.png │ │ └── send.png │ ├── Info.plist │ ├── String+extension.swift │ └── UIColor+extension.swift ├── Podfile └── Tests │ ├── Info.plist │ └── Tests.swift ├── GTChatKit.podspec ├── GTChatKit ├── Assets │ └── .gitkeep └── Classes │ ├── .gitkeep │ ├── Extensions │ ├── UIColor+GTChatKit.swift │ ├── UIImage+GTChatKit.swift │ └── UITextView_GTChatKit.swift │ ├── GTChatNodeController.swift │ ├── GTChatNodeFlowLayout.swift │ └── Views │ ├── GTChatMessageBoxNode.swift │ ├── GTChatMessageButtonNode.swift │ └── GTChatMessageInputBoxNode.swift ├── LICENSE ├── README.md ├── _Pods.xcodeproj └── resource ├── append.gif ├── messageBoxActive.png ├── messageBoxInActive.png └── prepend.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # OS X 2 | .DS_Store 3 | 4 | # Xcode 5 | build/ 6 | *.pbxuser 7 | !default.pbxuser 8 | *.mode1v3 9 | !default.mode1v3 10 | *.mode2v3 11 | !default.mode2v3 12 | *.perspectivev3 13 | !default.perspectivev3 14 | xcuserdata/ 15 | *.xccheckout 16 | profile 17 | *.moved-aside 18 | DerivedData 19 | *.hmap 20 | *.ipa 21 | 22 | # Bundler 23 | .bundle 24 | 25 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 26 | # Carthage/Checkouts 27 | 28 | Carthage/Build 29 | 30 | # We recommend against adding the Pods directory to your .gitignore. However 31 | # you should judge for yourself, the pros and cons are mentioned at: 32 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 33 | # 34 | # Note: if you ignore the Pods directory, make sure to uncomment 35 | # `pod install` in .travis.yml 36 | # 37 | # Pods/ 38 | -------------------------------------------------------------------------------- /.swiftlint.yml: -------------------------------------------------------------------------------- 1 | excluded: # paths to ignore during linting. Takes precedence over `included`. 2 | - Pods 3 | - Tests 4 | 5 | # Rules 6 | disabled_rules: 7 | - trailing_whitespace 8 | - vertical_whitespace 9 | 10 | line_length: 120 11 | 12 | file_length: 13 | warning: 1000 14 | error: 1200 15 | 16 | identifier_name: 17 | excluded: 18 | - url 19 | - id 20 | - x 21 | - y -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | osx_image: xcode9.1 3 | 4 | cache: cocoapods 5 | podfile: Example/Podfile 6 | 7 | before_install: 8 | - brew bundle check $BREWFILE || brew bundle $BREWFILE || (brew update && brew bundle $BREWFILE) 9 | - gem install bundler --no-document 10 | - pod install --project-directory=Example 11 | 12 | #script: 13 | # - swiftlint 14 | 15 | branches: 16 | only: 17 | - master -------------------------------------------------------------------------------- /Brewfile: -------------------------------------------------------------------------------- 1 | brew "swiftlint" -------------------------------------------------------------------------------- /Example/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .Trashes 3 | *.lock 4 | Pods/ 5 | build/**/* 6 | -------------------------------------------------------------------------------- /Example/GTChatKit.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 4386545AAE4878AECC2A9E42 /* Pods_GTChatKit_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F63FBCACB72506A223A4520C /* Pods_GTChatKit_Example.framework */; }; 11 | 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; }; 12 | 607FACD81AFB9204008FA782 /* ChatNodeController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD71AFB9204008FA782 /* ChatNodeController.swift */; }; 13 | 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; }; 14 | 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; }; 15 | 607FACEC1AFB9204008FA782 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* Tests.swift */; }; 16 | 93F61BA486D11BA8989D2904 /* Pods_GTChatKit_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7F5A41D6F38F3CA88CB59024 /* Pods_GTChatKit_Tests.framework */; }; 17 | 9BB2E2112049228900F7B531 /* ChatCellNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BB2E2102049228900F7B531 /* ChatCellNode.swift */; }; 18 | 9BB2E213204923DC00F7B531 /* UIColor+extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BB2E212204923DC00F7B531 /* UIColor+extension.swift */; }; 19 | 9BD8FD952049428C00FD79A5 /* ChatLoadingIndicatorNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BD8FD942049428C00FD79A5 /* ChatLoadingIndicatorNode.swift */; }; 20 | 9BD8FDA12049897D00FD79A5 /* String+extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BD8FDA02049897D00FD79A5 /* String+extension.swift */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXContainerItemProxy section */ 24 | 607FACE61AFB9204008FA782 /* PBXContainerItemProxy */ = { 25 | isa = PBXContainerItemProxy; 26 | containerPortal = 607FACC81AFB9204008FA782 /* Project object */; 27 | proxyType = 1; 28 | remoteGlobalIDString = 607FACCF1AFB9204008FA782; 29 | remoteInfo = GTChatKit; 30 | }; 31 | /* End PBXContainerItemProxy section */ 32 | 33 | /* Begin PBXFileReference section */ 34 | 0A067D1A4EB354A2357CB3AE /* Pods-GTChatKit_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-GTChatKit_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-GTChatKit_Example/Pods-GTChatKit_Example.debug.xcconfig"; sourceTree = ""; }; 35 | 167F5C255AAD559BD1CEDFAB /* Pods-GTChatKit_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-GTChatKit_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-GTChatKit_Tests/Pods-GTChatKit_Tests.release.xcconfig"; sourceTree = ""; }; 36 | 5D8BB56EAD578BAD0B6540D2 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; 37 | 607FACD01AFB9204008FA782 /* GTChatKit_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GTChatKit_Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 38 | 607FACD41AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 39 | 607FACD51AFB9204008FA782 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 40 | 607FACD71AFB9204008FA782 /* ChatNodeController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatNodeController.swift; sourceTree = ""; }; 41 | 607FACDC1AFB9204008FA782 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 42 | 607FACDF1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 43 | 607FACE51AFB9204008FA782 /* GTChatKit_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GTChatKit_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 44 | 607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 45 | 607FACEB1AFB9204008FA782 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = ""; }; 46 | 7F5A41D6F38F3CA88CB59024 /* Pods_GTChatKit_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_GTChatKit_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 47 | 91E1DF4354FF047711399466 /* Pods-GTChatKit_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-GTChatKit_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-GTChatKit_Example/Pods-GTChatKit_Example.release.xcconfig"; sourceTree = ""; }; 48 | 982BBE882747B9EDF13205E6 /* GTChatKit.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = GTChatKit.podspec; path = ../GTChatKit.podspec; sourceTree = ""; }; 49 | 9BB2E2102049228900F7B531 /* ChatCellNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatCellNode.swift; sourceTree = ""; }; 50 | 9BB2E212204923DC00F7B531 /* UIColor+extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+extension.swift"; sourceTree = ""; }; 51 | 9BD8FD942049428C00FD79A5 /* ChatLoadingIndicatorNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatLoadingIndicatorNode.swift; sourceTree = ""; }; 52 | 9BD8FDA02049897D00FD79A5 /* String+extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+extension.swift"; sourceTree = ""; }; 53 | ADF7DEAED2FA41632D6589DA /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; 54 | F63FBCACB72506A223A4520C /* Pods_GTChatKit_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_GTChatKit_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 55 | F665CC749B98012C3F8C38C3 /* Pods-GTChatKit_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-GTChatKit_Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-GTChatKit_Tests/Pods-GTChatKit_Tests.debug.xcconfig"; sourceTree = ""; }; 56 | /* End PBXFileReference section */ 57 | 58 | /* Begin PBXFrameworksBuildPhase section */ 59 | 607FACCD1AFB9204008FA782 /* Frameworks */ = { 60 | isa = PBXFrameworksBuildPhase; 61 | buildActionMask = 2147483647; 62 | files = ( 63 | 4386545AAE4878AECC2A9E42 /* Pods_GTChatKit_Example.framework in Frameworks */, 64 | ); 65 | runOnlyForDeploymentPostprocessing = 0; 66 | }; 67 | 607FACE21AFB9204008FA782 /* Frameworks */ = { 68 | isa = PBXFrameworksBuildPhase; 69 | buildActionMask = 2147483647; 70 | files = ( 71 | 93F61BA486D11BA8989D2904 /* Pods_GTChatKit_Tests.framework in Frameworks */, 72 | ); 73 | runOnlyForDeploymentPostprocessing = 0; 74 | }; 75 | /* End PBXFrameworksBuildPhase section */ 76 | 77 | /* Begin PBXGroup section */ 78 | 4F19E21A00B1E2EF242DC3BD /* Pods */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | 0A067D1A4EB354A2357CB3AE /* Pods-GTChatKit_Example.debug.xcconfig */, 82 | 91E1DF4354FF047711399466 /* Pods-GTChatKit_Example.release.xcconfig */, 83 | F665CC749B98012C3F8C38C3 /* Pods-GTChatKit_Tests.debug.xcconfig */, 84 | 167F5C255AAD559BD1CEDFAB /* Pods-GTChatKit_Tests.release.xcconfig */, 85 | ); 86 | name = Pods; 87 | sourceTree = ""; 88 | }; 89 | 607FACC71AFB9204008FA782 = { 90 | isa = PBXGroup; 91 | children = ( 92 | 607FACF51AFB993E008FA782 /* Podspec Metadata */, 93 | 607FACD21AFB9204008FA782 /* Example for GTChatKit */, 94 | 607FACE81AFB9204008FA782 /* Tests */, 95 | 607FACD11AFB9204008FA782 /* Products */, 96 | 4F19E21A00B1E2EF242DC3BD /* Pods */, 97 | 930A48B8D1872C973E50222C /* Frameworks */, 98 | ); 99 | sourceTree = ""; 100 | }; 101 | 607FACD11AFB9204008FA782 /* Products */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | 607FACD01AFB9204008FA782 /* GTChatKit_Example.app */, 105 | 607FACE51AFB9204008FA782 /* GTChatKit_Tests.xctest */, 106 | ); 107 | name = Products; 108 | sourceTree = ""; 109 | }; 110 | 607FACD21AFB9204008FA782 /* Example for GTChatKit */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | 9BD8FD982049462A00FD79A5 /* Extensions */, 114 | 9BD8FD972049462500FD79A5 /* Controllers */, 115 | 9BD8FD962049462000FD79A5 /* Views */, 116 | 607FACD51AFB9204008FA782 /* AppDelegate.swift */, 117 | 607FACDC1AFB9204008FA782 /* Images.xcassets */, 118 | 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */, 119 | 607FACD31AFB9204008FA782 /* Supporting Files */, 120 | ); 121 | name = "Example for GTChatKit"; 122 | path = GTChatKit; 123 | sourceTree = ""; 124 | }; 125 | 607FACD31AFB9204008FA782 /* Supporting Files */ = { 126 | isa = PBXGroup; 127 | children = ( 128 | 607FACD41AFB9204008FA782 /* Info.plist */, 129 | ); 130 | name = "Supporting Files"; 131 | sourceTree = ""; 132 | }; 133 | 607FACE81AFB9204008FA782 /* Tests */ = { 134 | isa = PBXGroup; 135 | children = ( 136 | 607FACEB1AFB9204008FA782 /* Tests.swift */, 137 | 607FACE91AFB9204008FA782 /* Supporting Files */, 138 | ); 139 | path = Tests; 140 | sourceTree = ""; 141 | }; 142 | 607FACE91AFB9204008FA782 /* Supporting Files */ = { 143 | isa = PBXGroup; 144 | children = ( 145 | 607FACEA1AFB9204008FA782 /* Info.plist */, 146 | ); 147 | name = "Supporting Files"; 148 | sourceTree = ""; 149 | }; 150 | 607FACF51AFB993E008FA782 /* Podspec Metadata */ = { 151 | isa = PBXGroup; 152 | children = ( 153 | 982BBE882747B9EDF13205E6 /* GTChatKit.podspec */, 154 | ADF7DEAED2FA41632D6589DA /* README.md */, 155 | 5D8BB56EAD578BAD0B6540D2 /* LICENSE */, 156 | ); 157 | name = "Podspec Metadata"; 158 | sourceTree = ""; 159 | }; 160 | 930A48B8D1872C973E50222C /* Frameworks */ = { 161 | isa = PBXGroup; 162 | children = ( 163 | F63FBCACB72506A223A4520C /* Pods_GTChatKit_Example.framework */, 164 | 7F5A41D6F38F3CA88CB59024 /* Pods_GTChatKit_Tests.framework */, 165 | ); 166 | name = Frameworks; 167 | sourceTree = ""; 168 | }; 169 | 9BD8FD962049462000FD79A5 /* Views */ = { 170 | isa = PBXGroup; 171 | children = ( 172 | 9BB2E2102049228900F7B531 /* ChatCellNode.swift */, 173 | 9BD8FD942049428C00FD79A5 /* ChatLoadingIndicatorNode.swift */, 174 | ); 175 | name = Views; 176 | sourceTree = ""; 177 | }; 178 | 9BD8FD972049462500FD79A5 /* Controllers */ = { 179 | isa = PBXGroup; 180 | children = ( 181 | 607FACD71AFB9204008FA782 /* ChatNodeController.swift */, 182 | ); 183 | name = Controllers; 184 | sourceTree = ""; 185 | }; 186 | 9BD8FD982049462A00FD79A5 /* Extensions */ = { 187 | isa = PBXGroup; 188 | children = ( 189 | 9BB2E212204923DC00F7B531 /* UIColor+extension.swift */, 190 | 9BD8FDA02049897D00FD79A5 /* String+extension.swift */, 191 | ); 192 | name = Extensions; 193 | sourceTree = ""; 194 | }; 195 | /* End PBXGroup section */ 196 | 197 | /* Begin PBXNativeTarget section */ 198 | 607FACCF1AFB9204008FA782 /* GTChatKit_Example */ = { 199 | isa = PBXNativeTarget; 200 | buildConfigurationList = 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "GTChatKit_Example" */; 201 | buildPhases = ( 202 | 1A830048CC1351F5D34082FD /* [CP] Check Pods Manifest.lock */, 203 | 607FACCC1AFB9204008FA782 /* Sources */, 204 | 607FACCD1AFB9204008FA782 /* Frameworks */, 205 | 607FACCE1AFB9204008FA782 /* Resources */, 206 | 920B6A0FE6CC7323F151C241 /* [CP] Embed Pods Frameworks */, 207 | A67BBF1F9071D4CEBD79E445 /* [CP] Copy Pods Resources */, 208 | ); 209 | buildRules = ( 210 | ); 211 | dependencies = ( 212 | ); 213 | name = GTChatKit_Example; 214 | productName = GTChatKit; 215 | productReference = 607FACD01AFB9204008FA782 /* GTChatKit_Example.app */; 216 | productType = "com.apple.product-type.application"; 217 | }; 218 | 607FACE41AFB9204008FA782 /* GTChatKit_Tests */ = { 219 | isa = PBXNativeTarget; 220 | buildConfigurationList = 607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "GTChatKit_Tests" */; 221 | buildPhases = ( 222 | 5C5421F32ECBC0622E21AB98 /* [CP] Check Pods Manifest.lock */, 223 | 607FACE11AFB9204008FA782 /* Sources */, 224 | 607FACE21AFB9204008FA782 /* Frameworks */, 225 | 607FACE31AFB9204008FA782 /* Resources */, 226 | AF1087CF9A6FCDABF7A5943C /* [CP] Embed Pods Frameworks */, 227 | 61998261350B21DA4A7D9A88 /* [CP] Copy Pods Resources */, 228 | ); 229 | buildRules = ( 230 | ); 231 | dependencies = ( 232 | 607FACE71AFB9204008FA782 /* PBXTargetDependency */, 233 | ); 234 | name = GTChatKit_Tests; 235 | productName = Tests; 236 | productReference = 607FACE51AFB9204008FA782 /* GTChatKit_Tests.xctest */; 237 | productType = "com.apple.product-type.bundle.unit-test"; 238 | }; 239 | /* End PBXNativeTarget section */ 240 | 241 | /* Begin PBXProject section */ 242 | 607FACC81AFB9204008FA782 /* Project object */ = { 243 | isa = PBXProject; 244 | attributes = { 245 | LastSwiftUpdateCheck = 0830; 246 | LastUpgradeCheck = 0830; 247 | ORGANIZATIONNAME = CocoaPods; 248 | TargetAttributes = { 249 | 607FACCF1AFB9204008FA782 = { 250 | CreatedOnToolsVersion = 6.3.1; 251 | DevelopmentTeam = JTEXWEH4CZ; 252 | LastSwiftMigration = 0900; 253 | }; 254 | 607FACE41AFB9204008FA782 = { 255 | CreatedOnToolsVersion = 6.3.1; 256 | DevelopmentTeam = JTEXWEH4CZ; 257 | LastSwiftMigration = 0900; 258 | ProvisioningStyle = Automatic; 259 | TestTargetID = 607FACCF1AFB9204008FA782; 260 | }; 261 | }; 262 | }; 263 | buildConfigurationList = 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "GTChatKit" */; 264 | compatibilityVersion = "Xcode 3.2"; 265 | developmentRegion = English; 266 | hasScannedForEncodings = 0; 267 | knownRegions = ( 268 | en, 269 | Base, 270 | ); 271 | mainGroup = 607FACC71AFB9204008FA782; 272 | productRefGroup = 607FACD11AFB9204008FA782 /* Products */; 273 | projectDirPath = ""; 274 | projectRoot = ""; 275 | targets = ( 276 | 607FACCF1AFB9204008FA782 /* GTChatKit_Example */, 277 | 607FACE41AFB9204008FA782 /* GTChatKit_Tests */, 278 | ); 279 | }; 280 | /* End PBXProject section */ 281 | 282 | /* Begin PBXResourcesBuildPhase section */ 283 | 607FACCE1AFB9204008FA782 /* Resources */ = { 284 | isa = PBXResourcesBuildPhase; 285 | buildActionMask = 2147483647; 286 | files = ( 287 | 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */, 288 | 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */, 289 | ); 290 | runOnlyForDeploymentPostprocessing = 0; 291 | }; 292 | 607FACE31AFB9204008FA782 /* Resources */ = { 293 | isa = PBXResourcesBuildPhase; 294 | buildActionMask = 2147483647; 295 | files = ( 296 | ); 297 | runOnlyForDeploymentPostprocessing = 0; 298 | }; 299 | /* End PBXResourcesBuildPhase section */ 300 | 301 | /* Begin PBXShellScriptBuildPhase section */ 302 | 1A830048CC1351F5D34082FD /* [CP] Check Pods Manifest.lock */ = { 303 | isa = PBXShellScriptBuildPhase; 304 | buildActionMask = 2147483647; 305 | files = ( 306 | ); 307 | inputPaths = ( 308 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 309 | "${PODS_ROOT}/Manifest.lock", 310 | ); 311 | name = "[CP] Check Pods Manifest.lock"; 312 | outputPaths = ( 313 | "$(DERIVED_FILE_DIR)/Pods-GTChatKit_Example-checkManifestLockResult.txt", 314 | ); 315 | runOnlyForDeploymentPostprocessing = 0; 316 | shellPath = /bin/sh; 317 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 318 | showEnvVarsInLog = 0; 319 | }; 320 | 5C5421F32ECBC0622E21AB98 /* [CP] Check Pods Manifest.lock */ = { 321 | isa = PBXShellScriptBuildPhase; 322 | buildActionMask = 2147483647; 323 | files = ( 324 | ); 325 | inputPaths = ( 326 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 327 | "${PODS_ROOT}/Manifest.lock", 328 | ); 329 | name = "[CP] Check Pods Manifest.lock"; 330 | outputPaths = ( 331 | "$(DERIVED_FILE_DIR)/Pods-GTChatKit_Tests-checkManifestLockResult.txt", 332 | ); 333 | runOnlyForDeploymentPostprocessing = 0; 334 | shellPath = /bin/sh; 335 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 336 | showEnvVarsInLog = 0; 337 | }; 338 | 61998261350B21DA4A7D9A88 /* [CP] Copy Pods Resources */ = { 339 | isa = PBXShellScriptBuildPhase; 340 | buildActionMask = 2147483647; 341 | files = ( 342 | ); 343 | inputPaths = ( 344 | ); 345 | name = "[CP] Copy Pods Resources"; 346 | outputPaths = ( 347 | ); 348 | runOnlyForDeploymentPostprocessing = 0; 349 | shellPath = /bin/sh; 350 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-GTChatKit_Tests/Pods-GTChatKit_Tests-resources.sh\"\n"; 351 | showEnvVarsInLog = 0; 352 | }; 353 | 920B6A0FE6CC7323F151C241 /* [CP] Embed Pods Frameworks */ = { 354 | isa = PBXShellScriptBuildPhase; 355 | buildActionMask = 2147483647; 356 | files = ( 357 | ); 358 | inputPaths = ( 359 | "${SRCROOT}/Pods/Target Support Files/Pods-GTChatKit_Example/Pods-GTChatKit_Example-frameworks.sh", 360 | "${BUILT_PRODUCTS_DIR}/GTChatKit/GTChatKit.framework", 361 | "${BUILT_PRODUCTS_DIR}/PINCache/PINCache.framework", 362 | "${BUILT_PRODUCTS_DIR}/PINOperation/PINOperation.framework", 363 | "${BUILT_PRODUCTS_DIR}/PINRemoteImage/PINRemoteImage.framework", 364 | "${BUILT_PRODUCTS_DIR}/Texture/AsyncDisplayKit.framework", 365 | ); 366 | name = "[CP] Embed Pods Frameworks"; 367 | outputPaths = ( 368 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GTChatKit.framework", 369 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PINCache.framework", 370 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PINOperation.framework", 371 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PINRemoteImage.framework", 372 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AsyncDisplayKit.framework", 373 | ); 374 | runOnlyForDeploymentPostprocessing = 0; 375 | shellPath = /bin/sh; 376 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-GTChatKit_Example/Pods-GTChatKit_Example-frameworks.sh\"\n"; 377 | showEnvVarsInLog = 0; 378 | }; 379 | A67BBF1F9071D4CEBD79E445 /* [CP] Copy Pods Resources */ = { 380 | isa = PBXShellScriptBuildPhase; 381 | buildActionMask = 2147483647; 382 | files = ( 383 | ); 384 | inputPaths = ( 385 | ); 386 | name = "[CP] Copy Pods Resources"; 387 | outputPaths = ( 388 | ); 389 | runOnlyForDeploymentPostprocessing = 0; 390 | shellPath = /bin/sh; 391 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-GTChatKit_Example/Pods-GTChatKit_Example-resources.sh\"\n"; 392 | showEnvVarsInLog = 0; 393 | }; 394 | AF1087CF9A6FCDABF7A5943C /* [CP] Embed Pods Frameworks */ = { 395 | isa = PBXShellScriptBuildPhase; 396 | buildActionMask = 2147483647; 397 | files = ( 398 | ); 399 | inputPaths = ( 400 | "${SRCROOT}/Pods/Target Support Files/Pods-GTChatKit_Tests/Pods-GTChatKit_Tests-frameworks.sh", 401 | "${BUILT_PRODUCTS_DIR}/Nimble/Nimble.framework", 402 | "${BUILT_PRODUCTS_DIR}/Quick/Quick.framework", 403 | ); 404 | name = "[CP] Embed Pods Frameworks"; 405 | outputPaths = ( 406 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Nimble.framework", 407 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Quick.framework", 408 | ); 409 | runOnlyForDeploymentPostprocessing = 0; 410 | shellPath = /bin/sh; 411 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-GTChatKit_Tests/Pods-GTChatKit_Tests-frameworks.sh\"\n"; 412 | showEnvVarsInLog = 0; 413 | }; 414 | /* End PBXShellScriptBuildPhase section */ 415 | 416 | /* Begin PBXSourcesBuildPhase section */ 417 | 607FACCC1AFB9204008FA782 /* Sources */ = { 418 | isa = PBXSourcesBuildPhase; 419 | buildActionMask = 2147483647; 420 | files = ( 421 | 607FACD81AFB9204008FA782 /* ChatNodeController.swift in Sources */, 422 | 9BB2E2112049228900F7B531 /* ChatCellNode.swift in Sources */, 423 | 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */, 424 | 9BB2E213204923DC00F7B531 /* UIColor+extension.swift in Sources */, 425 | 9BD8FDA12049897D00FD79A5 /* String+extension.swift in Sources */, 426 | 9BD8FD952049428C00FD79A5 /* ChatLoadingIndicatorNode.swift in Sources */, 427 | ); 428 | runOnlyForDeploymentPostprocessing = 0; 429 | }; 430 | 607FACE11AFB9204008FA782 /* Sources */ = { 431 | isa = PBXSourcesBuildPhase; 432 | buildActionMask = 2147483647; 433 | files = ( 434 | 607FACEC1AFB9204008FA782 /* Tests.swift in Sources */, 435 | ); 436 | runOnlyForDeploymentPostprocessing = 0; 437 | }; 438 | /* End PBXSourcesBuildPhase section */ 439 | 440 | /* Begin PBXTargetDependency section */ 441 | 607FACE71AFB9204008FA782 /* PBXTargetDependency */ = { 442 | isa = PBXTargetDependency; 443 | target = 607FACCF1AFB9204008FA782 /* GTChatKit_Example */; 444 | targetProxy = 607FACE61AFB9204008FA782 /* PBXContainerItemProxy */; 445 | }; 446 | /* End PBXTargetDependency section */ 447 | 448 | /* Begin PBXVariantGroup section */ 449 | 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */ = { 450 | isa = PBXVariantGroup; 451 | children = ( 452 | 607FACDF1AFB9204008FA782 /* Base */, 453 | ); 454 | name = LaunchScreen.xib; 455 | sourceTree = ""; 456 | }; 457 | /* End PBXVariantGroup section */ 458 | 459 | /* Begin XCBuildConfiguration section */ 460 | 607FACED1AFB9204008FA782 /* Debug */ = { 461 | isa = XCBuildConfiguration; 462 | buildSettings = { 463 | ALWAYS_SEARCH_USER_PATHS = NO; 464 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 465 | CLANG_CXX_LIBRARY = "libc++"; 466 | CLANG_ENABLE_MODULES = YES; 467 | CLANG_ENABLE_OBJC_ARC = YES; 468 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 469 | CLANG_WARN_BOOL_CONVERSION = YES; 470 | CLANG_WARN_COMMA = YES; 471 | CLANG_WARN_CONSTANT_CONVERSION = YES; 472 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 473 | CLANG_WARN_EMPTY_BODY = YES; 474 | CLANG_WARN_ENUM_CONVERSION = YES; 475 | CLANG_WARN_INFINITE_RECURSION = YES; 476 | CLANG_WARN_INT_CONVERSION = YES; 477 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 478 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 479 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 480 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 481 | CLANG_WARN_STRICT_PROTOTYPES = YES; 482 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 483 | CLANG_WARN_UNREACHABLE_CODE = YES; 484 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 485 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 486 | COPY_PHASE_STRIP = NO; 487 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 488 | ENABLE_STRICT_OBJC_MSGSEND = YES; 489 | ENABLE_TESTABILITY = YES; 490 | GCC_C_LANGUAGE_STANDARD = gnu99; 491 | GCC_DYNAMIC_NO_PIC = NO; 492 | GCC_NO_COMMON_BLOCKS = YES; 493 | GCC_OPTIMIZATION_LEVEL = 0; 494 | GCC_PREPROCESSOR_DEFINITIONS = ( 495 | "DEBUG=1", 496 | "$(inherited)", 497 | ); 498 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 499 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 500 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 501 | GCC_WARN_UNDECLARED_SELECTOR = YES; 502 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 503 | GCC_WARN_UNUSED_FUNCTION = YES; 504 | GCC_WARN_UNUSED_VARIABLE = YES; 505 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 506 | MTL_ENABLE_DEBUG_INFO = YES; 507 | ONLY_ACTIVE_ARCH = YES; 508 | SDKROOT = iphoneos; 509 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 510 | SWIFT_VERSION = 4.0; 511 | }; 512 | name = Debug; 513 | }; 514 | 607FACEE1AFB9204008FA782 /* Release */ = { 515 | isa = XCBuildConfiguration; 516 | buildSettings = { 517 | ALWAYS_SEARCH_USER_PATHS = NO; 518 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 519 | CLANG_CXX_LIBRARY = "libc++"; 520 | CLANG_ENABLE_MODULES = YES; 521 | CLANG_ENABLE_OBJC_ARC = YES; 522 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 523 | CLANG_WARN_BOOL_CONVERSION = YES; 524 | CLANG_WARN_COMMA = YES; 525 | CLANG_WARN_CONSTANT_CONVERSION = YES; 526 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 527 | CLANG_WARN_EMPTY_BODY = YES; 528 | CLANG_WARN_ENUM_CONVERSION = YES; 529 | CLANG_WARN_INFINITE_RECURSION = YES; 530 | CLANG_WARN_INT_CONVERSION = YES; 531 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 532 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 533 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 534 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 535 | CLANG_WARN_STRICT_PROTOTYPES = YES; 536 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 537 | CLANG_WARN_UNREACHABLE_CODE = YES; 538 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 539 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 540 | COPY_PHASE_STRIP = NO; 541 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 542 | ENABLE_NS_ASSERTIONS = NO; 543 | ENABLE_STRICT_OBJC_MSGSEND = YES; 544 | GCC_C_LANGUAGE_STANDARD = gnu99; 545 | GCC_NO_COMMON_BLOCKS = YES; 546 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 547 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 548 | GCC_WARN_UNDECLARED_SELECTOR = YES; 549 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 550 | GCC_WARN_UNUSED_FUNCTION = YES; 551 | GCC_WARN_UNUSED_VARIABLE = YES; 552 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 553 | MTL_ENABLE_DEBUG_INFO = NO; 554 | SDKROOT = iphoneos; 555 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 556 | SWIFT_VERSION = 4.0; 557 | VALIDATE_PRODUCT = YES; 558 | }; 559 | name = Release; 560 | }; 561 | 607FACF01AFB9204008FA782 /* Debug */ = { 562 | isa = XCBuildConfiguration; 563 | baseConfigurationReference = 0A067D1A4EB354A2357CB3AE /* Pods-GTChatKit_Example.debug.xcconfig */; 564 | buildSettings = { 565 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 566 | DEVELOPMENT_TEAM = JTEXWEH4CZ; 567 | INFOPLIST_FILE = GTChatKit/Info.plist; 568 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 569 | MODULE_NAME = ExampleApp; 570 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; 571 | PRODUCT_NAME = "$(TARGET_NAME)"; 572 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 573 | SWIFT_VERSION = 4.0; 574 | }; 575 | name = Debug; 576 | }; 577 | 607FACF11AFB9204008FA782 /* Release */ = { 578 | isa = XCBuildConfiguration; 579 | baseConfigurationReference = 91E1DF4354FF047711399466 /* Pods-GTChatKit_Example.release.xcconfig */; 580 | buildSettings = { 581 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 582 | DEVELOPMENT_TEAM = JTEXWEH4CZ; 583 | INFOPLIST_FILE = GTChatKit/Info.plist; 584 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 585 | MODULE_NAME = ExampleApp; 586 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; 587 | PRODUCT_NAME = "$(TARGET_NAME)"; 588 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 589 | SWIFT_VERSION = 4.0; 590 | }; 591 | name = Release; 592 | }; 593 | 607FACF31AFB9204008FA782 /* Debug */ = { 594 | isa = XCBuildConfiguration; 595 | baseConfigurationReference = F665CC749B98012C3F8C38C3 /* Pods-GTChatKit_Tests.debug.xcconfig */; 596 | buildSettings = { 597 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 598 | CODE_SIGN_STYLE = Automatic; 599 | DEVELOPMENT_TEAM = JTEXWEH4CZ; 600 | FRAMEWORK_SEARCH_PATHS = ( 601 | "$(SDKROOT)/Developer/Library/Frameworks", 602 | "$(inherited)", 603 | ); 604 | GCC_PREPROCESSOR_DEFINITIONS = ( 605 | "DEBUG=1", 606 | "$(inherited)", 607 | ); 608 | INFOPLIST_FILE = Tests/Info.plist; 609 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 610 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; 611 | PRODUCT_NAME = "$(TARGET_NAME)"; 612 | PROVISIONING_PROFILE_SPECIFIER = ""; 613 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 614 | SWIFT_VERSION = 4.0; 615 | }; 616 | name = Debug; 617 | }; 618 | 607FACF41AFB9204008FA782 /* Release */ = { 619 | isa = XCBuildConfiguration; 620 | baseConfigurationReference = 167F5C255AAD559BD1CEDFAB /* Pods-GTChatKit_Tests.release.xcconfig */; 621 | buildSettings = { 622 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 623 | CODE_SIGN_STYLE = Automatic; 624 | DEVELOPMENT_TEAM = JTEXWEH4CZ; 625 | FRAMEWORK_SEARCH_PATHS = ( 626 | "$(SDKROOT)/Developer/Library/Frameworks", 627 | "$(inherited)", 628 | ); 629 | INFOPLIST_FILE = Tests/Info.plist; 630 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 631 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; 632 | PRODUCT_NAME = "$(TARGET_NAME)"; 633 | PROVISIONING_PROFILE_SPECIFIER = ""; 634 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 635 | SWIFT_VERSION = 4.0; 636 | }; 637 | name = Release; 638 | }; 639 | /* End XCBuildConfiguration section */ 640 | 641 | /* Begin XCConfigurationList section */ 642 | 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "GTChatKit" */ = { 643 | isa = XCConfigurationList; 644 | buildConfigurations = ( 645 | 607FACED1AFB9204008FA782 /* Debug */, 646 | 607FACEE1AFB9204008FA782 /* Release */, 647 | ); 648 | defaultConfigurationIsVisible = 0; 649 | defaultConfigurationName = Release; 650 | }; 651 | 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "GTChatKit_Example" */ = { 652 | isa = XCConfigurationList; 653 | buildConfigurations = ( 654 | 607FACF01AFB9204008FA782 /* Debug */, 655 | 607FACF11AFB9204008FA782 /* Release */, 656 | ); 657 | defaultConfigurationIsVisible = 0; 658 | defaultConfigurationName = Release; 659 | }; 660 | 607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "GTChatKit_Tests" */ = { 661 | isa = XCConfigurationList; 662 | buildConfigurations = ( 663 | 607FACF31AFB9204008FA782 /* Debug */, 664 | 607FACF41AFB9204008FA782 /* Release */, 665 | ); 666 | defaultConfigurationIsVisible = 0; 667 | defaultConfigurationName = Release; 668 | }; 669 | /* End XCConfigurationList section */ 670 | }; 671 | rootObject = 607FACC81AFB9204008FA782 /* Project object */; 672 | } 673 | -------------------------------------------------------------------------------- /Example/GTChatKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/GTChatKit.xcodeproj/xcshareddata/xcschemes/GTChatKit-Example.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 45 | 46 | 48 | 54 | 55 | 56 | 57 | 58 | 64 | 65 | 66 | 67 | 68 | 69 | 80 | 82 | 88 | 89 | 90 | 91 | 92 | 93 | 99 | 101 | 107 | 108 | 109 | 110 | 112 | 113 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /Example/GTChatKit.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Example/GTChatKit/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // GTChatKit 4 | // 5 | // Created by Geektree0101 on 18/03/02. 6 | // Copyright © 2018 Geektree0101 All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import GTChatKit 11 | 12 | @UIApplicationMain 13 | class AppDelegate: UIResponder, UIApplicationDelegate { 14 | 15 | var window: UIWindow? 16 | 17 | 18 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 19 | // Override point for customization after application launch. 20 | UINavigationBar.appearance().barTintColor = UIColor.navigationBarColor 21 | UINavigationBar.appearance().tintColor = .white 22 | UINavigationBar.appearance().titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.white] 23 | 24 | 25 | self.window = UIWindow() 26 | let rootViewController = ChatNodeController() 27 | let navigationController = UINavigationController(rootViewController: rootViewController) 28 | 29 | self.window?.rootViewController = navigationController 30 | self.window?.makeKeyAndVisible() 31 | return true 32 | } 33 | 34 | func applicationWillResignActive(_ application: UIApplication) { 35 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 36 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 37 | } 38 | 39 | func applicationDidEnterBackground(_ application: UIApplication) { 40 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 41 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 42 | } 43 | 44 | func applicationWillEnterForeground(_ application: UIApplication) { 45 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 46 | } 47 | 48 | func applicationDidBecomeActive(_ application: UIApplication) { 49 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 50 | } 51 | 52 | func applicationWillTerminate(_ application: UIApplication) { 53 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 54 | } 55 | 56 | 57 | } 58 | 59 | -------------------------------------------------------------------------------- /Example/GTChatKit/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 25 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /Example/GTChatKit/ChatCellNode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ChatCellNode.swift 3 | // GTChatKit 4 | // 5 | // Created by Geektree0101 on 18/03/02. 6 | // Copyright © 2018 Geektree0101 All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import AsyncDisplayKit 11 | 12 | class ChatCellNode: ASCellNode { 13 | typealias ATString = NSAttributedString 14 | typealias Node = ChatCellNode 15 | 16 | let gfriend = String.gfriend 17 | 18 | lazy var profileImageNode: ASNetworkImageNode = { 19 | let node = ASNetworkImageNode() 20 | node.image = UIImage(named: self.gfriend) 21 | node.style.preferredSize = .init(width: 50.0, height: 50.0) 22 | node.clipsToBounds = true 23 | node.borderColor = UIColor.otherChat.cgColor 24 | node.cornerRadius = 25.0 25 | node.borderWidth = 1.0 26 | 27 | return node 28 | }() 29 | 30 | lazy var usernameNode: ASTextNode = { 31 | let node = ASTextNode() 32 | return node 33 | }() 34 | 35 | lazy var balloonNode: ASDisplayNode = { 36 | let node = ASDisplayNode() 37 | node.style.height = .init(unit: .points, value: 50.0) 38 | node.cornerRadius = 25.0 39 | node.style.maxWidth = .init(unit: .points, 40 | value: UIScreen.main.bounds.width / 2) 41 | let isMyChat: Bool = self.contentPosition == .left 42 | node.backgroundColor = isMyChat ? .otherChat: .myChat 43 | node.clipsToBounds = true 44 | return node 45 | }() 46 | 47 | lazy var contentNode: ASTextNode = { 48 | let node = ASTextNode() 49 | node.style.flexShrink = 1.0 50 | return node 51 | }() 52 | 53 | enum Position { 54 | case left 55 | case right 56 | } 57 | 58 | private let contentPosition: Position 59 | 60 | init(_ pos: Position) { 61 | self.contentPosition = pos 62 | super.init() 63 | 64 | self.contentNode.attributedText = 65 | ATString(string: String.randomMessage, 66 | attributes: Node.contentAttributes) 67 | 68 | self.usernameNode.attributedText = 69 | ATString(string: gfriend, 70 | attributes: Node.usernameAttributes) 71 | self.automaticallyManagesSubnodes = true 72 | } 73 | 74 | override func layoutSpecThatFits(_ constrainedSize: ASSizeRange) -> ASLayoutSpec { 75 | let contentCenterLayout = ASCenterLayoutSpec(centeringOptions: .XY, 76 | sizingOptions: [], 77 | child: contentNode) 78 | 79 | let contentOverlayedBalloonLayout = ASOverlayLayoutSpec(child: balloonNode, 80 | overlay: contentCenterLayout) 81 | 82 | let isLeft = self.contentPosition == .left 83 | 84 | let layoutInsets = UIEdgeInsetsMake(15.0, 85 | isLeft ? 15.0: .infinity, 86 | 0.0, 87 | isLeft ? .infinity: 15.0) 88 | 89 | if isLeft { 90 | let usernameWithProfileImageLayout = ASStackLayoutSpec(direction: .vertical, 91 | spacing: 5.0, 92 | justifyContent: .start, 93 | alignItems: .center, 94 | children: [profileImageNode, 95 | usernameNode]) 96 | 97 | let profileAttachBalloonLayout = ASStackLayoutSpec(direction: .horizontal, 98 | spacing: 10.0, 99 | justifyContent: .start, 100 | alignItems: .center, 101 | children: [usernameWithProfileImageLayout, contentOverlayedBalloonLayout]) 102 | 103 | return ASInsetLayoutSpec(insets: layoutInsets, 104 | child: profileAttachBalloonLayout) 105 | 106 | } else { 107 | return ASInsetLayoutSpec(insets: layoutInsets, 108 | child: contentOverlayedBalloonLayout) 109 | } 110 | 111 | } 112 | } 113 | 114 | extension ChatCellNode { 115 | static var usernameAttributes: [NSAttributedStringKey: Any] { 116 | return [NSAttributedStringKey.font: UIFont.systemFont(ofSize: 12.0), 117 | NSAttributedStringKey.foregroundColor: UIColor.darkGray] 118 | } 119 | 120 | static var contentAttributes: [NSAttributedStringKey: Any] { 121 | return [NSAttributedStringKey.font: UIFont.systemFont(ofSize: 15.0), 122 | NSAttributedStringKey.foregroundColor: UIColor.white] 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /Example/GTChatKit/ChatLoadingIndicatorNode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ChatIndicatorNode.swift 3 | // GTChatKit_Example 4 | // 5 | // Created by Geektree0101 on 18/03/02. 6 | // Copyright © 2018 Geektree0101 All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import AsyncDisplayKit 11 | import UIKit 12 | 13 | class ChatLoadingIndicatorNode: ASCellNode { 14 | 15 | lazy var indicatorNode: ASDisplayNode = { 16 | let node = ASDisplayNode(viewBlock: { 17 | let view = UIActivityIndicatorView(activityIndicatorStyle: .gray) 18 | view.hidesWhenStopped = true 19 | return view 20 | }) 21 | return node 22 | }() 23 | 24 | override init() { 25 | super.init() 26 | self.automaticallyManagesSubnodes = true 27 | self.style.preferredSize = .init(width: UIScreen.main.bounds.width, height: 100.0) 28 | } 29 | 30 | override func layoutSpecThatFits(_ constrainedSize: ASSizeRange) -> ASLayoutSpec { 31 | return ASCenterLayoutSpec(centeringOptions: .XY, 32 | sizingOptions: [], 33 | child: indicatorNode) 34 | } 35 | 36 | override func didEnterVisibleState() { 37 | super.didEnterVisibleState() 38 | guard let view = indicatorNode.view as? UIActivityIndicatorView else { return } 39 | view.startAnimating() 40 | view.transform = CGAffineTransform(scaleX: 0, y: 0) 41 | UIView.animate(withDuration: 0.5, animations: { 42 | view.transform = CGAffineTransform(scaleX: 2.0, y: 2.0) 43 | }) 44 | } 45 | 46 | override func didExitVisibleState() { 47 | super.didExitVisibleState() 48 | guard let view = indicatorNode.view as? UIActivityIndicatorView else { return } 49 | view.stopAnimating() 50 | UIView.animate(withDuration: 0.5, animations: { 51 | view.transform = CGAffineTransform(scaleX: 0, y: 0) 52 | }) 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Example/GTChatKit/ChatNodeController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // GTChatKit 4 | // 5 | // Created by Geektree0101 on 18/03/02. 6 | // Copyright © 2018 Geektree0101 All rights reserved. 7 | // 8 | 9 | import AsyncDisplayKit 10 | import GTChatKit 11 | 12 | class ChatNodeController: GTChatNodeController { 13 | 14 | var items: [Int] = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59] 15 | 16 | lazy var messageNode: GTChatMessageBoxNode = { 17 | let node = GTChatMessageBoxNode() 18 | node.setupDefaultMessageBox() 19 | return node 20 | }() 21 | 22 | private var keyboardHeight: CGFloat = 0.0 23 | 24 | enum Section: Int { 25 | case prependIndicator 26 | case messages 27 | case appendIndicator 28 | } 29 | 30 | struct Const { 31 | static let maxiumRange: Int = 100 32 | static let minimumRange: Int = 0 33 | static let forceLoadDelay: TimeInterval = 2.0 34 | static let moreItemCount: Int = 10 35 | } 36 | 37 | override func viewDidLoad() { 38 | super.viewDidLoad() 39 | self.leadingScreensForBatching = 3.0 40 | self.chatNode.delegate = self 41 | self.chatNode.dataSource = self 42 | self.title = "Buddy Chat" 43 | self.chatNode.backgroundColor = .white 44 | } 45 | 46 | override func layoutSpecThatFits(_ constrainedSize: ASSizeRange, chatNode: ASCollectionNode) -> ASLayoutSpec { 47 | let messageInsets: UIEdgeInsets = .init(top: .infinity, 48 | left: 0.0, 49 | bottom: self.keyboardVisibleHeight + 0.0, 50 | right: 0.0) 51 | let messageLayout = ASInsetLayoutSpec(insets: messageInsets, 52 | child: self.messageNode) 53 | let messageOverlayedLayout = ASOverlayLayoutSpec(child: chatNode, 54 | overlay: messageLayout) 55 | return ASInsetLayoutSpec(insets: .zero, child: messageOverlayedLayout) 56 | } 57 | 58 | override func viewDidAppear(_ animated: Bool) { 59 | super.viewDidAppear(animated) 60 | self.chatNode.reloadData() 61 | self.chatNode.reloadData(completion: { () in 62 | let center = self.items.count / 2 63 | self.chatNode.scrollToItem(at: .init(item: center, section: Section.messages.rawValue), 64 | at: .centeredVertically, animated: false) 65 | }) 66 | } 67 | 68 | override func didReceiveMemoryWarning() { 69 | super.didReceiveMemoryWarning() 70 | } 71 | 72 | override func scrollViewWillBeginDragging(_ scrollView: UIScrollView) { 73 | self.messageNode.dismissMessageInput() 74 | } 75 | 76 | } 77 | 78 | extension ChatNodeController: GTChatNodeDataSource { 79 | func numberOfSections(in collectionNode: ASCollectionNode) -> Int { 80 | return 3 81 | } 82 | 83 | func collectionNode(_ collectionNode: ASCollectionNode, numberOfItemsInSection section: Int) -> Int { 84 | switch section { 85 | case Section.prependIndicator.rawValue: 86 | return self.pagingStatus == .prepending ? 1: 0 87 | case Section.appendIndicator.rawValue: 88 | return self.pagingStatus == .appending ? 1: 0 89 | case Section.messages.rawValue: 90 | return self.items.count 91 | default: return 0 92 | } 93 | } 94 | 95 | func collectionNode(_ collectionNode: ASCollectionNode, nodeForItemAt indexPath: IndexPath) -> ASCellNode { 96 | switch indexPath.section { 97 | case Section.appendIndicator.rawValue: 98 | return ChatLoadingIndicatorNode() 99 | case Section.messages.rawValue: 100 | let random = Int(arc4random_uniform(UInt32(items.count))) 101 | return ChatCellNode(random % 2 == 0 ? .left: .right) 102 | case Section.prependIndicator.rawValue: 103 | return ChatLoadingIndicatorNode() 104 | default: return ASCellNode() 105 | } 106 | } 107 | } 108 | 109 | extension ChatNodeController: GTChatNodeDelegate { 110 | 111 | func shouldAppendBatchFetch(for chatNode: ASCollectionNode) -> Bool { 112 | return true 113 | } 114 | 115 | func shouldPrependBatchFetch(for chatNode: ASCollectionNode) -> Bool { 116 | return true 117 | } 118 | 119 | func chatNode(_ chatNode: ASCollectionNode, willBeginAppendBatchFetchWith context: ASBatchContext) { 120 | guard let lastId = self.items.last, lastId < Const.maxiumRange else { 121 | self.completeBatchFetching(true, endDirection: .prepend) 122 | self.chatNode.reloadSections(IndexSet(integer: Section.appendIndicator.rawValue)) 123 | return 124 | } 125 | 126 | self.chatNode.reloadSections(IndexSet(integer: Section.appendIndicator.rawValue)) 127 | 128 | DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + Const.forceLoadDelay, execute: { 129 | 130 | 131 | let startId = lastId + 1 132 | let newItems: [Int] = Array(startId ..< min(Const.maxiumRange, 133 | startId + Const.moreItemCount)) 134 | 135 | let appendIndexPaths: [IndexPath] = newItems.enumerated() 136 | .map { IndexPath(item: self.items.count + $0.offset, section: Section.messages.rawValue) } 137 | 138 | self.items = self.items + newItems 139 | 140 | self.chatNode.performBatchUpdates({ 141 | self.chatNode.insertItems(at: appendIndexPaths) 142 | }, completion: { done in 143 | self.completeBatchFetching(true, endDirection: .none) 144 | self.chatNode.reloadSections(IndexSet(integer: Section.appendIndicator.rawValue)) 145 | }) 146 | }) 147 | } 148 | 149 | func chatNode(_ chatNode: ASCollectionNode, willBeginPrependBatchFetchWith context: ASBatchContext) { 150 | guard let firstId = self.items.first, firstId != Const.minimumRange else { 151 | self.completeBatchFetching(true, endDirection: .prepend) 152 | self.chatNode.reloadSections(IndexSet(integer: Section.prependIndicator.rawValue)) 153 | return 154 | } 155 | 156 | self.chatNode.reloadSections(IndexSet(integer: Section.prependIndicator.rawValue)) 157 | 158 | DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + Const.forceLoadDelay, execute: { 159 | 160 | let startId = firstId 161 | let newItems: [Int] = Array(max(Const.minimumRange, startId - Const.moreItemCount) ..< startId) 162 | let prependIndexPaths: [IndexPath] = newItems.enumerated() 163 | .map { IndexPath(item: $0.offset, section: Section.messages.rawValue) } 164 | 165 | self.items = newItems + self.items 166 | 167 | self.chatNode.performBatch(animated: false, updates: { 168 | self.chatNode.insertItems(at: prependIndexPaths) 169 | }, completion: { done in 170 | self.completeBatchFetching(true, endDirection: .none) 171 | self.chatNode.reloadSections(IndexSet(integer: Section.prependIndicator.rawValue)) 172 | }) 173 | }) 174 | } 175 | } 176 | 177 | 178 | -------------------------------------------------------------------------------- /Example/GTChatKit/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ios-marketing", 45 | "size" : "1024x1024", 46 | "scale" : "1x" 47 | } 48 | ], 49 | "info" : { 50 | "version" : 1, 51 | "author" : "xcode" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Example/GTChatKit/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Example/GTChatKit/Images.xcassets/photo.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "photo.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Example/GTChatKit/Images.xcassets/photo.imageset/photo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GeekTree0101/GTChatKit/5152aea224fe50d82adbde2376e2f94272a5cf07/Example/GTChatKit/Images.xcassets/photo.imageset/photo.png -------------------------------------------------------------------------------- /Example/GTChatKit/Images.xcassets/photo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GeekTree0101/GTChatKit/5152aea224fe50d82adbde2376e2f94272a5cf07/Example/GTChatKit/Images.xcassets/photo.png -------------------------------------------------------------------------------- /Example/GTChatKit/Images.xcassets/resources/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Example/GTChatKit/Images.xcassets/resources/eumji.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "eumji.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Example/GTChatKit/Images.xcassets/resources/eumji.imageset/eumji.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GeekTree0101/GTChatKit/5152aea224fe50d82adbde2376e2f94272a5cf07/Example/GTChatKit/Images.xcassets/resources/eumji.imageset/eumji.jpg -------------------------------------------------------------------------------- /Example/GTChatKit/Images.xcassets/resources/eunha.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "eunha.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Example/GTChatKit/Images.xcassets/resources/eunha.imageset/eunha.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GeekTree0101/GTChatKit/5152aea224fe50d82adbde2376e2f94272a5cf07/Example/GTChatKit/Images.xcassets/resources/eunha.imageset/eunha.jpg -------------------------------------------------------------------------------- /Example/GTChatKit/Images.xcassets/resources/sinbi.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "sinbi.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Example/GTChatKit/Images.xcassets/resources/sinbi.imageset/sinbi.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GeekTree0101/GTChatKit/5152aea224fe50d82adbde2376e2f94272a5cf07/Example/GTChatKit/Images.xcassets/resources/sinbi.imageset/sinbi.jpg -------------------------------------------------------------------------------- /Example/GTChatKit/Images.xcassets/resources/sowon.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "sowon.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Example/GTChatKit/Images.xcassets/resources/sowon.imageset/sowon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GeekTree0101/GTChatKit/5152aea224fe50d82adbde2376e2f94272a5cf07/Example/GTChatKit/Images.xcassets/resources/sowon.imageset/sowon.jpg -------------------------------------------------------------------------------- /Example/GTChatKit/Images.xcassets/resources/yelin.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "yelin.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Example/GTChatKit/Images.xcassets/resources/yelin.imageset/yelin.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GeekTree0101/GTChatKit/5152aea224fe50d82adbde2376e2f94272a5cf07/Example/GTChatKit/Images.xcassets/resources/yelin.imageset/yelin.jpg -------------------------------------------------------------------------------- /Example/GTChatKit/Images.xcassets/resources/yuju.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "yuju.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Example/GTChatKit/Images.xcassets/resources/yuju.imageset/yuju.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GeekTree0101/GTChatKit/5152aea224fe50d82adbde2376e2f94272a5cf07/Example/GTChatKit/Images.xcassets/resources/yuju.imageset/yuju.jpg -------------------------------------------------------------------------------- /Example/GTChatKit/Images.xcassets/send.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "send.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Example/GTChatKit/Images.xcassets/send.imageset/send.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GeekTree0101/GTChatKit/5152aea224fe50d82adbde2376e2f94272a5cf07/Example/GTChatKit/Images.xcassets/send.imageset/send.png -------------------------------------------------------------------------------- /Example/GTChatKit/Images.xcassets/send.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GeekTree0101/GTChatKit/5152aea224fe50d82adbde2376e2f94272a5cf07/Example/GTChatKit/Images.xcassets/send.png -------------------------------------------------------------------------------- /Example/GTChatKit/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UIRequiresFullScreen 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /Example/GTChatKit/String+extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // String+extension.swift 3 | // GTChatKit_Example 4 | // 5 | // Created by Vingle on 2018. 3. 2.. 6 | // Copyright © 2018년 CocoaPods. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | extension String { 12 | 13 | static var randomMessage: String { 14 | let list = ["Hello World", 15 | "How are you today?", 16 | "하하하하하하", 17 | "I LOVE Texture", 18 | "在Vingle招聘iOS开发者!", 19 | "Vingle is hiring senior iOS developers"] 20 | let index = Int(arc4random_uniform(UInt32(list.count))) 21 | return list[index] 22 | } 23 | 24 | static var gfriend: String { 25 | let gfriends = ["eumji", "eunha", "sowon", "yelin", "yuju", "sinbi"] 26 | let randIndex = Int(arc4random_uniform(UInt32(gfriends.count))) 27 | return gfriends[randIndex] 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Example/GTChatKit/UIColor+extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+extension.swift 3 | // GTChatKit_Example 4 | // 5 | // Created by Geektree0101 on 18/03/02. 6 | // Copyright © 2018 Geektree0101 All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | extension UIColor { 13 | 14 | static func rand() -> UIColor { 15 | let list: [UIColor] = [.red, .blue, .darkGray, .orange, .green] 16 | let index = Int(arc4random_uniform(UInt32(list.count))) 17 | 18 | return list[index] 19 | } 20 | 21 | static var myChat: UIColor { 22 | return UIColor(red: 20/255, green: 111/255, blue: 249/255, alpha: 1.0) 23 | } 24 | 25 | static var frameColor: UIColor { 26 | return UIColor(red: 226/255, green: 253/255, blue: 255/255, alpha: 1.0) 27 | } 28 | 29 | static var navigationBarColor: UIColor { 30 | return UIColor(red: 0/255, green: 214/255, blue: 238/255, alpha: 1.0) 31 | } 32 | 33 | static var otherChat: UIColor { 34 | return UIColor(red: 14/255, green: 169/255, blue: 245/255, alpha: 1.0) 35 | } 36 | 37 | 38 | } 39 | -------------------------------------------------------------------------------- /Example/Podfile: -------------------------------------------------------------------------------- 1 | use_frameworks! 2 | 3 | target 'GTChatKit_Example' do 4 | pod 'GTChatKit', :path => '../' 5 | 6 | target 'GTChatKit_Tests' do 7 | inherit! :search_paths 8 | 9 | pod 'Quick', '~> 1.2.0' 10 | pod 'Nimble', '~> 7.0.2' 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /Example/Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Example/Tests/Tests.swift: -------------------------------------------------------------------------------- 1 | // https://github.com/Quick/Quick 2 | 3 | import Quick 4 | import Nimble 5 | import GTChatKit 6 | 7 | class TableOfContentsSpec: QuickSpec { 8 | override func spec() { 9 | describe("these will fail") { 10 | 11 | it("can do maths") { 12 | expect(1) == 2 13 | } 14 | 15 | it("can read") { 16 | expect("number") == "string" 17 | } 18 | 19 | it("will eventually fail") { 20 | expect("time").toEventually( equal("done") ) 21 | } 22 | 23 | context("these will pass") { 24 | 25 | it("can do maths") { 26 | expect(23) == 23 27 | } 28 | 29 | it("can read") { 30 | expect("🐮") == "🐮" 31 | } 32 | 33 | it("will eventually pass") { 34 | var time = "passing" 35 | 36 | DispatchQueue.main.async { 37 | time = "done" 38 | } 39 | 40 | waitUntil { done in 41 | Thread.sleep(forTimeInterval: 0.5) 42 | expect(time) == "done" 43 | 44 | done() 45 | } 46 | } 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /GTChatKit.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod lib lint GTChatKit.podspec' to ensure this is a 3 | # valid spec before submitting. 4 | # 5 | # Any lines starting with a # are optional, but their use is encouraged 6 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | s.name = 'GTChatKit' 11 | s.version = '4.2.0' 12 | s.summary = 'iOS ChatKit built on Texture(AsyncDisplayKit) and written in Swift' 13 | 14 | # This description is used to generate tags and improve search results. 15 | # * Think: What does it do? Why did you write it? What is the focus? 16 | # * Try to keep it short, snappy and to the point. 17 | # * Write the description between the DESC delimiters below. 18 | # * Finally, don't worry about the indent, CocoaPods strips it! 19 | 20 | s.description = <<-DESC 21 | iOS ChatKit built on Texture(AsyncDisplayKit) and written in Swift 22 | DESC 23 | 24 | s.homepage = 'https://github.com/Geektree0101/GTChatKit' 25 | # s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2' 26 | s.license = { :type => 'MIT', :file => 'LICENSE' } 27 | s.author = { 'Geektree0101' => 'h2s1880@gmail.com' } 28 | s.source = { :git => 'https://github.com/Geektree0101/GTChatKit.git', :tag => s.version.to_s } 29 | 30 | s.ios.deployment_target = '9.0' 31 | 32 | s.source_files = 'GTChatKit/Classes/**/*' 33 | 34 | s.dependency 'Texture', '~> 2.5' 35 | end 36 | -------------------------------------------------------------------------------- /GTChatKit/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GeekTree0101/GTChatKit/5152aea224fe50d82adbde2376e2f94272a5cf07/GTChatKit/Assets/.gitkeep -------------------------------------------------------------------------------- /GTChatKit/Classes/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GeekTree0101/GTChatKit/5152aea224fe50d82adbde2376e2f94272a5cf07/GTChatKit/Classes/.gitkeep -------------------------------------------------------------------------------- /GTChatKit/Classes/Extensions/UIColor+GTChatKit.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+GTChatKit.swift 3 | // GTChatKit 4 | // 5 | // Created by Geektree0101 on 18/03/02. 6 | // Copyright © 2018 Geektree0101 All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | extension UIColor { 13 | static var chatKitDefaultColor: UIColor { 14 | return UIColor(red: 0/255, green: 214/255, blue: 238/255, alpha: 1.0) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /GTChatKit/Classes/Extensions/UIImage+GTChatKit.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+GTChatKit.swift 3 | // GTChatKit 4 | // 5 | // Created by Geektree0101 on 18/03/02. 6 | // Copyright © 2018 Geektree0101 All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | extension UIImage { 13 | 14 | func applyButtonColor(with color: UIColor) -> UIImage { 15 | var image = withRenderingMode(.alwaysTemplate) 16 | UIGraphicsBeginImageContextWithOptions(size, false, scale) 17 | color.set() 18 | 19 | image.draw(in: CGRect(origin: .zero, size: size)) 20 | image = UIGraphicsGetImageFromCurrentImageContext()! 21 | UIGraphicsEndImageContext() 22 | return image 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /GTChatKit/Classes/Extensions/UITextView_GTChatKit.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UITextView_GTChatKit.swift 3 | // GTChatKit 4 | // 5 | // Created by Geektree0101 on 18/03/02. 6 | // Copyright © 2018 Geektree0101 All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | extension UITextView { 13 | var numberOfLines: Int { 14 | guard !text.isEmpty else { return 1 } 15 | 16 | let numberOfGlyphs = layoutManager.numberOfGlyphs 17 | var index = 0 18 | var lines = 0 19 | 20 | while (index < numberOfGlyphs) { 21 | var lineRange = NSRange(location: NSNotFound, length: 0) 22 | layoutManager.lineFragmentRect(forGlyphAt: index, effectiveRange: &lineRange) 23 | 24 | guard lineRange.location != NSNotFound else { break } 25 | index = NSMaxRange(lineRange) 26 | lines += 1 27 | } 28 | 29 | return lines 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /GTChatKit/Classes/GTChatNodeController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GTChatFlowLayout.swift 3 | // GTChatKit 4 | // 5 | // Created by Geektree0101 on 18/03/02. 6 | // Copyright © 2018 Geektree0101 All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import AsyncDisplayKit 11 | 12 | public protocol GTChatNodeDelegate: ASCollectionDelegate { 13 | func shouldAppendBatchFetch(for chatNode: ASCollectionNode) -> Bool 14 | func shouldPrependBatchFetch(for chatNode: ASCollectionNode) -> Bool 15 | 16 | func chatNode(_ chatNode: ASCollectionNode, 17 | willBeginAppendBatchFetchWith context: ASBatchContext) 18 | func chatNode(_ chatNode: ASCollectionNode, 19 | willBeginPrependBatchFetchWith context: ASBatchContext) 20 | } 21 | 22 | public protocol GTChatNodeDataSource: ASCollectionDataSource { 23 | 24 | } 25 | 26 | open class GTChatNodeController: ASViewController { 27 | public enum BatchFetchDirection: UInt { 28 | case append 29 | case prepend 30 | case none 31 | } 32 | 33 | public enum PaginationStatus { 34 | case initial 35 | case appending 36 | case prepending 37 | case some 38 | 39 | var isLoading: Bool { 40 | switch self { 41 | case .appending, .prepending: 42 | return true 43 | default: 44 | return false 45 | } 46 | } 47 | } 48 | 49 | open var leadingScreensForBatching: CGFloat { 50 | get { 51 | return self.chatNode.leadingScreensForBatching 52 | } 53 | set(newValue) { 54 | self.chatNode.leadingScreensForBatching = newValue 55 | } 56 | } 57 | 58 | // debug logging printer control property 59 | open var shouldPrintLog: Bool = true 60 | open let chatNode: ASCollectionNode 61 | 62 | // If you want force handling btchFetchingContext, set property as False 63 | open var isPagingStatusEnable: Bool = true 64 | open var pagingStatus: PaginationStatus = .initial 65 | open var hasNextPrependItem: Bool = true 66 | open var hasNextAppendItems: Bool = true 67 | open var keyboardVisibleHeight: CGFloat = 0.0 68 | 69 | fileprivate lazy var batchFetchingContext = ASBatchContext() 70 | 71 | convenience public init() { 72 | let layout = GTChatNodeFlowLayout() 73 | self.init(layout: layout) 74 | } 75 | 76 | required public init(layout: UICollectionViewFlowLayout) { 77 | chatNode = ASCollectionNode(frame: .zero, 78 | collectionViewLayout: layout) 79 | super.init(node: ASDisplayNode()) 80 | self.node.automaticallyManagesSubnodes = true 81 | self.setupChatRangeTuningParameters() 82 | 83 | self.node.layoutSpecBlock = { (_, constrainedSize) -> ASLayoutSpec in 84 | return self.layoutSpecThatFits(constrainedSize, chatNode: self.chatNode) 85 | } 86 | 87 | NotificationCenter.default.addObserver(self, 88 | selector: #selector(keyboardWillAppear), 89 | name: NSNotification.Name.UIKeyboardWillShow, 90 | object: nil) 91 | NotificationCenter.default.addObserver(self, 92 | selector: #selector(keyboardWillHide), 93 | name: NSNotification.Name.UIKeyboardWillHide, 94 | object: nil) 95 | } 96 | 97 | required public init?(coder aDecoder: NSCoder) { 98 | fatalError("init(coder:) has not been implemented") 99 | } 100 | 101 | deinit { 102 | self.chatNode.delegate = nil 103 | self.chatNode.dataSource = nil 104 | NotificationCenter.default.removeObserver(self, 105 | name: NSNotification.Name.UIKeyboardWillShow, 106 | object: nil) 107 | NotificationCenter.default.removeObserver(self, 108 | name: NSNotification.Name.UIKeyboardWillHide, 109 | object: nil) 110 | } 111 | 112 | // override 113 | open func setupChatRangeTuningParameters() { 114 | self.chatNode.setTuningParameters(ASRangeTuningParameters(leadingBufferScreenfuls: 1.5, 115 | trailingBufferScreenfuls: 1.5), 116 | for: .full, 117 | rangeType: .display) 118 | self.chatNode.setTuningParameters(ASRangeTuningParameters(leadingBufferScreenfuls: 2, 119 | trailingBufferScreenfuls: 2), 120 | for: .full, 121 | rangeType: .preload) 122 | } 123 | 124 | // override 125 | open func layoutSpecThatFits(_ constrainedSize: ASSizeRange, 126 | chatNode: ASCollectionNode) -> ASLayoutSpec { 127 | return ASInsetLayoutSpec(insets: .zero, child: self.chatNode) 128 | } 129 | 130 | @objc private func keyboardWillAppear(notification: NSNotification) { 131 | if let keyboardFrame: NSValue = notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue { 132 | let keyboardRectangle = keyboardFrame.cgRectValue 133 | self.keyboardVisibleHeight = keyboardRectangle.height 134 | self.node.setNeedsLayout() 135 | } 136 | } 137 | 138 | @objc private func keyboardWillHide(notification: NSNotification) { 139 | self.keyboardVisibleHeight = 0.0 140 | self.node.setNeedsLayout() 141 | } 142 | } 143 | 144 | // Update Pagination Status 145 | extension GTChatNodeController { 146 | open func completeBatchFetching(_ complated: Bool, endDirection: BatchFetchDirection) { 147 | guard isPagingStatusEnable else { 148 | print("[CAUTION] PagingStaute Disabled!") 149 | return 150 | } 151 | 152 | switch endDirection { 153 | case .append: 154 | self.hasNextAppendItems = false 155 | case .prepend: 156 | self.hasNextPrependItem = false 157 | default: 158 | break 159 | } 160 | 161 | switch self.pagingStatus { 162 | case .appending, .prepending: 163 | self.pagingStatus = .some 164 | default: break 165 | } 166 | 167 | self.batchFetchingContext.completeBatchFetching(complated) 168 | } 169 | } 170 | 171 | // Batch Fetch Handling 172 | extension GTChatNodeController: UIScrollViewDelegate { 173 | open func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) { } 174 | 175 | open func scrollViewWillBeginDragging(_ scrollView: UIScrollView) { } 176 | 177 | public func scrollViewDidScroll(_ scrollView: UIScrollView) { 178 | guard let chatDelegate = self.chatNode.delegate as? GTChatNodeDelegate, ASInterfaceStateIncludesVisible(self.interfaceState) else { return } 179 | self.chatNode.updateCurrentRange(with: .full) 180 | self.beginChatNodeBatch(scrollView, chatDelegate: chatDelegate) 181 | } 182 | 183 | private func beginChatNodeBatch(_ scrollView: UIScrollView, 184 | chatDelegate: GTChatNodeDelegate) { 185 | guard !self.pagingStatus.isLoading else { return } 186 | 187 | if scrollView.isDragging, scrollView.isTracking { 188 | return 189 | } 190 | 191 | let scrollVelocity = scrollView.panGestureRecognizer.velocity(in: super.view) 192 | 193 | let scope = shouldFetchBatch(for: scrollView, 194 | offset: scrollView.contentOffset.y, 195 | scrollDirection: scrollDirection(scrollVelocity), 196 | velocity: scrollVelocity) 197 | 198 | switch scope { 199 | case .append: 200 | guard chatDelegate.shouldAppendBatchFetch(for: self.chatNode), 201 | self.hasNextAppendItems else { 202 | return 203 | } 204 | self.batchFetchingContext.beginBatchFetching() 205 | if shouldPrintLog { 206 | print("[DEBUG] GTChat:\(Date().timeIntervalSinceReferenceDate) beging append fetching") 207 | } 208 | 209 | if isPagingStatusEnable { 210 | self.pagingStatus = .appending 211 | } 212 | chatDelegate.chatNode(self.chatNode, willBeginAppendBatchFetchWith: self.batchFetchingContext) 213 | case .prepend: 214 | guard chatDelegate.shouldPrependBatchFetch(for: self.chatNode), 215 | self.hasNextPrependItem else { 216 | return 217 | } 218 | if shouldPrintLog { 219 | print("[DEBUG] GTChat:\(Date().timeIntervalSinceReferenceDate) beging prepend fetching") 220 | } 221 | self.batchFetchingContext.beginBatchFetching() 222 | 223 | if isPagingStatusEnable { 224 | self.pagingStatus = .prepending 225 | } 226 | chatDelegate.chatNode(self.chatNode, willBeginPrependBatchFetchWith: self.batchFetchingContext) 227 | case .none: 228 | break 229 | } 230 | } 231 | 232 | private func scrollDirection(_ scrollVelocity: CGPoint) -> ASScrollDirection { 233 | if scrollVelocity.y < 0.0 { 234 | return .down 235 | } else if scrollVelocity.y > 0.0 { 236 | return .up 237 | } else { 238 | return ASScrollDirection(rawValue: 0) 239 | } 240 | } 241 | 242 | private func shouldFetchBatch(for scrollView: UIScrollView, 243 | offset: CGFloat, 244 | scrollDirection: ASScrollDirection, 245 | velocity: CGPoint) -> BatchFetchDirection { 246 | guard !self.batchFetchingContext.isFetching(), scrollView.window != nil else { 247 | return .none 248 | } 249 | 250 | let bounds: CGRect = scrollView.bounds 251 | let leadingScreens: CGFloat = self.chatNode.leadingScreensForBatching 252 | 253 | guard leadingScreens > 0.0, !bounds.isEmpty else { 254 | return .none 255 | } 256 | 257 | let contentSize: CGSize = scrollView.contentSize 258 | let viewLength = bounds.size.height 259 | let contentLength = contentSize.height 260 | 261 | // has small content 262 | if contentLength < viewLength { 263 | switch scrollDirection { 264 | case .down: return .prepend 265 | case .up: return .append 266 | default: return .none 267 | } 268 | } 269 | 270 | let triggerDistance = viewLength * leadingScreens 271 | let remainingDistance = contentLength - viewLength - offset 272 | 273 | switch scrollDirection { 274 | case .down: 275 | return remainingDistance <= triggerDistance ? .append: .none 276 | case .up: 277 | return offset < triggerDistance ? .prepend: .none 278 | default: 279 | return .none 280 | } 281 | } 282 | } 283 | -------------------------------------------------------------------------------- /GTChatKit/Classes/GTChatNodeFlowLayout.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GTChatFlowLayout.swift 3 | // GTChatKit 4 | // 5 | // Created by Geektree0101 on 18/03/02. 6 | // Copyright © 2018 Geektree0101 All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import AsyncDisplayKit 11 | 12 | open class GTChatNodeFlowLayout: UICollectionViewFlowLayout { 13 | private var topVisibleItem = Int.max 14 | private var bottomVisibleItem = -Int.max 15 | private var offset: CGFloat = 0.0 16 | private var visibleAttributes: [UICollectionViewLayoutAttributes]? 17 | private var isPrependingItems = false 18 | private var isAppendingItems = false 19 | 20 | override open func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? { 21 | visibleAttributes = super.layoutAttributesForElements(in: rect) 22 | offset = 0.0 23 | isPrependingItems = false 24 | isAppendingItems = false 25 | return visibleAttributes 26 | } 27 | 28 | override open func prepare(forCollectionViewUpdates updateItems: [UICollectionViewUpdateItem]) { 29 | guard let collectionView = self.collectionView else { return } 30 | guard let visibleAttributes = self.visibleAttributes else { return } 31 | 32 | bottomVisibleItem = -Int.max 33 | topVisibleItem = Int.max 34 | 35 | var containerHeight: CGFloat = collectionView.frame.size.height 36 | containerHeight -= collectionView.contentInset.top 37 | containerHeight -= collectionView.contentInset.bottom 38 | 39 | let container = CGRect(x: collectionView.contentOffset.x, 40 | y: collectionView.contentOffset.y, 41 | width: collectionView.frame.size.width, 42 | height: containerHeight) 43 | 44 | for attributes in visibleAttributes { 45 | if attributes.frame.intersects(container) { 46 | let item = attributes.indexPath.item 47 | 48 | if item < topVisibleItem { 49 | topVisibleItem = item 50 | } 51 | 52 | if item > bottomVisibleItem { 53 | bottomVisibleItem = item 54 | } 55 | } 56 | } 57 | 58 | super.prepare(forCollectionViewUpdates: updateItems) 59 | 60 | var shouldPrependItems = false 61 | var shouldAppendItems = false 62 | 63 | for updateItem in updateItems { 64 | switch updateItem.updateAction { 65 | case .insert: 66 | guard let indexPathAfterUpdate = updateItem.indexPathAfterUpdate, 67 | case let item = indexPathAfterUpdate.item else { 68 | continue 69 | } 70 | 71 | if topVisibleItem + updateItems.count > item, 72 | let newAttributes = self.layoutAttributesForItem(at: indexPathAfterUpdate) { 73 | offset += newAttributes.size.height + self.minimumLineSpacing 74 | shouldPrependItems = true 75 | shouldAppendItems = false 76 | } else if bottomVisibleItem <= item, 77 | let newAttributes = self.layoutAttributesForItem(at: indexPathAfterUpdate) { 78 | offset += newAttributes.size.height + self.minimumLineSpacing 79 | shouldAppendItems = true 80 | shouldPrependItems = false 81 | } 82 | case.delete: 83 | break 84 | default: 85 | break 86 | } 87 | } 88 | 89 | let collectionViewContentHeight = collectionView.contentSize.height 90 | var collectionViewFrameHeight = collectionView.frame.size.height 91 | collectionViewFrameHeight -= collectionView.contentInset.top 92 | collectionViewFrameHeight -= collectionView.contentInset.bottom 93 | 94 | guard shouldPrependItems || shouldAppendItems, 95 | collectionViewContentHeight + offset > collectionViewFrameHeight else { 96 | return 97 | } 98 | 99 | if shouldPrependItems { 100 | CATransaction.begin() 101 | CATransaction.setDisableActions(true) 102 | isPrependingItems = true 103 | } else if shouldAppendItems { 104 | isAppendingItems = true 105 | } 106 | } 107 | 108 | override open func finalizeCollectionViewUpdates() { 109 | guard let collectionView = self.collectionView else { return } 110 | if isPrependingItems { 111 | let newContentOffset = CGPoint(x: collectionView.contentOffset.x, 112 | y: collectionView.contentOffset.y + offset) 113 | collectionView.contentOffset = newContentOffset 114 | CATransaction.commit() 115 | } else if isAppendingItems { 116 | var yOffset: CGFloat = collectionView.contentSize.height + offset 117 | yOffset -= collectionView.frame.size.height 118 | yOffset += collectionView.contentInset.bottom 119 | let newContentOffset = CGPoint(x: collectionView.contentOffset.x, 120 | y: yOffset) 121 | collectionView.setContentOffset(newContentOffset, animated: true) 122 | } 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /GTChatKit/Classes/Views/GTChatMessageBoxNode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GTChatMessageBoxNode.swift 3 | // GTChatKit 4 | // 5 | // Created by Geektree0101 on 18/03/02. 6 | // Copyright © 2018 Geektree0101 All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import AsyncDisplayKit 11 | 12 | public class GTChatMessageBoxNode: ASDisplayNode { 13 | public typealias Node = GTChatMessageBoxNode 14 | public typealias ButtonGroupHandler = ([GTChatMessageButtonNode]) -> Void 15 | 16 | @objc lazy open var messageNode = GTChatMessageInputBoxNode() 17 | open var messageBoxInsets: UIEdgeInsets = UIEdgeInsetsMake(10.0, 10.0, 10.0, 10.0) 18 | private var leftButtonGroups: [GTChatMessageButtonNode] = [] 19 | private var leftButtonGroupSpacing: CGFloat = 10.0 20 | 21 | private var rightButtonGroups: [GTChatMessageButtonNode] = [] 22 | private var rightButtonGroupSpacing: CGFloat = 10.0 23 | 24 | fileprivate var minimumMessageBoxHeight: CGFloat = 50.0 25 | fileprivate var maximumVisibleMessageNumberOfLines: Int = 6 26 | 27 | override public init() { 28 | super.init() 29 | self.backgroundColor = .chatKitDefaultColor 30 | self.automaticallyManagesSubnodes = true 31 | self.messageNode.delegate = self 32 | } 33 | 34 | deinit { 35 | self.messageNode.delegate = nil 36 | } 37 | 38 | @discardableResult public func setupDefaultMessageBox() -> Node { 39 | let cameraButton = GTChatMessageButtonNode() 40 | .setButtonSize(.init(width: 24.0, height: 24.0)) 41 | .setButtonImage(#imageLiteral(resourceName: "photo"), color: .white, for: .normal) 42 | .setButtonImage(#imageLiteral(resourceName: "photo"), color: UIColor.white.withAlphaComponent(0.5), for: .disabled) 43 | 44 | let sendButton = GTChatMessageButtonNode() 45 | .setButtonSize(.init(width: 24.0, height: 24.0)) 46 | .setButtonImage(#imageLiteral(resourceName: "send"), color: .white, for: .normal) 47 | .setButtonImage(#imageLiteral(resourceName: "send"), color: UIColor.white.withAlphaComponent(0.5), for: .disabled) 48 | 49 | self.messageNode.setMessageContainerInsets(UIEdgeInsetsMake(5.0, 10.0, 5.0, 10.0)) 50 | 51 | self.setLeftButtons([cameraButton], spacing: 10.0) 52 | .setRightButtons([sendButton], spacing: 10.0) 53 | .setMessageBoxHeight(50.0, maxiumNumberOfLine: 6, isRounded: true) 54 | return self 55 | } 56 | 57 | @discardableResult public func setMessageBoxHeight(_ minimumHeight: CGFloat, 58 | maxiumNumberOfLine: Int, 59 | isRounded: Bool) -> Node { 60 | self.style.height = .init(unit: .points, value: minimumHeight) 61 | self.minimumMessageBoxHeight = minimumHeight 62 | self.maximumVisibleMessageNumberOfLines = maxiumNumberOfLine 63 | 64 | guard isRounded else { return self } 65 | self.messageNode.clipsToBounds = true 66 | let messageNodeSize = self.messageNode.calculateSizeThatFits(UIScreen.main.bounds.size) 67 | self.messageNode.cornerRadius = messageNodeSize.height / 2 68 | return self 69 | } 70 | 71 | @discardableResult public func setLeftButtons(_ buttons: [GTChatMessageButtonNode], 72 | spacing: CGFloat) -> Node { 73 | self.leftButtonGroupSpacing = spacing 74 | self.leftButtonGroups = buttons 75 | return self 76 | } 77 | 78 | @discardableResult public func setRightButtons(_ buttons: [GTChatMessageButtonNode], 79 | spacing: CGFloat) -> Node { 80 | self.rightButtonGroupSpacing = spacing 81 | self.rightButtonGroups = buttons 82 | return self 83 | } 84 | 85 | public func dismissMessageInput() { 86 | self.messageNode.resignFirstResponder() 87 | } 88 | 89 | override public func layoutSpecThatFits(_ constrainedSize: ASSizeRange) -> ASLayoutSpec { 90 | 91 | var messageBoxElements: [ASLayoutElement] = [] 92 | 93 | if let leftButtonGroupLayout = self.leftButtonGroupLayoutSpec() { 94 | let leftButtonRelativeLayout = ASRelativeLayoutSpec(horizontalPosition: .end, 95 | verticalPosition: .end, 96 | sizingOption: [], 97 | child: leftButtonGroupLayout) 98 | leftButtonRelativeLayout.style.spacingAfter = leftButtonGroupSpacing 99 | messageBoxElements.append(leftButtonRelativeLayout) 100 | } 101 | 102 | messageBoxElements.append(messageNode) 103 | 104 | if let rightButtonGroupLayout = self.rightButtonGroupLayoutSpec() { 105 | let rightButtonRelativeLayout = ASRelativeLayoutSpec(horizontalPosition: .end, 106 | verticalPosition: .end, 107 | sizingOption: [], 108 | child: rightButtonGroupLayout) 109 | rightButtonRelativeLayout.style.spacingBefore = rightButtonGroupSpacing 110 | messageBoxElements.append(rightButtonRelativeLayout) 111 | } 112 | 113 | let messageStackLayout = ASStackLayoutSpec(direction: .horizontal, 114 | spacing: 0.0, 115 | justifyContent: .spaceBetween, 116 | alignItems: .stretch, 117 | children: messageBoxElements) 118 | 119 | return ASInsetLayoutSpec(insets: self.messageBoxInsets, 120 | child: messageStackLayout) 121 | } 122 | 123 | private func rightButtonGroupLayoutSpec() -> ASLayoutElement? { 124 | guard self.rightButtonGroups.count > 1 else { 125 | guard let rightButtonNode = self.rightButtonGroups.first else { 126 | return nil 127 | } 128 | return rightButtonNode 129 | } 130 | 131 | let stackLayout = ASStackLayoutSpec(direction: .horizontal, 132 | spacing: self.rightButtonGroupSpacing, 133 | justifyContent: .start, 134 | alignItems: .center, 135 | children: self.rightButtonGroups) 136 | return stackLayout 137 | } 138 | 139 | private func leftButtonGroupLayoutSpec() -> ASLayoutElement? { 140 | guard self.leftButtonGroups.count > 1 else { 141 | guard let leftButtonNode = self.leftButtonGroups.first else { 142 | return nil 143 | } 144 | return leftButtonNode 145 | } 146 | 147 | let stackLayout = ASStackLayoutSpec(direction: .horizontal, 148 | spacing: self.leftButtonGroupSpacing, 149 | justifyContent: .start, 150 | alignItems: .center, 151 | children: self.leftButtonGroups) 152 | return stackLayout 153 | } 154 | } 155 | 156 | extension GTChatMessageBoxNode: ASEditableTextNodeDelegate { 157 | public func editableTextNodeDidUpdateText(_ editableTextNode: ASEditableTextNode) { 158 | let placeholderIsVisible = editableTextNode.isDisplayingPlaceholder() 159 | let targetLeftButtons = self.leftButtonGroups.filter { $0.autoInActive } 160 | let targetRightButtons = self.rightButtonGroups.filter { $0.autoInActive } 161 | 162 | for button in targetLeftButtons { 163 | button.isEnabled = !placeholderIsVisible 164 | } 165 | 166 | for button in targetRightButtons { 167 | button.isEnabled = !placeholderIsVisible 168 | } 169 | 170 | let numberOflines = min(self.maximumVisibleMessageNumberOfLines, 171 | editableTextNode.textView.numberOfLines) 172 | 173 | let fontSize = editableTextNode.textView.font?.pointSize ?? 0.0 174 | var calcultedHeight = CGFloat(max(0, numberOflines - 1)) * fontSize 175 | calcultedHeight += minimumMessageBoxHeight 176 | self.style.height = .init(unit: .points, 177 | value: calcultedHeight) 178 | self.setNeedsLayout() 179 | } 180 | } 181 | -------------------------------------------------------------------------------- /GTChatKit/Classes/Views/GTChatMessageButtonNode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GTChatMessageButtonNode.swift 3 | // GTChatKit 4 | // 5 | // Created by Geektree0101 on 18/03/02. 6 | // Copyright © 2018 Geektree0101 All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import AsyncDisplayKit 11 | 12 | public class GTChatMessageButtonNode: ASButtonNode { 13 | public typealias Node = GTChatMessageButtonNode 14 | 15 | open var buttonSize: CGSize = .init(width: 24, height: 24) 16 | open var buttonColor: UIColor = .white 17 | open var buttonTintColor: UIColor = .white 18 | 19 | // When message is placeholder then automatically inactive 20 | open var autoInActive: Bool = true 21 | 22 | override public init() { 23 | super.init() 24 | self.tintColor = self.buttonTintColor 25 | self.imageNode.contentMode = .scaleAspectFit 26 | self.style.flexGrow = 0.0 27 | self.style.flexShrink = 1.0 28 | self.style.preferredSize = self.buttonSize 29 | } 30 | 31 | @discardableResult open func setButtonImage(_ image: UIImage, 32 | color: UIColor, 33 | for status: UIControlState) -> Node { 34 | self.setImage(image.applyButtonColor(with: color), for: status) 35 | return self 36 | } 37 | 38 | @discardableResult open func setButtonSize(_ size: CGSize) -> Node { 39 | self.buttonSize = size 40 | self.style.preferredSize = size 41 | return self 42 | } 43 | 44 | @discardableResult open func setButtonTintColor(_ color: UIColor) -> Node { 45 | self.buttonTintColor = color 46 | self.tintColor = color 47 | return self 48 | } 49 | 50 | @discardableResult open func setButtonText(_ title: NSAttributedString, 51 | for state: UIControlState) -> Node { 52 | self.setAttributedTitle(title, for: state) 53 | return self 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /GTChatKit/Classes/Views/GTChatMessageInputBoxNode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GTChatMessageInputBoxNode.swift 3 | // GTChatKit 4 | // 5 | // Created by Geektree0101 on 18/03/02. 6 | // Copyright © 2018 Geektree0101 All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import AsyncDisplayKit 11 | 12 | public class GTChatMessageInputBoxNode: ASEditableTextNode { 13 | public typealias Node = GTChatMessageInputBoxNode 14 | 15 | public override init() { 16 | super.init(textKitComponents: ASTextKitComponents(attributedSeedString: nil, 17 | textContainerSize: .zero), 18 | placeholderTextKitComponents: ASTextKitComponents(attributedSeedString: nil, 19 | textContainerSize: .zero)) 20 | 21 | self.backgroundColor = .white 22 | self.placeholderEnabled = true 23 | self.setPlaceholder("Type Message", 24 | attribute: Node.defaultPlaceholdereAttributes) 25 | self.setTypingAttributes(Node.defaultTypingAttributes) 26 | 27 | self.cursorColor(.chatKitDefaultColor) 28 | self.style.flexGrow = 1.0 29 | self.style.flexShrink = 1.0 30 | } 31 | 32 | deinit { 33 | self.delegate = nil 34 | } 35 | 36 | @discardableResult func setPlaceholder(_ text: String, 37 | attribute: [NSAttributedStringKey: Any]) -> Node { 38 | self.attributedPlaceholderText = .init(string: text, 39 | attributes: attribute) 40 | return self 41 | } 42 | 43 | @discardableResult func setTypingAttributes(_ attribute: [String: Any]) -> Node { 44 | self.typingAttributes = attribute 45 | return self 46 | } 47 | 48 | @discardableResult func setMessageContainerInsets(_ insets: UIEdgeInsets) -> Node { 49 | self.textContainerInset = insets 50 | return self 51 | } 52 | 53 | @discardableResult func cursorColor(_ color: UIColor) -> Node { 54 | self.tintColor = color 55 | return self 56 | } 57 | 58 | override public func didLoad() { 59 | super.didLoad() 60 | self.textView.showsVerticalScrollIndicator = false 61 | self.textView.showsHorizontalScrollIndicator = false 62 | } 63 | } 64 | 65 | extension GTChatMessageInputBoxNode { 66 | static var defaultPlaceholdereAttributes: [NSAttributedStringKey: Any] { 67 | return [NSAttributedStringKey.foregroundColor: UIColor.lightGray, 68 | NSAttributedStringKey.font: UIFont.systemFont(ofSize: 15.0)] 69 | } 70 | 71 | static var defaultTypingAttributes: [String: Any] { 72 | return [NSAttributedStringKey.foregroundColor.rawValue: UIColor.darkGray, 73 | NSAttributedStringKey.font.rawValue: UIFont.systemFont(ofSize: 15.0)] 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 Geektree0101 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GTChatKit: iOS ChatKit built on Texture 2 | 3 | [![Travis CI](https://travis-ci.org/GeekTree0101/GTChatKit.svg?branch=master)](https://travis-ci.org/GeekTree0101/GTChatKit) 4 | [![Version](https://img.shields.io/cocoapods/v/GTChatKit.svg?style=flat)](http://cocoapods.org/pods/GTChatKit) 5 | [![License](https://img.shields.io/cocoapods/l/GTChatKit.svg?style=flat)](http://cocoapods.org/pods/GTChatKit) 6 | [![Platform](https://img.shields.io/cocoapods/p/GTChatKit.svg?style=flat)](http://cocoapods.org/pods/GTChatKit) 7 | 8 | GTChatKit is build on Texture for easy building iOS Message Application. 9 | Also it support Bi-directional Paging CollectionView 10 | 11 | Why? Texture 12 | Texture 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/) 13 | 14 | ### Pagination Example 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 |
AppendingPrepending
26 | 27 | ### Message Input Box Example 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
InActiveActive
40 | 41 | ## Usage 42 | [example source](https://github.com/GeekTree0101/GTChatKit/tree/master/Example) 43 | 44 | ### 1. Create GTChatNodeController subclass 45 | 46 | ``` swift 47 | class ChatNodeController: GTChatNodeController { ... } 48 | ``` 49 | > and you can create subclass instance 50 | ``` swift 51 | let viewController = ChatNodeController() 52 | ``` 53 | > if you want custom collection flow layout follow it 54 | ``` swift 55 | let customFlowLayout = YOURCUSTOMCollectionFlowLayout() 56 | let viewController = GTChatNodeController(layout: customFlowLayout) 57 | ``` 58 | 59 | > you can access chatNode and node(backgroundNode) 60 | ``` swift 61 | class ChatNodeController: GTChatNodeController { 62 | 63 | ... 64 | 65 | func foo() { 66 | 67 | let collectionView = self.chatNode // chatNode is equal to UICollectionView 68 | let backgroundView = self.node // self.node is equal to backgroundView(UIView) 69 | } 70 | 71 | } 72 | ``` 73 | 74 | ### 2. GTChatNodeDelegate implementation 75 | ```swift 76 | extension ChatNodeController: GTChatNodeDelegate { 77 | func shouldAppendBatchFetch(for chatNode: ASCollectionNode) -> Bool { 78 | // Should Append Batch Fetch 79 | return true 80 | } 81 | 82 | func shouldPrependBatchFetch(for chatNode: ASCollectionNode) -> Bool { 83 | // Should Prepend Batch Fetch 84 | return true 85 | } 86 | 87 | func chatNode(_ chatNode: ASCollectionNode, willBeginAppendBatchFetchWith context: ASBatchContext) { 88 | // Network Call Handling 89 | // If Network Call Completed then context should be completed 90 | // required example 91 | // eg) self.completeBatchFetching(true, endDirection: .none) 92 | } 93 | 94 | func chatNode(_ chatNode: ASCollectionNode, willBeginPrependBatchFetchWith context: ASBatchContext) { 95 | ... 96 | } 97 | } 98 | ``` 99 | 100 | ### 3. completeBatchFetching 101 | 102 | ``` swift 103 | func completeBatchFetching(_ complated: Bool, endDirection: BatchFetchDirection) { ... } 104 | 105 | endDirection: automatically block append or prepend batch fetching 106 | self.completeBatchFetching(true, endDirection: .append) -> no more append doesn't work 107 | self.completeBatchFetching(true, endDirection: .prepend) -> no more prepend doesn't work 108 | ``` 109 | 110 | ### 4. pagingStatus property 111 | 112 | you can see 4 steps paging status 113 | 1. initial 114 | 2. appending 115 | 3. prepending 116 | 4. some 117 | 118 | (2), (3) is Loading status 119 | (4: some) is means networking is finished and got new items 120 | you do not need to be aware of (1: initial status) existence 121 | 122 | ### 5. If you need attach message input node then override layoutSpecThatFits method on subclass 123 | 124 | > Also, when keyboard is activated, you can get keyboard height from keyboardVisibleHeight property 125 | ``` swift 126 | override func layoutSpecThatFits(_ constrainedSize: ASSizeRange, chatNode: ASCollectionNode) -> ASLayoutSpec { 127 | let messageInsets: UIEdgeInsets = .init(top: .infinity, 128 | left: 0.0, 129 | bottom: self.keyboardVisibleHeight, 130 | right: 0.0) 131 | 132 | let messageLayout = ASInsetLayoutSpec(insets: messageInsets, 133 | child: self.messageNode) 134 | 135 | // overlay message input box onto chatNode 136 | let messageOverlayedLayout = ASOverlayLayoutSpec(child: chatNode, 137 | overlay: messageLayout) 138 | 139 | return ASInsetLayoutSpec(insets: .zero, child: messageOverlayedLayout) 140 | } 141 | ``` 142 | 143 | ### 6. overriding setupChatRangeTuningParameters method 144 | > If you deal with the tuning parameters for range type on your scrolling node 145 | > More Information [Here](http://texturegroup.org/docs/intelligent-preloading.html) 146 | 147 | ``` swift 148 | // default 149 | open func setupChatRangeTuningParameters() { 150 | self.chatNode.setTuningParameters(ASRangeTuningParameters(leadingBufferScreenfuls: 1.5, 151 | trailingBufferScreenfuls: 1.5), 152 | for: .full, 153 | rangeType: .display) 154 | self.chatNode.setTuningParameters(ASRangeTuningParameters(leadingBufferScreenfuls: 2, 155 | trailingBufferScreenfuls: 2), 156 | for: .full, 157 | rangeType: .preload) 158 | } 159 | ``` 160 | 161 | ### 7. GTChatKit System Message Input Box 162 | 163 | ``` swift 164 | let node = GTChatMessageBoxNode() 165 | 166 | // Create ChatMessageButtonNode 167 | let cameraButton = GTChatMessageButtonNode() 168 | .setButtonSize(.init(width: 24.0, height: 24.0)) 169 | .setButtonImage(#imageLiteral(resourceName: "photo"), color: .white, for: .normal) 170 | .setButtonImage(#imageLiteral(resourceName: "photo"), color: UIColor.white.withAlphaComponent(0.5), for: .disabled) 171 | 172 | let sendButton = GTChatMessageButtonNode() 173 | .setButtonSize(.init(width: 24.0, height: 24.0)) 174 | .setButtonImage(#imageLiteral(resourceName: "send"), color: .white, for: .normal) 175 | .setButtonImage(#imageLiteral(resourceName: "send"), color: UIColor.white.withAlphaComponent(0.5), for: .disabled) 176 | 177 | node.messageNode.setMessageContainerInsets(UIEdgeInsetsMake(5.0, 10.0, 5.0, 10.0)) 178 | 179 | // apply Message Box Attributes 180 | node.setLeftButtons([cameraButton], spacing: 10.0) // attach left button items 181 | .setRightButtons([sendButton], spacing: 10.0) // attach right button items 182 | .setMessageBoxHeight(50.0, maxiumNumberOfLine: 6, isRounded: true) // set message input box size 183 | ``` 184 | 185 | ## Requirements 186 | - Xcode <~ 9.0 187 | - iOS <~ 9.x 188 | - Swift <~ 3.x, 4.0 189 | 190 | ## Installation 191 | 192 | GTChatKit is available through [CocoaPods](http://cocoapods.org). To install 193 | it, simply add the following line to your Podfile: 194 | 195 | ```ruby 196 | pod 'GTChatKit' 197 | ``` 198 | 199 | ## Author 200 | 201 | Geektree0101, h2s1880@gmail.com 202 | 203 | ## License 204 | 205 | GTChatKit is available under the MIT license. See the LICENSE file for more info. 206 | -------------------------------------------------------------------------------- /_Pods.xcodeproj: -------------------------------------------------------------------------------- 1 | Example/Pods/Pods.xcodeproj -------------------------------------------------------------------------------- /resource/append.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GeekTree0101/GTChatKit/5152aea224fe50d82adbde2376e2f94272a5cf07/resource/append.gif -------------------------------------------------------------------------------- /resource/messageBoxActive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GeekTree0101/GTChatKit/5152aea224fe50d82adbde2376e2f94272a5cf07/resource/messageBoxActive.png -------------------------------------------------------------------------------- /resource/messageBoxInActive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GeekTree0101/GTChatKit/5152aea224fe50d82adbde2376e2f94272a5cf07/resource/messageBoxInActive.png -------------------------------------------------------------------------------- /resource/prepend.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GeekTree0101/GTChatKit/5152aea224fe50d82adbde2376e2f94272a5cf07/resource/prepend.gif --------------------------------------------------------------------------------