Compare commits

..

167 Commits

Author SHA1 Message Date
Christine Corbett
26fb5cbcf4 groups and calls have optional avatar; consumer must specify that it should be used and provide images in project of naming convention. otherwise no image will be used 2015-01-27 22:53:25 -10:00
Christine Corbett
c8262eee36 calls and group update messages now blue styled in correct font 2015-01-25 19:10:42 -10:00
Joyce Yan
184f53b07b Design tweaks based on @abolishme's work. 2015-01-24 08:31:23 -10:00
dtsbourg
ed9858bd6d revert b73b5d 2014-12-29 23:48:01 +01:00
dtsbourg
9dffc05aa7 Merge branch 'FredericJacobs-JSignalQ' into JSignalQ 2014-12-29 22:07:24 +01:00
Frederic Jacobs
cb5c4facbc Removing unused properties + bug fix call label 2014-12-29 21:56:58 +01:00
dtsbourg
84d1b659f3 Typo fix 2014-12-29 21:21:19 +01:00
dtsbourg
b73b5d9983 Performance enhancement for collection view reloading 2014-12-29 19:25:29 +01:00
dtsbourg
6a30411791 Merge remote-tracking branch 'jsq/master' into JSignalQ-6.1.1 2014-12-23 18:04:39 +01:00
Jesse Squires
395b1342a9 unit tests and refinements 2014-12-19 17:41:19 -05:00
Jesse Squires
ea3b8cc6fc bump version numbers 2014-12-19 16:44:57 -05:00
Jesse Squires
697c839c80 clean up from PR #644 code review 2014-12-19 16:39:26 -05:00
Jesse Squires
d6c9dd0ce9 Merge pull request #644 from evilstudios/develop
fix #480: scrollToBottomAnimated: fix long message handling
2014-12-19 16:13:44 -05:00
Jesse Squires
16c42a11e5 fix #648. fix #646. close #649. 2014-12-19 16:03:56 -05:00
Jesse Squires
9980266b62 address code review comments from PR #646, ref #645, #314, #640 2014-12-19 15:42:21 -05:00
Jesse Squires
38c14c19e7 Merge pull request #646 from evilstudios/keyboard-notification-fix
Fix #645: add 'keyboardDidHide' notification handling
2014-12-19 15:33:04 -05:00
Jesse Squires
736d110eba Update README.md 2014-12-14 18:16:49 -05:00
Jesse Squires
7c57677738 fix keyboard dismissal and firstResponder bugs. close #640. close #510. 2014-12-14 16:12:07 -05:00
Jesse Squires
69e2518345 add assert to didPressAccessoryButton: 2014-12-13 17:35:05 -05:00
Jesse Squires
3a50f7f9c2 clean up from PR #651. update docs. 2014-12-13 17:34:03 -05:00
Jesse Squires
6e4857ab8d Merge pull request #651 from deepakraj89/Fix_ScrollAnimation
Fix for Scroll Animation (close #515)
2014-12-13 17:13:19 -05:00
Jesse Squires
260e51ce2c update README for customizing toolbar buttons. close #669 2014-12-13 17:10:54 -05:00
Jesse Squires
a81bfa2277 Merge branch 'develop' of https://github.com/jessesquires/JSQMessagesViewController into develop 2014-12-13 16:57:02 -05:00
Jesse Squires
847f49e6e7 add button customization comments to demo. #669 2014-12-13 16:56:53 -05:00
dtsbourg
8703ce020c JSQDisplayedMessage: implement tap delegate 2014-12-10 21:45:29 +01:00
Jesse Squires
7d8cd7b867 Merge pull request #673 from ranunez/develop
Updated link in README for updated iOS 6 adoption stats
2014-12-09 15:37:59 -08:00
Ricardo Nunez
8d9f241038 Updated link in README for updated iOS 6 adoption stats 2014-12-09 15:16:40 -08:00
dtsbourg
fcbbfdc43f Fix crash on long tap on error and info messages 2014-12-09 22:37:56 +01:00
Jesse Squires
66fb14161d Update README.md 2014-12-08 00:29:00 -08:00
dtsbourg
bc976a04d9 Cells: change isKindOfClass to messageType check 2014-12-07 14:42:27 +01:00
Jesse Squires
4ab13ad7ac Merge branch 'develop' of https://github.com/jessesquires/JSQMessagesViewController into develop 2014-12-07 01:58:34 -08:00
Jesse Squires
d5f8d4291b proj settings 2014-12-06 17:09:40 -08:00
dtsbourg
43f6e75bbf Set adapter type as property 2014-12-06 18:23:03 +01:00
dtsbourg
59ea2b6920 Revert to TSMessageAdapterType for naming to avoid conflicts 2014-12-06 16:57:31 +01:00
dtsbourg
dee758a3ff TSMessageType added to JSQMessageData 2014-12-06 16:52:16 +01:00
Jesse Squires
17153bdd38 add migration section to README. close #663 2014-12-04 22:19:25 -08:00
dtsbourg
82482a1fc5 Remove call button on toolbar 2014-12-04 16:11:34 +01:00
Deepak
442b597c95 More refactoring to the newly added methods 2014-12-01 22:32:58 -08:00
Jesse Squires
1bb258691b Merge pull request #655 from evermeer/patch-1
Update README. Added EVCloudKitDao as app using this library.
2014-12-01 00:45:54 -08:00
dtsbourg
7c2cec63f9 Remove unnecessary res 2014-11-30 19:55:56 +01:00
dtsbourg
91fbb4dce7 JSQDisplayedMessage: Update UI 2014-11-30 19:55:27 +01:00
Edwin Vermeer
681b6d329b Added EVCloudKitDao as app using this library.
EVCloudKitDao is a library for simplified access to CloudKit. As a sample there is a fully functional chat demo included which is using this library
2014-11-30 17:28:26 +01:00
dtsbourg
0d8fabe142 Calls: Update UI 2014-11-30 16:51:24 +01:00
dtsbourg
4049f54789 JSQDisplayedMessage: Link to UI 2014-11-29 15:30:53 +01:00
dtsbourg
54ae40b07a JSQDisplayedMessageCollectionViewCell: Base class 2014-11-29 15:06:43 +01:00
dtsbourg
bcf0ac6e1f JSQErrorMessage: Model 2014-11-29 14:48:59 +01:00
dtsbourg
e70cec697f JSQDisplayedMessage: Model + JSQInfoMessage: Model 2014-11-29 14:39:59 +01:00
Deepak
7234f10f81 Added two public methods to control collectionview scroll animation 2014-11-28 13:13:26 -08:00
Deepak
fd7f27b74b Fix for Scroll Animation 2014-11-27 11:57:04 -08:00
dtsbourg
b22b7a4caf JSQMessagesBubbleImageFactory: Add a failed message bubble 2014-11-27 12:43:24 +01:00
dtsbourg
b8b3fb9122 JSQMessageData: add message status field 2014-11-27 12:29:49 +01:00
dtsbourg
5fc12f5cba Merge branch 'master' of https://github.com/jessesquires/JSQMessagesViewController into JSignalQ 2014-11-26 18:04:32 +01:00
dtsbourg
4cad607ae2 none 2014-11-26 18:01:19 +01:00
Sean Conrad
276e9f94a6 add 'keyboardDidHide' notification handling
:: JSQMessagesKeyboardControllerDelegate protocol adds options `keyboardControllerDidReceiveKeyboardHideNotification:` method
:: this method is called within the completion block of the typical keyboard frame change notification handler, ensuring that the 'hide' message is received last
:: `JSQMessagesViewController` uses this delegate callback to call `jsq_setToolbarBottomLayoutGuideConstant:` with a value of `0.0f` (ensuring that a 'hidden' keyboard results in a 0-position input toolbar)
2014-11-25 18:24:30 -08:00
Sean Conrad
6a04d7585d improve layout for smaller cells
in some cases, `Top` alignment is best - this commit handles those cases
2014-11-25 16:02:44 -08:00
Sean Conrad
28b17896cc scrollToBottomAnimated: fix long message handling
fixes #480
2014-11-25 15:08:37 -08:00
Jesse Squires
8f28bc513e v6.1.0 2014-11-23 16:43:10 -08:00
Jesse Squires
512d2a9394 fix semantics regarding avatarPlaceholderImage and avatarHighlightedImage. close #624 2014-11-23 16:29:19 -08:00
Jesse Squires
81488d5ee6 add an emptyCache property to invalidation context for explicitly clearing the cache via invalidation. close #633 2014-11-23 16:20:49 -08:00
Jesse Squires
08ebf9b608 Update README.md 2014-11-23 12:39:09 -08:00
Jesse Squires
56f0d40214 Merge branch 'develop' of https://github.com/jessesquires/JSQMessagesViewController into develop 2014-11-22 13:47:03 -08:00
Jesse Squires
5d83de37cd expose left and right bar button container views. update docs. close #634 2014-11-22 13:46:31 -08:00
Jesse Squires
2626e8419b make hash required for message data protocols. close #631 2014-11-22 13:21:50 -08:00
dtsbourg
597670e446 JSQCallCollectionViewCell: UI 2014-11-21 23:01:16 +01:00
dtsbourg
881ddddeb4 Demo: make JSQM6.0 work with JSQCall 2014-11-21 22:14:53 +01:00
dtsbourg
32395453ff Finish merging 2014-11-21 13:43:21 +01:00
dtsbourg
5c6dce5a04 Fix merge from master conflicts 2014-11-21 13:37:28 +01:00
dtsbourg
3d248e4af0 JSQCall : layout 2014-11-21 12:02:20 +01:00
dtsbourg
6bbef1949b JSQCall model 2014-11-20 14:57:18 +01:00
dtsbourg
1031a89858 JSQMessage: Add failed state 2014-11-20 10:10:55 +01:00
dtsbourg
21d877492e InputToolbar: blue BarButtonItems 2014-11-19 13:05:35 +01:00
dtsbourg
5670accd2c General: Font update 2014-11-18 18:05:24 +01:00
dtsbourg
d138d4f3a3 InputToolbar: Fine tune enabling on rightBarButtonItem 2014-11-17 20:41:08 +01:00
dtsbourg
cddbbf2c75 InputToolbar: Bar button item always responds to tap events 2014-11-17 20:27:57 +01:00
dtsbourg
104ba0e023 MessageStatus: add kMessageNone status 2014-11-17 20:22:59 +01:00
dtsbourg
a27fa1091e Test: Custom UIButton in factory 2014-11-17 20:17:08 +01:00
Jesse Squires
a7a9cd7c64 Update README.md 2014-11-12 20:50:36 -08:00
dtsbourg
7446b63cbb remove * 2014-11-12 22:31:22 +01:00
dtsbourg
73482f6ace ≈Merge branch 'issue_492_scrollviewperformance' into JSignalQ 2014-11-12 22:26:40 +01:00
dtsbourg
2dad6e3036 add message status 2014-11-12 22:22:59 +01:00
Jesse Squires
b20af9e524 Merge pull request #618 from ranunez/develop
Updated link in README to reflect new stats on iOS 6 adoption
2014-11-11 22:28:42 -08:00
Ricardo Nunez
5ba9d2ee09 Updated link in README to reflect new stats on iOS 6 adoption 2014-11-11 21:45:31 -08:00
Jesse Squires
fe0540167b force toolbar to dismiss to bottom of view on viewDidDisappear. fix #314 2014-11-11 18:32:01 -08:00
Jesse Squires
45ce02baa6 remove todo 2014-11-11 18:05:31 -08:00
Jesse Squires
7722bce9d8 fix pod spec 2014-11-09 15:11:39 -08:00
Jesse Squires
ea74142adb Update README.md 2014-11-09 13:27:27 -08:00
Jesse Squires
ae9869d7ff update screenshots and spec 2014-11-09 13:25:50 -08:00
Jesse Squires
36b066fbdc Update README.md 2014-11-09 13:14:56 -08:00
Jesse Squires
387a7544b3 update pod spec 2014-11-09 13:11:12 -08:00
Jesse Squires
484a4b59bd update screenshots 2014-11-09 13:09:59 -08:00
Jesse Squires
f6e96e9a07 add message bubble red color 2014-11-09 12:21:36 -08:00
Jesse Squires
cdc86cc0a3 Update README.md 2014-11-09 12:08:58 -08:00
Jesse Squires
03b74fe77e Update README.md 2014-11-09 11:37:39 -08:00
Jesse Squires
280ff293f1 Update README.md 2014-11-09 11:21:25 -08:00
Jesse Squires
3b8cf0fa35 Update README.md 2014-11-09 11:20:14 -08:00
Jesse Squires
591e9198bb fix version numbers 2014-11-09 11:10:39 -08:00
Jesse Squires
0d20dadb8e refactor JSQMessage hierarchy. remove Text and Media subclasses, absorb into single JSQMessage class. close #602 2014-11-09 10:58:04 -08:00
Jesse Squires
72a4b5b970 adjust input toolbar layout and button sizes. 2014-11-07 19:27:50 -08:00
Jesse Squires
b291898161 fix toolbar constraints and correctly size send button to fit text. close #603 2014-11-07 19:13:36 -08:00
Jesse Squires
5627228464 expose cache countLimit. set default to 200. ref: #492 2014-11-07 18:18:46 -08:00
Jesse Squires
4281751534 verify outlets. close #604 2014-11-07 18:06:27 -08:00
Jesse Squires
c81aa93726 subclass text view to prevent unwanted text selection. close #591 2014-11-04 22:56:39 -08:00
Jesse Squires
468e102a7c minor optimizations 2014-11-04 22:26:36 -08:00
Jesse Squires
b3a80d9afc minor optimizations 2014-11-04 22:25:03 -08:00
Jesse Squires
dbfe58fc6d revert 4aedb06. close #597. cc: #484. sad face. 2014-11-04 21:35:04 -08:00
Jesse Squires
2070cde22d implement better message bubble size caching in layout for scrolling performance. #492 2014-11-02 20:17:54 -08:00
Jesse Squires
e99b127694 fix scroll position #256 2014-11-02 20:13:47 -08:00
Jesse Squires
08a9ec95fa fix message hashes 2014-11-02 19:56:42 -08:00
Jesse Squires
0d8667d14e fix issue where scroll to bottom fails until contentSize is at least a certain height. close #256 2014-11-02 19:36:40 -08:00
Jesse Squires
5c8dee520c Merge branch 'develop' of https://github.com/jessesquires/JSQMessagesViewController into develop 2014-11-02 19:13:40 -08:00
Jesse Squires
42c29ce4a1 fix auto layout constraint issues and warnings. set bubble width instead of margin. close #584, close #322 2014-11-02 19:13:05 -08:00
Jesse Squires
66a7d47ff3 edit cell 2014-11-02 18:22:27 -08:00
Jesse Squires
049035cdb6 Update README.md 2014-11-02 01:19:41 -07:00
Jesse Squires
4aedb062cc remove FIXME for radar 18326340. issue has been resolved as of Xcode 6.1 ref #484 2014-11-01 15:44:58 -07:00
Jesse Squires
c0edc6f7aa fix tests 2014-10-30 22:32:41 -07:00
Jesse Squires
9b579e91b9 fix composer text view insets. prevent single-line scrolling. fix #559 2014-10-30 21:40:27 -07:00
Jesse Squires
e88501ed61 prevent cell tap delegate methods from being called with a nil indexPath. fix #586 2014-10-30 21:36:43 -07:00
Jesse Squires
49f2c24533 fix #589. update insets when setting topContentAdditional inset 2014-10-30 21:33:17 -07:00
Jesse Squires
74965225f0 Merge pull request #585 from dtsbourg/issue_492_scrollviewperformance
Rasterize collection view cell for scrolling performance, ref #492
2014-10-28 17:20:45 -07:00
dtsbourg
99971a8d38 Merge branch 'JSignalQ' of https://github.com/dtsbourg/JSQMessagesViewController into JSignalQ 2014-10-28 23:39:44 +01:00
dtsbourg
da7203dee2 [UIColor whiteColor] 2014-10-28 23:37:11 +01:00
dtsbourg
88e16ac830 white bg ? 2014-10-28 23:37:11 +01:00
dtsbourg
41dddfea3a cell xib white bg 2014-10-28 23:37:11 +01:00
dtsbourg
ebea4ef0b8 Restore white bg 2014-10-28 23:37:11 +01:00
dtsbourg
f115194efa Signal 2014-10-28 23:37:11 +01:00
dtsbourg
39393e4b8b Rasterize collection view cell for scrolling performance 2014-10-28 23:36:27 +01:00
dtsbourg
06e7c2bec9 [UIColor whiteColor] 2014-10-28 22:51:14 +01:00
dtsbourg
6dded2cce9 white bg ? 2014-10-28 22:28:47 +01:00
dtsbourg
f03bac13a0 cell xib white bg 2014-10-28 22:23:39 +01:00
dtsbourg
33b81ca6b0 Restore white bg 2014-10-28 22:19:28 +01:00
dtsbourg
752edc4f0f Signal 2014-10-28 21:49:55 +01:00
Jesse Squires
71acc85bb4 Update README.md 2014-10-25 15:59:40 -07:00
Jesse Squires
3868620d62 Update README.md 2014-10-25 15:45:16 -07:00
Jesse Squires
58e4ac6624 fix #422 2014-10-25 15:34:22 -07:00
Jesse Squires
b5b6e8c2af update version numbers 2014-10-20 23:23:09 -07:00
Jesse Squires
065d60d997 update umbrella header 2014-10-20 23:22:03 -07:00
Jesse Squires
3f0f52f704 more unit test refinements 2014-10-20 23:17:14 -07:00
Jesse Squires
188ab824b8 refine category unit tests. update image category for asset methods. 2014-10-20 23:07:35 -07:00
Jesse Squires
e2b62c4996 change JSQVideoMediaItem to inherit from JSQMediaItem. mask JSQVideoMediaItem. closes #571. 2014-10-20 22:32:17 -07:00
Jesse Squires
1af170b983 change JSQLocationMediaItem to inherit from JSQMediaItem. mask JSQLocationMediaItem. #571 2014-10-20 22:23:35 -07:00
Jesse Squires
b590303a4f new abstract base class, JSQMediaItem, for pulling out common media item behavior. refactor JSQPhotoMediaItem to inherit from JSQMediaItem. #571 2014-10-20 22:08:23 -07:00
Jesse Squires
a38125e726 mask media views for JSQPhotoMediaItem. ref #571 2014-10-20 21:26:05 -07:00
Jesse Squires
b75870a241 add convenience method to JSQMessagesMediaViewBubbleImageMasker. #571 2014-10-20 21:06:16 -07:00
Jesse Squires
d4a5bc6d09 add new JSQMessagesMediaViewBubbleImageMasker. ref #571 2014-10-20 20:22:44 -07:00
Jesse Squires
da92497d42 update default map region span to 500 meters 2014-10-20 18:44:25 -07:00
Jesse Squires
6f7f318bcd update pods 2014-10-20 18:35:33 -07:00
Jesse Squires
45549628ae more edits for #563 2014-10-19 23:34:07 -07:00
Jesse Squires
02fdee07d0 Allow using a custom nib. ref #563 2014-10-19 23:30:29 -07:00
Jesse Squires
005378f8f3 update demo 2014-10-19 18:44:01 -07:00
Jesse Squires
0638d8caf2 refactor assets directory. use asset bundle. update categories for bundle. update tests 2014-10-19 18:22:22 -07:00
Jesse Squires
a023fee709 complete localization! close #237 whoo! :) 2014-10-19 17:22:42 -07:00
Jesse Squires
f201b085e3 add new empty strings file. ref #237 2014-10-19 16:33:29 -07:00
Jesse Squires
a56ceebdd3 use new collection view layout size helper method. cap label heights and avatar sizes constraints to 1.0 to fix auto-layout warnings. ref #322 2014-10-19 15:49:27 -07:00
Jesse Squires
f914b81044 new flow layout item size helper method 2014-10-19 15:27:29 -07:00
Jesse Squires
639df113ff improve scrolling performance. we don't need to keep calling setNeedsUpdateConstraints. ref #492. 2014-10-19 15:09:02 -07:00
Jesse Squires
3954411213 prepareForReuse 2014-10-19 14:39:18 -07:00
Jesse Squires
3e8a3cbfc1 add spec to project 2014-10-19 14:02:12 -07:00
Jesse Squires
833cf417f5 update JSQLocationMediaItem to specify a custom map region. close #565 2014-10-19 12:18:50 -07:00
Jesse Squires
3684895342 minor fixes 2014-10-19 11:22:08 -07:00
Jesse Squires
dee7714d9e re-add video item 2014-10-19 11:15:31 -07:00
Jesse Squires
dd9458a70f remove video item 2014-10-19 11:14:39 -07:00
Jesse Squires
d85c94e57f fix JSQVideoMediaItem typo. close #570 2014-10-19 11:12:58 -07:00
Jesse Squires
454be29f8d revert @import for #import. fix #541 2014-10-15 21:16:47 -07:00
Jesse Squires
d0fd6e58ec refactor 2014-10-15 21:08:36 -07:00
Jesse Squires
3b159c1df9 Merge pull request #560 from ghazel/menu_disable_scroll_554
don't scroll if the menu is visible. fix #554
2014-10-15 21:00:04 -07:00
Jesse Squires
33e780e535 adjust bubble size calculations. fix #553. 2014-10-15 20:57:13 -07:00
Greg Hazel
ddca80232a don't scroll if the menu is visible 2014-10-14 20:14:20 -07:00
266 changed files with 9191 additions and 5339 deletions

0
Assets/JSQmessages.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

0
Assets/jsq_message_chat_icon.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

0
Assets/jsq_messages_banner.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

0
Assets/jsq_messages_banner.psd Executable file → Normal file
View File

0
Assets/jsq_messages_icon.psd Executable file → Normal file
View File

0
Assets/jsq_messages_splash.psd Executable file → Normal file
View File

0
Assets/jsq_messages_splash_ipad.psd Executable file → Normal file
View File

0
CONTRIBUTING.md Executable file → Normal file
View File

4645
JSQMessages.xcodeproj/project.pbxproj Executable file → Normal file

File diff suppressed because it is too large Load Diff

0
JSQMessages.xcodeproj/project.xcworkspace/contents.xcworkspacedata generated Executable file → Normal file
View File

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
<false/>
</dict>
</plist>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0510"
LastUpgradeVersion = "0600"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@ -14,7 +14,7 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "26344A22808645D9967C8244"
BlueprintIdentifier = "4F6B28C25B7B1259BD8C5B8B"
BuildableName = "libPods.a"
BlueprintName = "Pods"
ReferencedContainer = "container:Pods/Pods.xcodeproj">
@ -28,7 +28,7 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "885D592818CBD13D00D77BB3"
BlueprintIdentifier = "88A25F0119D8DEC400924534"
BuildableName = "JSQMessages.app"
BlueprintName = "JSQMessages"
ReferencedContainer = "container:JSQMessages.xcodeproj">
@ -42,7 +42,7 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "885D594C18CBD13D00D77BB3"
BlueprintIdentifier = "88A25F1A19D8DEC400924534"
BuildableName = "JSQMessagesTests.xctest"
BlueprintName = "JSQMessagesTests"
ReferencedContainer = "container:JSQMessages.xcodeproj">
@ -60,7 +60,7 @@
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "885D594C18CBD13D00D77BB3"
BlueprintIdentifier = "88A25F1A19D8DEC400924534"
BuildableName = "JSQMessagesTests.xctest"
BlueprintName = "JSQMessagesTests"
ReferencedContainer = "container:JSQMessages.xcodeproj">
@ -70,7 +70,7 @@
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "885D592818CBD13D00D77BB3"
BlueprintIdentifier = "88A25F0119D8DEC400924534"
BuildableName = "JSQMessages.app"
BlueprintName = "JSQMessages"
ReferencedContainer = "container:JSQMessages.xcodeproj">
@ -89,7 +89,7 @@
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "885D592818CBD13D00D77BB3"
BlueprintIdentifier = "88A25F0119D8DEC400924534"
BuildableName = "JSQMessages.app"
BlueprintName = "JSQMessages"
ReferencedContainer = "container:JSQMessages.xcodeproj">
@ -107,7 +107,7 @@
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "885D592818CBD13D00D77BB3"
BlueprintIdentifier = "88A25F0119D8DEC400924534"
BuildableName = "JSQMessages.app"
BlueprintName = "JSQMessages"
ReferencedContainer = "container:JSQMessages.xcodeproj">

11
JSQMessages.xcworkspace/contents.xcworkspacedata generated Executable file → Normal file
View File

@ -1 +1,10 @@
<?xml version='1.0' encoding='UTF-8'?><Workspace version='1.0'><FileRef location='group:JSQMessages.xcodeproj'/><FileRef location='group:Pods/Pods.xcodeproj'/></Workspace>
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:JSQMessages.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
<false/>
</dict>
</plist>

View File

@ -1,6 +1,6 @@
//
// Created by Jesse Squires
// http://www.hexedbits.com
// http://www.jessesquires.com
//
//
// Documentation
@ -16,9 +16,10 @@
// Released under an MIT license: http://opensource.org/licenses/MIT
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface JSQAppDelegate : UIResponder <UIApplicationDelegate>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;

View File

@ -1,6 +1,6 @@
//
// Created by Jesse Squires
// http://www.hexedbits.com
// http://www.jessesquires.com
//
//
// Documentation
@ -16,12 +16,19 @@
// Released under an MIT license: http://opensource.org/licenses/MIT
//
#import "JSQAppDelegate.h"
#import "AppDelegate.h"
@implementation JSQAppDelegate
#import "NSUserDefaults+DemoSettings.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Load our default settings
[NSUserDefaults saveIncomingAvatarSetting:YES];
[NSUserDefaults saveOutgoingAvatarSetting:YES];
return YES;
}

