mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-29 15:52:40 +00:00
Contextual menu: Improve reactions menu position.
This commit is contained in:
parent
4cb166072a
commit
366d27ebab
1 changed files with 29 additions and 9 deletions
|
@ -5099,14 +5099,34 @@
|
||||||
|
|
||||||
if (RiotSettings.shared.messageReaction && [cell isKindOfClass:MXKRoomBubbleTableViewCell.class])
|
if (RiotSettings.shared.messageReaction && [cell isKindOfClass:MXKRoomBubbleTableViewCell.class])
|
||||||
{
|
{
|
||||||
// Note: For the moment, we use the frame of the cell instead of the component
|
MXKRoomBubbleTableViewCell *roomBubbleTableViewCell = (MXKRoomBubbleTableViewCell*)cell;
|
||||||
// From UI perpective, that means the menu will be around a paragraph instead of a message
|
MXKRoomBubbleCellData *bubbleCellData = roomBubbleTableViewCell.bubbleData;
|
||||||
// This is not bad as the paragraph is kept visible to provide more context to the user
|
NSArray *bubbleComponents = bubbleCellData.bubbleComponents;
|
||||||
// TO FIX: if paragraph is bigger than the screen, the menu is displayed in the middle
|
|
||||||
CGRect frame = ((MXKRoomBubbleTableViewCell*)cell).frame;
|
|
||||||
frame = [self.bubblesTableView convertRect:frame toView:[self.bubblesTableView superview]];
|
|
||||||
|
|
||||||
[self.roomContextualMenuPresenter showReactionsMenuForEvent:event.eventId inRoom:event.roomId session:self.mainSession aroundFrame:frame];
|
NSInteger foundComponentIndex = [bubbleComponents indexOfObjectPassingTest:^BOOL(MXKRoomBubbleComponent * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||||
|
if (obj.event.eventId == event.eventId)
|
||||||
|
{
|
||||||
|
*stop = YES;
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}];
|
||||||
|
|
||||||
|
CGRect bubbleComponentFrame;
|
||||||
|
|
||||||
|
if (bubbleComponents.count > 0)
|
||||||
|
{
|
||||||
|
NSInteger selectedComponentIndex = foundComponentIndex != NSNotFound ? foundComponentIndex : 0;
|
||||||
|
bubbleComponentFrame = [roomBubbleTableViewCell componentFrameForIndex:selectedComponentIndex];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bubbleComponentFrame = roomBubbleTableViewCell.frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGRect bubbleComponentFrameInOverlayView = [self.bubblesTableView convertRect:bubbleComponentFrame toView:self.overlayContainerView];
|
||||||
|
|
||||||
|
[self.roomContextualMenuPresenter showReactionsMenuForEvent:event.eventId inRoom:event.roomId session:self.mainSession aroundFrame:bubbleComponentFrameInOverlayView];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue