OWSMessageBubbleView.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. //
  2. // Copyright (c) 2019 Open Whisper Systems. All rights reserved.
  3. //
  4. NS_ASSUME_NONNULL_BEGIN
  5. @class ContactShareViewModel;
  6. @class ConversationStyle;
  7. @protocol ConversationViewItem;
  8. @class OWSContact;
  9. @class OWSLinkPreview;
  10. @class OWSQuotedReplyModel;
  11. @class TSAttachmentPointer;
  12. @class TSAttachmentStream;
  13. @class TSOutgoingMessage;
  14. typedef NS_ENUM(NSUInteger, OWSMessageGestureLocation) {
  15. // Message text, etc.
  16. OWSMessageGestureLocation_Default,
  17. OWSMessageGestureLocation_OversizeText,
  18. OWSMessageGestureLocation_Media,
  19. OWSMessageGestureLocation_QuotedReply,
  20. OWSMessageGestureLocation_LinkPreview,
  21. };
  22. @protocol OWSMessageBubbleViewDelegate
  23. - (void)didTapImageViewItem:(id<ConversationViewItem>)viewItem
  24. attachmentStream:(TSAttachmentStream *)attachmentStream
  25. imageView:(UIView *)imageView;
  26. - (void)didTapVideoViewItem:(id<ConversationViewItem>)viewItem
  27. attachmentStream:(TSAttachmentStream *)attachmentStream
  28. imageView:(UIView *)imageView;
  29. - (void)didTapAudioViewItem:(id<ConversationViewItem>)viewItem attachmentStream:(TSAttachmentStream *)attachmentStream;
  30. - (void)didTapTruncatedTextMessage:(id<ConversationViewItem>)conversationItem;
  31. - (void)didTapFailedIncomingAttachment:(id<ConversationViewItem>)viewItem;
  32. - (void)didTapConversationItem:(id<ConversationViewItem>)viewItem quotedReply:(OWSQuotedReplyModel *)quotedReply;
  33. - (void)didTapConversationItem:(id<ConversationViewItem>)viewItem
  34. quotedReply:(OWSQuotedReplyModel *)quotedReply
  35. failedThumbnailDownloadAttachmentPointer:(TSAttachmentPointer *)attachmentPointer;
  36. - (void)didTapConversationItem:(id<ConversationViewItem>)viewItem linkPreview:(OWSLinkPreview *)linkPreview;
  37. - (void)didTapContactShareViewItem:(id<ConversationViewItem>)viewItem;
  38. - (void)didTapSendMessageToContactShare:(ContactShareViewModel *)contactShare
  39. NS_SWIFT_NAME(didTapSendMessage(toContactShare:));
  40. - (void)didTapSendInviteToContactShare:(ContactShareViewModel *)contactShare
  41. NS_SWIFT_NAME(didTapSendInvite(toContactShare:));
  42. - (void)didTapShowAddToContactUIForContactShare:(ContactShareViewModel *)contactShare
  43. NS_SWIFT_NAME(didTapShowAddToContactUI(forContactShare:));
  44. @property (nonatomic, readonly, nullable) NSString *lastSearchedText;
  45. @end
  46. #pragma mark -
  47. @interface OWSMessageBubbleView : UIView
  48. @property (nonatomic, nullable) id<ConversationViewItem> viewItem;
  49. @property (nonatomic) ConversationStyle *conversationStyle;
  50. @property (nonatomic) NSCache *cellMediaCache;
  51. @property (nonatomic, nullable, readonly) UIView *bodyMediaView;
  52. @property (nonatomic, weak) id<OWSMessageBubbleViewDelegate> delegate;
  53. - (instancetype)init NS_UNAVAILABLE;
  54. - (instancetype)initWithFrame:(CGRect)frame NS_DESIGNATED_INITIALIZER;
  55. - (instancetype)initWithCoder:(NSCoder *)coder NS_UNAVAILABLE;
  56. - (void)configureViews;
  57. - (void)loadContent;
  58. - (void)unloadContent;
  59. - (CGSize)measureSize;
  60. - (void)prepareForReuse;
  61. + (NSDictionary *)senderNamePrimaryAttributes;
  62. + (NSDictionary *)senderNameSecondaryAttributes;
  63. #pragma mark - Gestures
  64. - (OWSMessageGestureLocation)gestureLocationForLocation:(CGPoint)locationInMessageBubble;
  65. // This only needs to be called when we use the cell _outside_ the context
  66. // of a conversation view message cell.
  67. - (void)addTapGestureHandler;
  68. - (void)handleTapGesture:(UITapGestureRecognizer *)sender;
  69. @end
  70. NS_ASSUME_NONNULL_END