Conform cells to RoomCellReadMarkerDisplayable.

This commit is contained in:
SBiOSoftWhare 2022-02-17 19:22:56 +01:00
parent 5bf67bbddd
commit 5d9040db4b
6 changed files with 44 additions and 38 deletions

View file

@ -16,7 +16,7 @@
import UIKit
class FileWithoutThumbnailBaseBubbleCell: SizableBaseRoomCell, RoomCellReactionsDisplayable {
class FileWithoutThumbnailBaseBubbleCell: SizableBaseRoomCell, RoomCellReactionsDisplayable, RoomCellReadMarkerDisplayable {
weak var fileAttachementView: FileWithoutThumbnailCellContentView?

View file

@ -16,7 +16,7 @@
import UIKit
class TextMessageBaseBubbleCell: SizableBaseRoomCell, RoomCellURLPreviewDisplayable, RoomCellReactionsDisplayable, RoomCellThreadSummaryDisplayable, RoomCellReadReceiptsDisplayable {
class TextMessageBaseBubbleCell: SizableBaseRoomCell, RoomCellURLPreviewDisplayable, RoomCellReactionsDisplayable, RoomCellThreadSummaryDisplayable, RoomCellReadReceiptsDisplayable, RoomCellReadMarkerDisplayable {
// MARK: - Properties

View file

@ -16,7 +16,7 @@
import Foundation
class LocationBubbleCell: SizableBaseRoomCell, RoomCellReactionsDisplayable {
class LocationBubbleCell: SizableBaseRoomCell, RoomCellReactionsDisplayable, RoomCellReadMarkerDisplayable {
private var locationView: RoomTimelineLocationView!

View file

@ -16,7 +16,7 @@
import Foundation
class PollBubbleCell: SizableBaseRoomCell, RoomCellReactionsDisplayable {
class PollBubbleCell: SizableBaseRoomCell, RoomCellReactionsDisplayable, RoomCellReadMarkerDisplayable {
private var pollView: UIView?
private var event: MXEvent?

View file

@ -16,7 +16,7 @@
import Foundation
class VoiceMessageBubbleCell: SizableBaseRoomCell, RoomCellReactionsDisplayable {
class VoiceMessageBubbleCell: SizableBaseRoomCell, RoomCellReactionsDisplayable, RoomCellReadMarkerDisplayable {
private(set) var playbackController: VoiceMessagePlaybackController!

View file

@ -210,40 +210,46 @@ class PlainRoomTimelineCellDecorator: RoomTimelineCellDecorator {
cellData: MXKRoomBubbleCellData,
contentViewPositionY: CGFloat) {
guard let overlayContainer = cell.bubbleOverlayContainer else {
return
if let readMarkerDisplayable = cell as? RoomCellReadMarkerDisplayable {
readMarkerDisplayable.addReadMarkerView(readMarkerView)
} else {
guard let overlayContainer = cell.bubbleOverlayContainer else {
return
}
// The read marker is added into the overlay container.
// CAUTION: Keep disabled the user interaction on this container to not disturb tap gesture handling.
overlayContainer.backgroundColor = UIColor.clear
overlayContainer.alpha = 1
overlayContainer.isUserInteractionEnabled = false
overlayContainer.isHidden = false
// Add read marker to overlayContainer
readMarkerView.translatesAutoresizingMaskIntoConstraints = false
overlayContainer.addSubview(readMarkerView)
cell.readMarkerView = readMarkerView
// Force read marker constraints
let topConstraint = readMarkerView.topAnchor.constraint(equalTo: overlayContainer.topAnchor, constant: contentViewPositionY - PlainRoomCellLayoutConstants.readMarkerViewHeight)
let leadingConstraint = readMarkerView.leadingAnchor.constraint(equalTo: overlayContainer.leadingAnchor)
let trailingConstraint = readMarkerView.trailingAnchor.constraint(equalTo: overlayContainer.trailingAnchor)
let heightConstraint = readMarkerView.heightAnchor.constraint(equalToConstant: PlainRoomCellLayoutConstants.readMarkerViewHeight)
NSLayoutConstraint.activate([topConstraint,
leadingConstraint,
trailingConstraint,
heightConstraint])
cell.readMarkerViewTopConstraint = topConstraint
cell.readMarkerViewLeadingConstraint = leadingConstraint
cell.readMarkerViewTrailingConstraint = trailingConstraint
cell.readMarkerViewHeightConstraint = heightConstraint
}
// The read marker is added into the overlay container.
// CAUTION: Keep disabled the user interaction on this container to not disturb tap gesture handling.
overlayContainer.backgroundColor = UIColor.clear
overlayContainer.alpha = 1
overlayContainer.isUserInteractionEnabled = false
overlayContainer.isHidden = false
// Add read marker to overlayContainer
readMarkerView.translatesAutoresizingMaskIntoConstraints = false
overlayContainer.addSubview(readMarkerView)
cell.readMarkerView = readMarkerView
// Force read marker constraints
let topConstraint = readMarkerView.topAnchor.constraint(equalTo: overlayContainer.topAnchor, constant: contentViewPositionY - PlainRoomCellLayoutConstants.readMarkerViewHeight)
let leadingConstraint = readMarkerView.leadingAnchor.constraint(equalTo: overlayContainer.leadingAnchor)
let trailingConstraint = readMarkerView.trailingAnchor.constraint(equalTo: overlayContainer.trailingAnchor)
let heightConstraint = readMarkerView.heightAnchor.constraint(equalToConstant: PlainRoomCellLayoutConstants.readMarkerViewHeight)
NSLayoutConstraint.activate([topConstraint,
leadingConstraint,
trailingConstraint,
heightConstraint])
cell.readMarkerViewTopConstraint = topConstraint
cell.readMarkerViewLeadingConstraint = leadingConstraint
cell.readMarkerViewTrailingConstraint = trailingConstraint
cell.readMarkerViewHeightConstraint = heightConstraint
}
func dissmissReadMarkerView(forCell cell: MXKRoomBubbleTableViewCell,