зеркало из https://github.com/nextcloud/talk-ios.git
Add tap gesture recognizer to chat cells' avatar.
Signed-off-by: Ivan Sein <ivan@nextcloud.com>
This commit is contained in:
Родитель
50ae79c653
Коммит
c32e143873
|
@ -36,7 +36,7 @@ static NSString *AutoCompletionCellIdentifier = @"AutoCompletionCellIdentifier
|
|||
|
||||
@class ChatMessageTableViewCell;
|
||||
|
||||
@protocol ChatMessageTableViewCellDelegate <NSObject>
|
||||
@protocol ChatMessageTableViewCellDelegate <ChatTableViewCellDelegate>
|
||||
|
||||
- (void)cellWantsToScrollToMessage:(NCChatMessage *)message;
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
|
||||
@interface ChatMessageTableViewCell ()
|
||||
@property (nonatomic, strong) UIView *quoteContainerView;
|
||||
@property (nonatomic, strong) NCChatMessage *message;
|
||||
@end
|
||||
|
||||
@implementation ChatMessageTableViewCell
|
||||
|
@ -54,11 +53,13 @@
|
|||
{
|
||||
_avatarView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kChatMessageCellAvatarHeight, kChatMessageCellAvatarHeight)];
|
||||
_avatarView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
_avatarView.userInteractionEnabled = NO;
|
||||
_avatarView.userInteractionEnabled = YES;
|
||||
_avatarView.backgroundColor = [NCAppBranding placeholderColor];
|
||||
_avatarView.layer.cornerRadius = kChatMessageCellAvatarHeight/2.0;
|
||||
_avatarView.layer.masksToBounds = YES;
|
||||
_avatarView.contentMode = UIViewContentModeScaleToFill;
|
||||
UITapGestureRecognizer *avatarTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(avatarTapped:)];
|
||||
[_avatarView addGestureRecognizer:avatarTap];
|
||||
[self.contentView addSubview:_avatarView];
|
||||
|
||||
_statusView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kChatCellStatusViewHeight, kChatCellStatusViewHeight)];
|
||||
|
@ -78,8 +79,8 @@
|
|||
[self.contentView addSubview:self.quoteContainerView];
|
||||
[_quoteContainerView addSubview:self.quotedMessageView];
|
||||
|
||||
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(quoteTapped:)];
|
||||
[self.quoteContainerView addGestureRecognizer:tapRecognizer];
|
||||
UITapGestureRecognizer *quoteTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(quoteTapped:)];
|
||||
[self.quoteContainerView addGestureRecognizer:quoteTap];
|
||||
}
|
||||
|
||||
NSDictionary *views = @{@"avatarView": self.avatarView,
|
||||
|
@ -162,6 +163,22 @@
|
|||
[self.statusView.subviews makeObjectsPerformSelector: @selector(removeFromSuperview)];
|
||||
}
|
||||
|
||||
#pragma mark - Gesture recognizers
|
||||
|
||||
- (void)avatarTapped:(UIGestureRecognizer *)gestureRecognizer
|
||||
{
|
||||
if (self.delegate && self.message) {
|
||||
[self.delegate cellWantsToDisplayOptionsForMessageActor:self.message];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)quoteTapped:(UIGestureRecognizer *)gestureRecognizer
|
||||
{
|
||||
if (self.delegate && self.message && self.message.parent) {
|
||||
[self.delegate cellWantsToScrollToMessage:self.message.parent];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Getters
|
||||
|
||||
- (UILabel *)titleLabel
|
||||
|
@ -234,6 +251,7 @@
|
|||
self.titleLabel.text = message.actorDisplayName;
|
||||
self.bodyTextView.attributedText = message.parsedMessage;
|
||||
self.messageId = message.messageId;
|
||||
self.message = message;
|
||||
NSDate *date = [[NSDate alloc] initWithTimeIntervalSince1970:message.timestamp];
|
||||
self.dateLabel.text = [NCUtils getTimeFromDate:date];
|
||||
TalkAccount *activeAccount = [[NCDatabaseManager sharedInstance] activeAccount];
|
||||
|
@ -286,8 +304,6 @@
|
|||
self.bodyTextView.textColor = [UIColor tertiaryLabelColor];
|
||||
}
|
||||
}
|
||||
|
||||
self.message = message;
|
||||
}
|
||||
|
||||
- (void)setGuestAvatar:(NSString *)displayName
|
||||
|
@ -362,12 +378,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void)quoteTapped:(UIGestureRecognizer *)gestureRecognizer {
|
||||
if (self.delegate && self.message && self.message.parent) {
|
||||
[self.delegate cellWantsToScrollToMessage:self.message.parent];
|
||||
}
|
||||
}
|
||||
|
||||
+ (CGFloat)defaultFontSize
|
||||
{
|
||||
CGFloat pointSize = 16.0;
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "NCChatMessage.h"
|
||||
|
||||
static CGFloat kChatCellStatusViewHeight = 20.0;
|
||||
|
||||
typedef enum ChatMessageDeliveryState {
|
||||
|
@ -32,8 +34,15 @@ typedef enum ChatMessageDeliveryState {
|
|||
ChatMessageDeliveryStateFailed
|
||||
} ChatMessageDeliveryState;
|
||||
|
||||
@protocol ChatTableViewCellDelegate <NSObject>
|
||||
|
||||
- (void)cellWantsToDisplayOptionsForMessageActor:(NCChatMessage *)message;
|
||||
|
||||
@end
|
||||
|
||||
@interface ChatTableViewCell : UITableViewCell
|
||||
|
||||
@property (nonatomic, assign) NSInteger messageId;
|
||||
@property (nonatomic, strong) NCChatMessage *message;
|
||||
|
||||
@end
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
{
|
||||
[super prepareForReuse];
|
||||
self.messageId = -1;
|
||||
self.message = nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -38,7 +38,7 @@ static NSString *GroupedFileMessageCellIdentifier = @"GroupedFileMessageCellId
|
|||
|
||||
@class FileMessageTableViewCell;
|
||||
|
||||
@protocol FileMessageTableViewCellDelegate <NSObject>
|
||||
@protocol FileMessageTableViewCellDelegate <ChatTableViewCellDelegate>
|
||||
|
||||
- (void)cellWantsToDownloadFile:(NCMessageFileParameter *)fileParameter;
|
||||
|
||||
|
|
|
@ -60,10 +60,12 @@
|
|||
{
|
||||
_avatarView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kFileMessageCellAvatarHeight, kFileMessageCellAvatarHeight)];
|
||||
_avatarView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
_avatarView.userInteractionEnabled = NO;
|
||||
_avatarView.userInteractionEnabled = YES;
|
||||
_avatarView.backgroundColor = [NCAppBranding placeholderColor];
|
||||
_avatarView.layer.cornerRadius = kFileMessageCellAvatarHeight/2.0;
|
||||
_avatarView.layer.masksToBounds = YES;
|
||||
UITapGestureRecognizer *avatarTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(avatarTapped:)];
|
||||
[_avatarView addGestureRecognizer:avatarTap];
|
||||
|
||||
_previewImageView = [[FilePreviewImageView alloc] initWithFrame:CGRectMake(0, 0, kFileMessageCellFilePreviewHeight, kFileMessageCellFilePreviewHeight)];
|
||||
_previewImageView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
|
@ -162,6 +164,7 @@
|
|||
self.titleLabel.text = message.actorDisplayName;
|
||||
self.bodyTextView.attributedText = message.parsedMessage;
|
||||
self.messageId = message.messageId;
|
||||
self.message = message;
|
||||
|
||||
NSDate *date = [[NSDate alloc] initWithTimeIntervalSince1970:message.timestamp];
|
||||
self.dateLabel.text = [NCUtils getTimeFromDate:date];
|
||||
|
@ -296,6 +299,26 @@
|
|||
[self.fileStatusView addSubview:_activityIndicator];
|
||||
}
|
||||
|
||||
#pragma mark - Gesture recognizers
|
||||
|
||||
- (void)avatarTapped:(UIGestureRecognizer *)gestureRecognizer
|
||||
{
|
||||
if (self.delegate && self.message) {
|
||||
[self.delegate cellWantsToDisplayOptionsForMessageActor:self.message];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)previewTapped:(UITapGestureRecognizer *)recognizer
|
||||
{
|
||||
if (!self.fileParameter || !self.fileParameter.path || !self.fileParameter.link) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.delegate) {
|
||||
[self.delegate cellWantsToDownloadFile:self.fileParameter];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Getters
|
||||
|
||||
|
@ -346,17 +369,6 @@
|
|||
return _bodyTextView;
|
||||
}
|
||||
|
||||
- (void)previewTapped:(UITapGestureRecognizer *)recognizer
|
||||
{
|
||||
if (!self.fileParameter || !self.fileParameter.path || !self.fileParameter.link) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.delegate) {
|
||||
[self.delegate cellWantsToDownloadFile:self.fileParameter];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setGuestAvatar:(NSString *)displayName
|
||||
{
|
||||
UIColor *guestAvatarColor = [NCAppBranding placeholderColor];
|
||||
|
|
|
@ -83,6 +83,7 @@
|
|||
{
|
||||
self.bodyTextView.attributedText = message.parsedMessage;
|
||||
self.messageId = message.messageId;
|
||||
self.message = message;
|
||||
|
||||
TalkAccount *activeAccount = [[NCDatabaseManager sharedInstance] activeAccount];
|
||||
ServerCapabilities *serverCapabilities = [[NCDatabaseManager sharedInstance] serverCapabilitiesForAccountId:activeAccount.accountId];
|
||||
|
|
|
@ -37,7 +37,7 @@ static NSString *GroupedLocationMessageCellIdentifier = @"GroupedLocationMessa
|
|||
|
||||
@class LocationMessageTableViewCell;
|
||||
|
||||
@protocol LocationMessageTableViewCellDelegate <NSObject>
|
||||
@protocol LocationMessageTableViewCellDelegate <ChatTableViewCellDelegate>
|
||||
|
||||
- (void)cellWantsToOpenLocation:(GeoLocationRichObject *)geoLocationRichObject;
|
||||
|
||||
|
|
|
@ -57,10 +57,12 @@
|
|||
{
|
||||
_avatarView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kLocationMessageCellAvatarHeight, kLocationMessageCellAvatarHeight)];
|
||||
_avatarView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
_avatarView.userInteractionEnabled = NO;
|
||||
_avatarView.userInteractionEnabled = YES;
|
||||
_avatarView.backgroundColor = [NCAppBranding placeholderColor];
|
||||
_avatarView.layer.cornerRadius = kLocationMessageCellAvatarHeight/2.0;
|
||||
_avatarView.layer.masksToBounds = YES;
|
||||
UITapGestureRecognizer *avatarTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(avatarTapped:)];
|
||||
[_avatarView addGestureRecognizer:avatarTap];
|
||||
|
||||
_previewImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kLocationMessageCellPreviewWidth, kLocationMessageCellPreviewHeight)];
|
||||
_previewImageView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
|
@ -150,6 +152,7 @@
|
|||
self.titleLabel.text = message.actorDisplayName;
|
||||
self.bodyTextView.attributedText = message.parsedMessage;
|
||||
self.messageId = message.messageId;
|
||||
self.message = message;
|
||||
|
||||
NSDate *date = [[NSDate alloc] initWithTimeIntervalSince1970:message.timestamp];
|
||||
self.dateLabel.text = [NCUtils getTimeFromDate:date];
|
||||
|
@ -235,6 +238,26 @@
|
|||
}
|
||||
}
|
||||
|
||||
#pragma mark - Gesture recognizers
|
||||
|
||||
- (void)avatarTapped:(UIGestureRecognizer *)gestureRecognizer
|
||||
{
|
||||
if (self.delegate && self.message) {
|
||||
[self.delegate cellWantsToDisplayOptionsForMessageActor:self.message];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)previewTapped:(UITapGestureRecognizer *)recognizer
|
||||
{
|
||||
if (!self.geoLocationRichObject) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.delegate) {
|
||||
[self.delegate cellWantsToOpenLocation:self.geoLocationRichObject];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Getters
|
||||
|
||||
- (UILabel *)titleLabel
|
||||
|
@ -284,17 +307,6 @@
|
|||
return _bodyTextView;
|
||||
}
|
||||
|
||||
- (void)previewTapped:(UITapGestureRecognizer *)recognizer
|
||||
{
|
||||
if (!self.geoLocationRichObject) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.delegate) {
|
||||
[self.delegate cellWantsToOpenLocation:self.geoLocationRichObject];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setGuestAvatar:(NSString *)displayName
|
||||
{
|
||||
UIColor *guestAvatarColor = [NCAppBranding placeholderColor];
|
||||
|
|
|
@ -1254,6 +1254,11 @@ NSString * const NCChatViewControllerForwardNotification = @"NCChatViewControlle
|
|||
}
|
||||
}
|
||||
|
||||
- (void)presentOptionsForMessageActor:(NCChatMessage *)message
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - UIImagePickerController Delegate
|
||||
|
||||
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
|
||||
|
@ -2924,6 +2929,8 @@ NSString * const NCChatViewControllerForwardNotification = @"NCChatViewControlle
|
|||
return groupedCell;
|
||||
} else {
|
||||
ChatMessageTableViewCell *normalCell = (ChatMessageTableViewCell *)[self.tableView dequeueReusableCellWithIdentifier:ChatMessageCellIdentifier];
|
||||
normalCell.delegate = self;
|
||||
|
||||
[normalCell setupForMessage:message withLastCommonReadMessage:_room.lastCommonReadMessage];
|
||||
|
||||
return normalCell;
|
||||
|
@ -3259,6 +3266,13 @@ NSString * const NCChatViewControllerForwardNotification = @"NCChatViewControlle
|
|||
}
|
||||
}
|
||||
|
||||
- (void)cellWantsToDisplayOptionsForMessageActor:(NCChatMessage *)message {
|
||||
NSIndexPath *indexPath = [self indexPathForMessage:message];
|
||||
if (indexPath) {
|
||||
[self presentOptionsForMessageActor:message];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - NCChatFileControllerDelegate
|
||||
|
||||
- (void)fileControllerDidLoadFile:(NCChatFileController *)fileController withFileStatus:(NCChatFileStatus *)fileStatus
|
||||
|
|
|
@ -117,6 +117,8 @@
|
|||
{
|
||||
self.bodyTextView.attributedText = message.systemMessageFormat;
|
||||
self.messageId = message.messageId;
|
||||
self.message = message;
|
||||
|
||||
if (!message.isGroupMessage) {
|
||||
NSDate *date = [[NSDate alloc] initWithTimeIntervalSince1970:message.timestamp];
|
||||
self.dateLabel.text = [NCUtils getTimeFromDate:date];
|
||||
|
|
|
@ -33,7 +33,7 @@ static CGFloat kVoiceMessageCellPlayerHeight = 44.0;
|
|||
static NSString *VoiceMessageCellIdentifier = @"VoiceMessageCellIdentifier";
|
||||
static NSString *GroupedVoiceMessageCellIdentifier = @"GroupedVoiceMessageCellIdentifier";
|
||||
|
||||
@protocol VoiceMessageTableViewCellDelegate <NSObject>
|
||||
@protocol VoiceMessageTableViewCellDelegate <ChatTableViewCellDelegate>
|
||||
|
||||
- (void)cellWantsToPlayAudioFile:(NCMessageFileParameter *)fileParameter;
|
||||
- (void)cellWantsToPauseAudioFile:(NCMessageFileParameter *)fileParameter;
|
||||
|
|
|
@ -60,10 +60,12 @@
|
|||
{
|
||||
_avatarView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kVoiceMessageCellAvatarHeight, kVoiceMessageCellAvatarHeight)];
|
||||
_avatarView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
_avatarView.userInteractionEnabled = NO;
|
||||
_avatarView.userInteractionEnabled = YES;
|
||||
_avatarView.backgroundColor = [NCAppBranding placeholderColor];
|
||||
_avatarView.layer.cornerRadius = kVoiceMessageCellAvatarHeight/2.0;
|
||||
_avatarView.layer.masksToBounds = YES;
|
||||
UITapGestureRecognizer *avatarTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(avatarTapped:)];
|
||||
[_avatarView addGestureRecognizer:avatarTap];
|
||||
|
||||
_audioPlayerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 44)];
|
||||
_audioPlayerView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
|
@ -183,6 +185,7 @@
|
|||
{
|
||||
self.titleLabel.text = message.actorDisplayName;
|
||||
self.messageId = message.messageId;
|
||||
self.message = message;
|
||||
|
||||
NSDate *date = [[NSDate alloc] initWithTimeIntervalSince1970:message.timestamp];
|
||||
self.dateLabel.text = [NCUtils getTimeFromDate:date];
|
||||
|
@ -366,6 +369,15 @@
|
|||
[self.fileStatusView addSubview:_activityIndicator];
|
||||
}
|
||||
|
||||
#pragma mark - Gesture recognizers
|
||||
|
||||
- (void)avatarTapped:(UIGestureRecognizer *)gestureRecognizer
|
||||
{
|
||||
if (self.delegate && self.message) {
|
||||
[self.delegate cellWantsToDisplayOptionsForMessageActor:self.message];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Getters
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче