forked from jessesquires/JSQMessagesViewController
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJSQMessagesCollectionViewCell.h
207 lines (178 loc) · 7.28 KB
/
JSQMessagesCollectionViewCell.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
//
// 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 <UIKit/UIKit.h>
#import "JSQMessagesLabel.h"
#import "JSQMessagesCellTextView.h"
@class JSQMessagesCollectionViewCell;
/**
* The `JSQMessagesCollectionViewCellDelegate` protocol defines methods that allow you to manage
* additional interactions within the collection view cell.
*/
@protocol JSQMessagesCollectionViewCellDelegate <NSObject>
@required
/**
* Tells the delegate that the avatarImageView of the cell has been tapped.
*
* @param cell The cell that received the tap touch event.
*/
- (void)messagesCollectionViewCellDidTapAvatar:(JSQMessagesCollectionViewCell *)cell;
/**
* Tells the delegate that the message bubble of the cell has been tapped.
*
* @param cell The cell that received the tap touch event.
*/
- (void)messagesCollectionViewCellDidTapMessageBubble:(JSQMessagesCollectionViewCell *)cell;
/**
* Tells the delegate that the cell has been tapped at the point specified by position.
*
* @param cell The cell that received the tap touch event.
* @param position The location of the received touch in the cell's coordinate system.
*
* @discussion This method is *only* called if position is *not* within the bounds of the cell's
* avatar image view or message bubble image view. In other words, this method is *not* called when the cell's
* avatar or message bubble are tapped.
*
* @see `messagesCollectionViewCellDidTapAvatar:`
* @see `messagesCollectionViewCellDidTapMessageBubble:`
*/
- (void)messagesCollectionViewCellDidTapCell:(JSQMessagesCollectionViewCell *)cell atPosition:(CGPoint)position;
/**
* Tells the delegate that an actions has been selected from the menu of this cell.
* This method is automatically called for any registered actions.
*
* @param cell The cell that displayed the menu.
* @param action The action that has been performed.
* @param sender The object that initiated the action.
*
* @see `JSQMessagesCollectionViewCell`
*/
- (void)messagesCollectionViewCell:(JSQMessagesCollectionViewCell *)cell didPerformAction:(SEL)action withSender:(id)sender;
@end
/**
* The `JSQMessagesCollectionViewCell` is an abstract base class that presents the content for
* a single message data item when that item is within the collection view’s visible bounds.
* The layout and presentation of cells is managed by the collection view and its corresponding layout object.
*
* @warning This class is intended to be subclassed. You should not use it directly.
*
* @see JSQMessagesCollectionViewCellIncoming.
* @see JSQMessagesCollectionViewCellOutgoing.
*/
@interface JSQMessagesCollectionViewCell : UICollectionViewCell
/**
* The object that acts as the delegate for the cell.
*/
@property (weak, nonatomic) id<JSQMessagesCollectionViewCellDelegate> delegate;
/**
* Returns the label that is pinned to the top of the cell.
* This label is most commonly used to display message timestamps.
*/
@property (weak, nonatomic, readonly) JSQMessagesLabel *cellTopLabel;
/**
* Returns the label that is pinned just above the messageBubbleImageView, and below the cellTopLabel.
* This label is most commonly used to display the message sender.
*/
@property (weak, nonatomic, readonly) JSQMessagesLabel *messageBubbleTopLabel;
/**
* Returns the label that is pinned to the bottom of the cell.
* This label is most commonly used to display message delivery status.
*/
@property (weak, nonatomic, readonly) JSQMessagesLabel *cellBottomLabel;
/**
* Returns the text view of the cell. This text view contains the message body text.
*
* @warning If mediaView returns a non-nil view, then this value will be `nil`.
*/
@property (weak, nonatomic, readonly) JSQMessagesCellTextView *textView;
/**
* Returns the bubble image view of the cell that is responsible for displaying message bubble images.
*
* @warning If mediaView returns a non-nil view, then this value will be `nil`.
*/
@property (weak, nonatomic, readonly) UIImageView *messageBubbleImageView;
/**
* Returns the message bubble container view of the cell. This view is the superview of
* the cell's textView and messageBubbleImageView.
*
* @discussion You may customize the cell by adding custom views to this container view.
* To do so, override `collectionView:cellForItemAtIndexPath:`
*
* @warning You should not try to manipulate any properties of this view, for example adjusting
* its frame, nor should you remove this view from the cell or remove any of its subviews.
* Doing so could result in unexpected behavior.
*/
@property (weak, nonatomic, readonly) UIView *messageBubbleContainerView;
/**
* Returns the avatar image view of the cell that is responsible for displaying avatar images.
*/
@property (weak, nonatomic, readonly) UIImageView *avatarImageView;
@property (unsafe_unretained, nonatomic) IBOutlet UIImageView *sentImageView;
/**
* Returns the avatar container view of the cell. This view is the superview of the cell's avatarImageView.
*
* @discussion You may customize the cell by adding custom views to this container view.
* To do so, override `collectionView:cellForItemAtIndexPath:`
*
* @warning You should not try to manipulate any properties of this view, for example adjusting
* its frame, nor should you remove this view from the cell or remove any of its subviews.
* Doing so could result in unexpected behavior.
*/
@property (weak, nonatomic, readonly) UIView *avatarContainerView;
/**
* The media view of the cell. This view displays the contents of a media message.
*
* @warning If this value is non-nil, then textView and messageBubbleImageView will both be `nil`.
*/
@property (weak, nonatomic) UIView *mediaView;
/**
* Returns the underlying gesture recognizer for tap gestures in the avatarImageView of the cell.
* This gesture handles the tap event for the avatarImageView and notifies the cell's delegate.
*/
@property (weak, nonatomic, readonly) UITapGestureRecognizer *tapGestureRecognizer;
#pragma mark - Class methods
/**
* Returns the `UINib` object initialized for the cell.
*
* @return The initialized `UINib` object or `nil` if there were errors during
* initialization or the nib file could not be located.
*/
+ (UINib *)nib;
/**
* Returns the default string used to identify a reusable cell for text message items.
*
* @return The string used to identify a reusable cell.
*/
+ (NSString *)cellReuseIdentifier;
/**
* Returns the default string used to identify a reusable cell for media message items.
*
* @return The string used to identify a reusable cell.
*/
+ (NSString *)mediaCellReuseIdentifier;
/**
* Registers an action to be available in the cell's menu.
*
* @param action The selector to register with the cell.
*
* @discussion Non-standard or non-system actions must be added to the `UIMenuController` manually.
* You can do this by creating a new `UIMenuItem` and adding it via the controller's `menuItems` property.
*
* @warning Note that all message cells share the all actions registered here.
*/
+ (void)registerMenuAction:(SEL)action;
@end