257
JSQMessagesDemo/Base.lproj/Main.storyboard Executable file → Normal file
View File

@ -1,13 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="5053" systemVersion="13C64" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="JRd-Be-psV">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6245" systemVersion="13F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="JRd-Be-psV">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/>
<deployment defaultVersion="1792" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6238"/>
</dependencies>
<scenes>
<!--Table View Controller - Root View Controller-->
<!--Root View Controller-->
<scene sceneID="IjL-71-Ll6">
<objects>
<tableViewController id="rXs-qR-ns2" customClass="JSQTableViewController" sceneMemberID="viewController">
<tableViewController id="rXs-qR-ns2" customClass="TableViewController" sceneMemberID="viewController">
<tableView key="view" opaque="NO" clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="10" sectionFooterHeight="10" id="d0b-Sx-5kJ">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@ -36,12 +37,252 @@
<connections>
<segue destination="JdJ-0X-ZL8" kind="push" identifier="seguePushDemoVC" id="Hvf-k8-GSP"/>
<segue destination="s4z-xn-r6C" kind="modal" identifier="segueModalDemoVC" id="4UP-0e-ylo"/>
<segue destination="y7K-ZU-Xs9" kind="push" identifier="SegueToSettings" id="u7b-st-FND"/>
</connections>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="IcC-ug-dCB" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-2982" y="274"/>
</scene>
<!--Settings-->
<scene sceneID="6rZ-ao-qyI">
<objects>
<tableViewController id="y7K-ZU-Xs9" customClass="DemoSettingsViewController" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="grouped" separatorStyle="default" allowsSelection="NO" rowHeight="44" sectionHeaderHeight="10" sectionFooterHeight="10" id="GY5-ob-knb">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<sections>
<tableViewSection headerTitle="Messages" id="ygb-Dp-o4r">
<cells>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="Eii-ro-1yZ">
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Eii-ro-1yZ" id="qU9-o3-MWC">
<autoresizingMask key="autoresizingMask"/>
<subviews>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="K7N-os-fuc">
<rect key="frame" x="263" y="6" width="51" height="31"/>
<constraints>
<constraint firstAttribute="width" constant="49" id="A6s-Sr-u8U"/>
<constraint firstAttribute="height" constant="31" id="z9i-uJ-MBq"/>
</constraints>
<connections>
<action selector="didTapSwitch:" destination="y7K-ZU-Xs9" eventType="valueChanged" id="Ebi-bs-7Bc"/>
</connections>
</switch>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Load extra messages" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bSS-CD-nfD">
<rect key="frame" x="8" y="10" width="247" height="24"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="bSS-CD-nfD" firstAttribute="top" secondItem="qU9-o3-MWC" secondAttribute="top" constant="10" id="4Iw-W0-qZs"/>
<constraint firstAttribute="trailing" secondItem="K7N-os-fuc" secondAttribute="trailing" constant="8" id="Fex-nr-C1R"/>
<constraint firstAttribute="bottom" secondItem="K7N-os-fuc" secondAttribute="bottom" constant="6" id="IBG-gn-Fpk"/>
<constraint firstItem="bSS-CD-nfD" firstAttribute="leading" secondItem="qU9-o3-MWC" secondAttribute="leading" constant="8" id="N5B-E5-Pzk"/>
<constraint firstItem="K7N-os-fuc" firstAttribute="leading" secondItem="bSS-CD-nfD" secondAttribute="trailing" constant="8" id="O2Y-G9-d6n"/>
<constraint firstItem="K7N-os-fuc" firstAttribute="top" secondItem="qU9-o3-MWC" secondAttribute="top" constant="6" id="UbM-aE-caS"/>
<constraint firstAttribute="bottom" secondItem="bSS-CD-nfD" secondAttribute="bottom" constant="9" id="poL-wE-Eir"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="bZI-G1-eYA">
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="bZI-G1-eYA" id="1Ho-Zz-KN0">
<autoresizingMask key="autoresizingMask"/>
<subviews>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="hMq-Ee-EJK">
<rect key="frame" x="263" y="6" width="51" height="31"/>
<constraints>
<constraint firstAttribute="height" constant="31" id="gM4-dK-cl7"/>
<constraint firstAttribute="width" constant="49" id="hvu-Yy-NTG"/>
</constraints>
<connections>
<action selector="didTapSwitch:" destination="y7K-ZU-Xs9" eventType="valueChanged" id="JCb-EJ-M9U"/>
</connections>
</switch>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Load really long message" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YV3-GH-Yul">
<rect key="frame" x="8" y="10" width="247" height="24"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="hMq-Ee-EJK" firstAttribute="leading" secondItem="YV3-GH-Yul" secondAttribute="trailing" constant="8" id="KFO-nO-4r4"/>
<constraint firstItem="YV3-GH-Yul" firstAttribute="top" secondItem="1Ho-Zz-KN0" secondAttribute="top" constant="10" id="Lgl-fY-a8c"/>
<constraint firstAttribute="bottom" secondItem="YV3-GH-Yul" secondAttribute="bottom" constant="9" id="NvL-b8-QDl"/>
<constraint firstAttribute="bottom" secondItem="hMq-Ee-EJK" secondAttribute="bottom" constant="6" id="aef-Rh-49d"/>
<constraint firstItem="hMq-Ee-EJK" firstAttribute="top" secondItem="1Ho-Zz-KN0" secondAttribute="top" constant="6" id="csX-us-yCd"/>
<constraint firstAttribute="trailing" secondItem="hMq-Ee-EJK" secondAttribute="trailing" constant="8" id="xDE-tf-5mB"/>
<constraint firstItem="YV3-GH-Yul" firstAttribute="leading" secondItem="1Ho-Zz-KN0" secondAttribute="leading" constant="8" id="xyR-oc-iUp"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="2Th-gL-oAN">
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="2Th-gL-oAN" id="OFq-Mz-mbl">
<autoresizingMask key="autoresizingMask"/>
<subviews>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="baL-Tb-bTJ">
<rect key="frame" x="263" y="6" width="51" height="31"/>
<constraints>
<constraint firstAttribute="width" constant="49" id="SaV-RG-DVL"/>
<constraint firstAttribute="height" constant="31" id="dXb-pb-etA"/>
</constraints>
<connections>
<action selector="didTapSwitch:" destination="y7K-ZU-Xs9" eventType="valueChanged" id="w1H-5W-oip"/>
</connections>
</switch>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Empty view, no messages" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="DoU-SU-Nek">
<rect key="frame" x="8" y="10" width="247" height="24"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="DoU-SU-Nek" firstAttribute="leading" secondItem="OFq-Mz-mbl" secondAttribute="leading" constant="8" id="A9k-hI-0BH"/>
<constraint firstAttribute="bottom" secondItem="baL-Tb-bTJ" secondAttribute="bottom" constant="6" id="Ff7-1T-EbZ"/>
<constraint firstItem="DoU-SU-Nek" firstAttribute="top" secondItem="OFq-Mz-mbl" secondAttribute="top" constant="10" id="Uji-LE-8IA"/>
<constraint firstAttribute="trailing" secondItem="baL-Tb-bTJ" secondAttribute="trailing" constant="8" id="dUp-7b-g3p"/>
<constraint firstItem="baL-Tb-bTJ" firstAttribute="leading" secondItem="DoU-SU-Nek" secondAttribute="trailing" constant="8" id="fxZ-zy-ksL"/>
<constraint firstAttribute="bottom" secondItem="DoU-SU-Nek" secondAttribute="bottom" constant="9" id="h0B-EX-3MW"/>
<constraint firstItem="baL-Tb-bTJ" firstAttribute="top" secondItem="OFq-Mz-mbl" secondAttribute="top" constant="6" id="v5e-xk-srk"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
</cells>
</tableViewSection>
<tableViewSection headerTitle="Avatars" id="ns0-OO-PGu">
<cells>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="hYS-4f-iL6">
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="hYS-4f-iL6" id="dk1-tc-gux">
<autoresizingMask key="autoresizingMask"/>
<subviews>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="fLZ-NC-aPO">
<rect key="frame" x="263" y="6" width="51" height="31"/>
<constraints>
<constraint firstAttribute="width" constant="49" id="1lf-6y-hgz"/>
<constraint firstAttribute="height" constant="31" id="rdQ-ol-d20"/>
</constraints>
<connections>
<action selector="didTapSwitch:" destination="y7K-ZU-Xs9" eventType="valueChanged" id="WnT-b7-og6"/>
</connections>
</switch>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Incoming avatars" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="RUq-Pa-3nx">
<rect key="frame" x="8" y="10" width="247" height="24"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstAttribute="bottom" secondItem="RUq-Pa-3nx" secondAttribute="bottom" constant="9" id="7Yt-uN-sOS"/>
<constraint firstItem="RUq-Pa-3nx" firstAttribute="top" secondItem="dk1-tc-gux" secondAttribute="top" constant="10" id="Aih-Lc-tq7"/>
<constraint firstItem="fLZ-NC-aPO" firstAttribute="leading" secondItem="RUq-Pa-3nx" secondAttribute="trailing" constant="8" id="Cfo-7m-Vyd"/>
<constraint firstAttribute="trailing" secondItem="fLZ-NC-aPO" secondAttribute="trailing" constant="8" id="Mgz-VG-tDn"/>
<constraint firstItem="fLZ-NC-aPO" firstAttribute="top" secondItem="dk1-tc-gux" secondAttribute="top" constant="6" id="S6i-he-vB9"/>
<constraint firstItem="RUq-Pa-3nx" firstAttribute="leading" secondItem="dk1-tc-gux" secondAttribute="leading" constant="8" id="mhd-oX-p53"/>
<constraint firstAttribute="bottom" secondItem="fLZ-NC-aPO" secondAttribute="bottom" constant="6" id="yyq-Sg-nJi"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="VF7-uo-6Pc">
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="VF7-uo-6Pc" id="zad-JQ-TRI">
<autoresizingMask key="autoresizingMask"/>
<subviews>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="LuM-mk-Zj6">
<rect key="frame" x="263" y="6" width="51" height="31"/>
<constraints>
<constraint firstAttribute="height" constant="31" id="QXv-ty-g0B"/>
<constraint firstAttribute="width" constant="49" id="rZ3-cO-f8t"/>
</constraints>
<connections>
<action selector="didTapSwitch:" destination="y7K-ZU-Xs9" eventType="valueChanged" id="rNB-Bx-Uh3"/>
</connections>
</switch>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Outgoing avatars" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="9Rr-S8-Uae">
<rect key="frame" x="8" y="10" width="247" height="24"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstAttribute="bottom" secondItem="LuM-mk-Zj6" secondAttribute="bottom" constant="6" id="1G7-8S-rYC"/>
<constraint firstAttribute="bottom" secondItem="9Rr-S8-Uae" secondAttribute="bottom" constant="9" id="5xp-ez-tac"/>
<constraint firstItem="LuM-mk-Zj6" firstAttribute="leading" secondItem="9Rr-S8-Uae" secondAttribute="trailing" constant="8" id="C5c-2A-mli"/>
<constraint firstAttribute="trailing" secondItem="LuM-mk-Zj6" secondAttribute="trailing" constant="8" id="Lep-LY-D1h"/>
<constraint firstItem="LuM-mk-Zj6" firstAttribute="top" secondItem="zad-JQ-TRI" secondAttribute="top" constant="6" id="Y6a-JS-aLj"/>
<constraint firstItem="9Rr-S8-Uae" firstAttribute="leading" secondItem="zad-JQ-TRI" secondAttribute="leading" constant="8" id="Yao-VR-Is6"/>
<constraint firstItem="9Rr-S8-Uae" firstAttribute="top" secondItem="zad-JQ-TRI" secondAttribute="top" constant="10" id="Yiv-t6-Xj5"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
</cells>
</tableViewSection>
<tableViewSection headerTitle="Dynamic Behaviors" footerTitle="NOTE: This feature is experimental" id="o5m-OT-1Iw">
<cells>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="q07-lZ-YdI">
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="q07-lZ-YdI" id="btE-Mk-fSE">
<autoresizingMask key="autoresizingMask"/>
<subviews>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="uXC-2j-cgi">
<rect key="frame" x="263" y="6" width="51" height="31"/>
<constraints>
<constraint firstAttribute="height" constant="31" id="5bI-xQ-njj"/>
<constraint firstAttribute="width" constant="49" id="PG2-X2-FdD"/>
</constraints>
<connections>
<action selector="didTapSwitch:" destination="y7K-ZU-Xs9" eventType="valueChanged" id="oHB-iq-JSz"/>
</connections>
</switch>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Springy bubbles" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3d2-fZ-dx9">
<rect key="frame" x="8" y="10" width="247" height="24"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="3d2-fZ-dx9" firstAttribute="leading" secondItem="btE-Mk-fSE" secondAttribute="leading" constant="8" id="6Cs-6l-Xzp"/>
<constraint firstItem="uXC-2j-cgi" firstAttribute="leading" secondItem="3d2-fZ-dx9" secondAttribute="trailing" constant="8" id="7Mq-HR-4nY"/>
<constraint firstItem="uXC-2j-cgi" firstAttribute="top" secondItem="btE-Mk-fSE" secondAttribute="top" constant="6" id="Ajq-5g-XKo"/>
<constraint firstAttribute="bottom" secondItem="3d2-fZ-dx9" secondAttribute="bottom" constant="9" id="EzH-aB-ePQ"/>
<constraint firstAttribute="bottom" secondItem="uXC-2j-cgi" secondAttribute="bottom" constant="6" id="RCb-Mi-FHX"/>
<constraint firstItem="3d2-fZ-dx9" firstAttribute="top" secondItem="btE-Mk-fSE" secondAttribute="top" constant="10" id="btF-q4-HJg"/>
<constraint firstAttribute="trailing" secondItem="uXC-2j-cgi" secondAttribute="trailing" constant="8" id="zzu-aP-ZiL"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
</cells>
</tableViewSection>
</sections>
<connections>
<outlet property="dataSource" destination="y7K-ZU-Xs9" id="4gP-Ip-VMs"/>
<outlet property="delegate" destination="y7K-ZU-Xs9" id="RdT-hW-mFp"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="Settings" id="hrw-Dp-Tor"/>
<connections>
<outlet property="emptySwitch" destination="baL-Tb-bTJ" id="qk7-dH-53U"/>
<outlet property="extraMessagesSwitch" destination="K7N-os-fuc" id="qlF-0W-3JO"/>
<outlet property="incomingAvatarsSwitch" destination="fLZ-NC-aPO" id="0ck-t9-Hwt"/>
<outlet property="longMessageSwitch" destination="hMq-Ee-EJK" id="Vs2-fX-Hys"/>
<outlet property="outgoingAvatarsSwitch" destination="LuM-mk-Zj6" id="EAh-35-xjI"/>
<outlet property="springySwitch" destination="uXC-2j-cgi" id="Jzx-1y-VZP"/>
</connections>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="5u5-k6-W2j" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-2982" y="1039"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="eGf-GM-ORQ">
<objects>
@ -57,10 +298,10 @@
</objects>
<point key="canvasLocation" x="-2409" y="619"/>
</scene>
<!--Demo View Controller-->
<!--Demo Messages View Controller-->
<scene sceneID="gOX-cv-CuN">
<objects>
<viewController storyboardIdentifier="DemoVC" id="JdJ-0X-ZL8" customClass="JSQDemoViewController" sceneMemberID="viewController">
<viewController storyboardIdentifier="DemoVC" id="JdJ-0X-ZL8" customClass="DemoMessagesViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="TE8-r2-pE8"/>
<viewControllerLayoutGuide type="bottom" id="H2n-HB-Ssl"/>
@ -91,10 +332,10 @@
</objects>
<point key="canvasLocation" x="-3413" y="274"/>
</scene>
<!--Demo View Controller-->
<!--Demo Messages View Controller-->
<scene sceneID="Rr5-W8-Xyh">
<objects>
<viewController id="2Qx-iu-03V" customClass="JSQDemoViewController" sceneMemberID="viewController">
<viewController id="2Qx-iu-03V" customClass="DemoMessagesViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="hTc-sT-can"/>
<viewControllerLayoutGuide type="bottom" id="BPF-eU-3uQ"/>

