session-ios/Signal/src/ViewControllers/ConversationView/ConversationViewItem.h

129 lines
4.0 KiB
C
Raw Normal View History

2017-10-10 22:13:54 +02:00
//
2018-02-23 21:44:46 +01:00
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
2017-10-10 22:13:54 +02:00
//
#import "ConversationViewLayout.h"
2018-02-23 21:44:46 +01:00
#import "OWSAudioPlayer.h"
2017-10-10 22:13:54 +02:00
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSInteger, OWSMessageCellType) {
OWSMessageCellType_Unknown,
2017-10-10 22:13:54 +02:00
OWSMessageCellType_TextMessage,
OWSMessageCellType_OversizeTextMessage,
OWSMessageCellType_StillImage,
OWSMessageCellType_AnimatedImage,
OWSMessageCellType_Audio,
OWSMessageCellType_Video,
OWSMessageCellType_GenericAttachment,
OWSMessageCellType_DownloadingAttachment,
2018-05-02 17:01:23 +02:00
OWSMessageCellType_ContactShare,
2017-10-10 22:13:54 +02:00
};
2017-10-12 19:48:09 +02:00
NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType);
#pragma mark -
@class ContactShareViewModel;
2017-10-10 22:13:54 +02:00
@class ConversationViewCell;
2017-10-26 18:09:36 +02:00
@class DisplayableText;
2017-10-10 22:13:54 +02:00
@class OWSAudioMessageView;
@class OWSQuotedReplyModel;
2018-07-11 20:12:58 +02:00
@class OWSUnreadIndicator;
2017-10-10 22:13:54 +02:00
@class TSAttachmentPointer;
@class TSAttachmentStream;
@class TSInteraction;
@class YapDatabaseReadTransaction;
2017-10-10 22:13:54 +02:00
2017-10-11 15:44:10 +02:00
// This is a ViewModel for cells in the conversation view.
//
// The lifetime of this class is the lifetime of that cell
// in the load window of the conversation view.
//
// Critically, this class implements ConversationViewLayoutItem
// and does caching of the cell's size.
2018-02-23 21:44:46 +01:00
@interface ConversationViewItem : NSObject <ConversationViewLayoutItem, OWSAudioPlayerDelegate>
2017-10-10 22:13:54 +02:00
@property (nonatomic, readonly) TSInteraction *interaction;
@property (nonatomic, readonly, nullable) OWSQuotedReplyModel *quotedReply;
2017-10-10 22:13:54 +02:00
@property (nonatomic, readonly) BOOL isGroupThread;
2018-03-29 17:25:19 +02:00
@property (nonatomic, readonly) BOOL hasBodyText;
@property (nonatomic, readonly) BOOL isQuotedReply;
@property (nonatomic, readonly) BOOL hasQuotedAttachment;
@property (nonatomic, readonly) BOOL hasQuotedText;
2018-07-11 20:12:58 +02:00
@property (nonatomic, readonly) BOOL hasCellHeader;
2018-07-11 21:43:25 +02:00
@property (nonatomic, readonly) BOOL isExpiringMessage;
2017-10-10 22:13:54 +02:00
@property (nonatomic) BOOL shouldShowDate;
2018-06-26 22:04:09 +02:00
@property (nonatomic) BOOL shouldShowSenderAvatar;
2018-07-02 15:42:48 +02:00
@property (nonatomic, nullable) NSAttributedString *senderName;
2018-06-26 22:04:09 +02:00
@property (nonatomic) BOOL shouldHideFooter;
2018-07-06 21:08:56 +02:00
@property (nonatomic) BOOL isFirstInCluster;
@property (nonatomic) BOOL isLastInCluster;
2017-10-10 22:13:54 +02:00
2018-07-11 20:12:58 +02:00
@property (nonatomic, nullable) OWSUnreadIndicator *unreadIndicator;
2018-06-25 21:20:17 +02:00
@property (nonatomic, readonly) ConversationStyle *conversationStyle;
2018-06-22 19:48:23 +02:00
2017-10-10 22:13:54 +02:00
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithInteraction:(TSInteraction *)interaction
isGroupThread:(BOOL)isGroupThread
2018-06-22 19:48:23 +02:00
transaction:(YapDatabaseReadTransaction *)transaction
2018-06-25 21:20:17 +02:00
conversationStyle:(ConversationStyle *)conversationStyle;
2017-10-10 22:13:54 +02:00
- (ConversationViewCell *)dequeueCellForCollectionView:(UICollectionView *)collectionView
indexPath:(NSIndexPath *)indexPath;
- (void)replaceInteraction:(TSInteraction *)interaction transaction:(YapDatabaseReadTransaction *)transaction;
2017-10-10 22:13:54 +02:00
- (void)clearCachedLayoutState;
#pragma mark - Audio Playback
@property (nonatomic, weak) OWSAudioMessageView *lastAudioMessageView;
2017-11-20 20:50:43 +01:00
@property (nonatomic, readonly) CGFloat audioDurationSeconds;
2017-10-10 22:13:54 +02:00
- (CGFloat)audioProgressSeconds;
#pragma mark - View State Caching
// These methods only apply to text & attachment messages.
- (OWSMessageCellType)messageCellType;
2018-03-29 17:25:19 +02:00
- (nullable DisplayableText *)displayableBodyText;
2017-10-10 22:13:54 +02:00
- (nullable TSAttachmentStream *)attachmentStream;
- (nullable TSAttachmentPointer *)attachmentPointer;
- (CGSize)mediaSize;
2017-10-10 22:13:54 +02:00
- (nullable DisplayableText *)displayableQuotedText;
- (nullable NSString *)quotedAttachmentMimetype;
2018-04-03 19:15:19 +02:00
- (nullable NSString *)quotedRecipientId;
2017-10-18 21:11:19 +02:00
// We don't want to try to load the media for this item (if any)
// if a load has previously failed.
@property (nonatomic) BOOL didCellMediaFailToLoad;
@property (nonatomic, readonly, nullable) ContactShareViewModel *contactShare;
#pragma mark - MessageActions
2017-10-10 22:13:54 +02:00
@property (nonatomic, readonly) BOOL hasBodyTextActionContent;
2018-07-12 06:11:36 +02:00
@property (nonatomic, readonly) BOOL hasMediaActionContent;
2018-07-12 06:35:54 +02:00
- (void)copyMediaAction;
- (void)copyTextAction;
- (void)shareMediaAction;
- (void)shareTextAction;
- (void)saveMediaAction;
2018-07-12 05:55:04 +02:00
- (void)deleteAction;
2018-08-07 23:38:59 +02:00
- (BOOL)canSaveMedia;
2017-10-10 22:13:54 +02:00
@end
NS_ASSUME_NONNULL_END