diff --git a/Riot/Modules/Room/Views/BubbleCells/RoomBubbleCellLayout.swift b/Riot/Modules/Room/Views/BubbleCells/RoomBubbleCellLayout.swift
index 641bc0677e..46ba7e6187 100644
--- a/Riot/Modules/Room/Views/BubbleCells/RoomBubbleCellLayout.swift
+++ b/Riot/Modules/Room/Views/BubbleCells/RoomBubbleCellLayout.swift
@@ -20,6 +20,9 @@ import Foundation
@objcMembers
final class RoomBubbleCellLayout: NSObject {
+ /// Inner content view margins
+ static let innerContentViewMargins: UIEdgeInsets = UIEdgeInsets(top: 0, left: 57, bottom: 0.0, right: 0)
+
// Reactions
static let reactionsViewTopMargin: CGFloat = 1.0
diff --git a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/BubbleRoomCellLayoutConstants.swift b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/BubbleRoomCellLayoutConstants.swift
index 2a978f82d4..52e264b13b 100644
--- a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/BubbleRoomCellLayoutConstants.swift
+++ b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/BubbleRoomCellLayoutConstants.swift
@@ -21,9 +21,38 @@ import Foundation
@objcMembers
final class BubbleRoomCellLayoutConstants: NSObject {
+ /// Inner content view margins
+ static let innerContentViewMargins: UIEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 5.0, right: 0)
+
+ // Text message bubbles margins from cell content view
+
static let outgoingBubbleBackgroundMargins: UIEdgeInsets = UIEdgeInsets(top: 0, left: 80, bottom: 0, right: 34)
- static let incomingBubbleBackgroundMargins: UIEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 80)
+ static let incomingBubbleBackgroundMargins: UIEdgeInsets = UIEdgeInsets(top: 0, left: 48, bottom: 0, right: 80)
+
+ static let bubbleTextViewInsets: UIEdgeInsets = UIEdgeInsets(top: 5, left: 5, bottom: 5, right: 45)
+
+ static let bubbleCornerRadius: CGFloat = 12.0
+
+ // Voice message
+
+ static let voiceMessagePlaybackViewRightMargin: CGFloat = 40
+
+ // Polls
+
+ static let pollBubbleBackgroundInsets: UIEdgeInsets = UIEdgeInsets(top: 2, left: 10, bottom: 0, right: 10)
+
+ // Decoration margins
+
+ // Timestamp margins
+
+ /// Timestamp margins for sticker cell, margin is relative to the image view
+ static let stickerTimestampViewMargins = UIEdgeInsets(top: 0, left: 0, bottom: 20, right: -27) // Right margin is not reliable there, if the text size change this one is not working anymore
+
+ /// Timestamp margins inside bubble
+ static let bubbleTimestampViewMargins = UIEdgeInsets(top: 0, left: 0, bottom: 4.0, right: 8.0)
- static let threadSummaryViewMargins: UIEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 5, right: 0)
+ static let reactionsViewMargins = UIEdgeInsets(top: 4, left: 0, bottom: 0, right: 0)
+
+ static let threadSummaryViewMargins: UIEdgeInsets = UIEdgeInsets(top: 8.0, left: 0, bottom: 5, right: 0)
}
diff --git a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/BubbleRoomCellLayoutUpdater.swift b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/BubbleRoomCellLayoutUpdater.swift
index 4cd22c10bb..eaea8739d1 100644
--- a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/BubbleRoomCellLayoutUpdater.swift
+++ b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/BubbleRoomCellLayoutUpdater.swift
@@ -152,11 +152,10 @@ class BubbleRoomCellLayoutUpdater: RoomCellLayoutUpdating {
private func getIncomingMessageTextViewInsets(from bubbleCell: MXKRoomBubbleTableViewCell) -> UIEdgeInsets {
- let bubbleBgRightMargin: CGFloat = 45
let messageViewMarginTop: CGFloat = 0
- let messageViewMarginBottom: CGFloat = -0
+ let messageViewMarginBottom: CGFloat = 0
let messageViewMarginLeft: CGFloat = 0
- let messageViewMarginRight: CGFloat = 80 + bubbleBgRightMargin
+ let messageViewMarginRight: CGFloat = BubbleRoomCellLayoutConstants.incomingBubbleBackgroundMargins.right + BubbleRoomCellLayoutConstants.bubbleTextViewInsets.right
let messageViewInsets = UIEdgeInsets(top: messageViewMarginTop, left: messageViewMarginLeft, bottom: messageViewMarginBottom, right: messageViewMarginRight)
@@ -180,13 +179,12 @@ class BubbleRoomCellLayoutUpdater: RoomCellLayoutUpdating {
}
private func getOutgoingMessageTextViewMargins(from bubbleCell: MXKRoomBubbleTableViewCell) -> UIEdgeInsets {
-
- let innerContentLeftMargin: CGFloat = 57
let messageViewMarginTop: CGFloat = 0
let messageViewMarginBottom: CGFloat = 0
- let messageViewMarginLeft: CGFloat = 80.0 + innerContentLeftMargin
- let messageViewMarginRight: CGFloat = 78.0
+ let messageViewMarginLeft =
+ BubbleRoomCellLayoutConstants.outgoingBubbleBackgroundMargins.left + BubbleRoomCellLayoutConstants.bubbleTextViewInsets.left
+ let messageViewMarginRight = BubbleRoomCellLayoutConstants.outgoingBubbleBackgroundMargins.right + BubbleRoomCellLayoutConstants.bubbleTextViewInsets.right
let messageViewInsets = UIEdgeInsets(top: messageViewMarginTop, left: messageViewMarginLeft, bottom: messageViewMarginBottom, right: messageViewMarginRight)
@@ -230,10 +228,8 @@ class BubbleRoomCellLayoutUpdater: RoomCellLayoutUpdating {
}
let contentView = cell.contentView
-
- // TODO: Use constants
- // Same as URL preview
- let rightMargin: CGFloat = 34.0
+
+ let rightMargin = BubbleRoomCellLayoutConstants.outgoingBubbleBackgroundMargins.right
if let attachViewLeadingConstraint = cell.attachViewLeadingConstraint {
attachViewLeadingConstraint.isActive = false
@@ -263,8 +259,7 @@ class BubbleRoomCellLayoutUpdater: RoomCellLayoutUpdating {
let contentView = cell.contentView
- // TODO: Use constants
- let leftMargin: CGFloat = 67
+ let leftMargin: CGFloat = BubbleRoomCellLayoutConstants.incomingBubbleBackgroundMargins.left
let leftConstraint = attachmentView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: -leftMargin)
diff --git a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/BubbleRoomTimelineCellDecorator.swift b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/BubbleRoomTimelineCellDecorator.swift
index 7feac51fb0..44efeceb11 100644
--- a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/BubbleRoomTimelineCellDecorator.swift
+++ b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/BubbleRoomTimelineCellDecorator.swift
@@ -44,8 +44,8 @@ class BubbleRoomTimelineCellDecorator: PlainRoomTimelineCellDecorator {
let attachmentView = cell.attachmentView {
// Prevent overlap with send status icon
- let bottomMargin: CGFloat = 20.0
- let rightMargin: CGFloat = -27.0
+ let bottomMargin: CGFloat = BubbleRoomCellLayoutConstants.stickerTimestampViewMargins.bottom
+ let rightMargin: CGFloat = BubbleRoomCellLayoutConstants.stickerTimestampViewMargins.right
self.addTimestampLabel(timestampLabel,
to: cell,
@@ -105,43 +105,38 @@ class BubbleRoomTimelineCellDecorator: PlainRoomTimelineCellDecorator {
let cellContentView = cell.contentView
cellContentView.addSubview(reactionsView)
-
- // TODO: Use constants
- let topMargin: CGFloat = 4.0
+
+ let topMargin: CGFloat = RoomBubbleCellLayout.reactionsViewTopMargin
let leftMargin: CGFloat
let rightMargin: CGFloat
// Incoming message
if cellData.isIncoming {
- var incomingLeftMargin = RoomBubbleCellLayout.reactionsViewLeftMargin
+ var incomingLeftMargin = BubbleRoomCellLayoutConstants.incomingBubbleBackgroundMargins.left
if cellData.containsBubbleComponentWithEncryptionBadge {
incomingLeftMargin += RoomBubbleCellLayout.encryptedContentLeftMargin
}
- leftMargin = incomingLeftMargin - 6.0
+ leftMargin = incomingLeftMargin
- // TODO: Use constants
- let messageViewMarginRight: CGFloat = 42.0
+ rightMargin = BubbleRoomCellLayoutConstants.incomingBubbleBackgroundMargins.right
- rightMargin = messageViewMarginRight
} else {
// Outgoing message
reactionsView.alignment = .right
-
- // TODO: Use constants
- var outgoingLeftMargin: CGFloat = 80.0
+
+ var outgoingLeftMargin = BubbleRoomCellLayoutConstants.outgoingBubbleBackgroundMargins.left
if cellData.containsBubbleComponentWithEncryptionBadge {
outgoingLeftMargin += RoomBubbleCellLayout.encryptedContentLeftMargin
}
leftMargin = outgoingLeftMargin
-
- // TODO: Use constants
- rightMargin = 33
+
+ rightMargin = BubbleRoomCellLayoutConstants.outgoingBubbleBackgroundMargins.right
}
let leadingConstraint = reactionsView.leadingAnchor.constraint(equalTo: cellContentView.leadingAnchor, constant: leftMargin)
@@ -190,14 +185,11 @@ class BubbleRoomTimelineCellDecorator: PlainRoomTimelineCellDecorator {
leftMargin += RoomBubbleCellLayout.encryptedContentLeftMargin
}
- leftMargin-=5.0
-
leadingOrTrailingConstraint = urlPreviewView.leadingAnchor.constraint(equalTo: cellContentView.leadingAnchor, constant: leftMargin)
} else {
// Outgoing message
- // TODO: Use constants
- let rightMargin: CGFloat = 34.0
+ let rightMargin: CGFloat = BubbleRoomCellLayoutConstants.outgoingBubbleBackgroundMargins.right
leadingOrTrailingConstraint = urlPreviewView.trailingAnchor.constraint(equalTo: cellContentView.trailingAnchor, constant: -rightMargin)
}
@@ -238,14 +230,12 @@ class BubbleRoomTimelineCellDecorator: PlainRoomTimelineCellDecorator {
// Incoming message
if cellData.isIncoming {
- leftMargin = RoomBubbleCellLayout.reactionsViewLeftMargin
+ leftMargin = BubbleRoomCellLayoutConstants.incomingBubbleBackgroundMargins.left
if cellData.containsBubbleComponentWithEncryptionBadge {
leftMargin += RoomBubbleCellLayout.encryptedContentLeftMargin
}
- leftMargin-=5.0
-
- rightMargin = RoomBubbleCellLayout.reactionsViewRightMargin
+ rightMargin = BubbleRoomCellLayoutConstants.incomingBubbleBackgroundMargins.right
leadingConstraint = threadSummaryView.leadingAnchor.constraint(equalTo: cellContentView.leadingAnchor,
constant: leftMargin)
@@ -253,10 +243,9 @@ class BubbleRoomTimelineCellDecorator: PlainRoomTimelineCellDecorator {
constant: -rightMargin)
} else {
// Outgoing message
-
- // TODO: Use constants
- leftMargin = 80.0
- rightMargin = 34.0
+
+ leftMargin = BubbleRoomCellLayoutConstants.outgoingBubbleBackgroundMargins.left
+ rightMargin = BubbleRoomCellLayoutConstants.outgoingBubbleBackgroundMargins.right
leadingConstraint = threadSummaryView.leadingAnchor.constraint(greaterThanOrEqualTo: cellContentView.leadingAnchor,
constant: leftMargin)
@@ -264,7 +253,8 @@ class BubbleRoomTimelineCellDecorator: PlainRoomTimelineCellDecorator {
constant: -rightMargin)
}
- let topMargin = RoomBubbleCellLayout.threadSummaryViewTopMargin + 15.0
+ let topMargin = RoomBubbleCellLayout.threadSummaryViewTopMargin
+
let height = ThreadSummaryView.contentViewHeight(forThread: threadSummaryView.thread,
fitting: cellData.maxTextViewWidth)
@@ -376,8 +366,8 @@ class BubbleRoomTimelineCellDecorator: PlainRoomTimelineCellDecorator {
to cell: MXKRoomBubbleTableViewCell,
on containerView: UIView,
constrainingView: UIView,
- rightMargin: CGFloat = 8.0,
- bottomMargin: CGFloat = 4.0) {
+ rightMargin: CGFloat = BubbleRoomCellLayoutConstants.bubbleTimestampViewMargins.right,
+ bottomMargin: CGFloat = BubbleRoomCellLayoutConstants.bubbleTimestampViewMargins.bottom) {
timestampLabel.translatesAutoresizingMaskIntoConstraints = false
cell.addTemporarySubview(timestampLabel)
diff --git a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/FileWithoutThumbnail/Common/FileWithoutThumbnailCellContentView.swift b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/FileWithoutThumbnail/Common/FileWithoutThumbnailCellContentView.swift
index ce0471dad6..1d2058a277 100644
--- a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/FileWithoutThumbnail/Common/FileWithoutThumbnailCellContentView.swift
+++ b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/FileWithoutThumbnail/Common/FileWithoutThumbnailCellContentView.swift
@@ -19,13 +19,6 @@ import Reusable
final class FileWithoutThumbnailCellContentView: UIView, NibLoadable {
- // MARK: - Constants
-
- private enum Constants {
- // TODO: Reuse constants, same as bubble bg
- static let cornerRadius: CGFloat = 12.0
- }
-
// MARK: - Properties
// MARK: Outlets
@@ -61,7 +54,7 @@ final class FileWithoutThumbnailCellContentView: UIView, NibLoadable {
override func layoutSubviews() {
super.layoutSubviews()
- self.layer.cornerRadius = Constants.cornerRadius
+ self.layer.cornerRadius = BubbleRoomCellLayoutConstants.bubbleCornerRadius
}
// MARK: - Public
diff --git a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/FileWithoutThumbnail/Incoming/FileWithoutThumbnailIncomingBubbleCell.swift b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/FileWithoutThumbnail/Incoming/FileWithoutThumbnailIncomingBubbleCell.swift
index bcc52efa84..dcf4ef4476 100644
--- a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/FileWithoutThumbnail/Incoming/FileWithoutThumbnailIncomingBubbleCell.swift
+++ b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/FileWithoutThumbnail/Incoming/FileWithoutThumbnailIncomingBubbleCell.swift
@@ -23,12 +23,8 @@ class FileWithoutThumbnailIncomingBubbleCell: FileWithoutThumbnailBaseBubbleCell
bubbleCellContentView?.showSenderInfo = true
- // TODO: Use constants
- let messageViewMarginRight: CGFloat = 80
- let messageLeftMargin: CGFloat = 48
-
- bubbleCellContentView?.innerContentViewTrailingConstraint.constant = messageViewMarginRight
- bubbleCellContentView?.innerContentViewLeadingConstraint.constant = messageLeftMargin
+ bubbleCellContentView?.innerContentViewLeadingConstraint.constant = BubbleRoomCellLayoutConstants.incomingBubbleBackgroundMargins.left
+ bubbleCellContentView?.innerContentViewTrailingConstraint.constant = BubbleRoomCellLayoutConstants.incomingBubbleBackgroundMargins.right
self.setupBubbleDecorations()
}
diff --git a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/FileWithoutThumbnail/Outgoing/FileWithoutThumbnailOutoingWithoutSenderInfoBubbleCell.swift b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/FileWithoutThumbnail/Outgoing/FileWithoutThumbnailOutoingWithoutSenderInfoBubbleCell.swift
index 4f22837706..f3d5e8a3a6 100644
--- a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/FileWithoutThumbnail/Outgoing/FileWithoutThumbnailOutoingWithoutSenderInfoBubbleCell.swift
+++ b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/FileWithoutThumbnail/Outgoing/FileWithoutThumbnailOutoingWithoutSenderInfoBubbleCell.swift
@@ -23,13 +23,8 @@ class FileWithoutThumbnailOutoingWithoutSenderInfoBubbleCell: FileWithoutThumbna
bubbleCellContentView?.showSenderInfo = false
- // TODO: Use constants
- // Same as outgoing message
- let rightMargin: CGFloat = 34.0
- let leftMargin: CGFloat = 80.0
-
- bubbleCellContentView?.innerContentViewTrailingConstraint.constant = rightMargin
- bubbleCellContentView?.innerContentViewLeadingConstraint.constant = leftMargin
+ bubbleCellContentView?.innerContentViewLeadingConstraint.constant = BubbleRoomCellLayoutConstants.outgoingBubbleBackgroundMargins.left
+ bubbleCellContentView?.innerContentViewTrailingConstraint.constant = BubbleRoomCellLayoutConstants.outgoingBubbleBackgroundMargins.right
self.setupBubbleDecorations()
}
diff --git a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/Location/Incoming/LocationIncomingBubbleCell.swift b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/Location/Incoming/LocationIncomingBubbleCell.swift
index 4a7fb08b5a..97a80a5caa 100644
--- a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/Location/Incoming/LocationIncomingBubbleCell.swift
+++ b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/Location/Incoming/LocationIncomingBubbleCell.swift
@@ -21,12 +21,8 @@ class LocationIncomingBubbleCell: LocationBubbleCell, BubbleIncomingRoomCellProt
override func setupViews() {
super.setupViews()
- // TODO: Use constants
- let messageViewMarginRight: CGFloat = 80
- let messageLeftMargin: CGFloat = 48
-
- bubbleCellContentView?.innerContentViewTrailingConstraint.constant = messageViewMarginRight
- bubbleCellContentView?.innerContentViewLeadingConstraint.constant = messageLeftMargin
+ bubbleCellContentView?.innerContentViewLeadingConstraint.constant = BubbleRoomCellLayoutConstants.incomingBubbleBackgroundMargins.left
+ bubbleCellContentView?.innerContentViewTrailingConstraint.constant = BubbleRoomCellLayoutConstants.incomingBubbleBackgroundMargins.right
self.setupBubbleDecorations()
}
diff --git a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/Location/Outgoing/LocationOutgoingWithoutSenderInfoBubbleCell.swift b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/Location/Outgoing/LocationOutgoingWithoutSenderInfoBubbleCell.swift
index ef2061224c..3d30a86b0a 100644
--- a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/Location/Outgoing/LocationOutgoingWithoutSenderInfoBubbleCell.swift
+++ b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/Location/Outgoing/LocationOutgoingWithoutSenderInfoBubbleCell.swift
@@ -23,9 +23,8 @@ class LocationOutgoingWithoutSenderInfoBubbleCell: LocationBubbleCell, BubbleOut
bubbleCellContentView?.showSenderInfo = false
- bubbleCellContentView?.innerContentViewTrailingConstraint.constant = BubbleRoomCellLayoutConstants.outgoingBubbleBackgroundMargins.right
-
bubbleCellContentView?.innerContentViewLeadingConstraint.constant = BubbleRoomCellLayoutConstants.outgoingBubbleBackgroundMargins.left
+ bubbleCellContentView?.innerContentViewTrailingConstraint.constant = BubbleRoomCellLayoutConstants.outgoingBubbleBackgroundMargins.right
self.setupBubbleDecorations()
}
diff --git a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/Poll/Incoming/PollIncomingBubbleCell.swift b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/Poll/Incoming/PollIncomingBubbleCell.swift
index c71810ef5a..aee7f10302 100644
--- a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/Poll/Incoming/PollIncomingBubbleCell.swift
+++ b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/Poll/Incoming/PollIncomingBubbleCell.swift
@@ -21,13 +21,11 @@ class PollIncomingBubbleCell: PollBaseBubbleCell, BubbleIncomingRoomCellProtocol
override func setupViews() {
super.setupViews()
- // TODO: Use constants
- let bubbleBackgroundSideMargin: CGFloat = 10
- let messageViewMarginRight: CGFloat = 80 + bubbleBackgroundSideMargin
- let messageLeftMargin: CGFloat = 48 + bubbleBackgroundSideMargin
+ let leftMargin: CGFloat = BubbleRoomCellLayoutConstants.incomingBubbleBackgroundMargins.left + BubbleRoomCellLayoutConstants.pollBubbleBackgroundInsets.left
+ let rightMargin: CGFloat = BubbleRoomCellLayoutConstants.incomingBubbleBackgroundMargins.right + BubbleRoomCellLayoutConstants.pollBubbleBackgroundInsets.right
- bubbleCellContentView?.innerContentViewTrailingConstraint.constant = messageViewMarginRight
- bubbleCellContentView?.innerContentViewLeadingConstraint.constant = messageLeftMargin
+ bubbleCellContentView?.innerContentViewLeadingConstraint.constant = leftMargin
+ bubbleCellContentView?.innerContentViewTrailingConstraint.constant = rightMargin
self.setupBubbleDecorations()
}
diff --git a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/Poll/Outgoing/PollOutgoingWithoutSenderInfoBubbleCell.swift b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/Poll/Outgoing/PollOutgoingWithoutSenderInfoBubbleCell.swift
index b16150d6c8..2525b2af85 100644
--- a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/Poll/Outgoing/PollOutgoingWithoutSenderInfoBubbleCell.swift
+++ b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/Poll/Outgoing/PollOutgoingWithoutSenderInfoBubbleCell.swift
@@ -22,12 +22,9 @@ class PollOutgoingWithoutSenderInfoBubbleCell: PollBaseBubbleCell, BubbleOutgoin
super.setupViews()
bubbleCellContentView?.showSenderInfo = false
-
- // TODO: Use constants
- // Same as outgoing message
- let bubbleBackgroundSideMargin: CGFloat = 10
- let rightMargin: CGFloat = 34.0 + bubbleBackgroundSideMargin
- let leftMargin: CGFloat = 80.0 + bubbleBackgroundSideMargin
+
+ let leftMargin: CGFloat = BubbleRoomCellLayoutConstants.outgoingBubbleBackgroundMargins.left + BubbleRoomCellLayoutConstants.pollBubbleBackgroundInsets.left
+ let rightMargin: CGFloat = BubbleRoomCellLayoutConstants.outgoingBubbleBackgroundMargins.right + BubbleRoomCellLayoutConstants.pollBubbleBackgroundInsets.right
bubbleCellContentView?.innerContentViewTrailingConstraint.constant = rightMargin
bubbleCellContentView?.innerContentViewLeadingConstraint.constant = leftMargin
diff --git a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/Poll/PollBaseBubbleCell.swift b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/Poll/PollBaseBubbleCell.swift
index 99a6afe568..bac34614c8 100644
--- a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/Poll/PollBaseBubbleCell.swift
+++ b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/Poll/PollBaseBubbleCell.swift
@@ -57,10 +57,10 @@ class PollBaseBubbleCell: PollBubbleCell {
private func addBubbleBackgroundView(_ bubbleBackgroundView: RoomMessageBubbleBackgroundView,
to pollView: UIView) {
- let topMargin: CGFloat = 2.0
- let leftMargin: CGFloat = 10.0
- let rightMargin: CGFloat = 10.0 // Add extra space for timestamp
- let bottomMargin: CGFloat = 0.0 //
+ let topMargin = BubbleRoomCellLayoutConstants.pollBubbleBackgroundInsets.top
+ let leftMargin = BubbleRoomCellLayoutConstants.pollBubbleBackgroundInsets.left
+ let rightMargin = BubbleRoomCellLayoutConstants.pollBubbleBackgroundInsets.right
+ let bottomMargin = BubbleRoomCellLayoutConstants.pollBubbleBackgroundInsets.bottom
let topAnchor = pollView.topAnchor
let leadingAnchor = pollView.leadingAnchor
diff --git a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/TextMessage/Common/TextMessageBaseBubbleCell.swift b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/TextMessage/Common/TextMessageBaseBubbleCell.swift
index f64e0d873d..2c24723d34 100644
--- a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/TextMessage/Common/TextMessageBaseBubbleCell.swift
+++ b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/TextMessage/Common/TextMessageBaseBubbleCell.swift
@@ -40,15 +40,7 @@ class TextMessageBaseBubbleCell: SizableBaseBubbleCell, RoomCellURLPreviewDispla
return
}
- // TODO: Use constants
-
- let messageLeftMargin: CGFloat = 48
-
- bubbleCellContentView?.innerContentViewLeadingConstraint.constant = messageLeftMargin
-
- self.bubbleCellContentView?.innerContentViewBottomContraint.constant = 5.0
-
- self.bubbleCellContentView?.innerContentViewTrailingConstraint.constant = 34.0
+ bubbleCellContentView?.innerContentViewBottomContraint.constant = BubbleRoomCellLayoutConstants.innerContentViewMargins.bottom
let textMessageContentView = TextMessageBubbleCellContentView.instantiate()
@@ -63,32 +55,6 @@ class TextMessageBaseBubbleCell: SizableBaseBubbleCell, RoomCellURLPreviewDispla
if let messageTextView = self.messageTextView {
messageTextView.tintColor = theme.tintColor
}
-
-// self.setupDebug()
- }
-
- // MARK: - Private
-
- private func setupDebug() {
-
- self.bubbleCellContentView?.innerContentView.backgroundColor = .yellow
-
- self.bubbleCellContentView?.layer.borderWidth = 1.0
- self.bubbleCellContentView?.layer.borderColor = UIColor.red.cgColor
-
- self.textMessageContentView?.layer.borderColor = UIColor.blue.cgColor
- self.textMessageContentView?.layer.borderWidth = 1.0
-
-
- self.bubbleCellContentView?.readReceiptsContainerView.layer.borderColor = UIColor.yellow.cgColor
- self.bubbleCellContentView?.readReceiptsContainerView.layer.borderWidth = 1.0
-
- self.bubbleCellContentView?.reactionsContainerView.layer.borderColor = UIColor.blue.cgColor
- self.bubbleCellContentView?.reactionsContainerView.layer.borderWidth = 1.0
- self.bubbleCellContentView?.reactionsContentView.backgroundColor = .blue
-
- self.bubbleCellContentView?.threadSummaryContainerView.layer.borderColor = UIColor.purple.cgColor
- self.bubbleCellContentView?.threadSummaryContainerView.layer.borderWidth = 1.0
}
}
diff --git a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/TextMessage/Common/TextMessageBubbleCellContentView.xib b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/TextMessage/Common/TextMessageBubbleCellContentView.xib
index 90fba02914..0a09502f12 100644
--- a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/TextMessage/Common/TextMessageBubbleCellContentView.xib
+++ b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/TextMessage/Common/TextMessageBubbleCellContentView.xib
@@ -39,7 +39,7 @@
-
+
diff --git a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/TextMessage/Incoming/TextMessageIncomingBubbleCell.swift b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/TextMessage/Incoming/TextMessageIncomingBubbleCell.swift
index 7d133e2f28..d2aa686ec0 100644
--- a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/TextMessage/Incoming/TextMessageIncomingBubbleCell.swift
+++ b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/TextMessage/Incoming/TextMessageIncomingBubbleCell.swift
@@ -39,10 +39,8 @@ class TextMessageIncomingBubbleCell: TextMessageBaseBubbleCell, BubbleIncomingRo
private func setupBubbleConstraints() {
- self.textMessageContentView?.bubbleBackgroundViewLeadingConstraint.constant = BubbleRoomCellLayoutConstants.incomingBubbleBackgroundMargins.left
+ self.bubbleCellContentView?.innerContentViewLeadingConstraint.constant = BubbleRoomCellLayoutConstants.incomingBubbleBackgroundMargins.left
- let innerContentViewTrailingMargin = self.bubbleCellContentView?.innerContentViewTrailingConstraint.constant ?? 0
-
- self.textMessageContentView?.bubbleBackgroundViewTrailingConstraint.constant = BubbleRoomCellLayoutConstants.incomingBubbleBackgroundMargins.right - innerContentViewTrailingMargin
+ self.bubbleCellContentView?.innerContentViewTrailingConstraint.constant = BubbleRoomCellLayoutConstants.incomingBubbleBackgroundMargins.right
}
}
diff --git a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/TextMessage/Outgoing/TextMessageOutgoingWithoutSenderInfoBubbleCell.swift b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/TextMessage/Outgoing/TextMessageOutgoingWithoutSenderInfoBubbleCell.swift
index 992d83ad9b..edc945b311 100644
--- a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/TextMessage/Outgoing/TextMessageOutgoingWithoutSenderInfoBubbleCell.swift
+++ b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/TextMessage/Outgoing/TextMessageOutgoingWithoutSenderInfoBubbleCell.swift
@@ -39,6 +39,9 @@ class TextMessageOutgoingWithoutSenderInfoBubbleCell: TextMessageBaseBubbleCell,
private func setupBubbleConstraints() {
+ self.bubbleCellContentView?.innerContentViewLeadingConstraint.constant = BubbleRoomCellLayoutConstants.outgoingBubbleBackgroundMargins.left
+ self.bubbleCellContentView?.innerContentViewTrailingConstraint.constant = BubbleRoomCellLayoutConstants.outgoingBubbleBackgroundMargins.right
+
guard let containerView = self.textMessageContentView, let bubbleBackgroundView = containerView.bubbleBackgroundView else {
return
}
@@ -57,7 +60,7 @@ class TextMessageOutgoingWithoutSenderInfoBubbleCell: TextMessageBaseBubbleCell,
// Setup new constraints
- let leadingConstraint = bubbleBackgroundView.leadingAnchor.constraint(greaterThanOrEqualTo: containerView.leadingAnchor, constant: BubbleRoomCellLayoutConstants.outgoingBubbleBackgroundMargins.left)
+ let leadingConstraint = bubbleBackgroundView.leadingAnchor.constraint(greaterThanOrEqualTo: containerView.leadingAnchor)
let trailingConstraint = bubbleBackgroundView.trailingAnchor.constraint(equalTo: containerView.trailingAnchor, constant: 0)
diff --git a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/VoiceMessage/Incoming/VoiceMessageIncomingBubbleCell.swift b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/VoiceMessage/Incoming/VoiceMessageIncomingBubbleCell.swift
index febaf87204..b8907847f3 100644
--- a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/VoiceMessage/Incoming/VoiceMessageIncomingBubbleCell.swift
+++ b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/VoiceMessage/Incoming/VoiceMessageIncomingBubbleCell.swift
@@ -20,16 +20,11 @@ class VoiceMessageIncomingBubbleCell: VoiceMessageBubbleCell, BubbleIncomingRoom
override func setupViews() {
super.setupViews()
+
+ bubbleCellContentView?.innerContentViewLeadingConstraint.constant = BubbleRoomCellLayoutConstants.incomingBubbleBackgroundMargins.left
+ bubbleCellContentView?.innerContentViewTrailingConstraint.constant = BubbleRoomCellLayoutConstants.incomingBubbleBackgroundMargins.right
- // TODO: Use constants
- let messageViewMarginRight: CGFloat = 80
- let messageLeftMargin: CGFloat = 48
- let playbackViewRightMargin: CGFloat = 40
-
- bubbleCellContentView?.innerContentViewTrailingConstraint.constant = messageViewMarginRight
- bubbleCellContentView?.innerContentViewLeadingConstraint.constant = messageLeftMargin
-
- playbackController.playbackView.stackViewTrailingContraint.constant = playbackViewRightMargin
+ playbackController.playbackView.stackViewTrailingContraint.constant = BubbleRoomCellLayoutConstants.voiceMessagePlaybackViewRightMargin
self.setupBubbleDecorations()
}
diff --git a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/VoiceMessage/Outgoing/VoiceMessageOutgoingWithoutSenderInfoBubbleCell.swift b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/VoiceMessage/Outgoing/VoiceMessageOutgoingWithoutSenderInfoBubbleCell.swift
index 5b0bffd7e4..60964b9b46 100644
--- a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/VoiceMessage/Outgoing/VoiceMessageOutgoingWithoutSenderInfoBubbleCell.swift
+++ b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/Cells/VoiceMessage/Outgoing/VoiceMessageOutgoingWithoutSenderInfoBubbleCell.swift
@@ -22,17 +22,11 @@ class VoiceMessageOutgoingWithoutSenderInfoBubbleCell: VoiceMessageBubbleCell, B
super.setupViews()
bubbleCellContentView?.showSenderInfo = false
-
- // TODO: Use constants
- // Same as outgoing message
- let rightMargin: CGFloat = 34.0
- let leftMargin: CGFloat = 80.0
- let playbackViewRightMargin: CGFloat = 40
-
- bubbleCellContentView?.innerContentViewTrailingConstraint.constant = rightMargin
- bubbleCellContentView?.innerContentViewLeadingConstraint.constant = leftMargin
+
+ bubbleCellContentView?.innerContentViewLeadingConstraint.constant = BubbleRoomCellLayoutConstants.outgoingBubbleBackgroundMargins.left
+ bubbleCellContentView?.innerContentViewTrailingConstraint.constant = BubbleRoomCellLayoutConstants.outgoingBubbleBackgroundMargins.right
- playbackController.playbackView.stackViewTrailingContraint.constant = playbackViewRightMargin
+ playbackController.playbackView.stackViewTrailingContraint.constant = BubbleRoomCellLayoutConstants.voiceMessagePlaybackViewRightMargin
self.setupBubbleDecorations()
}
diff --git a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/RoomMessageBubbleBackgroundView.swift b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/RoomMessageBubbleBackgroundView.swift
index da79211b25..45ad8e1be2 100644
--- a/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/RoomMessageBubbleBackgroundView.swift
+++ b/Riot/Modules/Room/Views/BubbleCells/Styles/Bubble/RoomMessageBubbleBackgroundView.swift
@@ -19,12 +19,6 @@ import UIKit
class RoomMessageBubbleBackgroundView: UIView {
- // MARK: - Constant
-
- private enum Constants {
- static let cornerRadius: CGFloat = 12.0
- }
-
// MARK: - Properties
private var heightConstraint: NSLayoutConstraint?
@@ -49,7 +43,7 @@ class RoomMessageBubbleBackgroundView: UIView {
private func commonInit() {
self.translatesAutoresizingMaskIntoConstraints = false
self.layer.masksToBounds = true
- self.layer.cornerRadius = Constants.cornerRadius
+ self.layer.cornerRadius = BubbleRoomCellLayoutConstants.bubbleCornerRadius
}
// MARK: - Public
@@ -82,7 +76,7 @@ extension RoomMessageBubbleBackgroundView: TimestampDisplayable {
self.removeTimestampView()
- self.addTimestampView(timestampView, rightMargin: 8.0, bottomMargin: 4.0)
+ self.addTimestampView(timestampView, rightMargin: BubbleRoomCellLayoutConstants.bubbleTimestampViewMargins.right, bottomMargin: BubbleRoomCellLayoutConstants.bubbleTimestampViewMargins.bottom)
self.timestampView = timestampView
}
diff --git a/changelog.d/5409.misc b/changelog.d/5409.misc
new file mode 100644
index 0000000000..6442410add
--- /dev/null
+++ b/changelog.d/5409.misc
@@ -0,0 +1 @@
+Message bubbles: Use layout constants instead magic numbers.
\ No newline at end of file