View File

@ -1,6 +1,6 @@
//
// Created by Jesse Squires
// http://www.hexedbits.com
// http://www.jessesquires.com
//
//
// Documentation
@ -16,34 +16,33 @@
// Released under an MIT license: http://opensource.org/licenses/MIT
//
// Import all the things
#import "JSQMessages.h"
@class JSQDemoViewController;
#import "DemoModelData.h"
#import "NSUserDefaults+DemoSettings.h"
@class DemoMessagesViewController;
@protocol JSQDemoViewControllerDelegate <NSObject>
- (void)didDismissJSQDemoViewController:(JSQDemoViewController *)vc;
- (void)didDismissJSQDemoViewController:(DemoMessagesViewController *)vc;
@end
@interface JSQDemoViewController : JSQMessagesViewController
@interface DemoMessagesViewController : JSQMessagesViewController <UIActionSheetDelegate>
@property (weak, nonatomic) id<JSQDemoViewControllerDelegate> delegateModal;
@property (strong, nonatomic) NSMutableArray *messages;
@property (copy, nonatomic) NSDictionary *avatars;
@property (strong, nonatomic) UIImageView *outgoingBubbleImageView;
@property (strong, nonatomic) UIImageView *incomingBubbleImageView;
@property (strong, nonatomic) DemoModelData *demoData;
- (void)receiveMessagePressed:(UIBarButtonItem *)sender;
- (void)closePressed:(UIBarButtonItem *)sender;
- (void)setupTestModel;
@end

View File

@ -0,0 +1,584 @@
//
// Created by Jesse Squires
// http://www.jessesquires.com
//
//
// Documentation
// http://cocoadocs.org/docsets/JSQMessagesViewController
//
//
// GitHub
// https://github.com/jessesquires/JSQMessagesViewController
//
//
// License
// Copyright (c) 2014 Jesse Squires
// Released under an MIT license: http://opensource.org/licenses/MIT
//
#import "DemoMessagesViewController.h"
#import "JSQCallCollectionViewCell.h"
#import "JSQCall.h"
#import "JSQDisplayedMessageCollectionViewCell.h"
#import "JSQErrorMessage.h"
#import "JSQInfoMessage.h"
@implementation DemoMessagesViewController
#pragma mark - View lifecycle
/**
* Override point for customization.
*
* Customize your view.
* Look at the properties on `JSQMessagesViewController` and `JSQMessagesCollectionView` to see what is possible.
*
* Customize your layout.
* Look at the properties on `JSQMessagesCollectionViewFlowLayout` to see what is possible.
*/
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"JSQMessages";
/**
* You MUST set your senderId and display name
*/
self.senderId = kJSQDemoAvatarIdSquires;
self.senderDisplayName = kJSQDemoAvatarDisplayNameSquires;
/**
* Load up our fake data for the demo
*/
self.demoData = [[DemoModelData alloc] init];
/**
* You can set custom avatar sizes
*/
if (![NSUserDefaults incomingAvatarSetting]) {
self.collectionView.collectionViewLayout.incomingAvatarViewSize = CGSizeZero;
}
if (![NSUserDefaults outgoingAvatarSetting]) {
self.collectionView.collectionViewLayout.outgoingAvatarViewSize = CGSizeZero;
}
self.showLoadEarlierMessagesHeader = YES;
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage jsq_defaultTypingIndicatorImage]
style:UIBarButtonItemStyleBordered
target:self
action:@selector(receiveMessagePressed:)];
/**
* Customize your toolbar buttons
*
* self.inputToolbar.contentView.leftBarButtonItem = custom button or nil to remove
* self.inputToolbar.contentView.rightBarButtonItem = custom button or nil to remove
*/
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
if (self.delegateModal) {
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop
target:self
action:@selector(closePressed:)];
}
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
/**
* Enable/disable springy bubbles, default is NO.
* You must set this from `viewDidAppear:`
* Note: this feature is mostly stable, but still experimental
*/
self.collectionView.collectionViewLayout.springinessEnabled = [NSUserDefaults springinessSetting];
}
#pragma mark - Testing
- (void)pushMainViewController
{
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UINavigationController *nc = [sb instantiateInitialViewController];
[self.navigationController pushViewController:nc.topViewController animated:YES];
}
#pragma mark - Actions
- (void)receiveMessagePressed:(UIBarButtonItem *)sender
{
/**
* DEMO ONLY
*
* The following is simply to simulate received messages for the demo.
* Do not actually do this.
*/
/**
* Show the typing indicator to be shown
*/
self.showTypingIndicator = !self.showTypingIndicator;
/**
* Scroll to actually view the indicator
*/
[self scrollToBottomAnimated:YES];
/**
* Copy last sent message, this will be the new "received" message
*/
JSQMessage *copyMessage = [[self.demoData.messages lastObject] copy];
if (!copyMessage) {
copyMessage = [JSQMessage messageWithSenderId:kJSQDemoAvatarIdJobs
displayName:kJSQDemoAvatarDisplayNameJobs
text:@"First received!"];
}
/**
* Allow typing indicator to show
*/
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
NSMutableArray *userIds = [[self.demoData.users allKeys] mutableCopy];
[userIds removeObject:self.senderId];
NSString *randomUserId = userIds[arc4random_uniform((int)[userIds count])];
JSQMessage *newMessage = nil;
id<JSQMessageMediaData> newMediaData = nil;
id newMediaAttachmentCopy = nil;
if ([copyMessage isKindOfClass:[JSQMessage class]]) {
/**
* Last message was a media message
*/
id<JSQMessageMediaData> copyMediaData = copyMessage.media;
if ([copyMediaData isKindOfClass:[JSQPhotoMediaItem class]]) {
JSQPhotoMediaItem *photoItemCopy = [((JSQPhotoMediaItem *)copyMediaData) copy];
photoItemCopy.appliesMediaViewMaskAsOutgoing = NO;
newMediaAttachmentCopy = [UIImage imageWithCGImage:photoItemCopy.image.CGImage];
/**
* Set image to nil to simulate "downloading" the image
* and show the placeholder view
*/
photoItemCopy.image = nil;
newMediaData = photoItemCopy;
}
else if ([copyMediaData isKindOfClass:[JSQLocationMediaItem class]]) {
JSQLocationMediaItem *locationItemCopy = [((JSQLocationMediaItem *)copyMediaData) copy];
locationItemCopy.appliesMediaViewMaskAsOutgoing = NO;
newMediaAttachmentCopy = [locationItemCopy.location copy];
/**
* Set location to nil to simulate "downloading" the location data
*/
locationItemCopy.location = nil;
newMediaData = locationItemCopy;
}
else if ([copyMediaData isKindOfClass:[JSQVideoMediaItem class]]) {
JSQVideoMediaItem *videoItemCopy = [((JSQVideoMediaItem *)copyMediaData) copy];
videoItemCopy.appliesMediaViewMaskAsOutgoing = NO;
newMediaAttachmentCopy = [videoItemCopy.fileURL copy];
/**
* Reset video item to simulate "downloading" the video
*/
videoItemCopy.fileURL = nil;
videoItemCopy.isReadyToPlay = NO;
newMediaData = videoItemCopy;
}
else {
NSLog(@"%s error: unrecognized media item", __PRETTY_FUNCTION__);
}
newMessage = [JSQMessage messageWithSenderId:randomUserId
displayName:self.demoData.users[randomUserId]
media:newMediaData];
}
else {
/**
* Last message was a text message
*/
newMessage = [JSQMessage messageWithSenderId:randomUserId
displayName:self.demoData.users[randomUserId]
text:copyMessage.text];
}
/**
* Upon receiving a message, you should:
*
* 1. Play sound (optional)
* 2. Add new id<JSQMessageData> object to your data source
* 3. Call `finishReceivingMessage`
*/
[JSQSystemSoundPlayer jsq_playMessageReceivedSound];
[self.demoData.messages addObject:newMessage];
[self finishReceivingMessageAnimated:YES];
if (newMessage.isMediaMessage) {
/**
* Simulate "downloading" media
*/
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
/**
* Media is "finished downloading", re-display visible cells
*
* If media cell is not visible, the next time it is dequeued the view controller will display its new attachment data
*
* Reload the specific item, or simply call `reloadData`
*/
if ([newMediaData isKindOfClass:[JSQPhotoMediaItem class]]) {
((JSQPhotoMediaItem *)newMediaData).image = newMediaAttachmentCopy;
[self.collectionView reloadData];
}
else if ([newMediaData isKindOfClass:[JSQLocationMediaItem class]]) {
[((JSQLocationMediaItem *)newMediaData)setLocation:newMediaAttachmentCopy withCompletionHandler:^{
[self.collectionView reloadData];
}];
}
else if ([newMediaData isKindOfClass:[JSQVideoMediaItem class]]) {
((JSQVideoMediaItem *)newMediaData).fileURL = newMediaAttachmentCopy;
((JSQVideoMediaItem *)newMediaData).isReadyToPlay = YES;
[self.collectionView reloadData];
}
else {
NSLog(@"%s error: unrecognized media item", __PRETTY_FUNCTION__);
}
});
}
});
}
- (void)closePressed:(UIBarButtonItem *)sender
{
[self.delegateModal didDismissJSQDemoViewController:self];
}
#pragma mark - JSQMessagesViewController method overrides
- (void)didPressSendButton:(UIButton *)button
withMessageText:(NSString *)text
senderId:(NSString *)senderId
senderDisplayName:(NSString *)senderDisplayName
date:(NSDate *)date
{
/**
* Sending a message. Your implementation of this method should do *at least* the following:
*
* 1. Play sound (optional)
* 2. Add new id<JSQMessageData> object to your data source
* 3. Call `finishSendingMessage`
*/
[JSQSystemSoundPlayer jsq_playMessageSentSound];
JSQMessage *message = [[JSQMessage alloc] initWithSenderId:senderId
senderDisplayName:senderDisplayName
date:date
text:text];
[self.demoData.messages addObject:message];
[self finishSendingMessageAnimated:YES];
}
- (void)didPressAccessoryButton:(UIButton *)sender
{
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"Media messages"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:@"Send photo", @"Send location", @"Send video", nil];
[sheet showFromToolbar:self.inputToolbar];
}
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
{
if (buttonIndex == actionSheet.cancelButtonIndex) {
return;
}
switch (buttonIndex) {
case 0:
[self.demoData addPhotoMediaMessage];
break;
case 1:
{
__weak UICollectionView *weakView = self.collectionView;
[self.demoData addLocationMediaMessageCompletion:^{
[weakView reloadData];
}];
}
break;
case 2:
[self.demoData addVideoMediaMessage];
break;
}
[JSQSystemSoundPlayer jsq_playMessageSentSound];
[self finishSendingMessageAnimated:YES];
}
#pragma mark - JSQMessages CollectionView DataSource
- (id<JSQMessageData>)collectionView:(JSQMessagesCollectionView *)collectionView messageDataForItemAtIndexPath:(NSIndexPath *)indexPath
{
return [self.demoData.messages objectAtIndex:indexPath.item];
}
- (id<JSQMessageBubbleImageDataSource>)collectionView:(JSQMessagesCollectionView *)collectionView messageBubbleImageDataForItemAtIndexPath:(NSIndexPath *)indexPath
{
/**
* You may return nil here if you do not want bubbles.
* In this case, you should set the background color of your collection view cell's textView.
*
* Otherwise, return your previously created bubble image data objects.
*/
JSQMessage *message = [self.demoData.messages objectAtIndex:indexPath.item];
if ([message.senderId isEqualToString:self.senderId]) {
return self.demoData.outgoingBubbleImageData;
}
return self.demoData.incomingBubbleImageData;
}
- (id<JSQMessageAvatarImageDataSource>)collectionView:(JSQMessagesCollectionView *)collectionView avatarImageDataForItemAtIndexPath:(NSIndexPath *)indexPath
{
/**
* Return `nil` here if you do not want avatars.
* If you do return `nil`, be sure to do the following in `viewDidLoad`:
*
* self.collectionView.collectionViewLayout.incomingAvatarViewSize = CGSizeZero;
* self.collectionView.collectionViewLayout.outgoingAvatarViewSize = CGSizeZero;
*
* It is possible to have only outgoing avatars or only incoming avatars, too.
*/
/**
* Return your previously created avatar image data objects.
*
* Note: these the avatars will be sized according to these values:
*
* self.collectionView.collectionViewLayout.incomingAvatarViewSize
* self.collectionView.collectionViewLayout.outgoingAvatarViewSize
*
* Override the defaults in `viewDidLoad`
*/
JSQMessage *message = [self.demoData.messages objectAtIndex:indexPath.item];
if (![message isKindOfClass:[JSQCall class]] || ![message isKindOfClass:[JSQErrorMessage class]] || ![message isKindOfClass:[JSQInfoMessage class]]) return nil;
if ([message.senderId isEqualToString:self.senderId]) {
if (![NSUserDefaults outgoingAvatarSetting]) {
return nil;
}
}
else {
if (![NSUserDefaults incomingAvatarSetting]) {
return nil;
}
}
return [self.demoData.avatars objectForKey:message.senderId];
}
- (NSAttributedString *)collectionView:(JSQMessagesCollectionView *)collectionView attributedTextForCellTopLabelAtIndexPath:(NSIndexPath *)indexPath
{
/**
* This logic should be consistent with what you return from `heightForCellTopLabelAtIndexPath:`
* The other label text delegate methods should follow a similar pattern.
*
* Show a timestamp for every 3rd message
*/
if (indexPath.item % 3 == 0) {
JSQMessage *message = [self.demoData.messages objectAtIndex:indexPath.item];
return [[JSQMessagesTimestampFormatter sharedFormatter] attributedTimestampForDate:message.date];
}
return nil;
}
- (NSAttributedString *)collectionView:(JSQMessagesCollectionView *)collectionView attributedTextForMessageBubbleTopLabelAtIndexPath:(NSIndexPath *)indexPath
{
JSQMessage *message = [self.demoData.messages objectAtIndex:indexPath.item];
/**
* iOS7-style sender name labels
*/
if ([message.senderId isEqualToString:self.senderId]) {
return nil;
}
if (indexPath.item - 1 > 0) {
JSQMessage *previousMessage = [self.demoData.messages objectAtIndex:indexPath.item - 1];
if ([[previousMessage senderId] isEqualToString:message.senderId]) {
return nil;
}
}
/**
* Don't specify attributes to use the defaults.
*/
return [[NSAttributedString alloc] initWithString:message.senderDisplayName];
}
- (NSAttributedString *)collectionView:(JSQMessagesCollectionView *)collectionView attributedTextForCellBottomLabelAtIndexPath:(NSIndexPath *)indexPath
{
return nil;
}
#pragma mark - UICollectionView DataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return [self.demoData.messages count];
}
- (UICollectionViewCell *)collectionView:(JSQMessagesCollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
/**
* Override point for customizing cells
*/
JSQMessage *msg = [self.demoData.messages objectAtIndex:indexPath.item];
if ([msg isKindOfClass:[JSQMessage class]])
{
JSQMessagesCollectionViewCell *cell = (JSQMessagesCollectionViewCell *)[super collectionView:collectionView cellForItemAtIndexPath:indexPath];
if (!msg.isMediaMessage) {
if ([msg.senderId isEqualToString:self.senderId]) {
cell.textView.textColor = [UIColor blackColor];
}
else {
cell.textView.textColor = [UIColor whiteColor];
}
cell.textView.linkTextAttributes = @{ NSForegroundColorAttributeName : cell.textView.textColor,
NSUnderlineStyleAttributeName : @(NSUnderlineStyleSingle | NSUnderlinePatternSolid) };
}
return cell;
} else if ([msg isKindOfClass:[JSQCall class]]) {
JSQCallCollectionViewCell *cell = (JSQCallCollectionViewCell *)[super collectionView:collectionView cellForItemAtIndexPath:indexPath];
return cell;
} else {
JSQDisplayedMessageCollectionViewCell * cell = (JSQDisplayedMessageCollectionViewCell *)[super collectionView:collectionView cellForItemAtIndexPath:indexPath];
return cell;
}
}
#pragma mark - JSQMessages collection view flow layout delegate
#pragma mark - Adjusting cell label heights
- (CGFloat)collectionView:(JSQMessagesCollectionView *)collectionView
layout:(JSQMessagesCollectionViewFlowLayout *)collectionViewLayout heightForCellTopLabelAtIndexPath:(NSIndexPath *)indexPath
{
/**
* Each label in a cell has a `height` delegate method that corresponds to its text dataSource method
*/
/**
* This logic should be consistent with what you return from `attributedTextForCellTopLabelAtIndexPath:`
* The other label height delegate methods should follow similarly
*
* Show a timestamp for every 3rd message
*/
// if (indexPath.item % 3 == 0) {
// return kJSQMessagesCollectionViewCellLabelHeightDefault;
// }
return 0.0f;
}
- (CGFloat)collectionView:(JSQMessagesCollectionView *)collectionView
layout:(JSQMessagesCollectionViewFlowLayout *)collectionViewLayout heightForMessageBubbleTopLabelAtIndexPath:(NSIndexPath *)indexPath
{
/**
* iOS7-style sender name labels
*/
JSQMessage *currentMessage = [self.demoData.messages objectAtIndex:indexPath.item];
if ([[currentMessage senderId] isEqualToString:self.senderId]) {
return 0.0f;
}
if (indexPath.item - 1 > 0) {
JSQMessage *previousMessage = [self.demoData.messages objectAtIndex:indexPath.item - 1];
if ([[previousMessage senderId] isEqualToString:[currentMessage senderId]]) {
return 0.0f;
}
}
return kJSQMessagesCollectionViewCellLabelHeightDefault;
}
- (CGFloat)collectionView:(JSQMessagesCollectionView *)collectionView
layout:(JSQMessagesCollectionViewFlowLayout *)collectionViewLayout heightForCellBottomLabelAtIndexPath:(NSIndexPath *)indexPath
{
return 0.0f;
}
#pragma mark - Responding to collection view tap events
- (void)collectionView:(JSQMessagesCollectionView *)collectionView
header:(JSQMessagesLoadEarlierHeaderView *)headerView didTapLoadEarlierMessagesButton:(UIButton *)sender
{
NSLog(@"Load earlier messages!");
}
- (void)collectionView:(JSQMessagesCollectionView *)collectionView didTapAvatarImageView:(UIImageView *)avatarImageView atIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"Tapped avatar!");
}
- (void)collectionView:(JSQMessagesCollectionView *)collectionView didTapMessageBubbleAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"Tapped message bubble!");
}
- (void)collectionView:(JSQMessagesCollectionView *)collectionView didTapCellAtIndexPath:(NSIndexPath *)indexPath touchLocation:(CGPoint)touchLocation
{
NSLog(@"Tapped cell at %@!", NSStringFromCGPoint(touchLocation));
}
@end

