diff --git a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/BubbleRoomCellLayoutUpdater.swift b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/BubbleRoomCellLayoutUpdater.swift index 28fdcb163..efa90a5e0 100644 --- a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/BubbleRoomCellLayoutUpdater.swift +++ b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/BubbleRoomCellLayoutUpdater.swift @@ -99,6 +99,14 @@ class BubbleRoomCellLayoutUpdater: RoomCellLayoutUpdating { cell.setNeedsUpdateConstraints() } + func setupLayout(forOutgoingFileAttachmentCell cell: MXKRoomBubbleTableViewCell) { + + // Hide avatar view + cell.pictureView?.isHidden = true + + self.setupOutgoingFileAttachViewMargins(for: cell) + } + // MARK: Themable func update(theme: Theme) { @@ -310,4 +318,28 @@ class BubbleRoomCellLayoutUpdater: RoomCellLayoutUpdating { cell.msgTextViewBottomConstraint.constant += bottomMargin } + + private func setupOutgoingFileAttachViewMargins(for cell: MXKRoomBubbleTableViewCell) { + + guard let attachmentView = cell.attachmentView else { + return + } + + let contentView = cell.contentView + + // TODO: Use constants + // Same as URL preview + let rightMargin: CGFloat = 34.0 + + if let attachViewLeadingConstraint = cell.attachViewLeadingConstraint { + attachViewLeadingConstraint.isActive = false + cell.attachViewLeadingConstraint = nil + } + + let rightConstraint = attachmentView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -rightMargin) + + NSLayoutConstraint.activate([ + rightConstraint + ]) + } }