RoomDataSource: Use RoomTimelineCellDecorator to animate read marker dismiss.

This commit is contained in:
SBiOSoftWhare 2022-02-17 17:46:26 +01:00
parent d6a85e0dcb
commit d187bba039

View file

@ -5821,44 +5821,23 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
- (void)animateReadMarkerView
{
// Check whether the cell with the read marker is known and if the marker is not animated yet.
if (readMarkerTableViewCell && readMarkerTableViewCell.readMarkerView.isHidden)
if (!readMarkerTableViewCell || readMarkerTableViewCell.readMarkerView.isHidden == NO)
{
return;
}
RoomBubbleCellData *cellData = (RoomBubbleCellData*)readMarkerTableViewCell.bubbleData;
// Do not display the marker if this is the last message.
if (cellData.containsLastMessage && readMarkerTableViewCell.readMarkerView.tag == cellData.mostRecentComponentIndex)
{
readMarkerTableViewCell.readMarkerView.hidden = YES;
readMarkerTableViewCell = nil;
}
else
{
readMarkerTableViewCell.readMarkerView.hidden = NO;
id<RoomTimelineCellDecorator> cellDecorator = [RoomTimelineConfiguration shared].currentStyle.cellDecorator;
// Animate the layout to hide the read marker
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[UIView animateWithDuration:1.5 delay:0 options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseIn
animations:^{
self->readMarkerTableViewCell.readMarkerViewLeadingConstraint.constant = self->readMarkerTableViewCell.readMarkerViewTrailingConstraint.constant = self->readMarkerTableViewCell.bubbleOverlayContainer.frame.size.width / 2;
self->readMarkerTableViewCell.readMarkerView.alpha = 0;
// Force to render the view
[self->readMarkerTableViewCell.bubbleOverlayContainer layoutIfNeeded];
}
completion:^(BOOL finished){
self->readMarkerTableViewCell.readMarkerView.hidden = YES;
self->readMarkerTableViewCell.readMarkerView.alpha = 1;
[cellDecorator dissmissReadMarkerViewForCell:readMarkerTableViewCell
cellData:cellData
animated:YES
completion:^{
self->readMarkerTableViewCell = nil;
}];
});
}
}
}
- (void)refreshRemoveJitsiWidgetView