View File

@ -0,0 +1,61 @@
//
// Created by Jesse Squires
// http://www.jessesquires.com
//
//
// Documentation
// http://cocoadocs.org/docsets/JSQMessagesViewController
//
//
// GitHub
// https://github.com/jessesquires/JSQMessagesViewController
//
//
// License
// Copyright (c) 2014 Jesse Squires
// Released under an MIT license: http://opensource.org/licenses/MIT
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
#import "JSQMessages.h"
/**
* This is for demo/testing purposes only.
* This object sets up some fake model data.
* Do not actually do anything like this.
*/
static NSString * const kJSQDemoAvatarDisplayNameSquires = @"Jesse Squires";
static NSString * const kJSQDemoAvatarDisplayNameCook = @"Tim Cook";
static NSString * const kJSQDemoAvatarDisplayNameJobs = @"Jobs";
static NSString * const kJSQDemoAvatarDisplayNameWoz = @"Steve Wozniak";
static NSString * const kJSQDemoAvatarIdSquires = @"053496-4509-289";
static NSString * const kJSQDemoAvatarIdCook = @"468-768355-23123";
static NSString * const kJSQDemoAvatarIdJobs = @"707-8956784-57";
static NSString * const kJSQDemoAvatarIdWoz = @"309-41802-93823";
@interface DemoModelData : NSObject
@property (strong, nonatomic) NSMutableArray *messages;
@property (strong, nonatomic) NSDictionary *avatars;
@property (strong, nonatomic) JSQMessagesBubbleImage *outgoingBubbleImageData;
@property (strong, nonatomic) JSQMessagesBubbleImage *incomingBubbleImageData;
@property (strong, nonatomic) NSDictionary *users;
- (void)addPhotoMediaMessage;
- (void)addLocationMediaMessageCompletion:(JSQLocationMediaItemCompletionBlock)completion;
- (void)addVideoMediaMessage;
@end

View File

@ -0,0 +1,236 @@
//
// Created by Jesse Squires
// http://www.jessesquires.com
//
//
// Documentation
// http://cocoadocs.org/docsets/JSQMessagesViewController
//
//
// GitHub
// https://github.com/jessesquires/JSQMessagesViewController
//
//
// License
// Copyright (c) 2014 Jesse Squires
// Released under an MIT license: http://opensource.org/licenses/MIT
//
#import "DemoModelData.h"
#import "NSUserDefaults+DemoSettings.h"
#import "JSQCall.h"
#import "JSQInfoMessage.h"
#import "JSQErrorMessage.h"
/**
* This is for demo/testing purposes only.
* This object sets up some fake model data.
* Do not actually do anything like this.
*/
@implementation DemoModelData
- (instancetype)init
{
self = [super init];
if (self) {
if ([NSUserDefaults emptyMessagesSetting]) {
self.messages = [NSMutableArray new];
}
else {
[self loadFakeMessages];
}
/**
* Create avatar images once.
*
* Be sure to create your avatars one time and reuse them for good performance.
*
* If you are not using avatars, ignore this.
*/
JSQMessagesAvatarImage *jsqImage = [JSQMessagesAvatarImageFactory avatarImageWithUserInitials:@"JSQ"
backgroundColor:[UIColor colorWithWhite:0.85f alpha:1.0f]
textColor:[UIColor colorWithWhite:0.60f alpha:1.0f]
font:[UIFont systemFontOfSize:14.0f]
diameter:kJSQMessagesCollectionViewAvatarSizeDefault];
JSQMessagesAvatarImage *cookImage = [JSQMessagesAvatarImageFactory avatarImageWithImage:[UIImage imageNamed:@"demo_avatar_cook"]
diameter:kJSQMessagesCollectionViewAvatarSizeDefault];
JSQMessagesAvatarImage *jobsImage = [JSQMessagesAvatarImageFactory avatarImageWithImage:[UIImage imageNamed:@"demo_avatar_jobs"]
diameter:kJSQMessagesCollectionViewAvatarSizeDefault];
JSQMessagesAvatarImage *wozImage = [JSQMessagesAvatarImageFactory avatarImageWithImage:[UIImage imageNamed:@"demo_avatar_woz"]
diameter:kJSQMessagesCollectionViewAvatarSizeDefault];
self.avatars = @{ kJSQDemoAvatarIdSquires : jsqImage,
kJSQDemoAvatarIdCook : cookImage,
kJSQDemoAvatarIdJobs : jobsImage,
kJSQDemoAvatarIdWoz : wozImage };
self.users = @{ kJSQDemoAvatarIdJobs : kJSQDemoAvatarDisplayNameJobs,
kJSQDemoAvatarIdCook : kJSQDemoAvatarDisplayNameCook,
kJSQDemoAvatarIdWoz : kJSQDemoAvatarDisplayNameWoz,
kJSQDemoAvatarIdSquires : kJSQDemoAvatarDisplayNameSquires };
/**
* Create message bubble images objects.
*
* Be sure to create your bubble images one time and reuse them for good performance.
*
*/
JSQMessagesBubbleImageFactory *bubbleFactory = [[JSQMessagesBubbleImageFactory alloc] init];
self.outgoingBubbleImageData = [bubbleFactory outgoingMessagesBubbleImageWithColor:[UIColor jsq_messageBubbleLightGrayColor]];
self.incomingBubbleImageData = [bubbleFactory incomingMessagesBubbleImageWithColor:[UIColor jsq_messageBubbleGreenColor]];
}
return self;
}
- (void)loadFakeMessages
{
/**
* Load some fake messages for demo.
*
* You should have a mutable array or orderedSet, or something.
*/
self.messages = [[NSMutableArray alloc] initWithObjects:
[[JSQCall alloc] initWithCallerId:kJSQDemoAvatarIdWoz
callerDisplayName:kJSQDemoAvatarDisplayNameWoz
date:[NSDate date]
status:kCallOutgoing],
[[JSQMessage alloc] initWithSenderId:kJSQDemoAvatarIdSquires
senderDisplayName:kJSQDemoAvatarDisplayNameSquires
date:[NSDate distantPast]
text:@"Welcome to JSQMessages: A messaging UI framework for iOS."],
[[JSQMessage alloc] initWithSenderId:kJSQDemoAvatarIdSquires
senderDisplayName:kJSQDemoAvatarDisplayNameSquires
date:[NSDate distantPast]
text:@"Welcome to JSQMessages: A messaging UI framework for iOS."],
[[JSQMessage alloc] initWithSenderId:kJSQDemoAvatarIdWoz
senderDisplayName:kJSQDemoAvatarDisplayNameWoz
date:[NSDate distantPast]
text:@"It is simple, elegant, and easy to use. There are super sweet default settings, but you can customize like crazy."],
[[JSQMessage alloc] initWithSenderId:kJSQDemoAvatarIdSquires
senderDisplayName:kJSQDemoAvatarDisplayNameSquires
date:[NSDate distantPast]
text:@"It even has data detectors. You can call me tonight. My cell number is 123-456-7890. My website is www.hexedbits.com."],
[[JSQMessage alloc] initWithSenderId:kJSQDemoAvatarIdJobs
senderDisplayName:kJSQDemoAvatarDisplayNameJobs
date:[NSDate date]
text:@"JSQMessagesViewController is nearly an exact replica of the iOS Messages App. And perhaps, better."],
[[JSQMessage alloc] initWithSenderId:kJSQDemoAvatarIdCook
senderDisplayName:kJSQDemoAvatarDisplayNameCook
date:[NSDate date]
text:@"It is unit-tested, free, open-source, and documented."],
[[JSQMessage alloc] initWithSenderId:kJSQDemoAvatarIdSquires
senderDisplayName:kJSQDemoAvatarDisplayNameSquires
date:[NSDate date]
text:@"Now with media messages!"],
[[JSQCall alloc] initWithCallerId:kJSQDemoAvatarIdWoz
callerDisplayName:kJSQDemoAvatarDisplayNameWoz
date:[NSDate date]
status:kCallIncoming],
[[JSQCall alloc] initWithCallerId:kJSQDemoAvatarIdWoz
callerDisplayName:kJSQDemoAvatarDisplayNameWoz
date:[NSDate date]
status:kCallMissed],
[[JSQInfoMessage alloc] initWithInfoType:JSQInfoMessageTypeSessionDidEnd
senderId:kJSQDemoAvatarIdCook
senderDisplayName:kJSQDemoAvatarDisplayNameCook
date:[NSDate date]],
[[JSQErrorMessage alloc] initWithErrorType:JSQErrorMessageMissingKeyId
senderId:kJSQDemoAvatarIdCook
senderDisplayName:kJSQDemoAvatarDisplayNameCook
date:[NSDate date]],
[[JSQErrorMessage alloc] initWithErrorType:JSQErrorMessageInvalidMessage
senderId:kJSQDemoAvatarIdCook
senderDisplayName:kJSQDemoAvatarDisplayNameCook
date:[NSDate date]],
[[JSQErrorMessage alloc] initWithErrorType:JSQErrorMessageInvalidVersion
senderId:kJSQDemoAvatarIdCook
senderDisplayName:kJSQDemoAvatarDisplayNameCook
date:[NSDate date]],
[[JSQErrorMessage alloc] initWithErrorType:JSQErrorMessageInvalidKeyException
senderId:kJSQDemoAvatarIdCook
senderDisplayName:kJSQDemoAvatarDisplayNameCook
date:[NSDate date]],
[[JSQErrorMessage alloc] initWithErrorType:JSQErrorMessageWrongTrustedIdentityKey
senderId:kJSQDemoAvatarIdCook
senderDisplayName:kJSQDemoAvatarDisplayNameCook
date:[NSDate date]],
nil];
[self addPhotoMediaMessage];
/**
* Setting to load extra messages for testing/demo
*/
if ([NSUserDefaults extraMessagesSetting]) {
NSArray *copyOfMessages = [self.messages copy];
for (NSUInteger i = 0; i < 4; i++) {
[self.messages addObjectsFromArray:copyOfMessages];
}
}
/**
* Setting to load REALLY long message for testing/demo
* You should see "END" twice
*/
if ([NSUserDefaults longMessageSetting]) {
JSQMessage *reallyLongMessage = [JSQMessage messageWithSenderId:kJSQDemoAvatarIdSquires
displayName:kJSQDemoAvatarDisplayNameSquires
text:@"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? END Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? END"];
[self.messages addObject:reallyLongMessage];
}
}
- (void)addPhotoMediaMessage
{
JSQPhotoMediaItem *photoItem = [[JSQPhotoMediaItem alloc] initWithImage:[UIImage imageNamed:@"goldengate"]];
JSQMessage *photoMessage = [JSQMessage messageWithSenderId:kJSQDemoAvatarIdSquires
displayName:kJSQDemoAvatarDisplayNameSquires
media:photoItem];
[self.messages addObject:photoMessage];
}
- (void)addLocationMediaMessageCompletion:(JSQLocationMediaItemCompletionBlock)completion
{
CLLocation *ferryBuildingInSF = [[CLLocation alloc] initWithLatitude:37.795313 longitude:-122.393757];
JSQLocationMediaItem *locationItem = [[JSQLocationMediaItem alloc] init];
[locationItem setLocation:ferryBuildingInSF withCompletionHandler:completion];
JSQMessage *locationMessage = [JSQMessage messageWithSenderId:kJSQDemoAvatarIdSquires
displayName:kJSQDemoAvatarDisplayNameSquires
media:locationItem];
[self.messages addObject:locationMessage];
}
- (void)addVideoMediaMessage
{
// don't have a real video, just pretending
NSURL *videoURL = [NSURL URLWithString:@"file://"];
JSQVideoMediaItem *videoItem = [[JSQVideoMediaItem alloc] initWithFileURL:videoURL isReadyToPlay:YES];
JSQMessage *videoMessage = [JSQMessage messageWithSenderId:kJSQDemoAvatarIdSquires
displayName:kJSQDemoAvatarDisplayNameSquires
media:videoItem];
[self.messages addObject:videoMessage];
}
@end

View File

@ -0,0 +1,42 @@
//
// Created by Jesse Squires
// http://www.jessesquires.com
//
//
// Documentation
// http://cocoadocs.org/docsets/JSQMessagesViewController
//
//
// GitHub
// https://github.com/jessesquires/JSQMessagesViewController
//
//
// License
// Copyright (c) 2014 Jesse Squires
// Released under an MIT license: http://opensource.org/licenses/MIT
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
/**
* This is for demo/testing purposes only.
*
* This is a terrible idea for a real app.
*/
@interface DemoSettingsViewController : UITableViewController
@property (weak, nonatomic) IBOutlet UISwitch *extraMessagesSwitch;
@property (weak, nonatomic) IBOutlet UISwitch *longMessageSwitch;
@property (weak, nonatomic) IBOutlet UISwitch *emptySwitch;
@property (weak, nonatomic) IBOutlet UISwitch *incomingAvatarsSwitch;
@property (weak, nonatomic) IBOutlet UISwitch *outgoingAvatarsSwitch;
@property (weak, nonatomic) IBOutlet UISwitch *springySwitch;
@end

View File

@ -0,0 +1,72 @@
//
// Created by Jesse Squires
// http://www.jessesquires.com
//
//
// Documentation
// http://cocoadocs.org/docsets/JSQMessagesViewController
//
//
// GitHub
// https://github.com/jessesquires/JSQMessagesViewController
//
//
// License
// Copyright (c) 2014 Jesse Squires
// Released under an MIT license: http://opensource.org/licenses/MIT
//
#import "DemoSettingsViewController.h"
#import "NSUserDefaults+DemoSettings.h"
/**
* This is for demo/testing purposes only.
*
* This is a terrible idea for a real app.
*/
@implementation DemoSettingsViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.extraMessagesSwitch.on = [NSUserDefaults extraMessagesSetting];
self.longMessageSwitch.on = [NSUserDefaults longMessageSetting];
self.emptySwitch.on = [NSUserDefaults emptyMessagesSetting];
self.incomingAvatarsSwitch.on = [NSUserDefaults incomingAvatarSetting];
self.outgoingAvatarsSwitch.on = [NSUserDefaults outgoingAvatarSetting];
self.springySwitch.on = [NSUserDefaults springinessSetting];
}
- (IBAction)didTapSwitch:(UISwitch *)sender
{
if (sender == self.extraMessagesSwitch) {
[NSUserDefaults saveExtraMessagesSetting:sender.on];
}
else if (sender == self.longMessageSwitch) {
[NSUserDefaults saveLongMessageSetting:sender.on];
}
else if (sender == self.emptySwitch) {
[NSUserDefaults saveEmptyMessagesSetting:sender.on];
}
else if (sender == self.incomingAvatarsSwitch) {
[NSUserDefaults saveIncomingAvatarSetting:sender.on];
}
else if (sender == self.outgoingAvatarsSwitch) {
[NSUserDefaults saveOutgoingAvatarSetting:sender.on];
}
else if (sender == self.springySwitch) {
[NSUserDefaults saveSpringinessSetting:sender.on];
}
[[NSUserDefaults standardUserDefaults] synchronize];
}
@end

View File

@ -6,18 +6,36 @@
"filename" : "Icon-Small@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-87.png",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-Spotlight-iOS7@2x-1.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-120-1.png",
"scale" : "3x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-120.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-180.png",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "ipad",

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 760 B

After

Width:  |  Height:  |  Size: 760 B

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 947 B

After

