mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-05-19 22:22:14 +02:00
Merge pull request #7533 from vector-im/nimau/7526_marker_overlap_bubble
Fix the position of the marker highlighting an event.
This commit is contained in:
@@ -256,40 +256,18 @@ NSString *const kMXKRoomBubbleCellKeyVerificationIncomingRequestDeclinePressed =
|
||||
|
||||
if (componentIndex < bubbleComponents.count)
|
||||
{
|
||||
MXKRoomBubbleComponent *component = bubbleComponents[componentIndex];
|
||||
|
||||
// Define the marker frame
|
||||
CGFloat markPosY = component.position.y + self.msgTextViewTopConstraint.constant;
|
||||
|
||||
NSInteger mostRecentComponentIndex = bubbleComponents.count - 1;
|
||||
if ([bubbleData isKindOfClass:RoomBubbleCellData.class])
|
||||
CGRect componentFrame = [self componentFrameInContentViewForIndex:componentIndex];
|
||||
if (CGRectIsEmpty(componentFrame))
|
||||
{
|
||||
mostRecentComponentIndex = ((RoomBubbleCellData*)bubbleData).mostRecentComponentIndex;
|
||||
}
|
||||
|
||||
// Compute the mark height.
|
||||
// Use the rest of the cell height by default.
|
||||
CGFloat markHeight = self.contentView.frame.size.height - markPosY;
|
||||
if (componentIndex != mostRecentComponentIndex)
|
||||
{
|
||||
// There is another component (with display) after this component in the cell.
|
||||
// Stop the marker height to the top of this component.
|
||||
for (NSInteger index = componentIndex + 1; index < bubbleComponents.count; index ++)
|
||||
{
|
||||
MXKRoomBubbleComponent *nextComponent = bubbleComponents[index];
|
||||
|
||||
if (nextComponent.attributedTextMessage)
|
||||
{
|
||||
markHeight = nextComponent.position.y - component.position.y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
UIView *markerView = [[UIView alloc] initWithFrame:CGRectMake(VECTOR_ROOMBUBBLETABLEVIEWCELL_MARK_X,
|
||||
markPosY,
|
||||
VECTOR_ROOMBUBBLETABLEVIEWCELL_MARK_WIDTH,
|
||||
markHeight)];
|
||||
CGRect markerFrame = CGRectMake(VECTOR_ROOMBUBBLETABLEVIEWCELL_MARK_X,
|
||||
CGRectGetMinY(componentFrame),
|
||||
VECTOR_ROOMBUBBLETABLEVIEWCELL_MARK_WIDTH,
|
||||
CGRectGetHeight(componentFrame));
|
||||
|
||||
UIView *markerView = [[UIView alloc] initWithFrame:markerFrame];
|
||||
markerView.backgroundColor = ThemeService.shared.theme.tintColor;
|
||||
|
||||
[markerView setTranslatesAutoresizingMaskIntoConstraints:NO];
|
||||
@@ -303,28 +281,28 @@ NSString *const kMXKRoomBubbleCellKeyVerificationIncomingRequestDeclinePressed =
|
||||
toItem:self.contentView
|
||||
attribute:NSLayoutAttributeLeading
|
||||
multiplier:1.0
|
||||
constant:VECTOR_ROOMBUBBLETABLEVIEWCELL_MARK_X];
|
||||
constant:CGRectGetMinX(markerFrame)];
|
||||
NSLayoutConstraint *topConstraint = [NSLayoutConstraint constraintWithItem:markerView
|
||||
attribute:NSLayoutAttributeTop
|
||||
relatedBy:NSLayoutRelationEqual
|
||||
toItem:self.contentView
|
||||
attribute:NSLayoutAttributeTop
|
||||
multiplier:1.0
|
||||
constant:markPosY];
|
||||
constant:CGRectGetMinY(markerFrame)];
|
||||
NSLayoutConstraint *widthConstraint = [NSLayoutConstraint constraintWithItem:markerView
|
||||
attribute:NSLayoutAttributeWidth
|
||||
relatedBy:NSLayoutRelationEqual
|
||||
toItem:nil
|
||||
attribute:NSLayoutAttributeNotAnAttribute
|
||||
multiplier:1.0
|
||||
constant:VECTOR_ROOMBUBBLETABLEVIEWCELL_MARK_WIDTH];
|
||||
constant:CGRectGetWidth(markerFrame)];
|
||||
NSLayoutConstraint *heightConstraint = [NSLayoutConstraint constraintWithItem:markerView
|
||||
attribute:NSLayoutAttributeHeight
|
||||
relatedBy:NSLayoutRelationEqual
|
||||
toItem:nil
|
||||
attribute:NSLayoutAttributeNotAnAttribute
|
||||
multiplier:1.0
|
||||
constant:markHeight];
|
||||
constant:CGRectGetHeight(markerFrame)];
|
||||
|
||||
// Available on iOS 8 and later
|
||||
[NSLayoutConstraint activateConstraints:@[leftConstraint, topConstraint, widthConstraint, heightConstraint]];
|
||||
|
||||
@@ -7504,23 +7504,47 @@ static CGSize kThreadListBarButtonItemImageSize;
|
||||
return;
|
||||
}
|
||||
|
||||
NSMutableArray<NSIndexPath *> *rowsToReload = [[NSMutableArray alloc] init];
|
||||
// Get the current hightlighted event because we will need to reload it
|
||||
NSString *currentHiglightedEventId = self.customizedRoomDataSource.highlightedEventId;
|
||||
if (currentHiglightedEventId)
|
||||
{
|
||||
NSInteger currentHiglightedRow = [self.roomDataSource indexOfCellDataWithEventId:currentHiglightedEventId];
|
||||
if (currentHiglightedRow != NSNotFound)
|
||||
{
|
||||
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:currentHiglightedRow inSection:0];
|
||||
if ([[self.bubblesTableView indexPathsForVisibleRows] containsObject:indexPath])
|
||||
{
|
||||
[rowsToReload addObject:indexPath];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.customizedRoomDataSource.highlightedEventId = eventId;
|
||||
|
||||
// Add the new highligted event to the list of rows to reload
|
||||
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:0];
|
||||
if ([[self.bubblesTableView indexPathsForVisibleRows] containsObject:indexPath])
|
||||
BOOL indexPathIsVisible = [[self.bubblesTableView indexPathsForVisibleRows] containsObject:indexPath];
|
||||
if (indexPathIsVisible)
|
||||
{
|
||||
[self.bubblesTableView reloadRowsAtIndexPaths:@[indexPath]
|
||||
[rowsToReload addObject:indexPath];
|
||||
}
|
||||
|
||||
// Reload rows
|
||||
if (rowsToReload.count > 0)
|
||||
{
|
||||
[self.bubblesTableView reloadRowsAtIndexPaths:rowsToReload
|
||||
withRowAnimation:UITableViewRowAnimationNone];
|
||||
[self.bubblesTableView scrollToRowAtIndexPath:indexPath
|
||||
atScrollPosition:UITableViewScrollPositionMiddle
|
||||
animated:YES];
|
||||
}
|
||||
else if ([self.bubblesTableView vc_hasIndexPath:indexPath])
|
||||
|
||||
// Scroll to the newly highlighted row
|
||||
if (indexPathIsVisible || [self.bubblesTableView vc_hasIndexPath:indexPath])
|
||||
{
|
||||
[self.bubblesTableView scrollToRowAtIndexPath:indexPath
|
||||
atScrollPosition:UITableViewScrollPositionMiddle
|
||||
animated:YES];
|
||||
}
|
||||
|
||||
if (completion)
|
||||
{
|
||||
completion();
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
Fix the position of the marker highlighting an event.
|
||||
Reference in New Issue
Block a user