@@ -41,8 +41,8 @@ open class MessageSizeCalculator: CellSizeCalculator {
4141 public var incomingMessagePadding = UIEdgeInsets ( top: 0 , left: 4 , bottom: 0 , right: 30 )
4242 public var outgoingMessagePadding = UIEdgeInsets ( top: 0 , left: 30 , bottom: 0 , right: 4 )
4343
44- public var incomingCellTopLabelAlignment = LabelAlignment ( textAlignment: . left, textInsets: UIEdgeInsets ( left: 42 ) )
45- public var outgoingCellTopLabelAlignment = LabelAlignment ( textAlignment: . right, textInsets: UIEdgeInsets ( right: 42 ) )
44+ public var incomingMessageTopLabelAlignment = LabelAlignment ( textAlignment: . left, textInsets: UIEdgeInsets ( left: 42 ) )
45+ public var outgoingMessageTopLabelAlignment = LabelAlignment ( textAlignment: . right, textInsets: UIEdgeInsets ( right: 42 ) )
4646
4747 public var incomingCellBottomLabelAlignment = LabelAlignment ( textAlignment: . left, textInsets: UIEdgeInsets ( left: 42 ) )
4848 public var outgoingCellBottomLabelAlignment = LabelAlignment ( textAlignment: . right, textInsets: UIEdgeInsets ( right: 42 ) )
@@ -59,8 +59,9 @@ open class MessageSizeCalculator: CellSizeCalculator {
5959
6060 attributes. messageContainerPadding = messageContainerPadding ( for: message)
6161 attributes. messageContainerSize = messageContainerSize ( for: message)
62- attributes. topLabelAlignment = cellTopLabelAlignment ( for: message)
63- attributes. topLabelSize = cellTopLabelSize ( for: message, at: indexPath)
62+ attributes. cellTopLabelSize = cellTopLabelSize ( for: message, at: indexPath)
63+ attributes. messageTopLabelSize = messageTopLabelSize ( for: message, at: indexPath)
64+ attributes. messageTopLabelAlignment = messageTopLabelAlignment ( for: message)
6465
6566 attributes. bottomLabelAlignment = cellBottomLabelAlignment ( for: message)
6667 attributes. bottomLabelSize = cellBottomLabelSize ( for: message, at: indexPath)
@@ -75,32 +76,20 @@ open class MessageSizeCalculator: CellSizeCalculator {
7576
7677 open func cellContentHeight( for message: MessageType , at indexPath: IndexPath ) -> CGFloat {
7778
78- let avatarVerticalPosition = avatarPosition ( for: message) . vertical
7979 let avatarHeight = avatarSize ( for: message) . height
8080 let messageContainerHeight = messageContainerSize ( for: message) . height
8181 let bottomLabelHeight = cellBottomLabelSize ( for: message, at: indexPath) . height
82- let topLabelHeight = cellTopLabelSize ( for: message, at: indexPath) . height
82+ let cellTopLabelHeight = cellTopLabelSize ( for: message, at: indexPath) . height
83+ let messageTopLabelHeight = messageTopLabelSize ( for: message, at: indexPath) . height
8384 let messageVerticalPadding = messageContainerPadding ( for: message) . vertical
8485
8586 var cellHeight : CGFloat = 0
8687
87- switch avatarVerticalPosition {
88- case . cellTop:
89- cellHeight += max ( avatarHeight, topLabelHeight)
90- cellHeight += bottomLabelHeight
91- cellHeight += messageContainerHeight
92- cellHeight += messageVerticalPadding
93- case . cellBottom:
94- cellHeight += max ( avatarHeight, bottomLabelHeight)
95- cellHeight += topLabelHeight
96- cellHeight += messageContainerHeight
97- cellHeight += messageVerticalPadding
98- case . messageTop, . messageCenter, . messageBottom:
99- cellHeight += max ( avatarHeight, messageContainerHeight)
100- cellHeight += messageVerticalPadding
101- cellHeight += topLabelHeight
102- cellHeight += bottomLabelHeight
103- }
88+ cellHeight += max ( avatarHeight, messageContainerHeight)
89+ cellHeight += messageVerticalPadding
90+ cellHeight += cellTopLabelHeight
91+ cellHeight += messageTopLabelHeight
92+ cellHeight += bottomLabelHeight
10493
10594 return cellHeight
10695 }
@@ -127,19 +116,28 @@ open class MessageSizeCalculator: CellSizeCalculator {
127116 return isFromCurrentSender ? outgoingAvatarSize : incomingAvatarSize
128117 }
129118
130- // MARK: - Top Label
119+ // MARK: - Top cell Label
131120
132121 public func cellTopLabelSize( for message: MessageType , at indexPath: IndexPath ) -> CGSize {
133122 let layoutDelegate = messagesLayout. messagesLayoutDelegate
134123 let collectionView = messagesLayout. messagesCollectionView
135124 let height = layoutDelegate. cellTopLabelHeight ( for: message, at: indexPath, in: collectionView)
136125 return CGSize ( width: messagesLayout. itemWidth, height: height)
137126 }
138-
139- public func cellTopLabelAlignment( for message: MessageType ) -> LabelAlignment {
127+
128+ // MARK: - Top message Label
129+
130+ public func messageTopLabelSize( for message: MessageType , at indexPath: IndexPath ) -> CGSize {
131+ let layoutDelegate = messagesLayout. messagesLayoutDelegate
132+ let collectionView = messagesLayout. messagesCollectionView
133+ let height = layoutDelegate. messageTopLabelHeight ( for: message, at: indexPath, in: collectionView)
134+ return CGSize ( width: messagesLayout. itemWidth, height: height)
135+ }
136+
137+ public func messageTopLabelAlignment( for message: MessageType ) -> LabelAlignment {
140138 let dataSource = messagesLayout. messagesDataSource
141139 let isFromCurrentSender = dataSource. isFromCurrentSender ( message: message)
142- return isFromCurrentSender ? outgoingCellTopLabelAlignment : incomingCellTopLabelAlignment
140+ return isFromCurrentSender ? outgoingMessageTopLabelAlignment : incomingMessageTopLabelAlignment
143141 }
144142
145143 // MARK: - Bottom Label
0 commit comments