Width:  |  Height:  |  Size: 947 B

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -9,6 +9,11 @@
"idiom" : "universal",
"scale" : "2x",
"filename" : "demo_avatar_cook@2x.png"
},
{
"idiom" : "universal",
"scale" : "3x",
"filename" : "demo_avatar_cook@3x.png"
}
],
"info" : {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

View File

@ -9,6 +9,11 @@
"idiom" : "universal",
"scale" : "2x",
"filename" : "demo_avatar_jobs@2x.png"
},
{
"idiom" : "universal",
"scale" : "3x",
"filename" : "demo_avatar_jobs@3x.png"
}
],
"info" : {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -9,6 +9,11 @@
"idiom" : "universal",
"scale" : "2x",
"filename" : "demo_avatar_woz@2x.png"
},
{
"idiom" : "universal",
"scale" : "3x",
"filename" : "demo_avatar_woz@3x.png"
}
],
"info" : {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

View File

@ -1,5 +1,32 @@
{
"images" : [
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "736h",
"filename" : "jsq_messages_splash_55inch.png",
"minimum-system-version" : "8.0",
"orientation" : "portrait",
"scale" : "3x"
},
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "736h",
"filename" : "jsq_messages_splash_55inch_landscape.png",
"minimum-system-version" : "8.0",
"orientation" : "landscape",
"scale" : "3x"
},
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "667h",
"filename" : "jsq_messages_splash_47inch.png",
"minimum-system-version" : "8.0",
"orientation" : "portrait",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 43 KiB

View File

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 43 KiB

View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "goldengate.png"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "goldengate@2x.png"
},
{
"idiom" : "universal",
"scale" : "3x",
"filename" : "goldengate@3x.png"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 651 KiB

View File

@ -4,30 +4,28 @@
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>Messages</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>com.hexedbits.${PRODUCT_NAME:rfc1034identifier}</string>
<string>com.hexedbits.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>5.3.2</string>
<string>6.1.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>5.3.2</string>
<string>6.1.1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIMainStoryboardFile~ipad</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>

View File

@ -1,480 +0,0 @@
//
// Created by Jesse Squires
// http://www.hexedbits.com
//
//
// Documentation
// http://cocoadocs.org/docsets/JSQMessagesViewController
//
//
// GitHub
// https://github.com/jessesquires/JSQMessagesViewController
//
//
// License
// Copyright (c) 2014 Jesse Squires
// Released under an MIT license: http://opensource.org/licenses/MIT
//
#import "JSQDemoViewController.h"
static NSString * const kJSQDemoAvatarNameCook = @"Tim Cook";
static NSString * const kJSQDemoAvatarNameJobs = @"Jobs";
static NSString * const kJSQDemoAvatarNameWoz = @"Steve Wozniak";
@implementation JSQDemoViewController
#pragma mark - Demo setup
- (void)setupTestModel
{
/**
* Load some fake messages for demo.
*
* You should have a mutable array or orderedSet, or something.
*/
self.messages = [[NSMutableArray alloc] initWithObjects:
[[JSQMessage alloc] initWithText:@"Welcome to JSQMessages: A messaging UI framework for iOS." sender:self.sender date:[NSDate distantPast]],
[[JSQMessage alloc] initWithText:@"It is simple, elegant, and easy to use. There are super sweet default settings, but you can customize like crazy." sender:kJSQDemoAvatarNameWoz date:[NSDate distantPast]],
[[JSQMessage alloc] initWithText:@"It even has data detectors. You can call me tonight. My cell number is 123-456-7890. My website is www.hexedbits.com." sender:self.sender date:[NSDate distantPast]],
[[JSQMessage alloc] initWithText:@"JSQMessagesViewController is nearly an exact replica of the iOS Messages App. And perhaps, better." sender:kJSQDemoAvatarNameJobs date:[NSDate date]],
[[JSQMessage alloc] initWithText:@"It is unit-tested, free, and open-source." sender:kJSQDemoAvatarNameCook date:[NSDate date]],
[[JSQMessage alloc] initWithText:@"Oh, and there's sweet documentation." sender:self.sender date:[NSDate date]],
nil];
/**
* Create avatar images once.
*
* Be sure to create your avatars one time and reuse them for good performance.
*
* If you are not using avatars, ignore this.
*/
CGFloat outgoingDiameter = self.collectionView.collectionViewLayout.outgoingAvatarViewSize.width;
UIImage *jsqImage = [JSQMessagesAvatarFactory avatarWithUserInitials:@"JSQ"
backgroundColor:[UIColor colorWithWhite:0.85f alpha:1.0f]
textColor:[UIColor colorWithWhite:0.60f alpha:1.0f]
font:[UIFont systemFontOfSize:14.0f]
diameter:outgoingDiameter];
CGFloat incomingDiameter = self.collectionView.collectionViewLayout.incomingAvatarViewSize.width;
UIImage *cookImage = [JSQMessagesAvatarFactory avatarWithImage:[UIImage imageNamed:@"demo_avatar_cook"]
diameter:incomingDiameter];
UIImage *jobsImage = [JSQMessagesAvatarFactory avatarWithImage:[UIImage imageNamed:@"demo_avatar_jobs"]
diameter:incomingDiameter];
UIImage *wozImage = [JSQMessagesAvatarFactory avatarWithImage:[UIImage imageNamed:@"demo_avatar_woz"]
diameter:incomingDiameter];
self.avatars = @{ self.sender : jsqImage,
kJSQDemoAvatarNameCook : cookImage,
kJSQDemoAvatarNameJobs : jobsImage,
kJSQDemoAvatarNameWoz : wozImage };
/**
* Change to add more messages for testing
*/
NSUInteger messagesToAdd = 0;
NSArray *copyOfMessages = [self.messages copy];
for (NSUInteger i = 0; i < messagesToAdd; i++) {
[self.messages addObjectsFromArray:copyOfMessages];
}
/**
* Change to YES to add a super long message for testing
* You should see "END" twice
*/
BOOL addREALLYLongMessage = NO;
if (addREALLYLongMessage) {
JSQMessage *reallyLongMessage = [JSQMessage messageWithText:@"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? END Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? END" sender:self.sender];
[self.messages addObject:reallyLongMessage];
}
}
#pragma mark - View lifecycle
/**
* Override point for customization.
*
* Customize your view.
* Look at the properties on `JSQMessagesViewController` to see what is possible.
*
* Customize your layout.
* Look at the properties on `JSQMessagesCollectionViewFlowLayout` to see what is possible.
*/
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"JSQMessages";
self.sender = @"Jesse Squires";
[self setupTestModel];
/**
* Remove camera button since media messages are not yet implemented
*
* self.inputToolbar.contentView.leftBarButtonItem = nil;
*
* Or, you can set a custom `leftBarButtonItem` and a custom `rightBarButtonItem`
*/
/**
* Create bubble images.
*
* Be sure to create your avatars one time and reuse them for good performance.
*
*/
self.outgoingBubbleImageView = [JSQMessagesBubbleImageFactory
outgoingMessageBubbleImageViewWithColor:[UIColor jsq_messageBubbleLightGrayColor]];
self.incomingBubbleImageView = [JSQMessagesBubbleImageFactory
incomingMessageBubbleImageViewWithColor:[UIColor jsq_messageBubbleGreenColor]];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"typing"]
style:UIBarButtonItemStyleBordered
target:self
action:@selector(receiveMessagePressed:)];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
if (self.delegateModal) {
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop
target:self
action:@selector(closePressed:)];
}
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
/**
* Enable/disable springy bubbles, default is NO.
* You must set this from `viewDidAppear:`
* Note: this feature is mostly stable, but still experimental
*/
self.collectionView.collectionViewLayout.springinessEnabled = YES;
}
#pragma mark - Actions
- (void)receiveMessagePressed:(UIBarButtonItem *)sender
{
/**
* The following is simply to simulate received messages for the demo.
* Do not actually do this.
*/
/**
* Set the typing indicator to be shown
*/
self.showTypingIndicator = !self.showTypingIndicator;
/**
* Scroll to actually view the indicator
*/
[self scrollToBottomAnimated:YES];
JSQMessage *copyMessage = [[self.messages lastObject] copy];
if (!copyMessage) {
copyMessage = [JSQMessage messageWithText:@"First received!" sender:kJSQDemoAvatarNameJobs];
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
NSMutableArray *copyAvatars = [[self.avatars allKeys] mutableCopy];
[copyAvatars removeObject:self.sender];
copyMessage.sender = [copyAvatars objectAtIndex:arc4random_uniform((int)[copyAvatars count])];
/**
* This you should do upon receiving a message:
*
* 1. Play sound (optional)
* 2. Add new id<JSQMessageData> object to your data source
* 3. Call `finishReceivingMessage`
*/
[JSQSystemSoundPlayer jsq_playMessageReceivedSound];
[self.messages addObject:copyMessage];
[self finishReceivingMessage];
});
}
- (void)closePressed:(UIBarButtonItem *)sender
{
[self.delegateModal didDismissJSQDemoViewController:self];
}
#pragma mark - JSQMessagesViewController method overrides
- (void)didPressSendButton:(UIButton *)button
withMessageText:(NSString *)text
sender:(NSString *)sender
date:(NSDate *)date
{
/**
* Sending a message. Your implementation of this method should do *at least* the following:
*
* 1. Play sound (optional)
* 2. Add new id<JSQMessageData> object to your data source
* 3. Call `finishSendingMessage`
*/
[JSQSystemSoundPlayer jsq_playMessageSentSound];
JSQMessage *message = [[JSQMessage alloc] initWithText:text sender:sender date:date];
[self.messages addObject:message];
[self finishSendingMessage];
}
- (void)didPressAccessoryButton:(UIButton *)sender
{
NSLog(@"Camera pressed!");
/**
* Accessory button has no default functionality, yet.
*/
}
#pragma mark - JSQMessages CollectionView DataSource
- (id<JSQMessageData>)collectionView:(JSQMessagesCollectionView *)collectionView messageDataForItemAtIndexPath:(NSIndexPath *)indexPath
{
return [self.messages objectAtIndex:indexPath.item];
}
- (UIImageView *)collectionView:(JSQMessagesCollectionView *)collectionView bubbleImageViewForItemAtIndexPath:(NSIndexPath *)indexPath
{
/**
* You may return nil here if you do not want bubbles.
* In this case, you should set the background color of your collection view cell's textView.
*/
/**
* Reuse created bubble images, but create new imageView to add to each cell
* Otherwise, each cell would be referencing the same imageView and bubbles would disappear from cells
*/
JSQMessage *message = [self.messages objectAtIndex:indexPath.item];
if ([message.sender isEqualToString:self.sender]) {
return [[UIImageView alloc] initWithImage:self.outgoingBubbleImageView.image
highlightedImage:self.outgoingBubbleImageView.highlightedImage];
}
return [[UIImageView alloc] initWithImage:self.incomingBubbleImageView.image
highlightedImage:self.incomingBubbleImageView.highlightedImage];
}
- (UIImageView *)collectionView:(JSQMessagesCollectionView *)collectionView avatarImageViewForItemAtIndexPath:(NSIndexPath *)indexPath
{
/**
* Return `nil` here if you do not want avatars.
* If you do return `nil`, be sure to do the following in `viewDidLoad`:
*
* self.collectionView.collectionViewLayout.incomingAvatarViewSize = CGSizeZero;
* self.collectionView.collectionViewLayout.outgoingAvatarViewSize = CGSizeZero;
*
* It is possible to have only outgoing avatars or only incoming avatars, too.
*/
/**
* Reuse created avatar images, but create new imageView to add to each cell
* Otherwise, each cell would be referencing the same imageView and avatars would disappear from cells
*
* Note: these images will be sized according to these values:
*
* self.collectionView.collectionViewLayout.incomingAvatarViewSize
* self.collectionView.collectionViewLayout.outgoingAvatarViewSize
*
* Override the defaults in `viewDidLoad`
*/
JSQMessage *message = [self.messages objectAtIndex:indexPath.item];
UIImage *avatarImage = [self.avatars objectForKey:message.sender];
return [[UIImageView alloc] initWithImage:avatarImage];
}
- (NSAttributedString *)collectionView:(JSQMessagesCollectionView *)collectionView attributedTextForCellTopLabelAtIndexPath:(NSIndexPath *)indexPath
{
/**
* This logic should be consistent with what you return from `heightForCellTopLabelAtIndexPath:`
* The other label text delegate methods should follow a similar pattern.
*
* Show a timestamp for every 3rd message
*/
if (indexPath.item % 3 == 0) {
JSQMessage *message = [self.messages objectAtIndex:indexPath.item];
return [[JSQMessagesTimestampFormatter sharedFormatter] attributedTimestampForDate:message.date];
}
return nil;
}
- (NSAttributedString *)collectionView:(JSQMessagesCollectionView *)collectionView attributedTextForMessageBubbleTopLabelAtIndexPath:(NSIndexPath *)indexPath
{
JSQMessage *message = [self.messages objectAtIndex:indexPath.item];
/**
* iOS7-style sender name labels
*/
if ([message.sender isEqualToString:self.sender]) {
return nil;
}
if (indexPath.item - 1 > 0) {
JSQMessage *previousMessage = [self.messages objectAtIndex:indexPath.item - 1];
if ([[previousMessage sender] isEqualToString:message.sender]) {
return nil;
}
}
/**
* Don't specify attributes to use the defaults.
*/
return [[NSAttributedString alloc] initWithString:message.sender];
}
- (NSAttributedString *)collectionView:(JSQMessagesCollectionView *)collectionView attributedTextForCellBottomLabelAtIndexPath:(NSIndexPath *)indexPath
{
return nil;
}
#pragma mark - UICollectionView DataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return [self.messages count];
}
- (UICollectionViewCell *)collectionView:(JSQMessagesCollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
/**
* Override point for customizing cells
*/
JSQMessagesCollectionViewCell *cell = (JSQMessagesCollectionViewCell *)[super collectionView:collectionView cellForItemAtIndexPath:indexPath];
/**
* Configure almost *anything* on the cell
*
* Text colors, label text, label colors, etc.
*
*
* DO NOT set `cell.textView.font` !
* Instead, you need to set `self.collectionView.collectionViewLayout.messageBubbleFont` to the font you want in `viewDidLoad`
*
*
* DO NOT manipulate cell layout information!
* Instead, override the properties you want on `self.collectionView.collectionViewLayout` from `viewDidLoad`
*/
JSQMessage *msg = [self.messages objectAtIndex:indexPath.item];
if ([msg.sender isEqualToString:self.sender]) {
cell.textView.textColor = [UIColor blackColor];
}
else {
cell.textView.textColor = [UIColor whiteColor];
}
cell.textView.linkTextAttributes = @{ NSForegroundColorAttributeName : cell.textView.textColor,
NSUnderlineStyleAttributeName : @(NSUnderlineStyleSingle | NSUnderlinePatternSolid) };
return cell;
}
#pragma mark - JSQMessages collection view flow layout delegate
#pragma mark - Adjusting cell label heights
- (CGFloat)collectionView:(JSQMessagesCollectionView *)collectionView
layout:(JSQMessagesCollectionViewFlowLayout *)collectionViewLayout heightForCellTopLabelAtIndexPath:(NSIndexPath *)indexPath
{
/**
* Each label in a cell has a `height` delegate method that corresponds to its text dataSource method
*/
/**
* This logic should be consistent with what you return from `attributedTextForCellTopLabelAtIndexPath:`
* The other label height delegate methods should follow similarly
*
* Show a timestamp for every 3rd message
*/
if (indexPath.item % 3 == 0) {
return kJSQMessagesCollectionViewCellLabelHeightDefault;
}
return 0.0f;
}
- (CGFloat)collectionView:(JSQMessagesCollectionView *)collectionView
layout:(JSQMessagesCollectionViewFlowLayout *)collectionViewLayout heightForMessageBubbleTopLabelAtIndexPath:(NSIndexPath *)indexPath
{
/**
* iOS7-style sender name labels
*/
JSQMessage *currentMessage = [self.messages objectAtIndex:indexPath.item];
if ([[currentMessage sender] isEqualToString:self.sender]) {
return 0.0f;
}
if (indexPath.item - 1 > 0) {
JSQMessage *previousMessage = [self.messages objectAtIndex:indexPath.item - 1];
if ([[previousMessage sender] isEqualToString:[currentMessage sender]]) {
return 0.0f;
}
}
return kJSQMessagesCollectionViewCellLabelHeightDefault;
}
- (CGFloat)collectionView:(JSQMessagesCollectionView *)collectionView
layout:(JSQMessagesCollectionViewFlowLayout *)collectionViewLayout heightForCellBottomLabelAtIndexPath:(NSIndexPath *)indexPath
{
return 0.0f;
}
#pragma mark - Responding to collection view tap events
- (void)collectionView:(JSQMessagesCollectionView *)collectionView
header:(JSQMessagesLoadEarlierHeaderView *)headerView didTapLoadEarlierMessagesButton:(UIButton *)sender
{
NSLog(@"Load earlier messages!");
}
- (void)collectionView:(JSQMessagesCollectionView *)collectionView didTapAvatarImageView:(UIImageView *)avatarImageView atIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"Tapped avatar!");
}
- (void)collectionView:(JSQMessagesCollectionView *)collectionView didTapMessageBubbleAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"Tapped message bubble!");
}
- (void)collectionView:(JSQMessagesCollectionView *)collectionView didTapCellAtIndexPath:(NSIndexPath *)indexPath touchLocation:(CGPoint)touchLocation
{
NSLog(@"Tapped cell at %@!", NSStringFromCGPoint(touchLocation));
}
@end

View File

@ -1,19 +0,0 @@
//
// Prefix header
//
// The contents of this file are implicitly included at the beginning of every source file.
//
#import <Availability.h>
#ifndef __IPHONE_5_0
#warning "This project uses features only available in iOS SDK 5.0 and later."
#endif
// Make NSLog more useful and pretty
#define NSLog(__FORMAT__, ...) NSLog((@"%s [Line %d] " __FORMAT__), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif

View File

@ -0,0 +1,41 @@
//
// Created by Jesse Squires
// http://www.jessesquires.com
//
//
// Documentation
// http://cocoadocs.org/docsets/JSQMessagesViewController
//
//
// GitHub
// https://github.com/jessesquires/JSQMessagesViewController
//
//
// License
// Copyright (c) 2014 Jesse Squires
// Released under an MIT license: http://opensource.org/licenses/MIT
//
#import <Foundation/Foundation.h>
@interface NSUserDefaults (DemoSettings)
+ (void)saveExtraMessagesSetting:(BOOL)value;
+ (BOOL)extraMessagesSetting;
+ (void)saveLongMessageSetting:(BOOL)value;
+ (BOOL)longMessageSetting;
+ (void)saveEmptyMessagesSetting:(BOOL)value;
+ (BOOL)emptyMessagesSetting;
+ (void)saveSpringinessSetting:(BOOL)value;
+ (BOOL)springinessSetting;
+ (void)saveOutgoingAvatarSetting:(BOOL)value;
+ (BOOL)outgoingAvatarSetting;
+ (void)saveIncomingAvatarSetting:(BOOL)value;
+ (BOOL)incomingAvatarSetting;
@end

View File

@ -0,0 +1,91 @@
//
// Created by Jesse Squires
// http://www.jessesquires.com
//
//
// Documentation
// http://cocoadocs.org/docsets/JSQMessagesViewController
//
//
// GitHub
// https://github.com/jessesquires/JSQMessagesViewController
//
//
// License
// Copyright (c) 2014 Jesse Squires
// Released under an MIT license: http://opensource.org/licenses/MIT
//
#import "NSUserDefaults+DemoSettings.h"
static NSString * const kSettingExtraMessages = @"kSettingExtraMessages";
static NSString * const kSettingLongMessage = @"kSettingLongMessage";
static NSString * const kSettingEmptyMessages = @"kSettingEmptyMessages";
static NSString * const kSettingSpringiness = @"kSettingSpringiness";
static NSString * const kSettingIncomingAvatar = @"kSettingIncomingAvatar";
static NSString * const kSettingOutgoingAvatar = @"kSettingOutgoingAvatar";
@implementation NSUserDefaults (DemoSettings)
+ (void)saveExtraMessagesSetting:(BOOL)value
{
[[NSUserDefaults standardUserDefaults] setBool:value forKey:kSettingExtraMessages];
}
+ (BOOL)extraMessagesSetting
{
return [[NSUserDefaults standardUserDefaults] boolForKey:kSettingExtraMessages];
}
+ (void)saveLongMessageSetting:(BOOL)value
{
[[NSUserDefaults standardUserDefaults] setBool:value forKey:kSettingLongMessage];
}
+ (BOOL)longMessageSetting
{
return [[NSUserDefaults standardUserDefaults] boolForKey:kSettingLongMessage];
}
+ (void)saveEmptyMessagesSetting:(BOOL)value
{
[[NSUserDefaults standardUserDefaults] setBool:value forKey:kSettingEmptyMessages];
}
+ (BOOL)emptyMessagesSetting
{
return [[NSUserDefaults standardUserDefaults] boolForKey:kSettingEmptyMessages];
}
+ (void)saveSpringinessSetting:(BOOL)value
{
[[NSUserDefaults standardUserDefaults] setBool:value forKey:kSettingSpringiness];
}
+ (BOOL)springinessSetting
{
return [[NSUserDefaults standardUserDefaults] boolForKey:kSettingSpringiness];
}
+ (void)saveOutgoingAvatarSetting:(BOOL)value
{
[[NSUserDefaults standardUserDefaults] setBool:value forKey:kSettingOutgoingAvatar];
}
+ (BOOL)outgoingAvatarSetting
{
return [[NSUserDefaults standardUserDefaults] boolForKey:kSettingOutgoingAvatar];
}
+ (void)saveIncomingAvatarSetting:(BOOL)value
{
[[NSUserDefaults standardUserDefaults] setBool:value forKey:kSettingIncomingAvatar];
}
+ (BOOL)incomingAvatarSetting
{
return [[NSUserDefaults standardUserDefaults] boolForKey:kSettingIncomingAvatar];
}
@end

View File

@ -1,6 +1,6 @@
//
// Created by Jesse Squires
// http://www.hexedbits.com
// http://www.jessesquires.com
//
//
// Documentation
@ -16,11 +16,12 @@
// Released under an MIT license: http://opensource.org/licenses/MIT
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "JSQDemoViewController.h"
#import "DemoMessagesViewController.h"
@interface JSQTableViewController : UITableViewController <JSQDemoViewControllerDelegate>
@interface TableViewController : UITableViewController <JSQDemoViewControllerDelegate>
- (IBAction)unwindSegue:(UIStoryboardSegue *)sender;

View File

@ -1,6 +1,6 @@
//
// Created by Jesse Squires
// http://www.hexedbits.com
// http://www.jessesquires.com
//
//
// Documentation
@ -16,9 +16,9 @@
// Released under an MIT license: http://opensource.org/licenses/MIT
//
#import "JSQTableViewController.h"
#import "TableViewController.h"
@implementation JSQTableViewController
@implementation TableViewController
#pragma mark - View lifecycle
@ -38,11 +38,15 @@
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2;
return 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section == 2) {
return 1;
}
return 2;
}
@ -75,10 +79,29 @@
break;
}
}
else if (indexPath.section == 2) {
switch (indexPath.row) {
case 0:
cell.textLabel.text = @"Settings";
break;
}
}
return cell;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
switch (section) {
case 0:
return @"Presentation";
case 2:
return @"Demo options";
default:
return nil;
}
}
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
{
return (section == [tableView numberOfSections] - 1) ? @"Copyright © 2014\nJesse Squires\nMIT License" : nil;
@ -95,7 +118,7 @@
break;
case 1:
{
JSQDemoViewController *vc = [JSQDemoViewController messagesViewController];
DemoMessagesViewController *vc = [DemoMessagesViewController messagesViewController];
[self.navigationController pushViewController:vc animated:YES];
}
break;
@ -108,7 +131,7 @@
break;
case 1:
{
JSQDemoViewController *vc = [JSQDemoViewController messagesViewController];
DemoMessagesViewController *vc = [DemoMessagesViewController messagesViewController];
vc.delegateModal = self;
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:vc];
[self presentViewController:nc animated:YES completion:nil];
@ -116,6 +139,13 @@
break;
}
}
else if (indexPath.section == 2) {
switch (indexPath.row) {
case 0:
[self performSegueWithIdentifier:@"SegueToSettings" sender:self];
break;
}
}
}
#pragma mark - Segues
@ -124,7 +154,7 @@
{
if ([segue.identifier isEqualToString:@"segueModalDemoVC"]) {
UINavigationController *nc = segue.destinationViewController;
JSQDemoViewController *vc = (JSQDemoViewController *)nc.topViewController;
DemoMessagesViewController *vc = (DemoMessagesViewController *)nc.topViewController;
vc.delegateModal = self;
}
}
@ -133,7 +163,7 @@
#pragma mark - Demo delegate
- (void)didDismissJSQDemoViewController:(JSQDemoViewController *)vc
- (void)didDismissJSQDemoViewController:(DemoMessagesViewController *)vc
{
[self dismissViewControllerAnimated:YES completion:nil];
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -1,2 +0,0 @@
/* Localized versions of Info.plist keys */

6
JSQMessagesDemo/main.m Executable file → Normal file
View File

@ -1,6 +1,6 @@
//
// Created by Jesse Squires
// http://www.hexedbits.com
// http://www.jessesquires.com
//
//
// Documentation
@ -18,11 +18,11 @@
#import <UIKit/UIKit.h>
#import "JSQAppDelegate.h"
#import "AppDelegate.h"
int main(int argc, char * argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([JSQAppDelegate class]));
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}

