Compare commits
167 Commits
version_5.
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
26fb5cbcf4 | ||
|
|
c8262eee36 | ||
|
|
184f53b07b | ||
|
|
ed9858bd6d | ||
|
|
9dffc05aa7 | ||
|
|
cb5c4facbc | ||
|
|
84d1b659f3 | ||
|
|
b73b5d9983 | ||
|
|
6a30411791 | ||
|
|
395b1342a9 | ||
|
|
ea3b8cc6fc | ||
|
|
697c839c80 | ||
|
|
d6c9dd0ce9 | ||
|
|
16c42a11e5 | ||
|
|
9980266b62 | ||
|
|
38c14c19e7 | ||
|
|
736d110eba | ||
|
|
7c57677738 | ||
|
|
69e2518345 | ||
|
|
3a50f7f9c2 | ||
|
|
6e4857ab8d | ||
|
|
260e51ce2c | ||
|
|
a81bfa2277 | ||
|
|
847f49e6e7 | ||
|
|
8703ce020c | ||
|
|
7d8cd7b867 | ||
|
|
8d9f241038 | ||
|
|
fcbbfdc43f | ||
|
|
66fb14161d | ||
|
|
bc976a04d9 | ||
|
|
4ab13ad7ac | ||
|
|
d5f8d4291b | ||
|
|
43f6e75bbf | ||
|
|
59ea2b6920 | ||
|
|
dee758a3ff | ||
|
|
17153bdd38 | ||
|
|
82482a1fc5 | ||
|
|
442b597c95 | ||
|
|
1bb258691b | ||
|
|
7c2cec63f9 | ||
|
|
91fbb4dce7 | ||
|
|
681b6d329b | ||
|
|
0d8fabe142 | ||
|
|
4049f54789 | ||
|
|
54ae40b07a | ||
|
|
bcf0ac6e1f | ||
|
|
e70cec697f | ||
|
|
7234f10f81 | ||
|
|
fd7f27b74b | ||
|
|
b22b7a4caf | ||
|
|
b8b3fb9122 | ||
|
|
5fc12f5cba | ||
|
|
4cad607ae2 | ||
|
|
276e9f94a6 | ||
|
|
6a04d7585d | ||
|
|
28b17896cc | ||
|
|
8f28bc513e | ||
|
|
512d2a9394 | ||
|
|
81488d5ee6 | ||
|
|
08ebf9b608 | ||
|
|
56f0d40214 | ||
|
|
5d83de37cd | ||
|
|
2626e8419b | ||
|
|
597670e446 | ||
|
|
881ddddeb4 | ||
|
|
32395453ff | ||
|
|
5c6dce5a04 | ||
|
|
3d248e4af0 | ||
|
|
6bbef1949b | ||
|
|
1031a89858 | ||
|
|
21d877492e | ||
|
|
5670accd2c | ||
|
|
d138d4f3a3 | ||
|
|
cddbbf2c75 | ||
|
|
104ba0e023 | ||
|
|
a27fa1091e | ||
|
|
a7a9cd7c64 | ||
|
|
7446b63cbb | ||
|
|
73482f6ace | ||
|
|
2dad6e3036 | ||
|
|
b20af9e524 | ||
|
|
5ba9d2ee09 | ||
|
|
fe0540167b | ||
|
|
45ce02baa6 | ||
|
|
7722bce9d8 | ||
|
|
ea74142adb | ||
|
|
ae9869d7ff | ||
|
|
36b066fbdc | ||
|
|
387a7544b3 | ||
|
|
484a4b59bd | ||
|
|
f6e96e9a07 | ||
|
|
cdc86cc0a3 | ||
|
|
03b74fe77e | ||
|
|
280ff293f1 | ||
|
|
3b8cf0fa35 | ||
|
|
591e9198bb | ||
|
|
0d20dadb8e | ||
|
|
72a4b5b970 | ||
|
|
b291898161 | ||
|
|
5627228464 | ||
|
|
4281751534 | ||
|
|
c81aa93726 | ||
|
|
468e102a7c | ||
|
|
b3a80d9afc | ||
|
|
dbfe58fc6d | ||
|
|
2070cde22d | ||
|
|
e99b127694 | ||
|
|
08a9ec95fa | ||
|
|
0d8667d14e | ||
|
|
5c8dee520c | ||
|
|
42c29ce4a1 | ||
|
|
66a7d47ff3 | ||
|
|
049035cdb6 | ||
|
|
4aedb062cc | ||
|
|
c0edc6f7aa | ||
|
|
9b579e91b9 | ||
|
|
e88501ed61 | ||
|
|
49f2c24533 | ||
|
|
74965225f0 | ||
|
|
99971a8d38 | ||
|
|
da7203dee2 | ||
|
|
88e16ac830 | ||
|
|
41dddfea3a | ||
|
|
ebea4ef0b8 | ||
|
|
f115194efa | ||
|
|
39393e4b8b | ||
|
|
06e7c2bec9 | ||
|
|
6dded2cce9 | ||
|
|
f03bac13a0 | ||
|
|
33b81ca6b0 | ||
|
|
752edc4f0f | ||
|
|
71acc85bb4 | ||
|
|
3868620d62 | ||
|
|
58e4ac6624 | ||
|
|
b5b6e8c2af | ||
|
|
065d60d997 | ||
|
|
3f0f52f704 | ||
|
|
188ab824b8 | ||
|
|
e2b62c4996 | ||
|
|
1af170b983 | ||
|
|
b590303a4f | ||
|
|
a38125e726 | ||
|
|
b75870a241 | ||
|
|
d4a5bc6d09 | ||
|
|
da92497d42 | ||
|
|
6f7f318bcd | ||
|
|
45549628ae | ||
|
|
02fdee07d0 | ||
|
|
005378f8f3 | ||
|
|
0638d8caf2 | ||
|
|
a023fee709 | ||
|
|
f201b085e3 | ||
|
|
a56ceebdd3 | ||
|
|
f914b81044 | ||
|
|
639df113ff | ||
|
|
3954411213 | ||
|
|
3e8a3cbfc1 | ||
|
|
833cf417f5 | ||
|
|
3684895342 | ||
|
|
dee7714d9e | ||
|
|
dd9458a70f | ||
|
|
d85c94e57f | ||
|
|
454be29f8d | ||
|
|
d0fd6e58ec | ||
|
|
3b159c1df9 | ||
|
|
33e780e535 | ||
|
|
ddca80232a |
0
Assets/JSQmessages.png
Executable file → Normal 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
|
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
0
Assets/jsq_messages_banner.png
Executable file → Normal file
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
0
Assets/jsq_messages_banner.psd
Executable file → Normal file
0
Assets/jsq_messages_icon.psd
Executable file → Normal file
0
Assets/jsq_messages_splash.psd
Executable file → Normal file
0
Assets/jsq_messages_splash_ipad.psd
Executable file → Normal file
0
CONTRIBUTING.md
Executable file → Normal file
4645
JSQMessages.xcodeproj/project.pbxproj
Executable file → Normal file
0
JSQMessages.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Executable file → Normal 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>
|
||||
16
JSQMessages.xcodeproj/xcshareddata/xcschemes/JSQMessages.xcscheme
Executable file → Normal 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
@ -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>
|
||||
|
||||
@ -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>
|
||||
5
JSQMessagesDemo/JSQAppDelegate.h → JSQMessagesDemo/AppDelegate.h
Executable file → Normal 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;
|
||||
|
||||
13
JSQMessagesDemo/JSQAppDelegate.m → JSQMessagesDemo/AppDelegate.m
Executable file → Normal 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
@ -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"/>
|
||||
|
||||
21
JSQMessagesDemo/JSQDemoViewController.h → JSQMessagesDemo/DemoMessagesViewController.h
Executable file → Normal 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
|
||||
584
JSQMessagesDemo/DemoMessagesViewController.m
Normal 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
|
||||
61
JSQMessagesDemo/DemoModelData.h
Normal 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
|
||||
236
JSQMessagesDemo/DemoModelData.m
Normal 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
|
||||
42
JSQMessagesDemo/DemoSettingsViewController.h
Normal 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
|
||||
72
JSQMessagesDemo/DemoSettingsViewController.m
Normal 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
|
||||
18
JSQMessagesDemo/Images.xcassets/AppIcon.appiconset/Contents.json
Executable file → Normal 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",
|
||||
|
||||
|
After Width: | Height: | Size: 2.2 KiB |
0
JSQMessagesDemo/Images.xcassets/AppIcon.appiconset/Icon-120.png
Executable file → Normal file
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
BIN
JSQMessagesDemo/Images.xcassets/AppIcon.appiconset/Icon-180.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
0
JSQMessagesDemo/Images.xcassets/AppIcon.appiconset/Icon-76.png
Executable file → Normal file
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
0
JSQMessagesDemo/Images.xcassets/AppIcon.appiconset/Icon-76@2x.png
Executable file → Normal file
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
BIN
JSQMessagesDemo/Images.xcassets/AppIcon.appiconset/Icon-87.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
0
JSQMessagesDemo/Images.xcassets/AppIcon.appiconset/Icon-Small.png
Executable file → Normal file
|
Before Width: | Height: | Size: 760 B After Width: | Height: | Size: 760 B |
0
JSQMessagesDemo/Images.xcassets/AppIcon.appiconset/Icon-Small@2x-1.png
Executable file → Normal file
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
0
JSQMessagesDemo/Images.xcassets/AppIcon.appiconset/Icon-Small@2x.png
Executable file → Normal file
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
0
JSQMessagesDemo/Images.xcassets/AppIcon.appiconset/Icon-Spotlight-iOS7.png
Executable file → Normal file
|
Before Width: | Height: | Size: 947 B After Width: | Height: | Size: 947 B |
0
JSQMessagesDemo/Images.xcassets/AppIcon.appiconset/Icon-Spotlight-iOS7@2x-1.png
Executable file → Normal file
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
0
JSQMessagesDemo/Images.xcassets/AppIcon.appiconset/Icon-Spotlight-iOS7@2x.png
Executable file → Normal file
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
5
JSQMessagesDemo/Images.xcassets/DemoAvatars/demo_avatar_cook.imageset/Contents.json
vendored
Executable file → Normal 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" : {
|
||||
|
||||
BIN
JSQMessagesDemo/Images.xcassets/DemoAvatars/demo_avatar_cook.imageset/demo_avatar_cook.png
vendored
Executable file → Normal file
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 6.6 KiB |
BIN
JSQMessagesDemo/Images.xcassets/DemoAvatars/demo_avatar_cook.imageset/demo_avatar_cook@2x.png
vendored
Executable file → Normal file
|
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 22 KiB |
BIN
JSQMessagesDemo/Images.xcassets/DemoAvatars/demo_avatar_cook.imageset/demo_avatar_cook@3x.png
vendored
Normal file
|
After Width: | Height: | Size: 68 KiB |
5
JSQMessagesDemo/Images.xcassets/DemoAvatars/demo_avatar_jobs.imageset/Contents.json
vendored
Executable file → Normal 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" : {
|
||||
|
||||
BIN
JSQMessagesDemo/Images.xcassets/DemoAvatars/demo_avatar_jobs.imageset/demo_avatar_jobs.png
vendored
Executable file → Normal file
|
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 1.9 KiB |
BIN
JSQMessagesDemo/Images.xcassets/DemoAvatars/demo_avatar_jobs.imageset/demo_avatar_jobs@2x.png
vendored
Executable file → Normal file
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 5.8 KiB |
BIN
JSQMessagesDemo/Images.xcassets/DemoAvatars/demo_avatar_jobs.imageset/demo_avatar_jobs@3x.png
vendored
Normal file
|
After Width: | Height: | Size: 20 KiB |
5
JSQMessagesDemo/Images.xcassets/DemoAvatars/demo_avatar_woz.imageset/Contents.json
vendored
Executable file → Normal 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" : {
|
||||
|
||||
BIN
JSQMessagesDemo/Images.xcassets/DemoAvatars/demo_avatar_woz.imageset/demo_avatar_woz.png
vendored
Executable file → Normal file
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 6.1 KiB |
BIN
JSQMessagesDemo/Images.xcassets/DemoAvatars/demo_avatar_woz.imageset/demo_avatar_woz@2x.png
vendored
Executable file → Normal file
|
Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 19 KiB |
BIN
JSQMessagesDemo/Images.xcassets/DemoAvatars/demo_avatar_woz.imageset/demo_avatar_woz@3x.png
vendored
Normal file
|
After Width: | Height: | Size: 65 KiB |
27
JSQMessagesDemo/Images.xcassets/LaunchImage.launchimage/Contents.json
Executable file → Normal 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",
|
||||
|
||||
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 42 KiB |
0
JSQMessagesDemo/Images.xcassets/LaunchImage.launchimage/jsq_messages_splash_ipad.png
Executable file → Normal file
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
0
JSQMessagesDemo/Images.xcassets/LaunchImage.launchimage/jsq_messages_splash_ipad@2x.png
Executable file → Normal file
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
0
JSQMessagesDemo/Images.xcassets/LaunchImage.launchimage/jsq_messages_splash_ipad@2x~landscape.png
Executable file → Normal file
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
0
JSQMessagesDemo/Images.xcassets/LaunchImage.launchimage/jsq_messages_splash_ipad~landscape.png
Executable file → Normal file
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
0
JSQMessagesDemo/Images.xcassets/LaunchImage.launchimage/slpash_iphone4inch.png
Executable file → Normal file
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
0
JSQMessagesDemo/Images.xcassets/LaunchImage.launchimage/splash_iphone35inch.png
Executable file → Normal file
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
23
JSQMessagesDemo/Images.xcassets/goldengate.imageset/Contents.json
vendored
Normal 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"
|
||||
}
|
||||
}
|
||||
BIN
JSQMessagesDemo/Images.xcassets/goldengate.imageset/goldengate.png
vendored
Normal file
|
After Width: | Height: | Size: 176 KiB |
BIN
JSQMessagesDemo/Images.xcassets/goldengate.imageset/goldengate@2x.png
vendored
Normal file
|
After Width: | Height: | Size: 196 KiB |
BIN
JSQMessagesDemo/Images.xcassets/goldengate.imageset/goldengate@3x.png
vendored
Normal file
|
After Width: | Height: | Size: 651 KiB |
16
JSQMessagesDemo/JSQMessages-Info.plist → JSQMessagesDemo/Info.plist
Executable file → Normal 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>
|
||||
@ -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
|
||||
@ -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
|
||||
41
JSQMessagesDemo/NSUserDefaults+DemoSettings.h
Normal 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
|
||||
91
JSQMessagesDemo/NSUserDefaults+DemoSettings.m
Normal 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
|
||||
7
JSQMessagesDemo/JSQTableViewController.h → JSQMessagesDemo/TableViewController.h
Executable file → Normal 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;
|
||||
|
||||
46
JSQMessagesDemo/JSQTableViewController.m → JSQMessagesDemo/TableViewController.m
Executable file → Normal 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];
|
||||
}
|
||||
BIN
JSQMessagesDemo/call_missed@2x.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
@ -1,2 +0,0 @@
|
||||
/* Localized versions of Info.plist keys */
|
||||
|
||||
6
JSQMessagesDemo/main.m
Executable file → Normal 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]));
|
||||
}
|
||||
}
|
||||
|
||||
16
JSQMessagesTests/CategoryTests/JSQMessagesNSStringTests.m
Executable file → Normal 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");
|
||||
|
||||
62
JSQMessagesTests/CategoryTests/JSQMessagesUIColorTests.m
Executable file → Normal 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");
|
||||
|
||||
45
JSQMessagesTests/CategoryTests/JSQMessagesUIImageTests.m
Executable file → Normal 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
@ -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");
|
||||
|
||||
|
||||
3
JSQMessagesTests/ControllerTests/JSQMessagesKeyboardControllerTests.m
Executable file → Normal 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"
|
||||
|
||||
|
||||
19
JSQMessagesTests/ControllerTests/JSQMessagesViewControllerTests.m
Executable file → Normal 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");
|
||||
|
||||
@ -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
|
||||
@ -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
|
||||
112
JSQMessagesTests/FactoryTests/JSQMessagesBubbleImageFactoryTests.m
Executable file → Normal 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
|
||||
|
||||
@ -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
|
||||
3
JSQMessagesTests/FactoryTests/JSQMessagesTimestampFormatterTests.m
Executable file → Normal 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"
|
||||
|
||||
|
||||
39
JSQMessagesTests/FactoryTests/JSQMessagesToolbarButtonFactoryTests.m
Executable file → Normal 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
|
||||
|
||||
6
JSQMessagesTests/JSQMessagesTests-Info.plist → JSQMessagesTests/Info.plist
Executable file → Normal 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>
|
||||
3
JSQMessagesTests/LayoutTests/JSQMessagesCollectionViewFlowLayoutTests.m
Executable file → Normal 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"
|
||||
|
||||
|
||||
5
JSQMessagesTests/LayoutTests/JSQMessagesCollectionViewLayoutAttributesTests.m
Executable file → Normal 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);
|
||||
|
||||
64
JSQMessagesTests/ModelTests/JSQLocationMediaItemTests.m
Normal 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
|
||||
112
JSQMessagesTests/ModelTests/JSQMessageMediaTests.m
Normal 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
|
||||
@ -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
|
||||
95
JSQMessagesTests/ModelTests/JSQMessageTextTests.m
Normal 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
|
||||
75
JSQMessagesTests/ModelTests/JSQMessagesAvatarImageTests.m
Normal 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
|
||||
65
JSQMessagesTests/ModelTests/JSQMessagesBubbleImageTests.m
Normal 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
|
||||
76
JSQMessagesTests/ModelTests/JSQPhotoMediaItemTests.m
Normal 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
|
||||
77
JSQMessagesTests/ModelTests/JSQVideoMediaItemTests.m
Normal 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
|
||||
12
JSQMessagesTests/ViewTests/JSQMessagesCollectionViewCellTests.m
Executable file → Normal 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
|
||||
|
||||
3
JSQMessagesTests/ViewTests/JSQMessagesCollectionViewTests.m
Executable file → Normal 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"
|
||||
|
||||
5
JSQMessagesTests/ViewTests/JSQMessagesComposerTextViewTests.m
Executable file → Normal 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");
|
||||
|
||||
3
JSQMessagesTests/ViewTests/JSQMessagesInputToolbarTests.m
Executable file → Normal 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
@ -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"
|
||||
|
||||
|
||||