├── .gitignore
├── .travis.yml
├── License.txt
├── PromoAssets
└── SimpleChatScreenShot.png
├── README.md
├── SimpleChat.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ └── contents.xcworkspacedata
└── xcuserdata
│ └── loganwright.xcuserdatad
│ └── xcschemes
│ ├── SimpleChat.xcscheme
│ └── xcschememanagement.plist
├── SimpleChat
├── AppDelegate.h
├── AppDelegate.m
├── Base.lproj
│ └── Main.storyboard
├── Images.xcassets
│ ├── AppIcon.appiconset
│ │ ├── Contents.json
│ │ └── SimpleChatIcon.png
│ ├── LaunchImage.launchimage
│ │ └── Contents.json
│ └── User.imageset
│ │ ├── Contents.json
│ │ └── User.png
├── LGSimpleChat
│ ├── LGSimpleChat.swift
│ └── License
├── SimpleChat-Bridging-Header.h
├── SimpleChat-Info.plist
├── SimpleChat-Prefix.pch
├── SwiftViewControllerExample
│ └── SwiftExampleViewController.swift
├── ViewControllerExample
│ ├── ViewController.h
│ └── ViewController.m
├── en.lproj
│ └── InfoPlist.strings
└── main.m
└── SimpleChatTests
├── SimpleChatTests-Info.plist
├── SimpleChatTests.m
└── en.lproj
└── InfoPlist.strings
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | build/
4 | *.pbxuser
5 | !default.pbxuser
6 | *.mode1v3
7 | !default.mode1v3
8 | *.mode2v3
9 | !default.mode2v3
10 | *.perspectivev3
11 | !default.perspectivev3
12 | xcuserdata
13 | *.xccheckout
14 | *.moved-aside
15 | DerivedData
16 | *.hmap
17 | *.ipa
18 | *.xcuserstate
19 |
20 | # CocoaPods
21 | #
22 | # We recommend against adding the Pods directory to your .gitignore. However
23 | # you should judge for yourself, the pros and cons are mentioned at:
24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
25 | #
26 | # Pods/
27 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: objective-c
2 |
--------------------------------------------------------------------------------
/License.txt:
--------------------------------------------------------------------------------
1 | Mozilla Public License
2 | Version 2.0
3 |
4 | 1. Definitions
5 |
6 | 1.1. “Contributor”
7 | means each individual or legal entity that creates, contributes to the creation of, or owns Covered Software.
8 |
9 | 1.2. “Contributor Version”
10 | means the combination of the Contributions of others (if any) used by a Contributor and that particular Contributor’s Contribution.
11 |
12 | 1.3. “Contribution”
13 | means Covered Software of a particular Contributor.
14 |
15 | 1.4. “Covered Software”
16 | means Source Code Form to which the initial Contributor has attached the notice in Exhibit A, the Executable Form of such Source Code Form, and Modifications of such Source Code Form, in each case including portions thereof.
17 |
18 | 1.5. “Incompatible With Secondary Licenses”
19 | means
20 |
21 | that the initial Contributor has attached the notice described in Exhibit B to the Covered Software; or
22 |
23 | that the Covered Software was made available under the terms of version 1.1 or earlier of the License, but not also under the terms of a Secondary License.
24 |
25 | 1.6. “Executable Form”
26 | means any form of the work other than Source Code Form.
27 |
28 | 1.7. “Larger Work”
29 | means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software.
30 |
31 | 1.8. “License”
32 | means this document.
33 |
34 | 1.9. “Licensable”
35 | means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently, any and all of the rights conveyed by this License.
36 |
37 | 1.10. “Modifications”
38 | means any of the following:
39 |
40 | any file in Source Code Form that results from an addition to, deletion from, or modification of the contents of Covered Software; or
41 |
42 | any new file in Source Code Form that contains any Covered Software.
43 |
44 | 1.11. “Patent Claims” of a Contributor
45 | means any patent claim(s), including without limitation, method, process, and apparatus claims, in any patent Licensable by such Contributor that would be infringed, but for the grant of the License, by the making, using, selling, offering for sale, having made, import, or transfer of either its Contributions or its Contributor Version.
46 |
47 | 1.12. “Secondary License”
48 | means either the GNU General Public License, Version 2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General Public License, Version 3.0, or any later versions of those licenses.
49 |
50 | 1.13. “Source Code Form”
51 | means the form of the work preferred for making modifications.
52 |
53 | 1.14. “You” (or “Your”)
54 | means an individual or a legal entity exercising rights under this License. For legal entities, “You” includes any entity that controls, is controlled by, or is under common control with You. For purposes of this definition, “control” means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity.
55 |
56 | 2. License Grants and Conditions
57 |
58 | 2.1. Grants
59 |
60 | Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license:
61 |
62 | under intellectual property rights (other than patent or trademark) Licensable by such Contributor to use, reproduce, make available, modify, display, perform, distribute, and otherwise exploit its Contributions, either on an unmodified basis, with Modifications, or as part of a Larger Work; and
63 |
64 | under Patent Claims of such Contributor to make, use, sell, offer for sale, have made, import, and otherwise transfer either its Contributions or its Contributor Version.
65 |
66 | 2.2. Effective Date
67 |
68 | The licenses granted in Section 2.1 with respect to any Contribution become effective for each Contribution on the date the Contributor first distributes such Contribution.
69 |
70 | 2.3. Limitations on Grant Scope
71 |
72 | The licenses granted in this Section 2 are the only rights granted under this License. No additional rights or licenses will be implied from the distribution or licensing of Covered Software under this License. Notwithstanding Section 2.1(b) above, no patent license is granted by a Contributor:
73 |
74 | for any code that a Contributor has removed from Covered Software; or
75 |
76 | for infringements caused by: (i) Your and any other third party’s modifications of Covered Software, or (ii) the combination of its Contributions with other software (except as part of its Contributor Version); or
77 |
78 | under Patent Claims infringed by Covered Software in the absence of its Contributions.
79 |
80 | This License does not grant any rights in the trademarks, service marks, or logos of any Contributor (except as may be necessary to comply with the notice requirements in Section 3.4).
81 |
82 | 2.4. Subsequent Licenses
83 |
84 | No Contributor makes additional grants as a result of Your choice to distribute the Covered Software under a subsequent version of this License (see Section 10.2) or under the terms of a Secondary License (if permitted under the terms of Section 3.3).
85 |
86 | 2.5. Representation
87 |
88 | Each Contributor represents that the Contributor believes its Contributions are its original creation(s) or it has sufficient rights to grant the rights to its Contributions conveyed by this License.
89 |
90 | 2.6. Fair Use
91 |
92 | This License is not intended to limit any rights You have under applicable copyright doctrines of fair use, fair dealing, or other equivalents.
93 |
94 | 2.7. Conditions
95 |
96 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Section 2.1.
97 |
98 | 3. Responsibilities
99 |
100 | 3.1. Distribution of Source Form
101 |
102 | All distribution of Covered Software in Source Code Form, including any Modifications that You create or to which You contribute, must be under the terms of this License. You must inform recipients that the Source Code Form of the Covered Software is governed by the terms of this License, and how they can obtain a copy of this License. You may not attempt to alter or restrict the recipients’ rights in the Source Code Form.
103 |
104 | 3.2. Distribution of Executable Form
105 |
106 | If You distribute Covered Software in Executable Form then:
107 |
108 | such Covered Software must also be made available in Source Code Form, as described in Section 3.1, and You must inform recipients of the Executable Form how they can obtain a copy of such Source Code Form by reasonable means in a timely manner, at a charge no more than the cost of distribution to the recipient; and
109 |
110 | You may distribute such Executable Form under the terms of this License, or sublicense it under different terms, provided that the license for the Executable Form does not attempt to limit or alter the recipients’ rights in the Source Code Form under this License.
111 |
112 | 3.3. Distribution of a Larger Work
113 |
114 | You may create and distribute a Larger Work under terms of Your choice, provided that You also comply with the requirements of this License for the Covered Software. If the Larger Work is a combination of Covered Software with a work governed by one or more Secondary Licenses, and the Covered Software is not Incompatible With Secondary Licenses, this License permits You to additionally distribute such Covered Software under the terms of such Secondary License(s), so that the recipient of the Larger Work may, at their option, further distribute the Covered Software under the terms of either this License or such Secondary License(s).
115 |
116 | 3.4. Notices
117 |
118 | You may not remove or alter the substance of any license notices (including copyright notices, patent notices, disclaimers of warranty, or limitations of liability) contained within the Source Code Form of the Covered Software, except that You may alter any license notices to the extent required to remedy known factual inaccuracies.
119 |
120 | 3.5. Application of Additional Terms
121 |
122 | You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, You may do so only on Your own behalf, and not on behalf of any Contributor. You must make it absolutely clear that any such warranty, support, indemnity, or liability obligation is offered by You alone, and You hereby agree to indemnify every Contributor for any liability incurred by such Contributor as a result of warranty, support, indemnity or liability terms You offer. You may include additional disclaimers of warranty and limitations of liability specific to any jurisdiction.
123 |
124 | 4. Inability to Comply Due to Statute or Regulation
125 |
126 | If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Software due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be placed in a text file included with all distributions of the Covered Software under this License. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it.
127 |
128 | 5. Termination
129 |
130 | 5.1. The rights granted under this License will terminate automatically if You fail to comply with any of its terms. However, if You become compliant, then the rights granted under this License from a particular Contributor are reinstated (a) provisionally, unless and until such Contributor explicitly and finally terminates Your grants, and (b) on an ongoing basis, if such Contributor fails to notify You of the non-compliance by some reasonable means prior to 60 days after You have come back into compliance. Moreover, Your grants from a particular Contributor are reinstated on an ongoing basis if such Contributor notifies You of the non-compliance by some reasonable means, this is the first time You have received notice of non-compliance with this License from such Contributor, and You become compliant prior to 30 days after Your receipt of the notice.
131 |
132 | 5.2. If You initiate litigation against any entity by asserting a patent infringement claim (excluding declaratory judgment actions, counter-claims, and cross-claims) alleging that a Contributor Version directly or indirectly infringes any patent, then the rights granted to You by any and all Contributors for the Covered Software under Section 2.1 of this License shall terminate.
133 |
134 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or Your distributors under this License prior to termination shall survive termination.
135 |
136 | 6. Disclaimer of Warranty
137 |
138 | Covered Software is provided under this License on an “as is” basis, without warranty of any kind, either expressed, implied, or statutory, including, without limitation, warranties that the Covered Software is free of defects, merchantable, fit for a particular purpose or non-infringing. The entire risk as to the quality and performance of the Covered Software is with You. Should any Covered Software prove defective in any respect, You (not any Contributor) assume the cost of any necessary servicing, repair, or correction. This disclaimer of warranty constitutes an essential part of this License. No use of any Covered Software is authorized under this License except under this disclaimer.
139 |
140 | 7. Limitation of Liability
141 |
142 | Under no circumstances and under no legal theory, whether tort (including negligence), contract, or otherwise, shall any Contributor, or anyone who distributes Covered Software as permitted above, be liable to You for any direct, indirect, special, incidental, or consequential damages of any character including, without limitation, damages for lost profits, loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses, even if such party shall have been informed of the possibility of such damages. This limitation of liability shall not apply to liability for death or personal injury resulting from such party’s negligence to the extent applicable law prohibits such limitation. Some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages, so this exclusion and limitation may not apply to You.
143 |
144 | 8. Litigation
145 |
146 | Any litigation relating to this License may be brought only in the courts of a jurisdiction where the defendant maintains its principal place of business and such litigation shall be governed by laws of that jurisdiction, without reference to its conflict-of-law provisions. Nothing in this Section shall prevent a party’s ability to bring cross-claims or counter-claims.
147 |
148 | 9. Miscellaneous
149 |
150 | This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not be used to construe this License against a Contributor.
151 |
152 | 10. Versions of the License
153 |
154 | 10.1. New Versions
155 |
156 | Mozilla Foundation is the license steward. Except as provided in Section 10.3, no one other than the license steward has the right to modify or publish new versions of this License. Each version will be given a distinguishing version number.
157 |
158 | 10.2. Effect of New Versions
159 |
160 | You may distribute the Covered Software under the terms of the version of the License under which You originally received the Covered Software, or under the terms of any subsequent version published by the license steward.
161 |
162 | 10.3. Modified Versions
163 |
164 | If you create software not governed by this License, and you want to create a new license for such software, you may create and use a modified version of this License if you rename the license and remove any references to the name of the license steward (except to note that such modified license differs from this License).
165 |
166 | 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses
167 |
168 | If You choose to distribute Source Code Form that is Incompatible With Secondary Licenses under the terms of this version of the License, the notice described in Exhibit B of this License must be attached.
169 |
170 | Exhibit A - Source Code Form License Notice
171 |
172 | This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
173 |
174 | If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice.
175 |
176 | You may add additional accurate notices of copyright ownership.
177 |
178 | Exhibit B - “Incompatible With Secondary Licenses” Notice
179 |
180 | This Source Code Form is “Incompatible With Secondary Licenses”, as defined by the Mozilla Public License, v. 2.0.
--------------------------------------------------------------------------------
/PromoAssets/SimpleChatScreenShot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loganwright/SimpleChat/19d12c80630498b642b0c7e6f8a98dc26317e856/PromoAssets/SimpleChatScreenShot.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | #
Welcome To SimpleChat 2.0!
2 |
3 | ##New Features
4 |
5 | 1. Completely redesigned implementation in Swift
6 | 2. Supports iOS 7.1+
7 | 3. New Screen Size Support
8 |
9 | #SimpleChat
10 |
11 | An easy to use bubble chat UI as an alternative to the traditional iOS talk bubbles.
12 |
13 |
14 | 
15 |
16 |
17 |
18 |
19 | ###Getting Started
20 |
21 | ####1. Add The `LGSimpleChat` Folder To Xcode
22 |
23 | - Drag the folder into your Xcode project
24 | - Make sure "Copy items into destination group's folder (if needed)" is selected
25 |
26 | ####2. ObjC
27 |
28 | - Import `<#YourProductModule#>-Swift.h`
29 | - Conform to `LGChatControllerDelegate`
30 | - Call `[self launchChatController]` (specified below)
31 |
32 | In `<#YourViewController#>.m`
33 |
34 | ```ObjC
35 | #import "<#YourViewController#>.h"
36 | #import "<#YourProductModule#>-Swift.h"
37 |
38 | @interface <#YourViewController#> ()
39 |
40 | @end
41 |
42 | @implementation
43 |
44 | #pragma mark - Launch Chat Controller
45 |
46 | - (void)launchChatController
47 | {
48 | LGChatController *chatController = [LGChatController new];
49 | chatController.opponentImage = [UIImage imageNamed:@"<#YourImageName#>"];
50 | chatController.title = @"<#YourTitle#>";
51 | LGChatMessage *helloWorld = [[LGChatMessage alloc] initWithContent:@"Hello World" sentByString:[LGChatMessage SentByUserString]];
52 | chatController.messages = @[helloWorld]; // Pass your messages here.
53 | chatController.delegate = self;
54 | [self.navigationController pushViewController:chatController animated:YES];
55 | }
56 |
57 | #pragma mark - LGChatControllerDelegate
58 |
59 | - (void)chatController:(LGChatController *)chatController didAddNewMessage:(LGChatMessage *)message
60 | {
61 | NSLog(@"Did Add Message: %@", message.content);
62 | }
63 |
64 | - (BOOL)shouldChatController:(LGChatController *)chatController addMessage:(LGChatMessage *)message
65 | {
66 | /*
67 | Use this space to prevent sending a message, or to alter a message. For example, you might want to hold a message until its successfully uploaded to a server.
68 | */
69 | return YES;
70 | }
71 |
72 | @end
73 |
74 | ```
75 |
76 | ### Initializing a Message
77 |
78 | ```ObjC
79 | LGChatMessage *helloWorld = [[LGChatMessage alloc] initWithContent:@"Hello World" sentByString:[LGChatMessage SentByUserString]];
80 |
81 | or
82 |
83 | LGChatMessage *helloWorld = [[LGChatMessage alloc] initWithContent:@"Hello World" sentByString:[LGChatMessage SentByOpponentString] timeStamp: someTimestamp];
84 | ```
85 |
86 | ### Stylization Options
87 |
88 | #### Chat Input
89 |
90 | ```ObjC
91 | - (void)styleChatInput
92 | {
93 | [LGChatInput setAppearanceBackgroundColor:<#UIColor#>];
94 | [LGChatInput setAppearanceIncludeBlur:<#Bool#>];
95 | [LGChatInput setAppearanceTextViewFont:<#UIFont#>];
96 | [LGChatInput setAppearanceTextViewTextColor:<#UIColor#>];
97 | [LGChatInput setAppearanceTintColor:<#UIColor#>];
98 | [LGChatInput setAppearanceTextViewBackgroundColor:<#UIColor#>];
99 | }
100 | ```
101 |
102 | #### Message Cell
103 |
104 | ```ObjC
105 | - (void)styleMessageCell
106 | {
107 | [LGChatMessageCell setAppearanceFont:<#UIFont#>];
108 | [LGChatMessageCell setAppearanceOpponentColor:[<#UIColor#>];
109 | [LGChatMessageCell setAppearanceUserColor:<#UIColor#>];
110 | }
111 | ```
112 |
113 | ####2. Swift
114 |
115 | - Import `<#YourProductModule#>-Swift.h`
116 | - Conform to `LGChatControllerDelegate`
117 | - Call `[self launchChatController]` (specified below)
118 |
119 | In `<#YourViewController#>.swift`
120 |
121 | ```Swift
122 |
123 | import UIKit
124 |
125 | class SwiftExampleViewController: UIViewController, LGChatControllerDelegate {
126 |
127 | override func viewDidLoad() {
128 | super.viewDidLoad()
129 | }
130 |
131 | // MARK: Launch Chat Controller
132 |
133 | func launchChatController() {
134 | let chatController = LGChatController()
135 | chatController.opponentImage = UIImage(named: "User")
136 | chatController.title = "Simple Chat"
137 | let helloWorld = LGChatMessage(content: "Hello World!", sentBy: .User)
138 | chatController.messages = [helloWorld]
139 | chatController.delegate = self
140 | self.navigationController?.pushViewController(chatController, animated: true)
141 | }
142 |
143 | // MARK: LGChatControllerDelegate
144 |
145 | func chatController(chatController: LGChatController, didAddNewMessage message: LGChatMessage) {
146 | println("Did Add Message: \(message.content)")
147 | }
148 |
149 | func shouldChatController(chatController: LGChatController, addMessage message: LGChatMessage) -> Bool {
150 | /*
151 | Use this space to prevent sending a message, or to alter a message. For example, you might want to hold a message until its successfully uploaded to a server.
152 | */
153 | return true
154 | }
155 |
156 | }
157 |
158 | ```
159 |
160 | ### Initializing a Message
161 |
162 | ```ObjC
163 | let message = LGChatMessage(content: "Hello World!", sentBy: .User)
164 |
165 | -- or --
166 |
167 | let message = LGChatMessage(content: "Hello World!", sentBy: .Opponent, timeStamp: someTimestamp)
168 | ```
169 |
170 | ### Stylization Options
171 |
172 | #### Chat Input
173 |
174 | ```Swift
175 | func stylizeChatInput() {
176 | LGChatInput.Appearance.backgroundColor = <#UIColor#>
177 | LGChatInput.Appearance.includeBlur = <#Bool#>
178 | LGChatInput.Appearance.textViewFont = <#UIFont#>
179 | LGChatInput.Appearance.textViewTextColor = <#UIColor#>
180 | LGChatInput.Appearance.tintColor = <#UIColor#>
181 | LGChatInput.Appearance.textViewBackgroundColor = <#UIColor#>
182 | }
183 | ```
184 |
185 | #### Message Cell
186 |
187 | ```ObjC
188 | func stylizeMessageCell() {
189 | LGChatMessageCell.Appearance.font = <#UIFont#>
190 | LGChatMessageCell.Appearance.opponentColor = <#UIColor#>
191 | LGChatMessageCell.Appearance.userColor = <#UIColor#>
192 | }
193 | ```
194 |
195 | ##License
196 |
197 | **You may not claim this code as your own!**
198 |
199 | This product is licensed under MPL 2.0.
200 |
201 | ```
202 |
203 | Mozilla Public License
204 | Version 2.0
205 |
206 | 1. Definitions
207 |
208 | 1.1. “Contributor”
209 | means each individual or legal entity that creates, contributes to the creation of, or owns Covered Software.
210 |
211 | 1.2. “Contributor Version”
212 | means the combination of the Contributions of others (if any) used by a Contributor and that particular Contributor’s Contribution.
213 |
214 | 1.3. “Contribution”
215 | means Covered Software of a particular Contributor.
216 |
217 | 1.4. “Covered Software”
218 | means Source Code Form to which the initial Contributor has attached the notice in Exhibit A, the Executable Form of such Source Code Form, and Modifications of such Source Code Form, in each case including portions thereof.
219 |
220 | 1.5. “Incompatible With Secondary Licenses”
221 | means
222 |
223 | that the initial Contributor has attached the notice described in Exhibit B to the Covered Software; or
224 |
225 | that the Covered Software was made available under the terms of version 1.1 or earlier of the License, but not also under the terms of a Secondary License.
226 |
227 | 1.6. “Executable Form”
228 | means any form of the work other than Source Code Form.
229 |
230 | 1.7. “Larger Work”
231 | means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software.
232 |
233 | 1.8. “License”
234 | means this document.
235 |
236 | 1.9. “Licensable”
237 | means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently, any and all of the rights conveyed by this License.
238 |
239 | 1.10. “Modifications”
240 | means any of the following:
241 |
242 | any file in Source Code Form that results from an addition to, deletion from, or modification of the contents of Covered Software; or
243 |
244 | any new file in Source Code Form that contains any Covered Software.
245 |
246 | 1.11. “Patent Claims” of a Contributor
247 | means any patent claim(s), including without limitation, method, process, and apparatus claims, in any patent Licensable by such Contributor that would be infringed, but for the grant of the License, by the making, using, selling, offering for sale, having made, import, or transfer of either its Contributions or its Contributor Version.
248 |
249 | 1.12. “Secondary License”
250 | means either the GNU General Public License, Version 2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General Public License, Version 3.0, or any later versions of those licenses.
251 |
252 | 1.13. “Source Code Form”
253 | means the form of the work preferred for making modifications.
254 |
255 | 1.14. “You” (or “Your”)
256 | means an individual or a legal entity exercising rights under this License. For legal entities, “You” includes any entity that controls, is controlled by, or is under common control with You. For purposes of this definition, “control” means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity.
257 |
258 | 2. License Grants and Conditions
259 |
260 | 2.1. Grants
261 |
262 | Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license:
263 |
264 | under intellectual property rights (other than patent or trademark) Licensable by such Contributor to use, reproduce, make available, modify, display, perform, distribute, and otherwise exploit its Contributions, either on an unmodified basis, with Modifications, or as part of a Larger Work; and
265 |
266 | under Patent Claims of such Contributor to make, use, sell, offer for sale, have made, import, and otherwise transfer either its Contributions or its Contributor Version.
267 |
268 | 2.2. Effective Date
269 |
270 | The licenses granted in Section 2.1 with respect to any Contribution become effective for each Contribution on the date the Contributor first distributes such Contribution.
271 |
272 | 2.3. Limitations on Grant Scope
273 |
274 | The licenses granted in this Section 2 are the only rights granted under this License. No additional rights or licenses will be implied from the distribution or licensing of Covered Software under this License. Notwithstanding Section 2.1(b) above, no patent license is granted by a Contributor:
275 |
276 | for any code that a Contributor has removed from Covered Software; or
277 |
278 | for infringements caused by: (i) Your and any other third party’s modifications of Covered Software, or (ii) the combination of its Contributions with other software (except as part of its Contributor Version); or
279 |
280 | under Patent Claims infringed by Covered Software in the absence of its Contributions.
281 |
282 | This License does not grant any rights in the trademarks, service marks, or logos of any Contributor (except as may be necessary to comply with the notice requirements in Section 3.4).
283 |
284 | 2.4. Subsequent Licenses
285 |
286 | No Contributor makes additional grants as a result of Your choice to distribute the Covered Software under a subsequent version of this License (see Section 10.2) or under the terms of a Secondary License (if permitted under the terms of Section 3.3).
287 |
288 | 2.5. Representation
289 |
290 | Each Contributor represents that the Contributor believes its Contributions are its original creation(s) or it has sufficient rights to grant the rights to its Contributions conveyed by this License.
291 |
292 | 2.6. Fair Use
293 |
294 | This License is not intended to limit any rights You have under applicable copyright doctrines of fair use, fair dealing, or other equivalents.
295 |
296 | 2.7. Conditions
297 |
298 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Section 2.1.
299 |
300 | 3. Responsibilities
301 |
302 | 3.1. Distribution of Source Form
303 |
304 | All distribution of Covered Software in Source Code Form, including any Modifications that You create or to which You contribute, must be under the terms of this License. You must inform recipients that the Source Code Form of the Covered Software is governed by the terms of this License, and how they can obtain a copy of this License. You may not attempt to alter or restrict the recipients’ rights in the Source Code Form.
305 |
306 | 3.2. Distribution of Executable Form
307 |
308 | If You distribute Covered Software in Executable Form then:
309 |
310 | such Covered Software must also be made available in Source Code Form, as described in Section 3.1, and You must inform recipients of the Executable Form how they can obtain a copy of such Source Code Form by reasonable means in a timely manner, at a charge no more than the cost of distribution to the recipient; and
311 |
312 | You may distribute such Executable Form under the terms of this License, or sublicense it under different terms, provided that the license for the Executable Form does not attempt to limit or alter the recipients’ rights in the Source Code Form under this License.
313 |
314 | 3.3. Distribution of a Larger Work
315 |
316 | You may create and distribute a Larger Work under terms of Your choice, provided that You also comply with the requirements of this License for the Covered Software. If the Larger Work is a combination of Covered Software with a work governed by one or more Secondary Licenses, and the Covered Software is not Incompatible With Secondary Licenses, this License permits You to additionally distribute such Covered Software under the terms of such Secondary License(s), so that the recipient of the Larger Work may, at their option, further distribute the Covered Software under the terms of either this License or such Secondary License(s).
317 |
318 | 3.4. Notices
319 |
320 | You may not remove or alter the substance of any license notices (including copyright notices, patent notices, disclaimers of warranty, or limitations of liability) contained within the Source Code Form of the Covered Software, except that You may alter any license notices to the extent required to remedy known factual inaccuracies.
321 |
322 | 3.5. Application of Additional Terms
323 |
324 | You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, You may do so only on Your own behalf, and not on behalf of any Contributor. You must make it absolutely clear that any such warranty, support, indemnity, or liability obligation is offered by You alone, and You hereby agree to indemnify every Contributor for any liability incurred by such Contributor as a result of warranty, support, indemnity or liability terms You offer. You may include additional disclaimers of warranty and limitations of liability specific to any jurisdiction.
325 |
326 | 4. Inability to Comply Due to Statute or Regulation
327 |
328 | If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Software due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be placed in a text file included with all distributions of the Covered Software under this License. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it.
329 |
330 | 5. Termination
331 |
332 | 5.1. The rights granted under this License will terminate automatically if You fail to comply with any of its terms. However, if You become compliant, then the rights granted under this License from a particular Contributor are reinstated (a) provisionally, unless and until such Contributor explicitly and finally terminates Your grants, and (b) on an ongoing basis, if such Contributor fails to notify You of the non-compliance by some reasonable means prior to 60 days after You have come back into compliance. Moreover, Your grants from a particular Contributor are reinstated on an ongoing basis if such Contributor notifies You of the non-compliance by some reasonable means, this is the first time You have received notice of non-compliance with this License from such Contributor, and You become compliant prior to 30 days after Your receipt of the notice.
333 |
334 | 5.2. If You initiate litigation against any entity by asserting a patent infringement claim (excluding declaratory judgment actions, counter-claims, and cross-claims) alleging that a Contributor Version directly or indirectly infringes any patent, then the rights granted to You by any and all Contributors for the Covered Software under Section 2.1 of this License shall terminate.
335 |
336 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or Your distributors under this License prior to termination shall survive termination.
337 |
338 | 6. Disclaimer of Warranty
339 |
340 | Covered Software is provided under this License on an “as is” basis, without warranty of any kind, either expressed, implied, or statutory, including, without limitation, warranties that the Covered Software is free of defects, merchantable, fit for a particular purpose or non-infringing. The entire risk as to the quality and performance of the Covered Software is with You. Should any Covered Software prove defective in any respect, You (not any Contributor) assume the cost of any necessary servicing, repair, or correction. This disclaimer of warranty constitutes an essential part of this License. No use of any Covered Software is authorized under this License except under this disclaimer.
341 |
342 | 7. Limitation of Liability
343 |
344 | Under no circumstances and under no legal theory, whether tort (including negligence), contract, or otherwise, shall any Contributor, or anyone who distributes Covered Software as permitted above, be liable to You for any direct, indirect, special, incidental, or consequential damages of any character including, without limitation, damages for lost profits, loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses, even if such party shall have been informed of the possibility of such damages. This limitation of liability shall not apply to liability for death or personal injury resulting from such party’s negligence to the extent applicable law prohibits such limitation. Some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages, so this exclusion and limitation may not apply to You.
345 |
346 | 8. Litigation
347 |
348 | Any litigation relating to this License may be brought only in the courts of a jurisdiction where the defendant maintains its principal place of business and such litigation shall be governed by laws of that jurisdiction, without reference to its conflict-of-law provisions. Nothing in this Section shall prevent a party’s ability to bring cross-claims or counter-claims.
349 |
350 | 9. Miscellaneous
351 |
352 | This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not be used to construe this License against a Contributor.
353 |
354 | 10. Versions of the License
355 |
356 | 10.1. New Versions
357 |
358 | Mozilla Foundation is the license steward. Except as provided in Section 10.3, no one other than the license steward has the right to modify or publish new versions of this License. Each version will be given a distinguishing version number.
359 |
360 | 10.2. Effect of New Versions
361 |
362 | You may distribute the Covered Software under the terms of the version of the License under which You originally received the Covered Software, or under the terms of any subsequent version published by the license steward.
363 |
364 | 10.3. Modified Versions
365 |
366 | If you create software not governed by this License, and you want to create a new license for such software, you may create and use a modified version of this License if you rename the license and remove any references to the name of the license steward (except to note that such modified license differs from this License).
367 |
368 | 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses
369 |
370 | If You choose to distribute Source Code Form that is Incompatible With Secondary Licenses under the terms of this version of the License, the notice described in Exhibit B of this License must be attached.
371 |
372 | Exhibit A - Source Code Form License Notice
373 |
374 | This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
375 |
376 | If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice.
377 |
378 | You may add additional accurate notices of copyright ownership.
379 |
380 | Exhibit B - “Incompatible With Secondary Licenses” Notice
381 |
382 | This Source Code Form is “Incompatible With Secondary Licenses”, as defined by the Mozilla Public License, v. 2.0.
383 | ```
384 |
385 |
404 |
--------------------------------------------------------------------------------
/SimpleChat.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 800D4D1A1A183A9E00F5CB14 /* LGSimpleChat.swift in Sources */ = {isa = PBXBuildFile; fileRef = 800D4D181A183A9E00F5CB14 /* LGSimpleChat.swift */; };
11 | 800D4D1B1A183A9E00F5CB14 /* License in Resources */ = {isa = PBXBuildFile; fileRef = 800D4D191A183A9E00F5CB14 /* License */; };
12 | 800D4D1F1A183AD600F5CB14 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 800D4D1E1A183AD600F5CB14 /* ViewController.m */; };
13 | 800D4D221A183AF000F5CB14 /* SwiftExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 800D4D211A183AF000F5CB14 /* SwiftExampleViewController.swift */; };
14 | 809B506B18D7B55B0032A48D /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 809B506A18D7B55B0032A48D /* Foundation.framework */; };
15 | 809B506D18D7B55B0032A48D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 809B506C18D7B55B0032A48D /* CoreGraphics.framework */; };
16 | 809B506F18D7B55B0032A48D /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 809B506E18D7B55B0032A48D /* UIKit.framework */; };
17 | 809B507518D7B55B0032A48D /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 809B507318D7B55B0032A48D /* InfoPlist.strings */; };
18 | 809B507718D7B55B0032A48D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 809B507618D7B55B0032A48D /* main.m */; };
19 | 809B507B18D7B55B0032A48D /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 809B507A18D7B55B0032A48D /* AppDelegate.m */; };
20 | 809B507E18D7B55B0032A48D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 809B507C18D7B55B0032A48D /* Main.storyboard */; };
21 | 809B508318D7B55B0032A48D /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 809B508218D7B55B0032A48D /* Images.xcassets */; };
22 | 809B508A18D7B55B0032A48D /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 809B508918D7B55B0032A48D /* XCTest.framework */; };
23 | 809B508B18D7B55B0032A48D /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 809B506A18D7B55B0032A48D /* Foundation.framework */; };
24 | 809B508C18D7B55B0032A48D /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 809B506E18D7B55B0032A48D /* UIKit.framework */; };
25 | 809B509418D7B55B0032A48D /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 809B509218D7B55B0032A48D /* InfoPlist.strings */; };
26 | 809B509618D7B55B0032A48D /* SimpleChatTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 809B509518D7B55B0032A48D /* SimpleChatTests.m */; };
27 | /* End PBXBuildFile section */
28 |
29 | /* Begin PBXContainerItemProxy section */
30 | 809B508D18D7B55B0032A48D /* PBXContainerItemProxy */ = {
31 | isa = PBXContainerItemProxy;
32 | containerPortal = 809B505F18D7B55B0032A48D /* Project object */;
33 | proxyType = 1;
34 | remoteGlobalIDString = 809B506618D7B55B0032A48D;
35 | remoteInfo = SimpleChat;
36 | };
37 | /* End PBXContainerItemProxy section */
38 |
39 | /* Begin PBXFileReference section */
40 | 800D4D181A183A9E00F5CB14 /* LGSimpleChat.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LGSimpleChat.swift; sourceTree = ""; };
41 | 800D4D191A183A9E00F5CB14 /* License */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = License; sourceTree = ""; };
42 | 800D4D1D1A183AD600F5CB14 /* ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; };
43 | 800D4D1E1A183AD600F5CB14 /* ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; };
44 | 800D4D211A183AF000F5CB14 /* SwiftExampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftExampleViewController.swift; sourceTree = ""; };
45 | 806254851A16AA32005A2FD1 /* SimpleChat-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SimpleChat-Bridging-Header.h"; sourceTree = ""; };
46 | 809B506718D7B55B0032A48D /* SimpleChat.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SimpleChat.app; sourceTree = BUILT_PRODUCTS_DIR; };
47 | 809B506A18D7B55B0032A48D /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
48 | 809B506C18D7B55B0032A48D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
49 | 809B506E18D7B55B0032A48D /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
50 | 809B507218D7B55B0032A48D /* SimpleChat-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SimpleChat-Info.plist"; sourceTree = ""; };
51 | 809B507418D7B55B0032A48D /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; };
52 | 809B507618D7B55B0032A48D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
53 | 809B507818D7B55B0032A48D /* SimpleChat-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SimpleChat-Prefix.pch"; sourceTree = ""; };
54 | 809B507918D7B55B0032A48D /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
55 | 809B507A18D7B55B0032A48D /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
56 | 809B507D18D7B55B0032A48D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
57 | 809B508218D7B55B0032A48D /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; };
58 | 809B508818D7B55B0032A48D /* SimpleChatTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SimpleChatTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
59 | 809B508918D7B55B0032A48D /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
60 | 809B509118D7B55B0032A48D /* SimpleChatTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SimpleChatTests-Info.plist"; sourceTree = ""; };
61 | 809B509318D7B55B0032A48D /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; };
62 | 809B509518D7B55B0032A48D /* SimpleChatTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SimpleChatTests.m; sourceTree = ""; };
63 | /* End PBXFileReference section */
64 |
65 | /* Begin PBXFrameworksBuildPhase section */
66 | 809B506418D7B55B0032A48D /* Frameworks */ = {
67 | isa = PBXFrameworksBuildPhase;
68 | buildActionMask = 2147483647;
69 | files = (
70 | 809B506D18D7B55B0032A48D /* CoreGraphics.framework in Frameworks */,
71 | 809B506F18D7B55B0032A48D /* UIKit.framework in Frameworks */,
72 | 809B506B18D7B55B0032A48D /* Foundation.framework in Frameworks */,
73 | );
74 | runOnlyForDeploymentPostprocessing = 0;
75 | };
76 | 809B508518D7B55B0032A48D /* Frameworks */ = {
77 | isa = PBXFrameworksBuildPhase;
78 | buildActionMask = 2147483647;
79 | files = (
80 | 809B508A18D7B55B0032A48D /* XCTest.framework in Frameworks */,
81 | 809B508C18D7B55B0032A48D /* UIKit.framework in Frameworks */,
82 | 809B508B18D7B55B0032A48D /* Foundation.framework in Frameworks */,
83 | );
84 | runOnlyForDeploymentPostprocessing = 0;
85 | };
86 | /* End PBXFrameworksBuildPhase section */
87 |
88 | /* Begin PBXGroup section */
89 | 800D4D171A183A9E00F5CB14 /* LGSimpleChat */ = {
90 | isa = PBXGroup;
91 | children = (
92 | 800D4D181A183A9E00F5CB14 /* LGSimpleChat.swift */,
93 | 800D4D191A183A9E00F5CB14 /* License */,
94 | );
95 | path = LGSimpleChat;
96 | sourceTree = "";
97 | };
98 | 800D4D1C1A183AD600F5CB14 /* ViewControllerExample */ = {
99 | isa = PBXGroup;
100 | children = (
101 | 800D4D1D1A183AD600F5CB14 /* ViewController.h */,
102 | 800D4D1E1A183AD600F5CB14 /* ViewController.m */,
103 | );
104 | path = ViewControllerExample;
105 | sourceTree = "";
106 | };
107 | 800D4D201A183AF000F5CB14 /* SwiftViewControllerExample */ = {
108 | isa = PBXGroup;
109 | children = (
110 | 800D4D211A183AF000F5CB14 /* SwiftExampleViewController.swift */,
111 | );
112 | path = SwiftViewControllerExample;
113 | sourceTree = "";
114 | };
115 | 809B505E18D7B55B0032A48D = {
116 | isa = PBXGroup;
117 | children = (
118 | 809B507018D7B55B0032A48D /* SimpleChat */,
119 | 809B508F18D7B55B0032A48D /* SimpleChatTests */,
120 | 809B506918D7B55B0032A48D /* Frameworks */,
121 | 809B506818D7B55B0032A48D /* Products */,
122 | );
123 | sourceTree = "";
124 | };
125 | 809B506818D7B55B0032A48D /* Products */ = {
126 | isa = PBXGroup;
127 | children = (
128 | 809B506718D7B55B0032A48D /* SimpleChat.app */,
129 | 809B508818D7B55B0032A48D /* SimpleChatTests.xctest */,
130 | );
131 | name = Products;
132 | sourceTree = "";
133 | };
134 | 809B506918D7B55B0032A48D /* Frameworks */ = {
135 | isa = PBXGroup;
136 | children = (
137 | 809B506A18D7B55B0032A48D /* Foundation.framework */,
138 | 809B506C18D7B55B0032A48D /* CoreGraphics.framework */,
139 | 809B506E18D7B55B0032A48D /* UIKit.framework */,
140 | 809B508918D7B55B0032A48D /* XCTest.framework */,
141 | );
142 | name = Frameworks;
143 | sourceTree = "";
144 | };
145 | 809B507018D7B55B0032A48D /* SimpleChat */ = {
146 | isa = PBXGroup;
147 | children = (
148 | 800D4D171A183A9E00F5CB14 /* LGSimpleChat */,
149 | 800D4D1C1A183AD600F5CB14 /* ViewControllerExample */,
150 | 800D4D201A183AF000F5CB14 /* SwiftViewControllerExample */,
151 | 809B507918D7B55B0032A48D /* AppDelegate.h */,
152 | 809B507A18D7B55B0032A48D /* AppDelegate.m */,
153 | 809B507C18D7B55B0032A48D /* Main.storyboard */,
154 | 809B508218D7B55B0032A48D /* Images.xcassets */,
155 | 809B507118D7B55B0032A48D /* Supporting Files */,
156 | );
157 | path = SimpleChat;
158 | sourceTree = "";
159 | };
160 | 809B507118D7B55B0032A48D /* Supporting Files */ = {
161 | isa = PBXGroup;
162 | children = (
163 | 809B507218D7B55B0032A48D /* SimpleChat-Info.plist */,
164 | 809B507318D7B55B0032A48D /* InfoPlist.strings */,
165 | 809B507618D7B55B0032A48D /* main.m */,
166 | 809B507818D7B55B0032A48D /* SimpleChat-Prefix.pch */,
167 | 806254851A16AA32005A2FD1 /* SimpleChat-Bridging-Header.h */,
168 | );
169 | name = "Supporting Files";
170 | sourceTree = "";
171 | };
172 | 809B508F18D7B55B0032A48D /* SimpleChatTests */ = {
173 | isa = PBXGroup;
174 | children = (
175 | 809B509518D7B55B0032A48D /* SimpleChatTests.m */,
176 | 809B509018D7B55B0032A48D /* Supporting Files */,
177 | );
178 | path = SimpleChatTests;
179 | sourceTree = "";
180 | };
181 | 809B509018D7B55B0032A48D /* Supporting Files */ = {
182 | isa = PBXGroup;
183 | children = (
184 | 809B509118D7B55B0032A48D /* SimpleChatTests-Info.plist */,
185 | 809B509218D7B55B0032A48D /* InfoPlist.strings */,
186 | );
187 | name = "Supporting Files";
188 | sourceTree = "";
189 | };
190 | /* End PBXGroup section */
191 |
192 | /* Begin PBXNativeTarget section */
193 | 809B506618D7B55B0032A48D /* SimpleChat */ = {
194 | isa = PBXNativeTarget;
195 | buildConfigurationList = 809B509918D7B55B0032A48D /* Build configuration list for PBXNativeTarget "SimpleChat" */;
196 | buildPhases = (
197 | 809B506318D7B55B0032A48D /* Sources */,
198 | 809B506418D7B55B0032A48D /* Frameworks */,
199 | 809B506518D7B55B0032A48D /* Resources */,
200 | );
201 | buildRules = (
202 | );
203 | dependencies = (
204 | );
205 | name = SimpleChat;
206 | productName = SimpleChat;
207 | productReference = 809B506718D7B55B0032A48D /* SimpleChat.app */;
208 | productType = "com.apple.product-type.application";
209 | };
210 | 809B508718D7B55B0032A48D /* SimpleChatTests */ = {
211 | isa = PBXNativeTarget;
212 | buildConfigurationList = 809B509C18D7B55B0032A48D /* Build configuration list for PBXNativeTarget "SimpleChatTests" */;
213 | buildPhases = (
214 | 809B508418D7B55B0032A48D /* Sources */,
215 | 809B508518D7B55B0032A48D /* Frameworks */,
216 | 809B508618D7B55B0032A48D /* Resources */,
217 | );
218 | buildRules = (
219 | );
220 | dependencies = (
221 | 809B508E18D7B55B0032A48D /* PBXTargetDependency */,
222 | );
223 | name = SimpleChatTests;
224 | productName = SimpleChatTests;
225 | productReference = 809B508818D7B55B0032A48D /* SimpleChatTests.xctest */;
226 | productType = "com.apple.product-type.bundle.unit-test";
227 | };
228 | /* End PBXNativeTarget section */
229 |
230 | /* Begin PBXProject section */
231 | 809B505F18D7B55B0032A48D /* Project object */ = {
232 | isa = PBXProject;
233 | attributes = {
234 | LastSwiftUpdateCheck = 0730;
235 | LastUpgradeCheck = 0730;
236 | ORGANIZATIONNAME = "Logan Wright";
237 | TargetAttributes = {
238 | 809B508718D7B55B0032A48D = {
239 | TestTargetID = 809B506618D7B55B0032A48D;
240 | };
241 | };
242 | };
243 | buildConfigurationList = 809B506218D7B55B0032A48D /* Build configuration list for PBXProject "SimpleChat" */;
244 | compatibilityVersion = "Xcode 3.2";
245 | developmentRegion = English;
246 | hasScannedForEncodings = 0;
247 | knownRegions = (
248 | en,
249 | Base,
250 | );
251 | mainGroup = 809B505E18D7B55B0032A48D;
252 | productRefGroup = 809B506818D7B55B0032A48D /* Products */;
253 | projectDirPath = "";
254 | projectRoot = "";
255 | targets = (
256 | 809B506618D7B55B0032A48D /* SimpleChat */,
257 | 809B508718D7B55B0032A48D /* SimpleChatTests */,
258 | );
259 | };
260 | /* End PBXProject section */
261 |
262 | /* Begin PBXResourcesBuildPhase section */
263 | 809B506518D7B55B0032A48D /* Resources */ = {
264 | isa = PBXResourcesBuildPhase;
265 | buildActionMask = 2147483647;
266 | files = (
267 | 809B508318D7B55B0032A48D /* Images.xcassets in Resources */,
268 | 809B507518D7B55B0032A48D /* InfoPlist.strings in Resources */,
269 | 800D4D1B1A183A9E00F5CB14 /* License in Resources */,
270 | 809B507E18D7B55B0032A48D /* Main.storyboard in Resources */,
271 | );
272 | runOnlyForDeploymentPostprocessing = 0;
273 | };
274 | 809B508618D7B55B0032A48D /* Resources */ = {
275 | isa = PBXResourcesBuildPhase;
276 | buildActionMask = 2147483647;
277 | files = (
278 | 809B509418D7B55B0032A48D /* InfoPlist.strings in Resources */,
279 | );
280 | runOnlyForDeploymentPostprocessing = 0;
281 | };
282 | /* End PBXResourcesBuildPhase section */
283 |
284 | /* Begin PBXSourcesBuildPhase section */
285 | 809B506318D7B55B0032A48D /* Sources */ = {
286 | isa = PBXSourcesBuildPhase;
287 | buildActionMask = 2147483647;
288 | files = (
289 | 800D4D1A1A183A9E00F5CB14 /* LGSimpleChat.swift in Sources */,
290 | 809B507B18D7B55B0032A48D /* AppDelegate.m in Sources */,
291 | 809B507718D7B55B0032A48D /* main.m in Sources */,
292 | 800D4D1F1A183AD600F5CB14 /* ViewController.m in Sources */,
293 | 800D4D221A183AF000F5CB14 /* SwiftExampleViewController.swift in Sources */,
294 | );
295 | runOnlyForDeploymentPostprocessing = 0;
296 | };
297 | 809B508418D7B55B0032A48D /* Sources */ = {
298 | isa = PBXSourcesBuildPhase;
299 | buildActionMask = 2147483647;
300 | files = (
301 | 809B509618D7B55B0032A48D /* SimpleChatTests.m in Sources */,
302 | );
303 | runOnlyForDeploymentPostprocessing = 0;
304 | };
305 | /* End PBXSourcesBuildPhase section */
306 |
307 | /* Begin PBXTargetDependency section */
308 | 809B508E18D7B55B0032A48D /* PBXTargetDependency */ = {
309 | isa = PBXTargetDependency;
310 | target = 809B506618D7B55B0032A48D /* SimpleChat */;
311 | targetProxy = 809B508D18D7B55B0032A48D /* PBXContainerItemProxy */;
312 | };
313 | /* End PBXTargetDependency section */
314 |
315 | /* Begin PBXVariantGroup section */
316 | 809B507318D7B55B0032A48D /* InfoPlist.strings */ = {
317 | isa = PBXVariantGroup;
318 | children = (
319 | 809B507418D7B55B0032A48D /* en */,
320 | );
321 | name = InfoPlist.strings;
322 | sourceTree = "";
323 | };
324 | 809B507C18D7B55B0032A48D /* Main.storyboard */ = {
325 | isa = PBXVariantGroup;
326 | children = (
327 | 809B507D18D7B55B0032A48D /* Base */,
328 | );
329 | name = Main.storyboard;
330 | sourceTree = "";
331 | };
332 | 809B509218D7B55B0032A48D /* InfoPlist.strings */ = {
333 | isa = PBXVariantGroup;
334 | children = (
335 | 809B509318D7B55B0032A48D /* en */,
336 | );
337 | name = InfoPlist.strings;
338 | sourceTree = "";
339 | };
340 | /* End PBXVariantGroup section */
341 |
342 | /* Begin XCBuildConfiguration section */
343 | 809B509718D7B55B0032A48D /* Debug */ = {
344 | isa = XCBuildConfiguration;
345 | buildSettings = {
346 | ALWAYS_SEARCH_USER_PATHS = NO;
347 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
348 | CLANG_CXX_LIBRARY = "libc++";
349 | CLANG_ENABLE_MODULES = YES;
350 | CLANG_ENABLE_OBJC_ARC = YES;
351 | CLANG_WARN_BOOL_CONVERSION = YES;
352 | CLANG_WARN_CONSTANT_CONVERSION = YES;
353 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
354 | CLANG_WARN_EMPTY_BODY = YES;
355 | CLANG_WARN_ENUM_CONVERSION = YES;
356 | CLANG_WARN_INT_CONVERSION = YES;
357 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
358 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
359 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
360 | COPY_PHASE_STRIP = NO;
361 | ENABLE_TESTABILITY = YES;
362 | GCC_C_LANGUAGE_STANDARD = gnu99;
363 | GCC_DYNAMIC_NO_PIC = NO;
364 | GCC_OPTIMIZATION_LEVEL = 0;
365 | GCC_PREPROCESSOR_DEFINITIONS = (
366 | "DEBUG=1",
367 | "$(inherited)",
368 | );
369 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
370 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
371 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
372 | GCC_WARN_UNDECLARED_SELECTOR = YES;
373 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
374 | GCC_WARN_UNUSED_FUNCTION = YES;
375 | GCC_WARN_UNUSED_VARIABLE = YES;
376 | IPHONEOS_DEPLOYMENT_TARGET = 7.1;
377 | ONLY_ACTIVE_ARCH = YES;
378 | SDKROOT = iphoneos;
379 | };
380 | name = Debug;
381 | };
382 | 809B509818D7B55B0032A48D /* Release */ = {
383 | isa = XCBuildConfiguration;
384 | buildSettings = {
385 | ALWAYS_SEARCH_USER_PATHS = NO;
386 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
387 | CLANG_CXX_LIBRARY = "libc++";
388 | CLANG_ENABLE_MODULES = YES;
389 | CLANG_ENABLE_OBJC_ARC = YES;
390 | CLANG_WARN_BOOL_CONVERSION = YES;
391 | CLANG_WARN_CONSTANT_CONVERSION = YES;
392 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
393 | CLANG_WARN_EMPTY_BODY = YES;
394 | CLANG_WARN_ENUM_CONVERSION = YES;
395 | CLANG_WARN_INT_CONVERSION = YES;
396 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
397 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
398 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
399 | COPY_PHASE_STRIP = YES;
400 | ENABLE_NS_ASSERTIONS = NO;
401 | GCC_C_LANGUAGE_STANDARD = gnu99;
402 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
403 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
404 | GCC_WARN_UNDECLARED_SELECTOR = YES;
405 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
406 | GCC_WARN_UNUSED_FUNCTION = YES;
407 | GCC_WARN_UNUSED_VARIABLE = YES;
408 | IPHONEOS_DEPLOYMENT_TARGET = 7.1;
409 | SDKROOT = iphoneos;
410 | VALIDATE_PRODUCT = YES;
411 | };
412 | name = Release;
413 | };
414 | 809B509A18D7B55B0032A48D /* Debug */ = {
415 | isa = XCBuildConfiguration;
416 | buildSettings = {
417 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
418 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
419 | CLANG_ENABLE_MODULES = YES;
420 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
421 | GCC_PREFIX_HEADER = "SimpleChat/SimpleChat-Prefix.pch";
422 | INFOPLIST_FILE = "SimpleChat/SimpleChat-Info.plist";
423 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
424 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
425 | PRODUCT_BUNDLE_IDENTIFIER = "lowri.${PRODUCT_NAME:rfc1034identifier}";
426 | PRODUCT_NAME = "$(TARGET_NAME)";
427 | SWIFT_OBJC_BRIDGING_HEADER = "SimpleChat/SimpleChat-Bridging-Header.h";
428 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
429 | WRAPPER_EXTENSION = app;
430 | };
431 | name = Debug;
432 | };
433 | 809B509B18D7B55B0032A48D /* Release */ = {
434 | isa = XCBuildConfiguration;
435 | buildSettings = {
436 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
437 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
438 | CLANG_ENABLE_MODULES = YES;
439 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
440 | GCC_PREFIX_HEADER = "SimpleChat/SimpleChat-Prefix.pch";
441 | INFOPLIST_FILE = "SimpleChat/SimpleChat-Info.plist";
442 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
443 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
444 | PRODUCT_BUNDLE_IDENTIFIER = "lowri.${PRODUCT_NAME:rfc1034identifier}";
445 | PRODUCT_NAME = "$(TARGET_NAME)";
446 | SWIFT_OBJC_BRIDGING_HEADER = "SimpleChat/SimpleChat-Bridging-Header.h";
447 | WRAPPER_EXTENSION = app;
448 | };
449 | name = Release;
450 | };
451 | 809B509D18D7B55B0032A48D /* Debug */ = {
452 | isa = XCBuildConfiguration;
453 | buildSettings = {
454 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/SimpleChat.app/SimpleChat";
455 | FRAMEWORK_SEARCH_PATHS = (
456 | "$(SDKROOT)/Developer/Library/Frameworks",
457 | "$(inherited)",
458 | "$(DEVELOPER_FRAMEWORKS_DIR)",
459 | );
460 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
461 | GCC_PREFIX_HEADER = "SimpleChat/SimpleChat-Prefix.pch";
462 | GCC_PREPROCESSOR_DEFINITIONS = (
463 | "DEBUG=1",
464 | "$(inherited)",
465 | );
466 | INFOPLIST_FILE = "SimpleChatTests/SimpleChatTests-Info.plist";
467 | PRODUCT_BUNDLE_IDENTIFIER = "lowri.${PRODUCT_NAME:rfc1034identifier}";
468 | PRODUCT_NAME = "$(TARGET_NAME)";
469 | TEST_HOST = "$(BUNDLE_LOADER)";
470 | WRAPPER_EXTENSION = xctest;
471 | };
472 | name = Debug;
473 | };
474 | 809B509E18D7B55B0032A48D /* Release */ = {
475 | isa = XCBuildConfiguration;
476 | buildSettings = {
477 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/SimpleChat.app/SimpleChat";
478 | FRAMEWORK_SEARCH_PATHS = (
479 | "$(SDKROOT)/Developer/Library/Frameworks",
480 | "$(inherited)",
481 | "$(DEVELOPER_FRAMEWORKS_DIR)",
482 | );
483 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
484 | GCC_PREFIX_HEADER = "SimpleChat/SimpleChat-Prefix.pch";
485 | INFOPLIST_FILE = "SimpleChatTests/SimpleChatTests-Info.plist";
486 | PRODUCT_BUNDLE_IDENTIFIER = "lowri.${PRODUCT_NAME:rfc1034identifier}";
487 | PRODUCT_NAME = "$(TARGET_NAME)";
488 | TEST_HOST = "$(BUNDLE_LOADER)";
489 | WRAPPER_EXTENSION = xctest;
490 | };
491 | name = Release;
492 | };
493 | /* End XCBuildConfiguration section */
494 |
495 | /* Begin XCConfigurationList section */
496 | 809B506218D7B55B0032A48D /* Build configuration list for PBXProject "SimpleChat" */ = {
497 | isa = XCConfigurationList;
498 | buildConfigurations = (
499 | 809B509718D7B55B0032A48D /* Debug */,
500 | 809B509818D7B55B0032A48D /* Release */,
501 | );
502 | defaultConfigurationIsVisible = 0;
503 | defaultConfigurationName = Release;
504 | };
505 | 809B509918D7B55B0032A48D /* Build configuration list for PBXNativeTarget "SimpleChat" */ = {
506 | isa = XCConfigurationList;
507 | buildConfigurations = (
508 | 809B509A18D7B55B0032A48D /* Debug */,
509 | 809B509B18D7B55B0032A48D /* Release */,
510 | );
511 | defaultConfigurationIsVisible = 0;
512 | defaultConfigurationName = Release;
513 | };
514 | 809B509C18D7B55B0032A48D /* Build configuration list for PBXNativeTarget "SimpleChatTests" */ = {
515 | isa = XCConfigurationList;
516 | buildConfigurations = (
517 | 809B509D18D7B55B0032A48D /* Debug */,
518 | 809B509E18D7B55B0032A48D /* Release */,
519 | );
520 | defaultConfigurationIsVisible = 0;
521 | defaultConfigurationName = Release;
522 | };
523 | /* End XCConfigurationList section */
524 | };
525 | rootObject = 809B505F18D7B55B0032A48D /* Project object */;
526 | }
527 |
--------------------------------------------------------------------------------
/SimpleChat.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/SimpleChat.xcodeproj/xcuserdata/loganwright.xcuserdatad/xcschemes/SimpleChat.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
49 |
50 |
51 |
52 |
61 |
62 |
68 |
69 |
70 |
71 |
75 |
76 |
77 |
78 |
84 |
85 |
91 |
92 |
93 |
94 |
96 |
97 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/SimpleChat.xcodeproj/xcuserdata/loganwright.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | SimpleChat.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 809B506618D7B55B0032A48D
16 |
17 | primary
18 |
19 |
20 | 809B508718D7B55B0032A48D
21 |
22 | primary
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/SimpleChat/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // SimpleChat
4 | //
5 | // Created by Logan Wright on 3/17/14.
6 | // Copyright (c) 2014 Logan Wright. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/SimpleChat/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // SimpleChat
4 | //
5 | // Created by Logan Wright on 3/17/14.
6 | // Copyright (c) 2014 Logan Wright. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @implementation AppDelegate
12 |
13 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
14 | {
15 | // Override point for customization after application launch.
16 | return YES;
17 | }
18 |
19 | - (void)applicationWillResignActive:(UIApplication *)application
20 | {
21 | // 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.
22 | // 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.
23 | }
24 |
25 | - (void)applicationDidEnterBackground:(UIApplication *)application
26 | {
27 | // 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.
28 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
29 | }
30 |
31 | - (void)applicationWillEnterForeground:(UIApplication *)application
32 | {
33 | // 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.
34 | }
35 |
36 | - (void)applicationDidBecomeActive:(UIApplication *)application
37 | {
38 | // 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.
39 | }
40 |
41 | - (void)applicationWillTerminate:(UIApplication *)application
42 | {
43 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
44 | }
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/SimpleChat/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/SimpleChat/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "40x40",
11 | "scale" : "2x"
12 | },
13 | {
14 | "size" : "60x60",
15 | "idiom" : "iphone",
16 | "filename" : "SimpleChatIcon.png",
17 | "scale" : "2x"
18 | },
19 | {
20 | "idiom" : "iphone",
21 | "size" : "60x60",
22 | "scale" : "3x"
23 | }
24 | ],
25 | "info" : {
26 | "version" : 1,
27 | "author" : "xcode"
28 | }
29 | }
--------------------------------------------------------------------------------
/SimpleChat/Images.xcassets/AppIcon.appiconset/SimpleChatIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loganwright/SimpleChat/19d12c80630498b642b0c7e6f8a98dc26317e856/SimpleChat/Images.xcassets/AppIcon.appiconset/SimpleChatIcon.png
--------------------------------------------------------------------------------
/SimpleChat/Images.xcassets/LaunchImage.launchimage/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "orientation" : "portrait",
5 | "idiom" : "iphone",
6 | "extent" : "full-screen",
7 | "minimum-system-version" : "7.0",
8 | "scale" : "2x"
9 | },
10 | {
11 | "orientation" : "portrait",
12 | "idiom" : "iphone",
13 | "subtype" : "retina4",
14 | "extent" : "full-screen",
15 | "minimum-system-version" : "7.0",
16 | "scale" : "2x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
--------------------------------------------------------------------------------
/SimpleChat/Images.xcassets/User.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x",
6 | "filename" : "User.png"
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 | }
--------------------------------------------------------------------------------
/SimpleChat/Images.xcassets/User.imageset/User.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loganwright/SimpleChat/19d12c80630498b642b0c7e6f8a98dc26317e856/SimpleChat/Images.xcassets/User.imageset/User.png
--------------------------------------------------------------------------------
/SimpleChat/LGSimpleChat/LGSimpleChat.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SimpleChatController.swift
3 | // SimpleChat
4 | //
5 | // Created by Logan Wright on 10/16/14.
6 | // Copyright (c) 2014 Logan Wright. All rights reserved.
7 | //
8 |
9 | /*
10 | Mozilla Public License
11 | Version 2.0
12 | https://tldrlegal.com/license/mozilla-public-license-2.0-(mpl-2)
13 | */
14 |
15 | import UIKit
16 |
17 | // MARK: Message
18 |
19 | class LGChatMessage : NSObject {
20 |
21 | enum SentBy : String {
22 | case User = "LGChatMessageSentByUser"
23 | case Opponent = "LGChatMessageSentByOpponent"
24 | }
25 |
26 | // MARK: ObjC Compatibility
27 |
28 | /*
29 | ObjC can't interact w/ enums properly, so this is used for converting compatible values.
30 | */
31 |
32 | var color : UIColor? = nil
33 |
34 | class func SentByUserString() -> String {
35 | return LGChatMessage.SentBy.User.rawValue
36 | }
37 |
38 | class func SentByOpponentString() -> String {
39 | return LGChatMessage.SentBy.Opponent.rawValue
40 | }
41 |
42 | var sentByString: String {
43 | get {
44 | return sentBy.rawValue
45 | }
46 | set {
47 | if let sentBy = SentBy(rawValue: newValue) {
48 | self.sentBy = sentBy
49 | } else {
50 | print("LGChatMessage.Error : Property Set : Incompatible string set to SentByString!")
51 | }
52 | }
53 | }
54 |
55 | // MARK: Public Properties
56 |
57 | var sentBy: SentBy
58 | var content: String
59 | var timeStamp: NSTimeInterval?
60 |
61 | required init (content: String, sentBy: SentBy, timeStamp: NSTimeInterval? = nil){
62 | self.sentBy = sentBy
63 | self.timeStamp = timeStamp
64 | self.content = content
65 | }
66 |
67 | // MARK: ObjC Compatibility
68 |
69 | convenience init (content: String, sentByString: String) {
70 | if let sentBy = SentBy(rawValue: sentByString) {
71 | self.init(content: content, sentBy: sentBy, timeStamp: nil)
72 | } else {
73 | fatalError("LGChatMessage.FatalError : Initialization : Incompatible string set to SentByString!")
74 | }
75 | }
76 |
77 | convenience init (content: String, sentByString: String, timeStamp: NSTimeInterval) {
78 | if let sentBy = SentBy(rawValue: sentByString) {
79 | self.init(content: content, sentBy: sentBy, timeStamp: timeStamp)
80 | } else {
81 | fatalError("LGChatMessage.FatalError : Initialization : Incompatible string set to SentByString!")
82 | }
83 | }
84 | }
85 |
86 | // MARK: Message Cell
87 |
88 | class LGChatMessageCell : UITableViewCell {
89 |
90 | // MARK: Global MessageCell Appearance Modifier
91 |
92 | struct Appearance {
93 | static var opponentColor = UIColor(red: 0.142954, green: 0.60323, blue: 0.862548, alpha: 0.88)
94 | static var userColor = UIColor(red: 0.14726, green: 0.838161, blue: 0.533935, alpha: 1)
95 | static var font: UIFont = UIFont.systemFontOfSize(17.0)
96 | }
97 |
98 | /*
99 | These methods are included for ObjC compatibility. If using Swift, you can set the Appearance variables directly.
100 | */
101 |
102 | class func setAppearanceOpponentColor(opponentColor: UIColor) {
103 | Appearance.opponentColor = opponentColor
104 | }
105 |
106 | class func setAppearanceUserColor(userColor: UIColor) {
107 | Appearance.userColor = userColor
108 | }
109 |
110 | class func setAppearanceFont(font: UIFont) {
111 | Appearance.font = font
112 | }
113 |
114 | // MARK: Message Bubble TextView
115 |
116 | private lazy var textView: MessageBubbleTextView = {
117 | let textView = MessageBubbleTextView(frame: CGRectZero, textContainer: nil)
118 | self.contentView.addSubview(textView)
119 | return textView
120 | }()
121 |
122 | private class MessageBubbleTextView : UITextView {
123 |
124 | override init(frame: CGRect = CGRectZero, textContainer: NSTextContainer? = nil) {
125 | super.init(frame: frame, textContainer: textContainer)
126 | self.font = Appearance.font
127 | self.scrollEnabled = false
128 | self.editable = false
129 | self.textContainerInset = UIEdgeInsets(top: 7, left: 7, bottom: 7, right: 7)
130 | self.layer.cornerRadius = 15
131 | self.layer.borderWidth = 2.0
132 | }
133 |
134 | required init(coder aDecoder: NSCoder) {
135 | fatalError("init(coder:) has not been implemented")
136 | }
137 | }
138 |
139 | // MARK: ImageView
140 |
141 | private lazy var opponentImageView: UIImageView = {
142 | let opponentImageView = UIImageView()
143 | opponentImageView.hidden = true
144 | opponentImageView.bounds.size = CGSize(width: self.minimumHeight, height: self.minimumHeight)
145 | let halfWidth = CGRectGetWidth(opponentImageView.bounds) / 2.0
146 | let halfHeight = CGRectGetHeight(opponentImageView.bounds) / 2.0
147 |
148 | // Center the imageview vertically to the textView when it is singleLine
149 | let textViewSingleLineCenter = self.textView.textContainerInset.top + (Appearance.font.lineHeight / 2.0)
150 | opponentImageView.center = CGPointMake(self.padding + halfWidth, textViewSingleLineCenter)
151 | opponentImageView.backgroundColor = UIColor.lightTextColor()
152 | opponentImageView.layer.rasterizationScale = UIScreen.mainScreen().scale
153 | opponentImageView.layer.shouldRasterize = true
154 | opponentImageView.layer.cornerRadius = halfHeight
155 | opponentImageView.layer.masksToBounds = true
156 | self.contentView.addSubview(opponentImageView)
157 | return opponentImageView
158 | }()
159 |
160 | // MARK: Sizing
161 |
162 | private let padding: CGFloat = 5.0
163 |
164 | private let minimumHeight: CGFloat = 30.0 // arbitrary minimum height
165 |
166 | private var size = CGSizeZero
167 |
168 | private var maxSize: CGSize {
169 | get {
170 | let maxWidth = CGRectGetWidth(self.bounds) * 0.75 // Cells can take up to 3/4 of screen
171 | let maxHeight = CGFloat.max
172 | return CGSize(width: maxWidth, height: maxHeight)
173 | }
174 | }
175 |
176 | // MARK: Setup Call
177 |
178 | /*!
179 | Use this in cellForRowAtIndexPath to setup the cell.
180 | */
181 | func setupWithMessage(message: LGChatMessage) -> CGSize {
182 | textView.text = message.content
183 | size = textView.sizeThatFits(maxSize)
184 | if size.height < minimumHeight {
185 | size.height = minimumHeight
186 | }
187 | textView.bounds.size = size
188 | self.styleTextViewForSentBy(message.sentBy)
189 | if let color = message.color {
190 | self.textView.layer.borderColor = color.CGColor
191 | }
192 | return size
193 | }
194 |
195 | // MARK: TextBubble Styling
196 |
197 | private func styleTextViewForSentBy(sentBy: LGChatMessage.SentBy) {
198 | let halfTextViewWidth = CGRectGetWidth(self.textView.bounds) / 2.0
199 | let targetX = halfTextViewWidth + padding
200 | let halfTextViewHeight = CGRectGetHeight(self.textView.bounds) / 2.0
201 | switch sentBy {
202 | case .Opponent:
203 | self.textView.center.x = targetX
204 | self.textView.center.y = halfTextViewHeight
205 | self.textView.layer.borderColor = Appearance.opponentColor.CGColor
206 |
207 | if self.opponentImageView.image != nil {
208 | self.opponentImageView.hidden = false
209 | self.textView.center.x += CGRectGetWidth(self.opponentImageView.bounds) + padding
210 | }
211 |
212 | case .User:
213 | self.opponentImageView.hidden = true
214 | self.textView.center.x = CGRectGetWidth(self.bounds) - targetX
215 | self.textView.center.y = halfTextViewHeight
216 | self.textView.layer.borderColor = Appearance.userColor.CGColor
217 | }
218 | }
219 | }
220 |
221 | // MARK: Chat Controller
222 |
223 | @objc protocol LGChatControllerDelegate {
224 | optional func shouldChatController(chatController: LGChatController, addMessage message: LGChatMessage) -> Bool
225 | optional func chatController(chatController: LGChatController, didAddNewMessage message: LGChatMessage)
226 | }
227 |
228 | class LGChatController : UIViewController, UITableViewDelegate, UITableViewDataSource, LGChatInputDelegate {
229 |
230 | // MARK: Constants
231 |
232 | private struct Constants {
233 | static let MessagesSection: Int = 0;
234 | static let MessageCellIdentifier: String = "LGChatController.Constants.MessageCellIdentifier"
235 | }
236 |
237 | // MARK: Public Properties
238 |
239 | /*!
240 | Use this to set the messages to be displayed
241 | */
242 | var messages: [LGChatMessage] = []
243 | var opponentImage: UIImage?
244 | weak var delegate: LGChatControllerDelegate?
245 |
246 | // MARK: Private Properties
247 |
248 | private let sizingCell = LGChatMessageCell()
249 | private let tableView: UITableView = UITableView()
250 | private let chatInput = LGChatInput(frame: CGRectZero)
251 | private var bottomChatInputConstraint: NSLayoutConstraint!
252 |
253 |
254 | // MARK: Life Cycle
255 |
256 | override func viewDidLoad() {
257 | super.viewDidLoad()
258 | self.setup()
259 | }
260 |
261 | override func viewWillAppear(animated: Bool) {
262 | super.viewWillAppear(animated)
263 | self.listenForKeyboardChanges()
264 | }
265 |
266 | override func viewDidAppear(animated: Bool) {
267 | super.viewDidAppear(animated)
268 | self.scrollToBottom()
269 | }
270 |
271 | override func viewWillDisappear(animated: Bool) {
272 | super.viewWillDisappear(animated)
273 | self.unregisterKeyboardObservers()
274 | }
275 |
276 | deinit {
277 | /*
278 | Need to remove delegate and datasource or they will try to send scrollView messages.
279 | */
280 | self.tableView.delegate = nil
281 | self.tableView.dataSource = nil
282 | }
283 |
284 | // MARK: Setup
285 |
286 | private func setup() {
287 | self.setupTableView()
288 | self.setupChatInput()
289 | self.setupLayoutConstraints()
290 | }
291 |
292 | private func setupTableView() {
293 | tableView.allowsSelection = false
294 | tableView.separatorStyle = .None
295 | tableView.frame = self.view.bounds
296 | tableView.registerClass(LGChatMessageCell.classForCoder(), forCellReuseIdentifier: "identifier")
297 | tableView.delegate = self
298 | tableView.dataSource = self
299 | tableView.contentInset = UIEdgeInsets(top: 10, left: 0, bottom: 0, right: 0)
300 | self.view.addSubview(tableView)
301 | }
302 |
303 | private func setupChatInput() {
304 | chatInput.delegate = self
305 | self.view.addSubview(chatInput)
306 | }
307 |
308 | private func setupLayoutConstraints() {
309 | chatInput.translatesAutoresizingMaskIntoConstraints = false
310 | tableView.translatesAutoresizingMaskIntoConstraints = false
311 | self.view.addConstraints(self.chatInputConstraints())
312 | self.view.addConstraints(self.tableViewConstraints())
313 | }
314 |
315 | private func chatInputConstraints() -> [NSLayoutConstraint] {
316 | self.bottomChatInputConstraint = NSLayoutConstraint(item: chatInput, attribute: .Bottom, relatedBy: .Equal, toItem: self.bottomLayoutGuide, attribute: .Top, multiplier: 1.0, constant: 0)
317 | let leftConstraint = NSLayoutConstraint(item: chatInput, attribute: .Left, relatedBy: .Equal, toItem: self.view, attribute: .Left, multiplier: 1.0, constant: 0.0)
318 | let rightConstraint = NSLayoutConstraint(item: chatInput, attribute: .Right, relatedBy: .Equal, toItem: self.view, attribute: .Right, multiplier: 1.0, constant: 0.0)
319 | return [leftConstraint, self.bottomChatInputConstraint, rightConstraint]
320 | }
321 |
322 | private func tableViewConstraints() -> [NSLayoutConstraint] {
323 | let leftConstraint = NSLayoutConstraint(item: tableView, attribute: .Left, relatedBy: .Equal, toItem: self.view, attribute: .Left, multiplier: 1.0, constant: 0.0)
324 | let rightConstraint = NSLayoutConstraint(item: tableView, attribute: .Right, relatedBy: .Equal, toItem: self.view, attribute: .Right, multiplier: 1.0, constant: 0.0)
325 | let topConstraint = NSLayoutConstraint(item: tableView, attribute: .Top, relatedBy: .Equal, toItem: self.view, attribute: .Top, multiplier: 1.0, constant: 0.0)
326 | let bottomConstraint = NSLayoutConstraint(item: tableView, attribute: .Bottom, relatedBy: .Equal, toItem: chatInput, attribute: .Top, multiplier: 1.0, constant: 0)
327 | return [rightConstraint, leftConstraint, topConstraint, bottomConstraint]//, rightConstraint, bottomConstraint]
328 | }
329 |
330 | // MARK: Keyboard Notifications
331 |
332 | private func listenForKeyboardChanges() {
333 | let defaultCenter = NSNotificationCenter.defaultCenter()
334 | defaultCenter.addObserver(self, selector: #selector(LGChatController.keyboardWillChangeFrame(_:)), name: UIKeyboardWillChangeFrameNotification, object: nil)
335 | }
336 |
337 | private func unregisterKeyboardObservers() {
338 | NSNotificationCenter.defaultCenter().removeObserver(self)
339 | }
340 |
341 | func keyboardWillChangeFrame(note: NSNotification) {
342 | let keyboardAnimationDetail = note.userInfo!
343 | let duration = keyboardAnimationDetail[UIKeyboardAnimationDurationUserInfoKey] as! NSTimeInterval
344 | var keyboardFrame = (keyboardAnimationDetail[UIKeyboardFrameEndUserInfoKey] as! NSValue).CGRectValue()
345 | if let window = self.view.window {
346 | keyboardFrame = window.convertRect(keyboardFrame, toView: self.view)
347 | }
348 | let animationCurve = keyboardAnimationDetail[UIKeyboardAnimationCurveUserInfoKey] as! UInt
349 |
350 | self.tableView.scrollEnabled = false
351 | self.tableView.decelerationRate = UIScrollViewDecelerationRateFast
352 | self.view.layoutIfNeeded()
353 | var chatInputOffset = -((CGRectGetHeight(self.view.bounds) - self.bottomLayoutGuide.length) - CGRectGetMinY(keyboardFrame))
354 | if chatInputOffset > 0 {
355 | chatInputOffset = 0
356 | }
357 | self.bottomChatInputConstraint.constant = chatInputOffset
358 | UIView.animateWithDuration(duration, delay: 0.0, options: UIViewAnimationOptions(rawValue: animationCurve), animations: { () -> Void in
359 | self.view.layoutIfNeeded()
360 | self.scrollToBottom()
361 | }, completion: {(finished) -> () in
362 | self.tableView.scrollEnabled = true
363 | self.tableView.decelerationRate = UIScrollViewDecelerationRateNormal
364 | })
365 | }
366 |
367 | // MARK: Rotation
368 | override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
369 | coordinator.animateAlongsideTransition({ (_) in
370 | self.tableView.reloadData()
371 | }) { (_) in
372 | UIView.animateWithDuration(0.25, delay: 0.0, options: UIViewAnimationOptions.CurveEaseOut, animations: { () -> Void in
373 | self.scrollToBottom()
374 | }, completion: nil)
375 | }
376 |
377 | }
378 |
379 | // MARK: Scrolling
380 |
381 | private func scrollToBottom() {
382 | if messages.count > 0 {
383 | var lastItemIdx = self.tableView.numberOfRowsInSection(Constants.MessagesSection) - 1
384 | if lastItemIdx < 0 {
385 | lastItemIdx = 0
386 | }
387 | let lastIndexPath = NSIndexPath(forRow: lastItemIdx, inSection: Constants.MessagesSection)
388 | self.tableView.scrollToRowAtIndexPath(lastIndexPath, atScrollPosition: .Bottom, animated: false)
389 | }
390 | }
391 |
392 | // MARK: New messages
393 |
394 | func addNewMessage(message: LGChatMessage) {
395 | messages += [message]
396 | tableView.reloadData()
397 | self.scrollToBottom()
398 | self.delegate?.chatController?(self, didAddNewMessage: message)
399 | }
400 |
401 | // MARK: SwiftChatInputDelegate
402 |
403 | func chatInputDidResize(chatInput: LGChatInput) {
404 | self.scrollToBottom()
405 | }
406 |
407 | func chatInput(chatInput: LGChatInput, didSendMessage message: String) {
408 | let newMessage = LGChatMessage(content: message, sentBy: .User)
409 | var shouldSendMessage = true
410 | if let value = self.delegate?.shouldChatController?(self, addMessage: newMessage) {
411 | shouldSendMessage = value
412 | }
413 |
414 | if shouldSendMessage {
415 | self.addNewMessage(newMessage)
416 | }
417 | }
418 |
419 | // MARK: UITableViewDelegate
420 |
421 | func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
422 | let padding: CGFloat = 10.0
423 | sizingCell.bounds.size.width = CGRectGetWidth(self.view.bounds)
424 | let height = self.sizingCell.setupWithMessage(messages[indexPath.row]).height + padding;
425 | return height
426 | }
427 |
428 | func scrollViewDidScroll(scrollView: UIScrollView) {
429 | if scrollView.dragging {
430 | self.chatInput.textView.resignFirstResponder()
431 | }
432 | }
433 |
434 | // MARK: UITableViewDataSource
435 |
436 | func numberOfSectionsInTableView(tableView: UITableView) -> Int {
437 | return 1;
438 | }
439 |
440 | func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
441 | return self.messages.count;
442 | }
443 |
444 | func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
445 | let cell = tableView.dequeueReusableCellWithIdentifier("identifier", forIndexPath: indexPath) as! LGChatMessageCell
446 | let message = self.messages[indexPath.row]
447 | cell.opponentImageView.image = message.sentBy == .Opponent ? self.opponentImage : nil
448 | cell.setupWithMessage(message)
449 | return cell;
450 | }
451 |
452 | }
453 |
454 | // MARK: Chat Input
455 |
456 | protocol LGChatInputDelegate : class {
457 | func chatInputDidResize(chatInput: LGChatInput)
458 | func chatInput(chatInput: LGChatInput, didSendMessage message: String)
459 | }
460 |
461 | class LGChatInput : UIView, LGStretchyTextViewDelegate {
462 |
463 | // MARK: Styling
464 |
465 | struct Appearance {
466 | static var includeBlur = true
467 | static var tintColor = UIColor(red: 0.0, green: 120 / 255.0, blue: 255 / 255.0, alpha: 1.0)
468 | static var backgroundColor = UIColor.whiteColor()
469 | static var textViewFont = UIFont.systemFontOfSize(17.0)
470 | static var textViewTextColor = UIColor.darkTextColor()
471 | static var textViewBackgroundColor = UIColor.whiteColor()
472 | }
473 |
474 | /*
475 | These methods are included for ObjC compatibility. If using Swift, you can set the Appearance variables directly.
476 | */
477 |
478 | class func setAppearanceIncludeBlur(includeBlur: Bool) {
479 | Appearance.includeBlur = includeBlur
480 | }
481 |
482 | class func setAppearanceTintColor(color: UIColor) {
483 | Appearance.tintColor = color
484 | }
485 |
486 | class func setAppearanceBackgroundColor(color: UIColor) {
487 | Appearance.backgroundColor = color
488 | }
489 |
490 | class func setAppearanceTextViewFont(textViewFont: UIFont) {
491 | Appearance.textViewFont = textViewFont
492 | }
493 |
494 | class func setAppearanceTextViewTextColor(textColor: UIColor) {
495 | Appearance.textViewTextColor = textColor
496 | }
497 |
498 | class func setAppearanceTextViewBackgroundColor(color: UIColor) {
499 | Appearance.textViewBackgroundColor = color
500 | }
501 |
502 | // MARK: Public Properties
503 |
504 | var textViewInsets = UIEdgeInsets(top: 5, left: 5, bottom: 5, right: 5)
505 | weak var delegate: LGChatInputDelegate?
506 |
507 | // MARK: Private Properties
508 |
509 | private let textView = LGStretchyTextView(frame: CGRectZero, textContainer: nil)
510 | private let sendButton = UIButton(type: .System)
511 | private let blurredBackgroundView: UIToolbar = UIToolbar()
512 | private var heightConstraint: NSLayoutConstraint!
513 | private var sendButtonHeightConstraint: NSLayoutConstraint!
514 |
515 | // MARK: Initialization
516 |
517 | override init(frame: CGRect = CGRectZero) {
518 | super.init(frame: frame)
519 | self.setup()
520 | self.stylize()
521 | }
522 |
523 | required init(coder aDecoder: NSCoder) {
524 | fatalError("init(coder:) has not been implemented")
525 | }
526 |
527 | // MARK: Setup
528 |
529 | func setup() {
530 | self.translatesAutoresizingMaskIntoConstraints = false
531 | self.setupSendButton()
532 | self.setupSendButtonConstraints()
533 | self.setupTextView()
534 | self.setupTextViewConstraints()
535 | self.setupBlurredBackgroundView()
536 | self.setupBlurredBackgroundViewConstraints()
537 | }
538 |
539 | func setupTextView() {
540 | textView.bounds = UIEdgeInsetsInsetRect(self.bounds, self.textViewInsets)
541 | textView.stretchyTextViewDelegate = self
542 | textView.center = CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds))
543 | self.styleTextView()
544 | self.addSubview(textView)
545 | }
546 |
547 | func styleTextView() {
548 | textView.layer.rasterizationScale = UIScreen.mainScreen().scale
549 | textView.layer.shouldRasterize = true
550 | textView.layer.cornerRadius = 5.0
551 | textView.layer.borderWidth = 1.0
552 | textView.layer.borderColor = UIColor(white: 0.0, alpha: 0.2).CGColor
553 | }
554 |
555 | func setupSendButton() {
556 | self.sendButton.enabled = false
557 | self.sendButton.setTitle("Send", forState: .Normal)
558 | self.sendButton.addTarget(self, action: #selector(LGChatInput.sendButtonPressed(_:)), forControlEvents: .TouchUpInside)
559 | self.sendButton.bounds = CGRect(x: 0, y: 0, width: 40, height: 1)
560 | self.addSubview(sendButton)
561 | }
562 |
563 | func setupSendButtonConstraints() {
564 | self.sendButton.translatesAutoresizingMaskIntoConstraints = false
565 | self.sendButton.removeConstraints(self.sendButton.constraints)
566 |
567 | // TODO: Fix so that button height doesn't change on first newLine
568 | let rightConstraint = NSLayoutConstraint(item: self, attribute: .Right, relatedBy: .Equal, toItem: self.sendButton, attribute: .Right, multiplier: 1.0, constant: textViewInsets.right)
569 | let bottomConstraint = NSLayoutConstraint(item: self, attribute: .Bottom, relatedBy: .Equal, toItem: self.sendButton, attribute: .Bottom, multiplier: 1.0, constant: textViewInsets.bottom)
570 | let widthConstraint = NSLayoutConstraint(item: self.sendButton, attribute: .Width, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 1.0, constant: 40)
571 | sendButtonHeightConstraint = NSLayoutConstraint(item: self.sendButton, attribute: .Height, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 1.0, constant: 30)
572 | self.addConstraints([sendButtonHeightConstraint, widthConstraint, rightConstraint, bottomConstraint])
573 | }
574 |
575 | func setupTextViewConstraints() {
576 | self.textView.translatesAutoresizingMaskIntoConstraints = false
577 | let topConstraint = NSLayoutConstraint(item: self, attribute: .Top, relatedBy: .Equal, toItem: self.textView, attribute: .Top, multiplier: 1.0, constant: -textViewInsets.top)
578 | let leftConstraint = NSLayoutConstraint(item: self, attribute: .Left, relatedBy: .Equal, toItem: self.textView, attribute: .Left, multiplier: 1, constant: -textViewInsets.left)
579 | let bottomConstraint = NSLayoutConstraint(item: self, attribute: .Bottom, relatedBy: .Equal, toItem: self.textView, attribute: .Bottom, multiplier: 1, constant: textViewInsets.bottom)
580 | let rightConstraint = NSLayoutConstraint(item: self.textView, attribute: .Right, relatedBy: .Equal, toItem: self.sendButton, attribute: .Left, multiplier: 1, constant: -textViewInsets.right)
581 | heightConstraint = NSLayoutConstraint(item: self, attribute: .Height, relatedBy: .Equal, toItem: nil, attribute: .Height, multiplier: 1.00, constant: 40)
582 | self.addConstraints([topConstraint, leftConstraint, bottomConstraint, rightConstraint, heightConstraint])
583 | }
584 |
585 | func setupBlurredBackgroundView() {
586 | self.addSubview(self.blurredBackgroundView)
587 | self.sendSubviewToBack(self.blurredBackgroundView)
588 | }
589 |
590 | func setupBlurredBackgroundViewConstraints() {
591 | self.blurredBackgroundView.translatesAutoresizingMaskIntoConstraints = false
592 | let topConstraint = NSLayoutConstraint(item: self, attribute: .Top, relatedBy: .Equal, toItem: self.blurredBackgroundView, attribute: .Top, multiplier: 1.0, constant: 0)
593 | let leftConstraint = NSLayoutConstraint(item: self, attribute: .Left, relatedBy: .Equal, toItem: self.blurredBackgroundView, attribute: .Left, multiplier: 1.0, constant: 0)
594 | let bottomConstraint = NSLayoutConstraint(item: self, attribute: .Bottom, relatedBy: .Equal, toItem: self.blurredBackgroundView, attribute: .Bottom, multiplier: 1.0, constant: 0)
595 | let rightConstraint = NSLayoutConstraint(item: self, attribute: .Right, relatedBy: .Equal, toItem: self.blurredBackgroundView, attribute: .Right, multiplier: 1.0, constant: 0)
596 | self.addConstraints([topConstraint, leftConstraint, bottomConstraint, rightConstraint])
597 | }
598 |
599 | // MARK: Styling
600 |
601 | func stylize() {
602 | self.textView.backgroundColor = Appearance.textViewBackgroundColor
603 | self.sendButton.tintColor = Appearance.tintColor
604 | self.textView.tintColor = Appearance.tintColor
605 | self.textView.font = Appearance.textViewFont
606 | self.textView.textColor = Appearance.textViewTextColor
607 | self.blurredBackgroundView.hidden = !Appearance.includeBlur
608 | self.backgroundColor = Appearance.backgroundColor
609 | }
610 |
611 | // MARK: StretchyTextViewDelegate
612 |
613 | func stretchyTextViewDidChangeSize(textView: LGStretchyTextView) {
614 | let textViewHeight = CGRectGetHeight(textView.bounds)
615 | if textView.text.characters.count == 0 {
616 | self.sendButtonHeightConstraint.constant = textViewHeight
617 | }
618 | let targetConstant = textViewHeight + textViewInsets.top + textViewInsets.bottom
619 | self.heightConstraint.constant = targetConstant
620 | self.delegate?.chatInputDidResize(self)
621 | }
622 |
623 | func stretchyTextView(textView: LGStretchyTextView, validityDidChange isValid: Bool) {
624 | self.sendButton.enabled = isValid
625 | }
626 |
627 | // MARK: Button Presses
628 |
629 | func sendButtonPressed(sender: UIButton) {
630 | if self.textView.text.characters.count > 0 {
631 | self.delegate?.chatInput(self, didSendMessage: self.textView.text)
632 | self.textView.text = ""
633 | }
634 | }
635 | }
636 |
637 | // MARK: Text View
638 |
639 | @objc protocol LGStretchyTextViewDelegate {
640 | func stretchyTextViewDidChangeSize(chatInput: LGStretchyTextView)
641 | optional func stretchyTextView(textView: LGStretchyTextView, validityDidChange isValid: Bool)
642 | }
643 |
644 | class LGStretchyTextView : UITextView, UITextViewDelegate {
645 |
646 | // MARK: Delegate
647 |
648 | weak var stretchyTextViewDelegate: LGStretchyTextViewDelegate?
649 |
650 | // MARK: Public Properties
651 |
652 | var maxHeightPortrait: CGFloat = 160
653 | var maxHeightLandScape: CGFloat = 60
654 | var maxHeight: CGFloat {
655 | get {
656 | return UIInterfaceOrientationIsPortrait(UIApplication.sharedApplication().statusBarOrientation) ? maxHeightPortrait : maxHeightLandScape
657 | }
658 | }
659 | // MARK: Private Properties
660 |
661 | private var maxSize: CGSize {
662 | get {
663 | return CGSize(width: CGRectGetWidth(self.bounds), height: self.maxHeightPortrait)
664 | }
665 | }
666 |
667 | private var isValid: Bool = false {
668 | didSet {
669 | if isValid != oldValue {
670 | stretchyTextViewDelegate?.stretchyTextView?(self, validityDidChange: isValid)
671 | }
672 | }
673 | }
674 |
675 | private let sizingTextView = UITextView()
676 |
677 | // MARK: Property Overrides
678 |
679 | override var contentSize: CGSize {
680 | didSet {
681 | resize()
682 | }
683 | }
684 |
685 | override var font: UIFont! {
686 | didSet {
687 | sizingTextView.font = font
688 | }
689 | }
690 |
691 | override var textContainerInset: UIEdgeInsets {
692 | didSet {
693 | sizingTextView.textContainerInset = textContainerInset
694 | }
695 | }
696 |
697 | // MARK: Initializers
698 |
699 | override init(frame: CGRect = CGRectZero, textContainer: NSTextContainer? = nil) {
700 | super.init(frame: frame, textContainer: textContainer);
701 | setup()
702 | }
703 |
704 | required init(coder aDecoder: NSCoder) {
705 | fatalError("init(coder:) has not been implemented")
706 | }
707 |
708 | // MARK: Setup
709 |
710 | func setup() {
711 | font = UIFont.systemFontOfSize(17.0)
712 | textContainerInset = UIEdgeInsets(top: 2, left: 2, bottom: 2, right: 2)
713 | delegate = self
714 | }
715 |
716 | // MARK: Sizing
717 |
718 | func resize() {
719 | bounds.size.height = self.targetHeight()
720 | stretchyTextViewDelegate?.stretchyTextViewDidChangeSize(self)
721 | }
722 |
723 | func targetHeight() -> CGFloat {
724 |
725 | /*
726 | There is an issue when calling `sizeThatFits` on self that results in really weird drawing issues with aligning line breaks ("\n"). For that reason, we have a textView whose job it is to size the textView. It's excess, but apparently necessary. If there's been an update to the system and this is no longer necessary, or if you find a better solution. Please remove it and submit a pull request as I'd rather not have it.
727 | */
728 |
729 | sizingTextView.text = self.text
730 | let targetSize = sizingTextView.sizeThatFits(maxSize)
731 | let targetHeight = targetSize.height
732 | let maxHeight = self.maxHeight
733 | return targetHeight < maxHeight ? targetHeight : maxHeight
734 | }
735 |
736 | // MARK: Alignment
737 |
738 | func align() {
739 | guard let end = self.selectedTextRange?.end, let caretRect: CGRect = self.caretRectForPosition(end) else { return }
740 |
741 | let topOfLine = CGRectGetMinY(caretRect)
742 | let bottomOfLine = CGRectGetMaxY(caretRect)
743 |
744 | let contentOffsetTop = self.contentOffset.y
745 | let bottomOfVisibleTextArea = contentOffsetTop + CGRectGetHeight(self.bounds)
746 |
747 | /*
748 | If the caretHeight and the inset padding is greater than the total bounds then we are on the first line and aligning will cause bouncing.
749 | */
750 |
751 | let caretHeightPlusInsets = CGRectGetHeight(caretRect) + self.textContainerInset.top + self.textContainerInset.bottom
752 | if caretHeightPlusInsets < CGRectGetHeight(self.bounds) {
753 | var overflow: CGFloat = 0.0
754 | if topOfLine < contentOffsetTop + self.textContainerInset.top {
755 | overflow = topOfLine - contentOffsetTop - self.textContainerInset.top
756 | } else if bottomOfLine > bottomOfVisibleTextArea - self.textContainerInset.bottom {
757 | overflow = (bottomOfLine - bottomOfVisibleTextArea) + self.textContainerInset.bottom
758 | }
759 | self.contentOffset.y += overflow
760 | }
761 | }
762 |
763 | // MARK: UITextViewDelegate
764 |
765 | func textViewDidChangeSelection(textView: UITextView) {
766 | self.align()
767 | }
768 |
769 | func textViewDidChange(textView: UITextView) {
770 | // TODO: Possibly filter spaces and newlines
771 | self.isValid = textView.text.characters.count > 0
772 | }
773 | }
774 |
--------------------------------------------------------------------------------
/SimpleChat/LGSimpleChat/License:
--------------------------------------------------------------------------------
1 |
2 | Mozilla Public License
3 | Version 2.0
4 |
5 | 1. Definitions
6 |
7 | 1.1. “Contributor”
8 | means each individual or legal entity that creates, contributes to the creation of, or owns Covered Software.
9 |
10 | 1.2. “Contributor Version”
11 | means the combination of the Contributions of others (if any) used by a Contributor and that particular Contributor’s Contribution.
12 |
13 | 1.3. “Contribution”
14 | means Covered Software of a particular Contributor.
15 |
16 | 1.4. “Covered Software”
17 | means Source Code Form to which the initial Contributor has attached the notice in Exhibit A, the Executable Form of such Source Code Form, and Modifications of such Source Code Form, in each case including portions thereof.
18 |
19 | 1.5. “Incompatible With Secondary Licenses”
20 | means
21 |
22 | that the initial Contributor has attached the notice described in Exhibit B to the Covered Software; or
23 |
24 | that the Covered Software was made available under the terms of version 1.1 or earlier of the License, but not also under the terms of a Secondary License.
25 |
26 | 1.6. “Executable Form”
27 | means any form of the work other than Source Code Form.
28 |
29 | 1.7. “Larger Work”
30 | means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software.
31 |
32 | 1.8. “License”
33 | means this document.
34 |
35 | 1.9. “Licensable”
36 | means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently, any and all of the rights conveyed by this License.
37 |
38 | 1.10. “Modifications”
39 | means any of the following:
40 |
41 | any file in Source Code Form that results from an addition to, deletion from, or modification of the contents of Covered Software; or
42 |
43 | any new file in Source Code Form that contains any Covered Software.
44 |
45 | 1.11. “Patent Claims” of a Contributor
46 | means any patent claim(s), including without limitation, method, process, and apparatus claims, in any patent Licensable by such Contributor that would be infringed, but for the grant of the License, by the making, using, selling, offering for sale, having made, import, or transfer of either its Contributions or its Contributor Version.
47 |
48 | 1.12. “Secondary License”
49 | means either the GNU General Public License, Version 2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General Public License, Version 3.0, or any later versions of those licenses.
50 |
51 | 1.13. “Source Code Form”
52 | means the form of the work preferred for making modifications.
53 |
54 | 1.14. “You” (or “Your”)
55 | means an individual or a legal entity exercising rights under this License. For legal entities, “You” includes any entity that controls, is controlled by, or is under common control with You. For purposes of this definition, “control” means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity.
56 |
57 | 2. License Grants and Conditions
58 |
59 | 2.1. Grants
60 |
61 | Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license:
62 |
63 | under intellectual property rights (other than patent or trademark) Licensable by such Contributor to use, reproduce, make available, modify, display, perform, distribute, and otherwise exploit its Contributions, either on an unmodified basis, with Modifications, or as part of a Larger Work; and
64 |
65 | under Patent Claims of such Contributor to make, use, sell, offer for sale, have made, import, and otherwise transfer either its Contributions or its Contributor Version.
66 |
67 | 2.2. Effective Date
68 |
69 | The licenses granted in Section 2.1 with respect to any Contribution become effective for each Contribution on the date the Contributor first distributes such Contribution.
70 |
71 | 2.3. Limitations on Grant Scope
72 |
73 | The licenses granted in this Section 2 are the only rights granted under this License. No additional rights or licenses will be implied from the distribution or licensing of Covered Software under this License. Notwithstanding Section 2.1(b) above, no patent license is granted by a Contributor:
74 |
75 | for any code that a Contributor has removed from Covered Software; or
76 |
77 | for infringements caused by: (i) Your and any other third party’s modifications of Covered Software, or (ii) the combination of its Contributions with other software (except as part of its Contributor Version); or
78 |
79 | under Patent Claims infringed by Covered Software in the absence of its Contributions.
80 |
81 | This License does not grant any rights in the trademarks, service marks, or logos of any Contributor (except as may be necessary to comply with the notice requirements in Section 3.4).
82 |
83 | 2.4. Subsequent Licenses
84 |
85 | No Contributor makes additional grants as a result of Your choice to distribute the Covered Software under a subsequent version of this License (see Section 10.2) or under the terms of a Secondary License (if permitted under the terms of Section 3.3).
86 |
87 | 2.5. Representation
88 |
89 | Each Contributor represents that the Contributor believes its Contributions are its original creation(s) or it has sufficient rights to grant the rights to its Contributions conveyed by this License.
90 |
91 | 2.6. Fair Use
92 |
93 | This License is not intended to limit any rights You have under applicable copyright doctrines of fair use, fair dealing, or other equivalents.
94 |
95 | 2.7. Conditions
96 |
97 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Section 2.1.
98 |
99 | 3. Responsibilities
100 |
101 | 3.1. Distribution of Source Form
102 |
103 | All distribution of Covered Software in Source Code Form, including any Modifications that You create or to which You contribute, must be under the terms of this License. You must inform recipients that the Source Code Form of the Covered Software is governed by the terms of this License, and how they can obtain a copy of this License. You may not attempt to alter or restrict the recipients’ rights in the Source Code Form.
104 |
105 | 3.2. Distribution of Executable Form
106 |
107 | If You distribute Covered Software in Executable Form then:
108 |
109 | such Covered Software must also be made available in Source Code Form, as described in Section 3.1, and You must inform recipients of the Executable Form how they can obtain a copy of such Source Code Form by reasonable means in a timely manner, at a charge no more than the cost of distribution to the recipient; and
110 |
111 | You may distribute such Executable Form under the terms of this License, or sublicense it under different terms, provided that the license for the Executable Form does not attempt to limit or alter the recipients’ rights in the Source Code Form under this License.
112 |
113 | 3.3. Distribution of a Larger Work
114 |
115 | You may create and distribute a Larger Work under terms of Your choice, provided that You also comply with the requirements of this License for the Covered Software. If the Larger Work is a combination of Covered Software with a work governed by one or more Secondary Licenses, and the Covered Software is not Incompatible With Secondary Licenses, this License permits You to additionally distribute such Covered Software under the terms of such Secondary License(s), so that the recipient of the Larger Work may, at their option, further distribute the Covered Software under the terms of either this License or such Secondary License(s).
116 |
117 | 3.4. Notices
118 |
119 | You may not remove or alter the substance of any license notices (including copyright notices, patent notices, disclaimers of warranty, or limitations of liability) contained within the Source Code Form of the Covered Software, except that You may alter any license notices to the extent required to remedy known factual inaccuracies.
120 |
121 | 3.5. Application of Additional Terms
122 |
123 | You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, You may do so only on Your own behalf, and not on behalf of any Contributor. You must make it absolutely clear that any such warranty, support, indemnity, or liability obligation is offered by You alone, and You hereby agree to indemnify every Contributor for any liability incurred by such Contributor as a result of warranty, support, indemnity or liability terms You offer. You may include additional disclaimers of warranty and limitations of liability specific to any jurisdiction.
124 |
125 | 4. Inability to Comply Due to Statute or Regulation
126 |
127 | If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Software due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be placed in a text file included with all distributions of the Covered Software under this License. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it.
128 |
129 | 5. Termination
130 |
131 | 5.1. The rights granted under this License will terminate automatically if You fail to comply with any of its terms. However, if You become compliant, then the rights granted under this License from a particular Contributor are reinstated (a) provisionally, unless and until such Contributor explicitly and finally terminates Your grants, and (b) on an ongoing basis, if such Contributor fails to notify You of the non-compliance by some reasonable means prior to 60 days after You have come back into compliance. Moreover, Your grants from a particular Contributor are reinstated on an ongoing basis if such Contributor notifies You of the non-compliance by some reasonable means, this is the first time You have received notice of non-compliance with this License from such Contributor, and You become compliant prior to 30 days after Your receipt of the notice.
132 |
133 | 5.2. If You initiate litigation against any entity by asserting a patent infringement claim (excluding declaratory judgment actions, counter-claims, and cross-claims) alleging that a Contributor Version directly or indirectly infringes any patent, then the rights granted to You by any and all Contributors for the Covered Software under Section 2.1 of this License shall terminate.
134 |
135 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or Your distributors under this License prior to termination shall survive termination.
136 |
137 | 6. Disclaimer of Warranty
138 |
139 | Covered Software is provided under this License on an “as is” basis, without warranty of any kind, either expressed, implied, or statutory, including, without limitation, warranties that the Covered Software is free of defects, merchantable, fit for a particular purpose or non-infringing. The entire risk as to the quality and performance of the Covered Software is with You. Should any Covered Software prove defective in any respect, You (not any Contributor) assume the cost of any necessary servicing, repair, or correction. This disclaimer of warranty constitutes an essential part of this License. No use of any Covered Software is authorized under this License except under this disclaimer.
140 |
141 | 7. Limitation of Liability
142 |
143 | Under no circumstances and under no legal theory, whether tort (including negligence), contract, or otherwise, shall any Contributor, or anyone who distributes Covered Software as permitted above, be liable to You for any direct, indirect, special, incidental, or consequential damages of any character including, without limitation, damages for lost profits, loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses, even if such party shall have been informed of the possibility of such damages. This limitation of liability shall not apply to liability for death or personal injury resulting from such party’s negligence to the extent applicable law prohibits such limitation. Some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages, so this exclusion and limitation may not apply to You.
144 |
145 | 8. Litigation
146 |
147 | Any litigation relating to this License may be brought only in the courts of a jurisdiction where the defendant maintains its principal place of business and such litigation shall be governed by laws of that jurisdiction, without reference to its conflict-of-law provisions. Nothing in this Section shall prevent a party’s ability to bring cross-claims or counter-claims.
148 |
149 | 9. Miscellaneous
150 |
151 | This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not be used to construe this License against a Contributor.
152 |
153 | 10. Versions of the License
154 |
155 | 10.1. New Versions
156 |
157 | Mozilla Foundation is the license steward. Except as provided in Section 10.3, no one other than the license steward has the right to modify or publish new versions of this License. Each version will be given a distinguishing version number.
158 |
159 | 10.2. Effect of New Versions
160 |
161 | You may distribute the Covered Software under the terms of the version of the License under which You originally received the Covered Software, or under the terms of any subsequent version published by the license steward.
162 |
163 | 10.3. Modified Versions
164 |
165 | If you create software not governed by this License, and you want to create a new license for such software, you may create and use a modified version of this License if you rename the license and remove any references to the name of the license steward (except to note that such modified license differs from this License).
166 |
167 | 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses
168 |
169 | If You choose to distribute Source Code Form that is Incompatible With Secondary Licenses under the terms of this version of the License, the notice described in Exhibit B of this License must be attached.
170 |
171 | Exhibit A - Source Code Form License Notice
172 |
173 | This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
174 |
175 | If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice.
176 |
177 | You may add additional accurate notices of copyright ownership.
178 |
179 | Exhibit B - “Incompatible With Secondary Licenses” Notice
180 |
181 | This Source Code Form is “Incompatible With Secondary Licenses”, as defined by the Mozilla Public License, v. 2.0.
--------------------------------------------------------------------------------
/SimpleChat/SimpleChat-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | //
2 | // Use this file to import your target's public headers that you would like to expose to Swift.
3 | //
4 |
5 |
--------------------------------------------------------------------------------
/SimpleChat/SimpleChat-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | ${PRODUCT_NAME}
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ${PRODUCT_NAME}
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1.0
25 | LSRequiresIPhoneOS
26 |
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/SimpleChat/SimpleChat-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header
3 | //
4 | // The contents of this file are implicitly included at the beginning of every source file.
5 | //
6 |
7 | #import
8 |
9 | #ifndef __IPHONE_5_0
10 | #warning "This project uses features only available in iOS SDK 5.0 and later."
11 | #endif
12 |
13 | #ifdef __OBJC__
14 | #import
15 | #import
16 | #endif
17 |
--------------------------------------------------------------------------------
/SimpleChat/SwiftViewControllerExample/SwiftExampleViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SwiftExampleViewController.swift
3 | // SimpleChat
4 | //
5 | // Created by Logan Wright on 11/15/14.
6 | // Copyright (c) 2014 Logan Wright. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class SwiftExampleViewController: UIViewController, LGChatControllerDelegate {
12 |
13 | override func viewDidLoad() {
14 | super.viewDidLoad()
15 | }
16 |
17 | // func stylizeChatInput() {
18 | // LGChatInput.Appearance.backgroundColor = <#UIColor#>
19 | // LGChatInput.Appearance.includeBlur = <#Bool#>
20 | // LGChatInput.Appearance.textViewFont = <#UIFont#>
21 | // LGChatInput.Appearance.textViewTextColor = <#UIColor#>
22 | // LGChatInput.Appearance.tintColor = <#UIColor#>
23 | // LGChatInput.Appearance.textViewBackgroundColor = <#UIColor#>
24 | // }
25 |
26 | // func stylizeMessageCell() {
27 | // LGChatMessageCell.Appearance.font = <#UIFont#>
28 | // LGChatMessageCell.Appearance.opponentColor = <#UIColor#>
29 | // LGChatMessageCell.Appearance.userColor = <#UIColor#>
30 | // }
31 |
32 |
33 | // MARK: Launch Chat Controller
34 |
35 | func launchChatController() {
36 | let chatController = LGChatController()
37 | chatController.opponentImage = UIImage(named: "User")
38 | chatController.title = "Simple Chat"
39 | let helloWorld = LGChatMessage(content: "Hello World!", sentBy: .User)
40 | chatController.messages = [helloWorld]
41 | chatController.delegate = self
42 | self.navigationController?.pushViewController(chatController, animated: true)
43 | }
44 |
45 | // MARK: LGChatControllerDelegate
46 |
47 | func chatController(chatController: LGChatController, didAddNewMessage message: LGChatMessage) {
48 | print("Did Add Message: \(message.content)")
49 | }
50 |
51 | func shouldChatController(chatController: LGChatController, addMessage message: LGChatMessage) -> Bool {
52 | /*
53 | Use this space to prevent sending a message, or to alter a message. For example, you might want to hold a message until its successfully uploaded to a server.
54 | */
55 | return true
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/SimpleChat/ViewControllerExample/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // SimpleChat
4 | //
5 | // Created by Logan Wright on 3/17/14.
6 | // Copyright (c) 2014 Logan Wright. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/SimpleChat/ViewControllerExample/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // SimpleChat
4 | //
5 | // Created by Logan Wright on 3/17/14.
6 | // Copyright (c) 2014 Logan Wright. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "SimpleChat-Swift.h"
11 |
12 | @interface ViewController ()
13 |
14 | @end
15 |
16 | @implementation ViewController
17 |
18 | - (void)viewDidLoad
19 | {
20 | [super viewDidLoad];
21 |
22 | UILabel * tapLabel = [UILabel new];
23 | tapLabel.bounds = CGRectMake(0, 0, 200, 100);
24 | tapLabel.text = @"** TAP TO OPEN **";
25 | tapLabel.textAlignment = NSTextAlignmentCenter;
26 | tapLabel.center = self.view.center;
27 | tapLabel.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin;
28 | [self.view addSubview:tapLabel];
29 |
30 | UITapGestureRecognizer * tap = [UITapGestureRecognizer new];
31 | [tap addTarget:self action:@selector(handleTap:)];
32 | [self.view addGestureRecognizer:tap];
33 | }
34 |
35 | - (void)handleTap:(UITapGestureRecognizer *)tap
36 | {
37 | [self launchChatController];
38 | }
39 |
40 | - (void)didReceiveMemoryWarning
41 | {
42 | [super didReceiveMemoryWarning];
43 | // Dispose of any resources that can be recreated.
44 | }
45 |
46 | #pragma mark - Styling
47 |
48 | //- (void)styleChatInput
49 | //{
50 | // [LGChatInput setAppearanceBackgroundColor:<#UIColor#>];
51 | // [LGChatInput setAppearanceIncludeBlur:<#Bool#>];
52 | // [LGChatInput setAppearanceTextViewFont:<#UIFont#>];
53 | // [LGChatInput setAppearanceTextViewTextColor:<#UIColor#>];
54 | // [LGChatInput setAppearanceTintColor:<#UIColor#>];
55 | // [LGChatInput setAppearanceTextViewBackgroundColor:<#UIColor#>];
56 | //}
57 |
58 | //- (void)styleMessageCell
59 | //{
60 | // [LGChatMessageCell setAppearanceFont:<#UIFont#>];
61 | // [LGChatMessageCell setAppearanceOpponentColor:[<#UIColor#>];
62 | // [LGChatMessageCell setAppearanceUserColor:<#UIColor#>];
63 | //}
64 |
65 | #pragma mark - Launch Chat Controller
66 |
67 | - (void)launchChatController
68 | {
69 | LGChatController *chatController = [LGChatController new];
70 | chatController.opponentImage = [UIImage imageNamed:@"User"];
71 | chatController.title = @"Simple Chat";
72 | LGChatMessage *helloWorld = [[LGChatMessage alloc] initWithContent:@"Hello World!" sentByString:[LGChatMessage SentByUserString]];
73 | chatController.messages = @[helloWorld]; // Pass your messages here.
74 | chatController.delegate = self;
75 | [self.navigationController pushViewController:chatController animated:YES];
76 | }
77 |
78 | #pragma mark - LGChatControllerDelegate
79 |
80 | - (void)chatController:(LGChatController *)chatController didAddNewMessage:(LGChatMessage *)message
81 | {
82 | NSLog(@"Did Add Message: %@", message.content);
83 | }
84 |
85 | - (BOOL)shouldChatController:(LGChatController *)chatController addMessage:(LGChatMessage *)message
86 | {
87 | /*
88 | This is implemented just for demonstration so the sent by is randomized. This way, the full functionality can be demonstrated.
89 | */
90 | message.sentByString = arc4random_uniform(2) == 0 ? [LGChatMessage SentByOpponentString] : [LGChatMessage SentByUserString];
91 | return YES;
92 | }
93 |
94 | @end
95 |
--------------------------------------------------------------------------------
/SimpleChat/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/SimpleChat/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // SimpleChat
4 | //
5 | // Created by Logan Wright on 3/17/14.
6 | // Copyright (c) 2014 Logan Wright. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "AppDelegate.h"
12 |
13 | int main(int argc, char * argv[])
14 | {
15 | @autoreleasepool {
16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/SimpleChatTests/SimpleChatTests-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 | CFBundlePackageType
14 | BNDL
15 | CFBundleShortVersionString
16 | 1.0
17 | CFBundleSignature
18 | ????
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/SimpleChatTests/SimpleChatTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // SimpleChatTests.m
3 | // SimpleChatTests
4 | //
5 | // Created by Logan Wright on 3/17/14.
6 | // Copyright (c) 2014 Logan Wright. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SimpleChatTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation SimpleChatTests
16 |
17 | - (void)setUp
18 | {
19 | [super setUp];
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 | }
22 |
23 | - (void)tearDown
24 | {
25 | // Put teardown code here. This method is called after the invocation of each test method in the class.
26 | [super tearDown];
27 | }
28 |
29 | - (void)testExample
30 | {
31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__);
32 | }
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/SimpleChatTests/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------