View File

@ -1,6 +1,6 @@
//
// Created by Jesse Squires
// http://www.hexedbits.com
// http://www.jessesquires.com
//
//
// MIT License
@ -9,7 +9,6 @@
//
#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>
#import "NSString+JSQMessages.h"
@ -20,24 +19,17 @@
@implementation JSQMessagesNSStringTests
- (void)setUp
{
[super setUp];
}
- (void)tearDown
{
[super tearDown];
}
- (void)testTrimingStringWhitespace
{
// GIVEN: a string of text
NSString *loremIpsum = @"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
// WHEN: the text is wrapped in white space
NSString *string1 = [NSString stringWithFormat:@" %@ ", loremIpsum];
NSString *string2 = [NSString stringWithFormat:@" %@", loremIpsum];
NSString *string3 = [NSString stringWithFormat:@"%@ ", loremIpsum];
// THEN: we can successfully trim extra white space
XCTAssertEqualObjects(loremIpsum, [string1 jsq_stringByTrimingWhitespace], @"Strings should be equal after trimming whitespace");
XCTAssertEqualObjects(loremIpsum, [string2 jsq_stringByTrimingWhitespace], @"Strings should be equal after trimming whitespace");

View File

@ -1,6 +1,6 @@
//
// Created by Jesse Squires
// http://www.hexedbits.com
// http://www.jessesquires.com
//
//
// MIT License
@ -9,7 +9,6 @@
//
#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>
#import "UIColor+JSQMessages.h"
@ -20,63 +19,20 @@
@implementation JSQMessagesUIColorTests
- (void)setUp
{
[super setUp];
}
- (void)tearDown
{
[super tearDown];
}
- (void)testGreenColor
{
CGFloat h, s, b, a;
UIColor *green = [UIColor jsq_messageBubbleGreenColor];
XCTAssertNotNil(green, @"Color should not be nil");
[green getHue:&h saturation:&s brightness:&b alpha:&a];
UIColor *copyGreen = [UIColor colorWithHue:h saturation:s brightness:b alpha:a];
XCTAssertEqualObjects(green, copyGreen, @"Colors should be equal");
}
- (void)testBlueColor
{
CGFloat h, s, b, a;
UIColor *blue = [UIColor jsq_messageBubbleBlueColor];
XCTAssertNotNil(blue, @"Color should not be nil");
[blue getHue:&h saturation:&s brightness:&b alpha:&a];
UIColor *copyBlue = [UIColor colorWithHue:h saturation:s brightness:b alpha:a];
XCTAssertEqualObjects(blue, copyBlue, @"Colors should be equal");
}
- (void)testGrayColor
{
CGFloat h, s, b, a;
UIColor *gray = [UIColor jsq_messageBubbleLightGrayColor];
XCTAssertNotNil(gray, @"Color should not be nil");
[gray getHue:&h saturation:&s brightness:&b alpha:&a];
UIColor *copyGray = [UIColor colorWithHue:h saturation:s brightness:b alpha:a];
XCTAssertEqualObjects(gray, copyGray, @"Colors should be equal");
}
- (void)testDarkeningColors
{
// GIVEN: a color and darkening value
CGFloat r = 0.89f, g = 0.34f, b = 0.67f, a = 1.0f;
CGFloat darkeningValue = 0.12f;
UIColor *color = [UIColor colorWithRed:r green:g blue:b alpha:a];
// WHEN: we darken that color
UIColor *darkColor = [color jsq_colorByDarkeningColorWithValue:darkeningValue];
// THEN: each RGB value is changed accordingly
CGFloat dr, dg, db, da;
[darkColor getRed:&dr green:&dg blue:&db alpha:&da];
XCTAssertEqual(dr, r - darkeningValue, @"Red values should be equal");
XCTAssertEqual(dg, g - darkeningValue, @"Green values should be equal");
XCTAssertEqual(db, b - darkeningValue, @"Blue values should be equal");
@ -85,13 +41,15 @@
- (void)testDarkeningColorsFloorToZero
{
// GIVEN: a color and darkening value
CGFloat r = 0.89f, g = 0.24f, b = 0.67f, a = 1.0f;
CGFloat darkeningValue = 0.5f;
UIColor *color = [UIColor colorWithRed:r green:g blue:b alpha:a];
// WHEN: we dark that color, such that some RGB values will be negative
UIColor *darkColor = [color jsq_colorByDarkeningColorWithValue:darkeningValue];
// THEN: the RGB values are floored to zero instead of being negative
CGFloat dr, dg, db, da;
[darkColor getRed:&dr green:&dg blue:&db alpha:&da];
XCTAssertEqual(dr, r - darkeningValue, @"Red values should be equal");

View File

@ -1,6 +1,6 @@
//
// Created by Jesse Squires
// http://www.hexedbits.com
// http://www.jessesquires.com
//
//
// MIT License
@ -9,7 +9,6 @@
//
#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>
#import "UIImage+JSQMessages.h"
@ -20,24 +19,17 @@
@implementation JSQMessagesUIImageTests
- (void)setUp
{
[super setUp];
}
- (void)tearDown
{
[super tearDown];
}
- (void)testImageMasking
{
UIImage *img = [UIImage imageNamed:@"bubble_min"];
// GIVEN: an image
UIImage *img = [UIImage jsq_bubbleCompactImage];
XCTAssertNotNil(img, @"Image should not be nil");
// WHEN: we mask that image
UIImage *imgMasked = [img jsq_imageMaskedWithColor:[UIColor whiteColor]];
XCTAssertNotNil(imgMasked, @"Image should not be nil");
// THEN: masking should succeed, and the new image should have the same properties
XCTAssertTrue(CGSizeEqualToSize(img.size, imgMasked.size), @"Image sizes should be equal");
XCTAssertEqual(img.scale, imgMasked.scale, @"Image scales should be equal");
@ -45,4 +37,31 @@
XCTAssertThrows([img jsq_imageMaskedWithColor:nil], @"Should throw when passing nil color");
}
- (void)testImageAssets
{
// GIVEN: our image assets
// WHEN: we create a new UIImage object
// THEN: the image is created successfully
XCTAssertNotNil([UIImage jsq_bubbleRegularImage]);
XCTAssertNotNil([UIImage jsq_bubbleRegularTaillessImage]);
XCTAssertNotNil([UIImage jsq_bubbleRegularStrokedImage]);
XCTAssertNotNil([UIImage jsq_bubbleRegularStrokedTaillessImage]);
XCTAssertNotNil([UIImage jsq_bubbleCompactImage]);
XCTAssertNotNil([UIImage jsq_bubbleCompactTaillessImage]);
XCTAssertNotNil([UIImage jsq_defaultAccessoryImage]);
XCTAssertNotNil([UIImage jsq_defaultTypingIndicatorImage]);
XCTAssertNotNil([UIImage jsq_defaultPlayImage]);
}
@end

26
JSQMessagesTests/CategoryTests/JSQMessagesUIViewTests.m Executable file → Normal file
View File

@ -1,6 +1,6 @@
//
// Created by Jesse Squires
// http://www.hexedbits.com
// http://www.jessesquires.com
//
//
// MIT License
@ -9,7 +9,6 @@
//
#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>
#import "UIView+JSQMessages.h"
@ -20,23 +19,24 @@
@implementation JSQMessagesUIViewTests
- (void)setUp
{
[super setUp];
}
- (void)tearDown
{
[super tearDown];
}
- (void)testViewAutoLayoutPinEdges
{
// GIVEN: a superview and subview
UIView *superview = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 50.0f, 50.0f)];
UIView *subview = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 50.0f, 50.0f)];
[superview setTranslatesAutoresizingMaskIntoConstraints:NO];
UIView *subview = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 25.0f, 25.0f)];
[subview setTranslatesAutoresizingMaskIntoConstraints:NO];
// WHEN: we add the subview to the superview
[superview addSubview:subview];
// WHEN: we pin the edges of the subview to the superview
XCTAssertNoThrow([superview jsq_pinAllEdgesOfSubview:subview], @"Pinning edges of subview to superview should not throw");
[superview setNeedsUpdateConstraints];
[superview layoutIfNeeded];
// THEN: add the layout constraints and laying out the views succeeds
XCTAssertEqual([[superview constraints] count], 4U, @"Superview should have 4 constraints");

View File

@ -1,6 +1,6 @@
//
// Created by Jesse Squires
// http://www.hexedbits.com
// http://www.jessesquires.com
//
//
// MIT License
@ -9,7 +9,6 @@
//
#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>
#import "JSQMessagesKeyboardController.h"

View File

@ -1,6 +1,6 @@
//
// Created by Jesse Squires
// http://www.hexedbits.com
// http://www.jessesquires.com
//
//
// MIT License
@ -9,10 +9,11 @@
//
#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>
#import "JSQMessagesViewController.h"
#import "JSQDemoViewController.h"
#import "DemoMessagesViewController.h"
@interface JSQMessagesViewController ()
@ -53,21 +54,23 @@
XCTAssertNotNil(vc.collectionView, @"Collection view should not be nil");
XCTAssertNotNil(vc.inputToolbar, @"Input toolbar should not be nil");
XCTAssertEqualObjects(vc.sender, @"JSQDefaultSender", @"Property should be equal to default value");
XCTAssertEqualObjects(vc.senderId, @"JSQDefaultSender", @"Property should be equal to default value");
XCTAssertEqualObjects(vc.senderDisplayName, @"JSQDefaultSender", @"Property should be equal to default value");
XCTAssertEqual(vc.automaticallyAdjustsScrollViewInsets, YES, @"Property should be equal to default value");
XCTAssertEqualObjects(vc.incomingCellIdentifier, [JSQMessagesCollectionViewCellIncoming cellReuseIdentifier], @"Property should be equal to default value");
XCTAssertEqualObjects(vc.outgoingCellIdentifier, [JSQMessagesCollectionViewCellOutgoing cellReuseIdentifier], @"Property should be equal to default value");
XCTAssertEqualObjects(vc.typingIndicatorColor, [UIColor jsq_messageBubbleLightGrayColor], @"Property should be equal to default value");
XCTAssertEqual(vc.showTypingIndicator, NO, @"Property should be equal to default value");
XCTAssertEqual(vc.showLoadEarlierMessagesHeader, NO, @"Property should be equal to default value");
}
- (void)testJSQMessagesViewControllerSubclassInitProgramatically
{
JSQDemoViewController *demoVC = [JSQDemoViewController messagesViewController];
DemoMessagesViewController *demoVC = [DemoMessagesViewController messagesViewController];
[demoVC view];
XCTAssertNotNil(demoVC, @"View controller should not be nil");
XCTAssertTrue([demoVC isKindOfClass:[JSQDemoViewController class]], @"View controller should be kind of class: %@", [JSQDemoViewController class]);
XCTAssertTrue([demoVC isKindOfClass:[DemoMessagesViewController class]], @"View controller should be kind of class: %@", [DemoMessagesViewController class]);
XCTAssertNotNil(demoVC.view, @"View should not be nil");
XCTAssertNotNil(demoVC.collectionView, @"Collection view should not be nil");
XCTAssertNotNil(demoVC.inputToolbar, @"Input toolbar should not be nil");
@ -78,10 +81,10 @@
UIStoryboard *mainSB = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
XCTAssertNotNil(mainSB, @"Storyboard should not be nil");
JSQDemoViewController *demoVC = [mainSB instantiateViewControllerWithIdentifier:@"DemoVC"];
DemoMessagesViewController *demoVC = [mainSB instantiateViewControllerWithIdentifier:@"DemoVC"];
[demoVC view];
XCTAssertNotNil(demoVC, @"View controller should not be nil");
XCTAssertTrue([demoVC isKindOfClass:[JSQDemoViewController class]], @"View controller should be kind of class: %@", [JSQDemoViewController class]);
XCTAssertTrue([demoVC isKindOfClass:[DemoMessagesViewController class]], @"View controller should be kind of class: %@", [DemoMessagesViewController class]);
XCTAssertNotNil(demoVC.view, @"View should not be nil");
XCTAssertNotNil(demoVC.collectionView, @"Collection view should not be nil");
XCTAssertNotNil(demoVC.inputToolbar, @"Input toolbar should not be nil");

View File

@ -1,59 +0,0 @@
//
// Created by Jesse Squires
// http://www.hexedbits.com
//
//
// MIT License
// Copyright (c) 2014 Jesse Squires
// http://opensource.org/licenses/MIT
//
#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>
#import "JSQMessagesAvatarFactory.h"
@interface JSQMessagesAvatarFactoryTests : XCTestCase
@end
@implementation JSQMessagesAvatarFactoryTests
- (void)setUp
{
[super setUp];
}
- (void)tearDown
{
[super tearDown];
}
- (void)testAvatarImage
{
UIImage *image = [UIImage imageNamed:@"demo_avatar_jobs"];
XCTAssertNotNil(image, @"Image should not be nil");
CGFloat diameter = 50.0f;
UIImage *avatar = [JSQMessagesAvatarFactory avatarWithImage:image diameter:diameter];
XCTAssertNotNil(avatar, @"Avatar should not be nil");
XCTAssertTrue(CGSizeEqualToSize(avatar.size, CGSizeMake(diameter, diameter)), @"Avatar size should be equal to diameter");
XCTAssertEqual(avatar.scale, image.scale, @"Avatar scale should be equal to original image scale");
}
- (void)testAvatarInitialsImage
{
CGFloat diameter = 50.0f;
UIImage *avatar = [JSQMessagesAvatarFactory avatarWithUserInitials:@"JSQ"
backgroundColor:[UIColor lightGrayColor]
textColor:[UIColor darkGrayColor]
font:[UIFont systemFontOfSize:13.0f]
diameter:diameter];
XCTAssertNotNil(avatar, @"Avatar should not be nil");
XCTAssertTrue(CGSizeEqualToSize(avatar.size, CGSizeMake(diameter, diameter)), @"Avatar size should be equal to diameter");
XCTAssertEqual(avatar.scale, [UIScreen mainScreen].scale, @"Avatar scale should be equal to screen scale");
}
@end

View File

@ -0,0 +1,73 @@
//
// Created by Jesse Squires
// http://www.jessesquires.com
//
//
// MIT License
// Copyright (c) 2014 Jesse Squires
// http://opensource.org/licenses/MIT
//
#import <XCTest/XCTest.h>
#import "JSQMessagesAvatarImageFactory.h"
@interface JSQMessagesAvatarImageFactoryTests : XCTestCase
@end
@implementation JSQMessagesAvatarImageFactoryTests
- (void)setUp
{
[super setUp];
}
- (void)tearDown
{
[super tearDown];
}
- (void)testAvatarImage
{
UIImage *image = [UIImage imageNamed:@"demo_avatar_jobs"];
XCTAssertNotNil(image, @"Image should not be nil");
CGFloat diameter = 50.0f;
JSQMessagesAvatarImage *avatar = [JSQMessagesAvatarImageFactory avatarImageWithPlaceholder:image diameter:diameter];
XCTAssertNotNil(avatar, @"Avatar should not be nil");
XCTAssertTrue(CGSizeEqualToSize(avatar.avatarPlaceholderImage.size, CGSizeMake(diameter, diameter)), @"Avatar size should be equal to diameter");
XCTAssertEqual(avatar.avatarPlaceholderImage.scale, [UIScreen mainScreen].scale, @"Avatar scale should be equal to screen scale");
avatar.avatarImage = [JSQMessagesAvatarImageFactory circularAvatarImage:image withDiameter:diameter];
XCTAssertTrue(CGSizeEqualToSize(avatar.avatarImage.size, CGSizeMake(diameter, diameter)), @"Avatar size should be equal to diameter");
XCTAssertEqual(avatar.avatarImage.scale, [UIScreen mainScreen].scale, @"Avatar scale should be equal to screen scale");
avatar.avatarHighlightedImage = [JSQMessagesAvatarImageFactory circularAvatarHighlightedImage:image withDiameter:diameter];
XCTAssertTrue(CGSizeEqualToSize(avatar.avatarHighlightedImage.size, CGSizeMake(diameter, diameter)), @"Avatar size should be equal to diameter");
XCTAssertEqual(avatar.avatarHighlightedImage.scale, [UIScreen mainScreen].scale, @"Avatar scale should be equal to screen scale");
}
- (void)testAvatarInitialsImage
{
CGFloat diameter = 50.0f;
JSQMessagesAvatarImage *avatar = [JSQMessagesAvatarImageFactory avatarImageWithUserInitials:@"JSQ"
backgroundColor:[UIColor lightGrayColor]
textColor:[UIColor darkGrayColor]
font:[UIFont systemFontOfSize:13.0f]
diameter:diameter];
XCTAssertNotNil(avatar, @"Avatar should not be nil");
XCTAssertTrue(CGSizeEqualToSize(avatar.avatarImage.size, CGSizeMake(diameter, diameter)), @"Avatar size should be equal to diameter");
XCTAssertEqual(avatar.avatarImage.scale, [UIScreen mainScreen].scale, @"Avatar scale should be equal to screen scale");
XCTAssertTrue(CGSizeEqualToSize(avatar.avatarHighlightedImage.size, CGSizeMake(diameter, diameter)), @"Avatar size should be equal to diameter");
XCTAssertEqual(avatar.avatarHighlightedImage.scale, [UIScreen mainScreen].scale, @"Avatar scale should be equal to screen scale");
XCTAssertTrue(CGSizeEqualToSize(avatar.avatarPlaceholderImage.size, CGSizeMake(diameter, diameter)), @"Avatar size should be equal to diameter");
XCTAssertEqual(avatar.avatarPlaceholderImage.scale, [UIScreen mainScreen].scale, @"Avatar scale should be equal to screen scale");
}
@end

View File

@ -1,6 +1,6 @@
//
// Created by Jesse Squires
// http://www.hexedbits.com
// http://www.jessesquires.com
//
//
// MIT License
@ -9,12 +9,16 @@
//
#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>
#import "JSQMessagesBubbleImageFactory.h"
#import "UIImage+JSQMessages.h"
@interface JSQMessagesBubbleImageFactoryTests : XCTestCase
@property (strong, nonatomic) JSQMessagesBubbleImageFactory *factory;
@end
@ -23,69 +27,109 @@
- (void)setUp
{
[super setUp];
self.factory = [[JSQMessagesBubbleImageFactory alloc] init];
}
- (void)tearDown
{
self.factory = nil;
[super tearDown];
}
- (void)testOutgoingMessageBubbleImageView
{
UIImage *bubble = [UIImage imageNamed:@"bubble_min"];
UIImage *bubble = [UIImage jsq_bubbleCompactImage];
XCTAssertNotNil(bubble, @"Bubble image should not be nil");
CGPoint center = CGPointMake(bubble.size.width / 2.0f, bubble.size.height / 2.0f);
UIEdgeInsets capInsets = UIEdgeInsetsMake(center.y, center.x, center.y, center.x);
JSQMessagesBubbleImage *bubbleImage = [self.factory outgoingMessagesBubbleImageWithColor:[UIColor lightGrayColor]];
XCTAssertNotNil(bubbleImage, @"Bubble image should not be nil");
UIImageView *imageView = [JSQMessagesBubbleImageFactory outgoingMessageBubbleImageViewWithColor:[UIColor lightGrayColor]];
XCTAssertNotNil(imageView, @"ImageView should not be nil");
XCTAssertEqualObjects(imageView.backgroundColor, [UIColor whiteColor], @"ImageView should have white background color");
XCTAssertTrue(CGSizeEqualToSize(imageView.frame.size, bubble.size), @"ImageView size should equal bubble size");
XCTAssertNotNil(bubbleImage.messageBubbleImage, "Image should not be nil");
XCTAssertEqual(bubbleImage.messageBubbleImage.scale, bubble.scale, @"Image scale should equal bubble image scale");
XCTAssertEqual(bubbleImage.messageBubbleImage.imageOrientation, bubble.imageOrientation, @"Image orientation should equal bubble image orientation");
XCTAssertTrue(bubbleImage.messageBubbleImage.resizingMode == UIImageResizingModeStretch, @"Image should be stretchable");
XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(bubbleImage.messageBubbleImage.capInsets, capInsets), @"Image capInsets should be equal to capInsets");
XCTAssertNotNil(imageView.image, @"Image should not be nil");
XCTAssertEqual(imageView.image.scale, bubble.scale, @"Image scale should equal bubble image scale");
XCTAssertEqual(imageView.image.imageOrientation, bubble.imageOrientation, @"Image orientation should equal bubble image orientation");
XCTAssertTrue(imageView.image.resizingMode == UIImageResizingModeStretch, @"Image should be stretchable");
XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(imageView.image.capInsets, capInsets), @"Image capInsets should be equal to capInsets");
XCTAssertNotNil(imageView.highlightedImage, @"HighlightedImage should not be nil");
XCTAssertEqual(imageView.highlightedImage.scale, bubble.scale, @"HighlightedImage scale should equal bubble image scale");
XCTAssertEqual(imageView.highlightedImage.imageOrientation, bubble.imageOrientation, @"HighlightedImage orientation should equal bubble image orientation");
XCTAssertTrue(imageView.highlightedImage.resizingMode == UIImageResizingModeStretch, @"HighlightedImage should be stretchable");
XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(imageView.highlightedImage.capInsets, capInsets), @"HighlightedImage capInsets should be equal to capInsets");
XCTAssertNotNil(bubbleImage.messageBubbleHighlightedImage, @"Highlighted image should not be nil");
XCTAssertEqual(bubbleImage.messageBubbleHighlightedImage.scale, bubble.scale, @"HighlightedImage scale should equal bubble image scale");
XCTAssertEqual(bubbleImage.messageBubbleHighlightedImage.imageOrientation, bubble.imageOrientation, @"HighlightedImage orientation should equal bubble image orientation");
XCTAssertTrue(bubbleImage.messageBubbleHighlightedImage.resizingMode == UIImageResizingModeStretch, @"HighlightedImage should be stretchable");
XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(bubbleImage.messageBubbleHighlightedImage.capInsets, capInsets), @"HighlightedImage capInsets should be equal to capInsets");
}
- (void)testIncomingMessageBubbleImageView
{
UIImage *bubble = [UIImage imageNamed:@"bubble_min"];
UIImage *bubble = [UIImage jsq_bubbleCompactImage];
XCTAssertNotNil(bubble, @"Bubble image should not be nil");
CGPoint center = CGPointMake(bubble.size.width / 2.0f, bubble.size.height / 2.0f);
UIEdgeInsets capInsets = UIEdgeInsetsMake(center.y, center.x, center.y, center.x);
JSQMessagesBubbleImage *bubbleImage = [self.factory incomingMessagesBubbleImageWithColor:[UIColor lightGrayColor]];
XCTAssertNotNil(bubbleImage, @"Bubble image should not be nil");
UIImageView *imageView = [JSQMessagesBubbleImageFactory incomingMessageBubbleImageViewWithColor:[UIColor lightGrayColor]];
XCTAssertNotNil(imageView, @"ImageView should not be nil");
XCTAssertEqualObjects(imageView.backgroundColor, [UIColor whiteColor], @"ImageView should have white background color");
XCTAssertTrue(CGSizeEqualToSize(imageView.frame.size, bubble.size), @"ImageView size should equal bubble size");
XCTAssertNotNil(bubbleImage.messageBubbleImage, "Image should not be nil");
XCTAssertEqual(bubbleImage.messageBubbleImage.scale, bubble.scale, @"Image scale should equal bubble image scale");
XCTAssertEqual(bubbleImage.messageBubbleImage.imageOrientation, UIImageOrientationUpMirrored, @"Image orientation should be flipped");
XCTAssertTrue(bubbleImage.messageBubbleImage.resizingMode == UIImageResizingModeStretch, @"Image should be stretchable");
XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(bubbleImage.messageBubbleImage.capInsets, capInsets), @"Image capInsets should be equal to capInsets");
XCTAssertNotNil(imageView.image, @"Image should not be nil");
XCTAssertEqual(imageView.image.scale, bubble.scale, @"Image scale should equal bubble image scale");
XCTAssertEqual(imageView.image.imageOrientation, UIImageOrientationUpMirrored, @"Image orientation should be flipped");
XCTAssertTrue(imageView.image.resizingMode == UIImageResizingModeStretch, @"Image should be stretchable");
XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(imageView.image.capInsets, capInsets), @"Image capInsets should be equal to capInsets");
XCTAssertNotNil(bubbleImage.messageBubbleHighlightedImage, @"Highlighted image should not be nil");
XCTAssertEqual(bubbleImage.messageBubbleHighlightedImage.scale, bubble.scale, @"HighlightedImage scale should equal bubble image scale");
XCTAssertEqual(bubbleImage.messageBubbleHighlightedImage.imageOrientation, UIImageOrientationUpMirrored, @"Image orientation should be flipped");
XCTAssertTrue(bubbleImage.messageBubbleHighlightedImage.resizingMode == UIImageResizingModeStretch, @"HighlightedImage should be stretchable");
XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(bubbleImage.messageBubbleHighlightedImage.capInsets, capInsets), @"HighlightedImage capInsets should be equal to capInsets");
}
- (void)testCustomOutgoingMessageBubbleImageView
{
UIImage *bubble = [UIImage jsq_bubbleRegularStrokedTaillessImage];
XCTAssertNotNil(bubble, @"Bubble image should not be nil");
UIEdgeInsets capInsets = UIEdgeInsetsMake(1, 1, 1, 1);
JSQMessagesBubbleImageFactory *factory = [[JSQMessagesBubbleImageFactory alloc] initWithBubbleImage:bubble capInsets:capInsets];
JSQMessagesBubbleImage *bubbleImage = [factory outgoingMessagesBubbleImageWithColor:[UIColor lightGrayColor]];
XCTAssertNotNil(bubbleImage, @"Bubble image should not be nil");
XCTAssertNotNil(imageView.highlightedImage, @"HighlightedImage should not be nil");
XCTAssertEqual(imageView.highlightedImage.scale, bubble.scale, @"HighlightedImage scale should equal bubble image scale");
XCTAssertEqual(imageView.highlightedImage.imageOrientation, UIImageOrientationUpMirrored, @"HighlightedImage orientation should be flipped");
XCTAssertTrue(imageView.highlightedImage.resizingMode == UIImageResizingModeStretch, @"HighlightedImage should be stretchable");
XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(imageView.highlightedImage.capInsets, capInsets), @"HighlightedImage capInsets should be equal to capInsets");
XCTAssertNotNil(bubbleImage.messageBubbleImage, "Image should not be nil");
XCTAssertEqual(bubbleImage.messageBubbleImage.scale, bubble.scale, @"Image scale should equal bubble image scale");
XCTAssertEqual(bubbleImage.messageBubbleImage.imageOrientation, bubble.imageOrientation, @"Image orientation should equal bubble image orientation");
XCTAssertTrue(bubbleImage.messageBubbleImage.resizingMode == UIImageResizingModeStretch, @"Image should be stretchable");
XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(bubbleImage.messageBubbleImage.capInsets, capInsets), @"Image capInsets should be equal to capInsets");
XCTAssertNotNil(bubbleImage.messageBubbleHighlightedImage, @"Highlighted image should not be nil");
XCTAssertEqual(bubbleImage.messageBubbleHighlightedImage.scale, bubble.scale, @"HighlightedImage scale should equal bubble image scale");
XCTAssertEqual(bubbleImage.messageBubbleHighlightedImage.imageOrientation, bubble.imageOrientation, @"HighlightedImage orientation should equal bubble image orientation");
XCTAssertTrue(bubbleImage.messageBubbleHighlightedImage.resizingMode == UIImageResizingModeStretch, @"HighlightedImage should be stretchable");
XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(bubbleImage.messageBubbleHighlightedImage.capInsets, capInsets), @"HighlightedImage capInsets should be equal to capInsets");
}
- (void)testCustomIncomingMessageBubbleImageView
{
UIImage *bubble = [UIImage jsq_bubbleRegularStrokedTaillessImage];
XCTAssertNotNil(bubble, @"Bubble image should not be nil");
UIEdgeInsets capInsets = UIEdgeInsetsMake(1, 1, 1, 1);
JSQMessagesBubbleImageFactory *factory = [[JSQMessagesBubbleImageFactory alloc] initWithBubbleImage:bubble capInsets:capInsets];
JSQMessagesBubbleImage *bubbleImage = [factory incomingMessagesBubbleImageWithColor:[UIColor lightGrayColor]];
XCTAssertNotNil(bubbleImage, @"Bubble image should not be nil");
XCTAssertNotNil(bubbleImage.messageBubbleImage, "Image should not be nil");
XCTAssertEqual(bubbleImage.messageBubbleImage.scale, bubble.scale, @"Image scale should equal bubble image scale");
XCTAssertEqual(bubbleImage.messageBubbleImage.imageOrientation, UIImageOrientationUpMirrored, @"Image orientation should be flipped");
XCTAssertTrue(bubbleImage.messageBubbleImage.resizingMode == UIImageResizingModeStretch, @"Image should be stretchable");
XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(bubbleImage.messageBubbleImage.capInsets, capInsets), @"Image capInsets should be equal to capInsets");
XCTAssertNotNil(bubbleImage.messageBubbleHighlightedImage, @"Highlighted image should not be nil");
XCTAssertEqual(bubbleImage.messageBubbleHighlightedImage.scale, bubble.scale, @"HighlightedImage scale should equal bubble image scale");
XCTAssertEqual(bubbleImage.messageBubbleHighlightedImage.imageOrientation, UIImageOrientationUpMirrored, @"Image orientation should be flipped");
XCTAssertTrue(bubbleImage.messageBubbleHighlightedImage.resizingMode == UIImageResizingModeStretch, @"HighlightedImage should be stretchable");
XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(bubbleImage.messageBubbleHighlightedImage.capInsets, capInsets), @"HighlightedImage capInsets should be equal to capInsets");
}
@end

