mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-24 10:32:46 +02:00
MESSENGER-3699 double tap for image attachments
This commit is contained in:
committed by
Frank Rotermund
parent
6445195cf6
commit
f2cfaf3b9e
@@ -820,11 +820,18 @@
|
||||
// Note: tap gesture recognizer is required here because mxkImageView enables user interaction to allow image stretching.
|
||||
// [collectionView:didSelectItemAtIndexPath] is not triggered when mxkImageView is displayed.
|
||||
UITapGestureRecognizer *cellTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onCollectionViewCellTap:)];
|
||||
[cellTapGesture setNumberOfTouchesRequired:1];
|
||||
[cellTapGesture setNumberOfTapsRequired:1];
|
||||
cell.tag = item;
|
||||
[cell addGestureRecognizer:cellTapGesture];
|
||||
|
||||
// BWI: allow changing the image zoom level by double tab
|
||||
if ([BwiBuildSettings allowDoubleTapOnImageAttachmentsForZoom]) {
|
||||
UITapGestureRecognizer *cellDoubleTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onCollectionViewCellDoubleTap:)];
|
||||
[cellDoubleTapGesture setNumberOfTapsRequired:2];
|
||||
cell.tag = item;
|
||||
[cell addGestureRecognizer:cellDoubleTapGesture];
|
||||
}
|
||||
|
||||
UILongPressGestureRecognizer *cellLongPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(onCollectionViewCellLongPress:)];
|
||||
[cell addGestureRecognizer:cellLongPressGesture];
|
||||
}
|
||||
@@ -1172,6 +1179,43 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)onCollectionViewCellDoubleTap:(UIGestureRecognizer*)gestureRecognizer
|
||||
{
|
||||
MXKMediaCollectionViewCell *selectedCell;
|
||||
|
||||
UIView *view = gestureRecognizer.view;
|
||||
if ([view isKindOfClass:[MXKMediaCollectionViewCell class]])
|
||||
{
|
||||
selectedCell = (MXKMediaCollectionViewCell*)view;
|
||||
}
|
||||
|
||||
// Notify the collection view delegate a cell has been selected.
|
||||
if (selectedCell && selectedCell.tag < attachments.count)
|
||||
{
|
||||
NSInteger item = isBackPaginationInProgress ? selectedCell.tag + 1: selectedCell.tag;
|
||||
|
||||
if (isBackPaginationInProgress)
|
||||
{
|
||||
if (item == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
item --;
|
||||
}
|
||||
|
||||
// Check whether the selected attachment is a video
|
||||
if (item < attachments.count)
|
||||
{
|
||||
MXKAttachment *attachment = attachments[item];
|
||||
if (attachment.type == MXKAttachmentTypeImage && attachment.contentURL)
|
||||
{
|
||||
[selectedCell.mxkImageView toggleZoomLevel];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)onCollectionViewCellLongPress:(UIGestureRecognizer*)gestureRecognizer
|
||||
{
|
||||
MXKMediaCollectionViewCell *selectedCell;
|
||||
|
||||
Reference in New Issue
Block a user