View File

@ -0,0 +1,37 @@
//
// Created by Jesse Squires
// http://www.jessesquires.com
//
//
// MIT License
// Copyright (c) 2014 Jesse Squires
// http://opensource.org/licenses/MIT
//
#import <XCTest/XCTest.h>
#import "JSQMessagesMediaViewBubbleImageMasker.h"
@interface JSQMessagesMediaViewBubbleImageMaskerTests : XCTestCase
@end
@implementation JSQMessagesMediaViewBubbleImageMaskerTests
- (void)testMediaViewBubbleImageMasker
{
// GIVEN: a new masker object
JSQMessagesMediaViewBubbleImageMasker *masker = [[JSQMessagesMediaViewBubbleImageMasker alloc] init];
XCTAssertNotNil(masker);
// WHEN: we apply a mask to a view
UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
// THEN: it succeeds without an error
XCTAssertNoThrow([masker applyOutgoingBubbleImageMaskToMediaView:view1]);
XCTAssertNoThrow([masker applyIncomingBubbleImageMaskToMediaView:view2]);
}
@end

View File

@ -1,6 +1,6 @@
//
// Created by Jesse Squires
// http://www.hexedbits.com
// http://www.jessesquires.com
//
//
// MIT License
@ -9,7 +9,6 @@
//
#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>
#import "JSQMessagesTimestampFormatter.h"

View File

@ -1,6 +1,6 @@
//
// Created by Jesse Squires
// http://www.hexedbits.com
// http://www.jessesquires.com
//
//
// MIT License
@ -9,7 +9,6 @@
//
#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>
#import "JSQMessagesToolbarButtonFactory.h"
@ -17,56 +16,22 @@
@interface JSQMessagesToolbarButtonFactoryTests : XCTestCase
@end
@implementation JSQMessagesToolbarButtonFactoryTests
- (void)setUp
{
[super setUp];
}
- (void)tearDown
{
[super tearDown];
}
- (void)testDefaultSendButtonItem
{
UIButton *button = [JSQMessagesToolbarButtonFactory defaultSendButtonItem];
XCTAssertNotNil(button, @"Button should not be nil");
XCTAssertTrue(CGRectEqualToRect(button.frame, CGRectZero), @"Button initial frame should equal CGRectZero");
NSString *title = @"Send";
XCTAssertEqualObjects([button titleForState:UIControlStateNormal], title, @"Button title should equal %@", title);
XCTAssertNil(button.imageView.image, @"Button image should be nil");
XCTAssertEqualObjects([button titleColorForState:UIControlStateNormal], [UIColor jsq_messageBubbleBlueColor], @"Button normal title color should be set");
XCTAssertEqualObjects([button titleColorForState:UIControlStateHighlighted], [[UIColor jsq_messageBubbleBlueColor] jsq_colorByDarkeningColorWithValue:0.1f], @"Button highlighted title color should be set");
XCTAssertEqualObjects([button titleColorForState:UIControlStateDisabled], [UIColor lightGrayColor], @"Button disabled title color should be set");
XCTAssertEqualObjects(button.titleLabel.font, [UIFont boldSystemFontOfSize:17.0f], @"Button font should be set");
XCTAssertEqual(button.contentMode, UIViewContentModeCenter, @"Button content mode should be set");
XCTAssertEqualObjects(button.backgroundColor, [UIColor clearColor], @"Button background color should be set");
XCTAssertEqualObjects(button.tintColor, [UIColor jsq_messageBubbleBlueColor], @"Button tint color should be set");
}
- (void)testDefaultAccessoryButtonItem
{
UIButton *button = [JSQMessagesToolbarButtonFactory defaultAccessoryButtonItem];
XCTAssertNotNil(button, @"Button should not be nil");
XCTAssertTrue(CGRectEqualToRect(button.frame, CGRectZero), @"Button frame should equal CGRectZero");
XCTAssertNil(button.titleLabel.text, @"Button title should be nil");
XCTAssertNotNil([button imageForState:UIControlStateNormal], @"Button normal image should not be nil");
XCTAssertNotNil([button imageForState:UIControlStateHighlighted], @"Button highlighted image should not be nil");
XCTAssertEqual(button.contentMode, UIViewContentModeScaleAspectFit, @"Button content mode should be set");
XCTAssertEqualObjects(button.backgroundColor, [UIColor clearColor], @"Button background color should be set");
XCTAssertEqualObjects(button.tintColor, [UIColor lightGrayColor], @"Button tint color should be set");
}
@end

View File

@ -5,11 +5,13 @@
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>com.hexedbits.${PRODUCT_NAME:rfc1034identifier}</string>
<string>com.hexedbits.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>

View File

@ -1,6 +1,6 @@
//
// Created by Jesse Squires
// http://www.hexedbits.com
// http://www.jessesquires.com
//
//
// MIT License
@ -9,7 +9,6 @@
//
#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>
#import "JSQMessagesCollectionViewFlowLayout.h"

View File

@ -1,6 +1,6 @@
//
// Created by Jesse Squires
// http://www.hexedbits.com
// http://www.jessesquires.com
//
//
// MIT License
@ -9,7 +9,6 @@
//
#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>
#import "JSQMessagesCollectionViewLayoutAttributes.h"
@ -35,7 +34,7 @@
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:0 inSection:0];
JSQMessagesCollectionViewLayoutAttributes *attrs = [JSQMessagesCollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:indexPath];
attrs.messageBubbleFont = [UIFont systemFontOfSize:15.0f];
attrs.messageBubbleLeftRightMargin = 40.0f;
attrs.messageBubbleContainerViewWidth = 40.0f;
attrs.textViewTextContainerInsets = UIEdgeInsetsMake(10.0f, 8.0f, 10.0f, 8.0f);
attrs.textViewFrameInsets = UIEdgeInsetsMake(0.0f, 0.0f, 0.0f, 6.0f);
attrs.incomingAvatarViewSize = CGSizeMake(34.0f, 34.0f);

View File

@ -0,0 +1,64 @@
//
// Created by Jesse Squires
// http://www.jessesquires.com
//
//
// MIT License
// Copyright (c) 2014 Jesse Squires
// http://opensource.org/licenses/MIT
//
#import <XCTest/XCTest.h>
#import "JSQLocationMediaItem.h"
@interface JSQLocationMediaItemTests : XCTestCase
@property (strong, nonatomic) CLLocation *location;
@end
@implementation JSQLocationMediaItemTests
- (void)setUp
{
[super setUp];
self.location = [[CLLocation alloc] initWithLatitude:37.795313 longitude:-122.393757];
}
- (void)tearDown
{
self.location = nil;
[super tearDown];
}
- (void)testLocationItemInit
{
JSQLocationMediaItem *item = [[JSQLocationMediaItem alloc] initWithLocation:self.location];
XCTAssertNotNil(item);
}
- (void)testMediaDataProtocol
{
JSQLocationMediaItem *item = [[JSQLocationMediaItem alloc] init];
XCTAssertTrue(!CGSizeEqualToSize([item mediaViewDisplaySize], CGSizeZero));
XCTAssertNotNil([item mediaPlaceholderView]);
XCTAssertNil([item mediaView], @"Media view should be nil if location is nil");
XCTestExpectation *expectation = [self expectationWithDescription:[NSString stringWithFormat:@"%s", __PRETTY_FUNCTION__]];
[item setLocation:self.location withCompletionHandler:^{
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:5 handler:^(NSError *error) {
XCTAssertNil(error, @"Expectation should not error");
}];
XCTAssertNotNil([item mediaView], @"Media view should NOT be nil once item has media data");
}
@end

View File

@ -0,0 +1,112 @@
//
// Created by Jesse Squires
// http://www.jessesquires.com
//
//
// MIT License
// Copyright (c) 2014 Jesse Squires
// http://opensource.org/licenses/MIT
//
#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>
#import "JSQMessage.h"
// Fake media object for testing
@interface FakeMedia : NSObject <JSQMessageMediaData, NSCoding>
@end
@implementation FakeMedia
- (UIView *)mediaView { return [UIView new]; }
- (UIView *)mediaPlaceholderView { return [self mediaView]; }
- (CGSize)mediaViewDisplaySize { return CGSizeMake(50, 50); }
- (void)encodeWithCoder:(NSCoder *)aCoder { }
- (id)initWithCoder:(NSCoder *)aDecoder { return [self init]; }
- (BOOL)isEqual:(id)object { return YES; }
@end
@interface JSQMessageMediaTests : XCTestCase
@property (strong, nonatomic) NSString *senderId;
@property (strong, nonatomic) NSString *senderDisplayName;
@property (strong, nonatomic) NSDate *date;
@property (strong, nonatomic) id<JSQMessageMediaData> mockMediaData;
@end
@implementation JSQMessageMediaTests
- (void)setUp
{
[super setUp];
self.senderId = @"324543-43556-212343";
self.senderDisplayName = @"Jesse Squires";
self.date = [NSDate date];
self.mockMediaData = [OCMockObject mockForProtocol:@protocol(JSQMessageMediaData)];
}
- (void)tearDown
{
self.senderId = nil;
self.senderDisplayName = nil;
self.date = nil;
self.mockMediaData = nil;
[super tearDown];
}
- (void)testMediaMessageInit
{
JSQMessage *msg = [[JSQMessage alloc] initWithSenderId:self.senderId
senderDisplayName:self.senderDisplayName
date:self.date
media:self.mockMediaData];
XCTAssertNotNil(msg, @"Message should not be nil");
}
- (void)testMediaMessageInvalidInit
{
XCTAssertThrows([[JSQMessage alloc] init], @"Invalid init should throw");
XCTAssertThrows([[JSQMessage alloc] initWithSenderId:nil senderDisplayName:nil date:nil media:nil], @"Invalid init should throw");
}
- (void)testMediaMessageIsEqual
{
JSQMessage *msg = [[JSQMessage alloc] initWithSenderId:self.senderId
senderDisplayName:self.senderDisplayName
date:self.date
media:self.mockMediaData];
JSQMessage *copy = [msg copy];
XCTAssertEqualObjects(msg, copy, @"Copied messages should be equal");
XCTAssertEqual([msg hash], [copy hash], @"Copied messages hashes should be equal");
XCTAssertEqualObjects(msg, msg, @"Messages should be equal to itself");
}
- (void)testMediaMessageArchiving
{
JSQMessage *msg = [[JSQMessage alloc] initWithSenderId:self.senderId
senderDisplayName:self.senderDisplayName
date:self.date
media:[FakeMedia new]];
NSData *msgData = [NSKeyedArchiver archivedDataWithRootObject:msg];
JSQMessage *unarchivedMsg = [NSKeyedUnarchiver unarchiveObjectWithData:msgData];
XCTAssertEqualObjects(msg, unarchivedMsg, @"Message should be equal");
}
@end

View File

@ -1,90 +0,0 @@
//
// Created by Jesse Squires
// http://www.hexedbits.com
//
//
// MIT License
// Copyright (c) 2014 Jesse Squires
// http://opensource.org/licenses/MIT
//
#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>
#import "JSQMessage.h"
@interface JSQMessageTests : XCTestCase
@property (strong, nonatomic) NSString *text;
@property (strong, nonatomic) NSString *sender;
@property (strong, nonatomic) NSDate *date;
@end
@implementation JSQMessageTests
- (void)setUp
{
[super setUp];
self.text = @"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque"
@"laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi"
@"architecto beatae vitae dicta sunt explicabo.";
self.sender = @"Jesse Squires";
self.date = [NSDate date];
}
- (void)tearDown
{
self.text = nil;
self.sender = nil;
self.date = nil;
[super tearDown];
}
- (void)testMessageInit
{
JSQMessage *msg0 = [[JSQMessage alloc] initWithText:self.text sender:self.sender date:self.date];
XCTAssertNotNil(msg0, @"Message should not be nil");
JSQMessage *msg1 = [JSQMessage messageWithText:self.text sender:self.sender];
XCTAssertNotNil(msg1, @"Message shold not be nil");
}
- (void)testMessageInvalidInit
{
XCTAssertThrows([JSQMessage messageWithText:nil sender:nil], @"Invalid init should throw");
XCTAssertThrows([JSQMessage messageWithText:self.text sender:nil], @"Invalid init should throw");
XCTAssertThrows([JSQMessage messageWithText:nil sender:self.sender], @"Invalid init should throw");
XCTAssertThrows([[JSQMessage alloc] initWithText:nil sender:nil date:nil], @"Invalid init should throw");
XCTAssertThrows([[JSQMessage alloc] initWithText:self.text sender:nil date:nil], @"Invalid init should throw");
XCTAssertThrows([[JSQMessage alloc] initWithText:nil sender:self.sender date:nil], @"Invalid init should throw");
XCTAssertThrows([[JSQMessage alloc] initWithText:nil sender:nil date:self.date], @"Invalid init should throw");
}
- (void)testMessageIsEqual
{
JSQMessage *msg = [JSQMessage messageWithText:self.text sender:self.sender];
JSQMessage *copy = [msg copy];
XCTAssertEqualObjects(msg, copy, @"Copied messages should be equal");
XCTAssertEqual([msg hash], [copy hash], @"Copied messages hashes should be equal");
XCTAssertTrue([msg isEqualToMessage:copy], @"Copied messages should be equal");
XCTAssertTrue([msg isEqualToMessage:msg], @"Messages should be equal to itself");
XCTAssertFalse([msg isEqualToMessage:nil], @"Initialized message should not be equal to nil");
}
- (void)testMessageArchiving
{
JSQMessage *msg = [JSQMessage messageWithText:self.text sender:self.sender];
NSData *msgData = [NSKeyedArchiver archivedDataWithRootObject:msg];
JSQMessage *unarchivedMsg = [NSKeyedUnarchiver unarchiveObjectWithData:msgData];
XCTAssertTrue([msg isEqualToMessage:unarchivedMsg], @"Message should be equal");
}
@end

View File

@ -0,0 +1,95 @@
//
// Created by Jesse Squires
// http://www.jessesquires.com
//
//
// MIT License
// Copyright (c) 2014 Jesse Squires
// http://opensource.org/licenses/MIT
//
#import <XCTest/XCTest.h>
#import "JSQMessage.h"
@interface JSQMessageTextTests : XCTestCase
@property (strong, nonatomic) NSString *senderId;
@property (strong, nonatomic) NSString *senderDisplayName;
@property (strong, nonatomic) NSDate *date;
@property (strong, nonatomic) NSString *text;
@end
@implementation JSQMessageTextTests
- (void)setUp
{
[super setUp];
self.senderId = @"324543-43556-212343";
self.senderDisplayName = @"Jesse Squires";
self.date = [NSDate date];
self.text = @"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque"
@"laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi"
@"architecto beatae vitae dicta sunt explicabo.";
}
- (void)tearDown
{
self.senderId = nil;
self.senderDisplayName = nil;
self.date = nil;
self.text = nil;
[super tearDown];
}
#pragma mark - Text messages
- (void)testTextMessageInit
{
JSQMessage *msg = [[JSQMessage alloc] initWithSenderId:self.senderId
senderDisplayName:self.senderDisplayName
date:self.date
text:self.text];
XCTAssertNotNil(msg, @"Message should not be nil");
}
- (void)testTextMessageInvalidInit
{
XCTAssertThrows([[JSQMessage alloc] init], @"Invalid init should throw");
XCTAssertThrows([[JSQMessage alloc] initWithSenderId:nil senderDisplayName:nil date:nil text:nil], @"Invalid init should throw");
}
- (void)testTextMessageIsEqual
{
JSQMessage *msg = [[JSQMessage alloc] initWithSenderId:self.senderId
senderDisplayName:self.senderDisplayName
date:self.date
text:self.text];
JSQMessage *copy = [msg copy];
XCTAssertEqualObjects(msg, copy, @"Copied messages should be equal");
XCTAssertEqual([msg hash], [copy hash], @"Copied messages hashes should be equal");
XCTAssertEqualObjects(msg, msg, @"Messages should be equal to itself");
}
- (void)testTextMessageArchiving
{
JSQMessage *msg = [[JSQMessage alloc] initWithSenderId:self.senderId
senderDisplayName:self.senderDisplayName
date:self.date
text:self.text];
NSData *msgData = [NSKeyedArchiver archivedDataWithRootObject:msg];
JSQMessage *unarchivedMsg = [NSKeyedUnarchiver unarchiveObjectWithData:msgData];
XCTAssertEqualObjects(msg, unarchivedMsg, @"Message should be equal");
}
@end

View File

@ -0,0 +1,75 @@
//
// Created by Jesse Squires
// http://www.jessesquires.com
//
//
// MIT License
// Copyright (c) 2014 Jesse Squires
// http://opensource.org/licenses/MIT
//
#import <XCTest/XCTest.h>
#import "JSQMessagesAvatarImage.h"
@interface JSQMessagesAvatarImageTests : XCTestCase
@end
@implementation JSQMessagesAvatarImageTests
- (void)setUp
{
[super setUp];
}
- (void)tearDown
{
[super tearDown];
}
- (void)testInitInvalid
{
XCTAssertThrows([[JSQMessagesAvatarImage alloc] init], @"Invalid init should throw");
XCTAssertThrows([JSQMessagesAvatarImage avatarImageWithPlaceholder:nil], @"Invalid init should throw");
XCTAssertThrows([[JSQMessagesAvatarImage alloc] initWithAvatarImage:nil highlightedImage:nil placeholderImage:nil], @"Invalid init should throw");
}
- (void)testInitValid
{
UIImage *mockImage = [UIImage imageNamed:@"demo_avatar_jobs"];
JSQMessagesAvatarImage *avatar = [JSQMessagesAvatarImage avatarImageWithPlaceholder:mockImage];
XCTAssertNotNil(avatar, @"Valid init should succeed");
JSQMessagesAvatarImage *avatar2 = [JSQMessagesAvatarImage avatarWithImage:mockImage];
XCTAssertNotNil(avatar2, @"Valid init should succeed");
XCTAssertEqualObjects(avatar2.avatarImage, avatar2.avatarHighlightedImage);
XCTAssertEqualObjects(avatar2.avatarHighlightedImage, avatar2.avatarPlaceholderImage);
}
- (void)testCopy
{
UIImage *mockImage = [UIImage imageNamed:@"demo_avatar_jobs"];
JSQMessagesAvatarImage *avatar = [[JSQMessagesAvatarImage alloc] initWithAvatarImage:mockImage
highlightedImage:mockImage
placeholderImage:mockImage];
JSQMessagesAvatarImage *copy = [avatar copy];
XCTAssertNotNil(copy, @"Copy should succeed");
XCTAssertFalse(avatar == copy, @"Copy should return new, distinct instance");
XCTAssertNotEqualObjects(avatar.avatarImage, copy.avatarImage, @"Images should not be equal");
XCTAssertNotEqual(avatar.avatarImage, copy.avatarImage, @"Images should not be equal");
XCTAssertNotEqualObjects(avatar.avatarHighlightedImage, copy.avatarHighlightedImage, @"Images should not be equal");
XCTAssertNotEqual(avatar.avatarHighlightedImage, copy.avatarHighlightedImage, @"Images should not be equal");
XCTAssertNotEqualObjects(avatar.avatarPlaceholderImage, copy.avatarPlaceholderImage, @"Images should not be equal");
XCTAssertNotEqual(avatar.avatarPlaceholderImage, copy.avatarPlaceholderImage, @"Images should not be equal");
}
@end

View File

@ -0,0 +1,65 @@
//
// Created by Jesse Squires
// http://www.jessesquires.com
//
//
// MIT License
// Copyright (c) 2014 Jesse Squires
// http://opensource.org/licenses/MIT
//
#import <XCTest/XCTest.h>
#import "JSQMessagesBubbleImage.h"
#import "UIImage+JSQMessages.h"
@interface JSQMessagesBubbleImageTests : XCTestCase
@end
@implementation JSQMessagesBubbleImageTests
- (void)setUp
{
[super setUp];
}
- (void)tearDown
{
[super tearDown];
}
- (void)testInitInvalid
{
XCTAssertThrows([[JSQMessagesBubbleImage alloc] init], @"Invalid init should throw");
XCTAssertThrows([[JSQMessagesBubbleImage alloc] initWithMessageBubbleImage:nil highlightedImage:nil], @"Invalid init should throw");
}
- (void)testInitValid
{
UIImage *mockImage = [UIImage jsq_bubbleCompactImage];
JSQMessagesBubbleImage *bubbleImage = [[JSQMessagesBubbleImage alloc] initWithMessageBubbleImage:mockImage highlightedImage:mockImage];
XCTAssertNotNil(bubbleImage, @"Valid init should succeed");
}
- (void)testCopy
{
UIImage *mockImage = [UIImage jsq_bubbleCompactImage];
JSQMessagesBubbleImage *bubbleImage = [[JSQMessagesBubbleImage alloc] initWithMessageBubbleImage:mockImage highlightedImage:mockImage];
JSQMessagesBubbleImage *copy = [bubbleImage copy];
XCTAssertNotNil(copy, @"Copy should succeed");
XCTAssertFalse(bubbleImage == copy, @"Copy should return new, distinct instance");
XCTAssertNotEqualObjects(bubbleImage.messageBubbleImage, copy.messageBubbleImage, @"Images should not be equal");
XCTAssertNotEqual(bubbleImage.messageBubbleImage, copy.messageBubbleImage, @"Images should not be equal");
XCTAssertNotEqualObjects(bubbleImage.messageBubbleHighlightedImage, copy.messageBubbleHighlightedImage, @"Images should not be equal");
XCTAssertNotEqual(bubbleImage.messageBubbleHighlightedImage, copy.messageBubbleHighlightedImage, @"Images should not be equal");
}
@end

View File

@ -0,0 +1,76 @@
//
// Created by Jesse Squires
// http://www.jessesquires.com
//
//
// MIT License
// Copyright (c) 2014 Jesse Squires
// http://opensource.org/licenses/MIT
//
#import <XCTest/XCTest.h>
#import "JSQPhotoMediaItem.h"
@interface JSQPhotoMediaItemTests : XCTestCase
@end
@implementation JSQPhotoMediaItemTests
- (void)setUp
{
[super setUp];
}
- (void)tearDown
{
[super tearDown];
}
- (void)testPhotoItemInit
{
JSQPhotoMediaItem *item = [[JSQPhotoMediaItem alloc] initWithImage:[UIImage new]];
XCTAssertNotNil(item);
}
- (void)testPhotoItemIsEqual
{
JSQPhotoMediaItem *item = [[JSQPhotoMediaItem alloc] initWithImage:[UIImage imageNamed:@"demo_avatar_jobs"]];
JSQPhotoMediaItem *copy = [item copy];
XCTAssertEqualObjects(item, copy, @"Copied items should be equal");
XCTAssertEqual([item hash], [copy hash], @"Copied item hashes should be equal");
XCTAssertEqualObjects(item, item, @"Item should be equal to itself");
}
- (void)testPhotoItemArchiving
{
JSQPhotoMediaItem *item = [[JSQPhotoMediaItem alloc] initWithImage:[UIImage new]];
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:item];
JSQPhotoMediaItem *unarchivedItem = [NSKeyedUnarchiver unarchiveObjectWithData:data];
XCTAssertEqualObjects(item, unarchivedItem);
}
- (void)testMediaDataProtocol
{
JSQPhotoMediaItem *item = [[JSQPhotoMediaItem alloc] initWithImage:nil];
XCTAssertTrue(!CGSizeEqualToSize([item mediaViewDisplaySize], CGSizeZero));
XCTAssertNotNil([item mediaPlaceholderView]);
XCTAssertNil([item mediaView], @"Media view should be nil if image is nil");
item.image = [UIImage imageNamed:@"demo_avatar_jobs"];
XCTAssertNotNil([item mediaView], @"Media view should NOT be nil once item has media data");
}
@end

View File

@ -0,0 +1,77 @@
//
// Created by Jesse Squires
// http://www.jessesquires.com
//
//
// MIT License
// Copyright (c) 2014 Jesse Squires
// http://opensource.org/licenses/MIT
//
#import <XCTest/XCTest.h>
#import "JSQVideoMediaItem.h"
@interface JSQVideoMediaItemTests : XCTestCase
@end
@implementation JSQVideoMediaItemTests
- (void)setUp
{
[super setUp];
}
- (void)tearDown
{
[super tearDown];
}
- (void)testVideoMediaItemInit
{
JSQVideoMediaItem *item = [[JSQVideoMediaItem alloc] initWithFileURL:[NSURL URLWithString:@"file://"] isReadyToPlay:NO];
XCTAssertNotNil(item);
}
- (void)testVideoItemIsEqual
{
JSQVideoMediaItem *item = [[JSQVideoMediaItem alloc] initWithFileURL:[NSURL URLWithString:@"file://"] isReadyToPlay:YES];
JSQVideoMediaItem *copy = [item copy];
XCTAssertEqualObjects(item, copy, @"Copied items should be equal");
XCTAssertEqual([item hash], [copy hash], @"Copied item hashes should be equal");
XCTAssertEqualObjects(item, item, @"Item should be equal to itself");
}
- (void)testVideoItemArchiving
{
JSQVideoMediaItem *item = [[JSQVideoMediaItem alloc] initWithFileURL:[NSURL URLWithString:@"file://"] isReadyToPlay:YES];
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:item];
JSQVideoMediaItem *unarchivedItem = [NSKeyedUnarchiver unarchiveObjectWithData:data];
XCTAssertEqualObjects(item, unarchivedItem);
}
- (void)testMediaDataProtocol
{
JSQVideoMediaItem *item = [[JSQVideoMediaItem alloc] init];
XCTAssertTrue(!CGSizeEqualToSize([item mediaViewDisplaySize], CGSizeZero));
XCTAssertNotNil([item mediaPlaceholderView]);
XCTAssertNil([item mediaView], @"Media view should be nil if fileURL is nil, and readyToPlay is NO");
item.fileURL = [NSURL URLWithString:@"file://"];
item.isReadyToPlay = YES;
XCTAssertNotNil([item mediaView], @"Media view should NOT be nil once item has media data");
}
@end

View File

@ -1,6 +1,6 @@
//
// Created by Jesse Squires
// http://www.hexedbits.com
// http://www.jessesquires.com
//
//
// MIT License
@ -9,7 +9,6 @@
//
#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>
#import "JSQMessagesCollectionViewCellIncoming.h"
#import "JSQMessagesCollectionViewCellOutgoing.h"
@ -31,19 +30,24 @@
[super tearDown];
}
- (void)testMessagesCollectionViewCellInit
- (void)testMessagesIncomingCollectionViewCellInit
{
UINib *incomingCell = [JSQMessagesCollectionViewCellIncoming nib];
XCTAssertNotNil(incomingCell, @"Nib should not be nil");
NSString *incomingCellId = [JSQMessagesCollectionViewCellIncoming cellReuseIdentifier];
XCTAssertNotNil(incomingCellId, @"Cell identifier should not be nil");
XCTAssertEqualObjects(incomingCellId, NSStringFromClass([JSQMessagesCollectionViewCellIncoming class]));
}
- (void)testMessagesOutgoingCollectionViewCellInit
{
UINib *outgoingCell = [JSQMessagesCollectionViewCellOutgoing nib];
XCTAssertNotNil(outgoingCell, @"Nib should not be nil");
NSString *outgoingCellId = [JSQMessagesCollectionViewCellOutgoing cellReuseIdentifier];
XCTAssertNotNil(outgoingCellId, @"Cell identifier should not be nil");
XCTAssertEqualObjects(outgoingCellId, NSStringFromClass([JSQMessagesCollectionViewCellOutgoing class]));
}
@end

View File

@ -1,6 +1,6 @@
//
// Created by Jesse Squires
// http://www.hexedbits.com
// http://www.jessesquires.com
//
//
// MIT License
@ -9,7 +9,6 @@
//
#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>
#import "JSQMessagesCollectionView.h"
#import "JSQMessagesCollectionViewFlowLayout.h"

View File

@ -1,6 +1,6 @@
//
// Created by Jesse Squires
// http://www.hexedbits.com
// http://www.jessesquires.com
//
//
// MIT License
@ -9,7 +9,6 @@
//
#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>
#import "JSQMessagesComposerTextView.h"
@ -55,7 +54,7 @@
XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(self.textView.scrollIndicatorInsets, UIEdgeInsetsMake(6.0f, 0.0f, 6.0f, 0.0f)), @"Property should be equal to default value");
XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(self.textView.textContainerInset, UIEdgeInsetsMake(4.0f, 2.0f, 4.0f, 2.0f)), @"Property should be equal to default value");
XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(self.textView.contentInset, UIEdgeInsetsMake(2.0f, 0.0f, 2.0f, 0.0f)), @"Property should be equal to default value");
XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(self.textView.contentInset, UIEdgeInsetsMake(1.0f, 0.0f, 1.0f, 0.0f)), @"Property should be equal to default value");
XCTAssertEqual(self.textView.scrollEnabled, YES, @"Property should be equal to default value");
XCTAssertEqual(self.textView.scrollsToTop, NO, @"Property should be equal to default value");

View File

@ -1,6 +1,6 @@
//
// Created by Jesse Squires
// http://www.hexedbits.com
// http://www.jessesquires.com
//
//
// MIT License
@ -9,7 +9,6 @@
//
#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>
#import "JSQMessagesViewController.h"
#import "JSQMessagesInputToolbar.h"

3
JSQMessagesTests/ViewTests/JSQMessagesLabelTests.m Executable file → Normal file
View File

@ -1,6 +1,6 @@
//
// Created by Jesse Squires
// http://www.hexedbits.com
// http://www.jessesquires.com
//
//
// MIT License
@ -9,7 +9,6 @@
//
#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>
#import "JSQMessagesLabel.h"

Some files were not shown because too many files have changed in this diff Show More